babylon.module.d.ts 6.1 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. get observers(): Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static get LogCache(): string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static set LogLevels(level: number);
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/stringTools" {
  378. /**
  379. * Helper to manipulate strings
  380. */
  381. export class StringTools {
  382. /**
  383. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  384. * @param str Source string
  385. * @param suffix Suffix to search for in the source string
  386. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  387. */
  388. static EndsWith(str: string, suffix: string): boolean;
  389. /**
  390. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  391. * @param str Source string
  392. * @param suffix Suffix to search for in the source string
  393. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  394. */
  395. static StartsWith(str: string, suffix: string): boolean;
  396. /**
  397. * Decodes a buffer into a string
  398. * @param buffer The buffer to decode
  399. * @returns The decoded string
  400. */
  401. static Decode(buffer: Uint8Array | Uint16Array): string;
  402. /**
  403. * Encode a buffer to a base64 string
  404. * @param buffer defines the buffer to encode
  405. * @returns the encoded string
  406. */
  407. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  408. }
  409. }
  410. declare module "babylonjs/Misc/deepCopier" {
  411. /**
  412. * Class containing a set of static utilities functions for deep copy.
  413. */
  414. export class DeepCopier {
  415. /**
  416. * Tries to copy an object by duplicating every property
  417. * @param source defines the source object
  418. * @param destination defines the target object
  419. * @param doNotCopyList defines a list of properties to avoid
  420. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  421. */
  422. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  423. }
  424. }
  425. declare module "babylonjs/Misc/precisionDate" {
  426. /**
  427. * Class containing a set of static utilities functions for precision date
  428. */
  429. export class PrecisionDate {
  430. /**
  431. * Gets either window.performance.now() if supported or Date.now() else
  432. */
  433. static get Now(): number;
  434. }
  435. }
  436. declare module "babylonjs/Misc/devTools" {
  437. /** @hidden */
  438. export class _DevTools {
  439. static WarnImport(name: string): string;
  440. }
  441. }
  442. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  443. /**
  444. * Interface used to define the mechanism to get data from the network
  445. */
  446. export interface IWebRequest {
  447. /**
  448. * Returns client's response url
  449. */
  450. responseURL: string;
  451. /**
  452. * Returns client's status
  453. */
  454. status: number;
  455. /**
  456. * Returns client's status as a text
  457. */
  458. statusText: string;
  459. }
  460. }
  461. declare module "babylonjs/Misc/webRequest" {
  462. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  463. import { Nullable } from "babylonjs/types";
  464. /**
  465. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  466. */
  467. export class WebRequest implements IWebRequest {
  468. private _xhr;
  469. /**
  470. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  471. * i.e. when loading files, where the server/service expects an Authorization header
  472. */
  473. static CustomRequestHeaders: {
  474. [key: string]: string;
  475. };
  476. /**
  477. * Add callback functions in this array to update all the requests before they get sent to the network
  478. */
  479. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  480. private _injectCustomRequestHeaders;
  481. /**
  482. * Gets or sets a function to be called when loading progress changes
  483. */
  484. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  485. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  486. /**
  487. * Returns client's state
  488. */
  489. get readyState(): number;
  490. /**
  491. * Returns client's status
  492. */
  493. get status(): number;
  494. /**
  495. * Returns client's status as a text
  496. */
  497. get statusText(): string;
  498. /**
  499. * Returns client's response
  500. */
  501. get response(): any;
  502. /**
  503. * Returns client's response url
  504. */
  505. get responseURL(): string;
  506. /**
  507. * Returns client's response as text
  508. */
  509. get responseText(): string;
  510. /**
  511. * Gets or sets the expected response type
  512. */
  513. get responseType(): XMLHttpRequestResponseType;
  514. set responseType(value: XMLHttpRequestResponseType);
  515. /** @hidden */
  516. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  517. /** @hidden */
  518. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  519. /**
  520. * Cancels any network activity
  521. */
  522. abort(): void;
  523. /**
  524. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  525. * @param body defines an optional request body
  526. */
  527. send(body?: Document | BodyInit | null): void;
  528. /**
  529. * Sets the request method, request URL
  530. * @param method defines the method to use (GET, POST, etc..)
  531. * @param url defines the url to connect with
  532. */
  533. open(method: string, url: string): void;
  534. /**
  535. * Sets the value of a request header.
  536. * @param name The name of the header whose value is to be set
  537. * @param value The value to set as the body of the header
  538. */
  539. setRequestHeader(name: string, value: string): void;
  540. /**
  541. * Get the string containing the text of a particular header's value.
  542. * @param name The name of the header
  543. * @returns The string containing the text of the given header name
  544. */
  545. getResponseHeader(name: string): Nullable<string>;
  546. }
  547. }
  548. declare module "babylonjs/Misc/fileRequest" {
  549. import { Observable } from "babylonjs/Misc/observable";
  550. /**
  551. * File request interface
  552. */
  553. export interface IFileRequest {
  554. /**
  555. * Raised when the request is complete (success or error).
  556. */
  557. onCompleteObservable: Observable<IFileRequest>;
  558. /**
  559. * Aborts the request for a file.
  560. */
  561. abort: () => void;
  562. }
  563. }
  564. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  565. /**
  566. * Define options used to create a render target texture
  567. */
  568. export class RenderTargetCreationOptions {
  569. /**
  570. * Specifies is mipmaps must be generated
  571. */
  572. generateMipMaps?: boolean;
  573. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  574. generateDepthBuffer?: boolean;
  575. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  576. generateStencilBuffer?: boolean;
  577. /** Defines texture type (int by default) */
  578. type?: number;
  579. /** Defines sampling mode (trilinear by default) */
  580. samplingMode?: number;
  581. /** Defines format (RGBA by default) */
  582. format?: number;
  583. }
  584. }
  585. declare module "babylonjs/Engines/constants" {
  586. /** Defines the cross module used constants to avoid circular dependncies */
  587. export class Constants {
  588. /** Defines that alpha blending is disabled */
  589. static readonly ALPHA_DISABLE: number;
  590. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  591. static readonly ALPHA_ADD: number;
  592. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  593. static readonly ALPHA_COMBINE: number;
  594. /** Defines that alpha blending is DEST - SRC * DEST */
  595. static readonly ALPHA_SUBTRACT: number;
  596. /** Defines that alpha blending is SRC * DEST */
  597. static readonly ALPHA_MULTIPLY: number;
  598. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  599. static readonly ALPHA_MAXIMIZED: number;
  600. /** Defines that alpha blending is SRC + DEST */
  601. static readonly ALPHA_ONEONE: number;
  602. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  603. static readonly ALPHA_PREMULTIPLIED: number;
  604. /**
  605. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  606. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  607. */
  608. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  609. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  610. static readonly ALPHA_INTERPOLATE: number;
  611. /**
  612. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  613. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  614. */
  615. static readonly ALPHA_SCREENMODE: number;
  616. /**
  617. * Defines that alpha blending is SRC + DST
  618. * Alpha will be set to SRC ALPHA + DST ALPHA
  619. */
  620. static readonly ALPHA_ONEONE_ONEONE: number;
  621. /**
  622. * Defines that alpha blending is SRC * DST ALPHA + DST
  623. * Alpha will be set to 0
  624. */
  625. static readonly ALPHA_ALPHATOCOLOR: number;
  626. /**
  627. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  628. */
  629. static readonly ALPHA_REVERSEONEMINUS: number;
  630. /**
  631. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  632. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  633. */
  634. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  635. /**
  636. * Defines that alpha blending is SRC + DST
  637. * Alpha will be set to SRC ALPHA
  638. */
  639. static readonly ALPHA_ONEONE_ONEZERO: number;
  640. /**
  641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  642. * Alpha will be set to DST ALPHA
  643. */
  644. static readonly ALPHA_EXCLUSION: number;
  645. /** Defines that alpha blending equation a SUM */
  646. static readonly ALPHA_EQUATION_ADD: number;
  647. /** Defines that alpha blending equation a SUBSTRACTION */
  648. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  649. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  650. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  651. /** Defines that alpha blending equation a MAX operation */
  652. static readonly ALPHA_EQUATION_MAX: number;
  653. /** Defines that alpha blending equation a MIN operation */
  654. static readonly ALPHA_EQUATION_MIN: number;
  655. /**
  656. * Defines that alpha blending equation a DARKEN operation:
  657. * It takes the min of the src and sums the alpha channels.
  658. */
  659. static readonly ALPHA_EQUATION_DARKEN: number;
  660. /** Defines that the ressource is not delayed*/
  661. static readonly DELAYLOADSTATE_NONE: number;
  662. /** Defines that the ressource was successfully delay loaded */
  663. static readonly DELAYLOADSTATE_LOADED: number;
  664. /** Defines that the ressource is currently delay loading */
  665. static readonly DELAYLOADSTATE_LOADING: number;
  666. /** Defines that the ressource is delayed and has not started loading */
  667. static readonly DELAYLOADSTATE_NOTLOADED: number;
  668. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  669. static readonly NEVER: number;
  670. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  671. static readonly ALWAYS: number;
  672. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  673. static readonly LESS: number;
  674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  675. static readonly EQUAL: number;
  676. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  677. static readonly LEQUAL: number;
  678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  679. static readonly GREATER: number;
  680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  681. static readonly GEQUAL: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  683. static readonly NOTEQUAL: number;
  684. /** Passed to stencilOperation to specify that stencil value must be kept */
  685. static readonly KEEP: number;
  686. /** Passed to stencilOperation to specify that stencil value must be replaced */
  687. static readonly REPLACE: number;
  688. /** Passed to stencilOperation to specify that stencil value must be incremented */
  689. static readonly INCR: number;
  690. /** Passed to stencilOperation to specify that stencil value must be decremented */
  691. static readonly DECR: number;
  692. /** Passed to stencilOperation to specify that stencil value must be inverted */
  693. static readonly INVERT: number;
  694. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  695. static readonly INCR_WRAP: number;
  696. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  697. static readonly DECR_WRAP: number;
  698. /** Texture is not repeating outside of 0..1 UVs */
  699. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  700. /** Texture is repeating outside of 0..1 UVs */
  701. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  702. /** Texture is repeating and mirrored */
  703. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  704. /** ALPHA */
  705. static readonly TEXTUREFORMAT_ALPHA: number;
  706. /** LUMINANCE */
  707. static readonly TEXTUREFORMAT_LUMINANCE: number;
  708. /** LUMINANCE_ALPHA */
  709. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  710. /** RGB */
  711. static readonly TEXTUREFORMAT_RGB: number;
  712. /** RGBA */
  713. static readonly TEXTUREFORMAT_RGBA: number;
  714. /** RED */
  715. static readonly TEXTUREFORMAT_RED: number;
  716. /** RED (2nd reference) */
  717. static readonly TEXTUREFORMAT_R: number;
  718. /** RG */
  719. static readonly TEXTUREFORMAT_RG: number;
  720. /** RED_INTEGER */
  721. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  722. /** RED_INTEGER (2nd reference) */
  723. static readonly TEXTUREFORMAT_R_INTEGER: number;
  724. /** RG_INTEGER */
  725. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  726. /** RGB_INTEGER */
  727. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  728. /** RGBA_INTEGER */
  729. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  730. /** UNSIGNED_BYTE */
  731. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  732. /** UNSIGNED_BYTE (2nd reference) */
  733. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  734. /** FLOAT */
  735. static readonly TEXTURETYPE_FLOAT: number;
  736. /** HALF_FLOAT */
  737. static readonly TEXTURETYPE_HALF_FLOAT: number;
  738. /** BYTE */
  739. static readonly TEXTURETYPE_BYTE: number;
  740. /** SHORT */
  741. static readonly TEXTURETYPE_SHORT: number;
  742. /** UNSIGNED_SHORT */
  743. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  744. /** INT */
  745. static readonly TEXTURETYPE_INT: number;
  746. /** UNSIGNED_INT */
  747. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  748. /** UNSIGNED_SHORT_4_4_4_4 */
  749. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  750. /** UNSIGNED_SHORT_5_5_5_1 */
  751. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  752. /** UNSIGNED_SHORT_5_6_5 */
  753. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  754. /** UNSIGNED_INT_2_10_10_10_REV */
  755. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  756. /** UNSIGNED_INT_24_8 */
  757. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  758. /** UNSIGNED_INT_10F_11F_11F_REV */
  759. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  760. /** UNSIGNED_INT_5_9_9_9_REV */
  761. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  762. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  763. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  764. /** nearest is mag = nearest and min = nearest and no mip */
  765. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  766. /** mag = nearest and min = nearest and mip = none */
  767. static readonly TEXTURE_NEAREST_NEAREST: number;
  768. /** Bilinear is mag = linear and min = linear and no mip */
  769. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  770. /** mag = linear and min = linear and mip = none */
  771. static readonly TEXTURE_LINEAR_LINEAR: number;
  772. /** Trilinear is mag = linear and min = linear and mip = linear */
  773. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  774. /** Trilinear is mag = linear and min = linear and mip = linear */
  775. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  776. /** mag = nearest and min = nearest and mip = nearest */
  777. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  778. /** mag = nearest and min = linear and mip = nearest */
  779. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  780. /** mag = nearest and min = linear and mip = linear */
  781. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  782. /** mag = nearest and min = linear and mip = none */
  783. static readonly TEXTURE_NEAREST_LINEAR: number;
  784. /** nearest is mag = nearest and min = nearest and mip = linear */
  785. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  786. /** mag = linear and min = nearest and mip = nearest */
  787. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  788. /** mag = linear and min = nearest and mip = linear */
  789. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  790. /** Bilinear is mag = linear and min = linear and mip = nearest */
  791. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  792. /** mag = linear and min = nearest and mip = none */
  793. static readonly TEXTURE_LINEAR_NEAREST: number;
  794. /** Explicit coordinates mode */
  795. static readonly TEXTURE_EXPLICIT_MODE: number;
  796. /** Spherical coordinates mode */
  797. static readonly TEXTURE_SPHERICAL_MODE: number;
  798. /** Planar coordinates mode */
  799. static readonly TEXTURE_PLANAR_MODE: number;
  800. /** Cubic coordinates mode */
  801. static readonly TEXTURE_CUBIC_MODE: number;
  802. /** Projection coordinates mode */
  803. static readonly TEXTURE_PROJECTION_MODE: number;
  804. /** Skybox coordinates mode */
  805. static readonly TEXTURE_SKYBOX_MODE: number;
  806. /** Inverse Cubic coordinates mode */
  807. static readonly TEXTURE_INVCUBIC_MODE: number;
  808. /** Equirectangular coordinates mode */
  809. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  810. /** Equirectangular Fixed coordinates mode */
  811. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  812. /** Equirectangular Fixed Mirrored coordinates mode */
  813. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  814. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  815. static readonly SCALEMODE_FLOOR: number;
  816. /** Defines that texture rescaling will look for the nearest power of 2 size */
  817. static readonly SCALEMODE_NEAREST: number;
  818. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  819. static readonly SCALEMODE_CEILING: number;
  820. /**
  821. * The dirty texture flag value
  822. */
  823. static readonly MATERIAL_TextureDirtyFlag: number;
  824. /**
  825. * The dirty light flag value
  826. */
  827. static readonly MATERIAL_LightDirtyFlag: number;
  828. /**
  829. * The dirty fresnel flag value
  830. */
  831. static readonly MATERIAL_FresnelDirtyFlag: number;
  832. /**
  833. * The dirty attribute flag value
  834. */
  835. static readonly MATERIAL_AttributesDirtyFlag: number;
  836. /**
  837. * The dirty misc flag value
  838. */
  839. static readonly MATERIAL_MiscDirtyFlag: number;
  840. /**
  841. * The all dirty flag value
  842. */
  843. static readonly MATERIAL_AllDirtyFlag: number;
  844. /**
  845. * Returns the triangle fill mode
  846. */
  847. static readonly MATERIAL_TriangleFillMode: number;
  848. /**
  849. * Returns the wireframe mode
  850. */
  851. static readonly MATERIAL_WireFrameFillMode: number;
  852. /**
  853. * Returns the point fill mode
  854. */
  855. static readonly MATERIAL_PointFillMode: number;
  856. /**
  857. * Returns the point list draw mode
  858. */
  859. static readonly MATERIAL_PointListDrawMode: number;
  860. /**
  861. * Returns the line list draw mode
  862. */
  863. static readonly MATERIAL_LineListDrawMode: number;
  864. /**
  865. * Returns the line loop draw mode
  866. */
  867. static readonly MATERIAL_LineLoopDrawMode: number;
  868. /**
  869. * Returns the line strip draw mode
  870. */
  871. static readonly MATERIAL_LineStripDrawMode: number;
  872. /**
  873. * Returns the triangle strip draw mode
  874. */
  875. static readonly MATERIAL_TriangleStripDrawMode: number;
  876. /**
  877. * Returns the triangle fan draw mode
  878. */
  879. static readonly MATERIAL_TriangleFanDrawMode: number;
  880. /**
  881. * Stores the clock-wise side orientation
  882. */
  883. static readonly MATERIAL_ClockWiseSideOrientation: number;
  884. /**
  885. * Stores the counter clock-wise side orientation
  886. */
  887. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  888. /**
  889. * Nothing
  890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  891. */
  892. static readonly ACTION_NothingTrigger: number;
  893. /**
  894. * On pick
  895. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  896. */
  897. static readonly ACTION_OnPickTrigger: number;
  898. /**
  899. * On left pick
  900. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  901. */
  902. static readonly ACTION_OnLeftPickTrigger: number;
  903. /**
  904. * On right pick
  905. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  906. */
  907. static readonly ACTION_OnRightPickTrigger: number;
  908. /**
  909. * On center pick
  910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  911. */
  912. static readonly ACTION_OnCenterPickTrigger: number;
  913. /**
  914. * On pick down
  915. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  916. */
  917. static readonly ACTION_OnPickDownTrigger: number;
  918. /**
  919. * On double pick
  920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  921. */
  922. static readonly ACTION_OnDoublePickTrigger: number;
  923. /**
  924. * On pick up
  925. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  926. */
  927. static readonly ACTION_OnPickUpTrigger: number;
  928. /**
  929. * On pick out.
  930. * This trigger will only be raised if you also declared a OnPickDown
  931. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnPickOutTrigger: number;
  934. /**
  935. * On long press
  936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnLongPressTrigger: number;
  939. /**
  940. * On pointer over
  941. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPointerOverTrigger: number;
  944. /**
  945. * On pointer out
  946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnPointerOutTrigger: number;
  949. /**
  950. * On every frame
  951. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnEveryFrameTrigger: number;
  954. /**
  955. * On intersection enter
  956. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  957. */
  958. static readonly ACTION_OnIntersectionEnterTrigger: number;
  959. /**
  960. * On intersection exit
  961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  962. */
  963. static readonly ACTION_OnIntersectionExitTrigger: number;
  964. /**
  965. * On key down
  966. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  967. */
  968. static readonly ACTION_OnKeyDownTrigger: number;
  969. /**
  970. * On key up
  971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  972. */
  973. static readonly ACTION_OnKeyUpTrigger: number;
  974. /**
  975. * Billboard mode will only apply to Y axis
  976. */
  977. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  978. /**
  979. * Billboard mode will apply to all axes
  980. */
  981. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  982. /**
  983. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  984. */
  985. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  986. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  987. * Test order :
  988. * Is the bounding sphere outside the frustum ?
  989. * If not, are the bounding box vertices outside the frustum ?
  990. * It not, then the cullable object is in the frustum.
  991. */
  992. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  993. /** Culling strategy : Bounding Sphere Only.
  994. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  995. * It's also less accurate than the standard because some not visible objects can still be selected.
  996. * Test : is the bounding sphere outside the frustum ?
  997. * If not, then the cullable object is in the frustum.
  998. */
  999. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1000. /** Culling strategy : Optimistic Inclusion.
  1001. * This in an inclusion test first, then the standard exclusion test.
  1002. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1003. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  1004. * Anyway, it's as accurate as the standard strategy.
  1005. * Test :
  1006. * Is the cullable object bounding sphere center in the frustum ?
  1007. * If not, apply the default culling strategy.
  1008. */
  1009. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1010. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1011. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1012. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1013. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  1014. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1015. * Test :
  1016. * Is the cullable object bounding sphere center in the frustum ?
  1017. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1018. */
  1019. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1020. /**
  1021. * No logging while loading
  1022. */
  1023. static readonly SCENELOADER_NO_LOGGING: number;
  1024. /**
  1025. * Minimal logging while loading
  1026. */
  1027. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1028. /**
  1029. * Summary logging while loading
  1030. */
  1031. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1032. /**
  1033. * Detailled logging while loading
  1034. */
  1035. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1036. }
  1037. }
  1038. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1039. import { Nullable } from "babylonjs/types";
  1040. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1041. /**
  1042. * This represents the required contract to create a new type of texture loader.
  1043. */
  1044. export interface IInternalTextureLoader {
  1045. /**
  1046. * Defines wether the loader supports cascade loading the different faces.
  1047. */
  1048. supportCascades: boolean;
  1049. /**
  1050. * This returns if the loader support the current file information.
  1051. * @param extension defines the file extension of the file being loaded
  1052. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1053. * @param fallback defines the fallback internal texture if any
  1054. * @param isBase64 defines whether the texture is encoded as a base64
  1055. * @param isBuffer defines whether the texture data are stored as a buffer
  1056. * @returns true if the loader can load the specified file
  1057. */
  1058. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  1059. /**
  1060. * Transform the url before loading if required.
  1061. * @param rootUrl the url of the texture
  1062. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1063. * @returns the transformed texture
  1064. */
  1065. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  1066. /**
  1067. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  1068. * @param rootUrl the url of the texture
  1069. * @param textureFormatInUse defines the current compressed format in use iun the engine
  1070. * @returns the fallback texture
  1071. */
  1072. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  1073. /**
  1074. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  1075. * @param data contains the texture data
  1076. * @param texture defines the BabylonJS internal texture
  1077. * @param createPolynomials will be true if polynomials have been requested
  1078. * @param onLoad defines the callback to trigger once the texture is ready
  1079. * @param onError defines the callback to trigger in case of error
  1080. */
  1081. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1082. /**
  1083. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  1084. * @param data contains the texture data
  1085. * @param texture defines the BabylonJS internal texture
  1086. * @param callback defines the method to call once ready to upload
  1087. */
  1088. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1089. }
  1090. }
  1091. declare module "babylonjs/Engines/IPipelineContext" {
  1092. /**
  1093. * Class used to store and describe the pipeline context associated with an effect
  1094. */
  1095. export interface IPipelineContext {
  1096. /**
  1097. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1098. */
  1099. isAsync: boolean;
  1100. /**
  1101. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1102. */
  1103. isReady: boolean;
  1104. /** @hidden */
  1105. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1106. }
  1107. }
  1108. declare module "babylonjs/Meshes/dataBuffer" {
  1109. /**
  1110. * Class used to store gfx data (like WebGLBuffer)
  1111. */
  1112. export class DataBuffer {
  1113. /**
  1114. * Gets or sets the number of objects referencing this buffer
  1115. */
  1116. references: number;
  1117. /** Gets or sets the size of the underlying buffer */
  1118. capacity: number;
  1119. /**
  1120. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1121. */
  1122. is32Bits: boolean;
  1123. /**
  1124. * Gets the underlying buffer
  1125. */
  1126. get underlyingResource(): any;
  1127. }
  1128. }
  1129. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1130. /** @hidden */
  1131. export interface IShaderProcessor {
  1132. attributeProcessor?: (attribute: string) => string;
  1133. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1134. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1135. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1136. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1137. lineProcessor?: (line: string, isFragment: boolean) => string;
  1138. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1139. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1140. }
  1141. }
  1142. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1143. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1144. /** @hidden */
  1145. export interface ProcessingOptions {
  1146. defines: string[];
  1147. indexParameters: any;
  1148. isFragment: boolean;
  1149. shouldUseHighPrecisionShader: boolean;
  1150. supportsUniformBuffers: boolean;
  1151. shadersRepository: string;
  1152. includesShadersStore: {
  1153. [key: string]: string;
  1154. };
  1155. processor?: IShaderProcessor;
  1156. version: string;
  1157. platformName: string;
  1158. lookForClosingBracketForUniformBuffer?: boolean;
  1159. }
  1160. }
  1161. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1162. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1163. /** @hidden */
  1164. export class ShaderCodeNode {
  1165. line: string;
  1166. children: ShaderCodeNode[];
  1167. additionalDefineKey?: string;
  1168. additionalDefineValue?: string;
  1169. isValid(preprocessors: {
  1170. [key: string]: string;
  1171. }): boolean;
  1172. process(preprocessors: {
  1173. [key: string]: string;
  1174. }, options: ProcessingOptions): string;
  1175. }
  1176. }
  1177. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1178. /** @hidden */
  1179. export class ShaderCodeCursor {
  1180. private _lines;
  1181. lineIndex: number;
  1182. get currentLine(): string;
  1183. get canRead(): boolean;
  1184. set lines(value: string[]);
  1185. }
  1186. }
  1187. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1188. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1189. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1190. /** @hidden */
  1191. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1192. process(preprocessors: {
  1193. [key: string]: string;
  1194. }, options: ProcessingOptions): string;
  1195. }
  1196. }
  1197. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1198. /** @hidden */
  1199. export class ShaderDefineExpression {
  1200. isTrue(preprocessors: {
  1201. [key: string]: string;
  1202. }): boolean;
  1203. }
  1204. }
  1205. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1206. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1207. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1208. /** @hidden */
  1209. export class ShaderCodeTestNode extends ShaderCodeNode {
  1210. testExpression: ShaderDefineExpression;
  1211. isValid(preprocessors: {
  1212. [key: string]: string;
  1213. }): boolean;
  1214. }
  1215. }
  1216. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1217. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1218. /** @hidden */
  1219. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1220. define: string;
  1221. not: boolean;
  1222. constructor(define: string, not?: boolean);
  1223. isTrue(preprocessors: {
  1224. [key: string]: string;
  1225. }): boolean;
  1226. }
  1227. }
  1228. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1229. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1230. /** @hidden */
  1231. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1232. leftOperand: ShaderDefineExpression;
  1233. rightOperand: ShaderDefineExpression;
  1234. isTrue(preprocessors: {
  1235. [key: string]: string;
  1236. }): boolean;
  1237. }
  1238. }
  1239. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1240. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1241. /** @hidden */
  1242. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1243. leftOperand: ShaderDefineExpression;
  1244. rightOperand: ShaderDefineExpression;
  1245. isTrue(preprocessors: {
  1246. [key: string]: string;
  1247. }): boolean;
  1248. }
  1249. }
  1250. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1251. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1252. /** @hidden */
  1253. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1254. define: string;
  1255. operand: string;
  1256. testValue: string;
  1257. constructor(define: string, operand: string, testValue: string);
  1258. isTrue(preprocessors: {
  1259. [key: string]: string;
  1260. }): boolean;
  1261. }
  1262. }
  1263. declare module "babylonjs/Offline/IOfflineProvider" {
  1264. /**
  1265. * Class used to enable access to offline support
  1266. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1267. */
  1268. export interface IOfflineProvider {
  1269. /**
  1270. * Gets a boolean indicating if scene must be saved in the database
  1271. */
  1272. enableSceneOffline: boolean;
  1273. /**
  1274. * Gets a boolean indicating if textures must be saved in the database
  1275. */
  1276. enableTexturesOffline: boolean;
  1277. /**
  1278. * Open the offline support and make it available
  1279. * @param successCallback defines the callback to call on success
  1280. * @param errorCallback defines the callback to call on error
  1281. */
  1282. open(successCallback: () => void, errorCallback: () => void): void;
  1283. /**
  1284. * Loads an image from the offline support
  1285. * @param url defines the url to load from
  1286. * @param image defines the target DOM image
  1287. */
  1288. loadImage(url: string, image: HTMLImageElement): void;
  1289. /**
  1290. * Loads a file from offline support
  1291. * @param url defines the URL to load from
  1292. * @param sceneLoaded defines a callback to call on success
  1293. * @param progressCallBack defines a callback to call when progress changed
  1294. * @param errorCallback defines a callback to call on error
  1295. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1296. */
  1297. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1298. }
  1299. }
  1300. declare module "babylonjs/Misc/filesInputStore" {
  1301. /**
  1302. * Class used to help managing file picking and drag'n'drop
  1303. * File Storage
  1304. */
  1305. export class FilesInputStore {
  1306. /**
  1307. * List of files ready to be loaded
  1308. */
  1309. static FilesToLoad: {
  1310. [key: string]: File;
  1311. };
  1312. }
  1313. }
  1314. declare module "babylonjs/Misc/retryStrategy" {
  1315. import { WebRequest } from "babylonjs/Misc/webRequest";
  1316. /**
  1317. * Class used to define a retry strategy when error happens while loading assets
  1318. */
  1319. export class RetryStrategy {
  1320. /**
  1321. * Function used to defines an exponential back off strategy
  1322. * @param maxRetries defines the maximum number of retries (3 by default)
  1323. * @param baseInterval defines the interval between retries
  1324. * @returns the strategy function to use
  1325. */
  1326. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1327. }
  1328. }
  1329. declare module "babylonjs/Misc/baseError" {
  1330. /**
  1331. * @ignore
  1332. * Application error to support additional information when loading a file
  1333. */
  1334. export abstract class BaseError extends Error {
  1335. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1336. }
  1337. }
  1338. declare module "babylonjs/Misc/fileTools" {
  1339. import { WebRequest } from "babylonjs/Misc/webRequest";
  1340. import { Nullable } from "babylonjs/types";
  1341. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1342. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1343. import { BaseError } from "babylonjs/Misc/baseError";
  1344. /** @ignore */
  1345. export class LoadFileError extends BaseError {
  1346. request?: WebRequest;
  1347. file?: File;
  1348. /**
  1349. * Creates a new LoadFileError
  1350. * @param message defines the message of the error
  1351. * @param request defines the optional web request
  1352. * @param file defines the optional file
  1353. */
  1354. constructor(message: string, object?: WebRequest | File);
  1355. }
  1356. /** @ignore */
  1357. export class RequestFileError extends BaseError {
  1358. request: WebRequest;
  1359. /**
  1360. * Creates a new LoadFileError
  1361. * @param message defines the message of the error
  1362. * @param request defines the optional web request
  1363. */
  1364. constructor(message: string, request: WebRequest);
  1365. }
  1366. /** @ignore */
  1367. export class ReadFileError extends BaseError {
  1368. file: File;
  1369. /**
  1370. * Creates a new ReadFileError
  1371. * @param message defines the message of the error
  1372. * @param file defines the optional file
  1373. */
  1374. constructor(message: string, file: File);
  1375. }
  1376. /**
  1377. * @hidden
  1378. */
  1379. export class FileTools {
  1380. /**
  1381. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1382. */
  1383. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1384. /**
  1385. * Gets or sets the base URL to use to load assets
  1386. */
  1387. static BaseUrl: string;
  1388. /**
  1389. * Default behaviour for cors in the application.
  1390. * It can be a string if the expected behavior is identical in the entire app.
  1391. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1392. */
  1393. static CorsBehavior: string | ((url: string | string[]) => string);
  1394. /**
  1395. * Gets or sets a function used to pre-process url before using them to load assets
  1396. */
  1397. static PreprocessUrl: (url: string) => string;
  1398. /**
  1399. * Removes unwanted characters from an url
  1400. * @param url defines the url to clean
  1401. * @returns the cleaned url
  1402. */
  1403. private static _CleanUrl;
  1404. /**
  1405. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1406. * @param url define the url we are trying
  1407. * @param element define the dom element where to configure the cors policy
  1408. */
  1409. static SetCorsBehavior(url: string | string[], element: {
  1410. crossOrigin: string | null;
  1411. }): void;
  1412. /**
  1413. * Loads an image as an HTMLImageElement.
  1414. * @param input url string, ArrayBuffer, or Blob to load
  1415. * @param onLoad callback called when the image successfully loads
  1416. * @param onError callback called when the image fails to load
  1417. * @param offlineProvider offline provider for caching
  1418. * @param mimeType optional mime type
  1419. * @returns the HTMLImageElement of the loaded image
  1420. */
  1421. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  1422. /**
  1423. * Reads a file from a File object
  1424. * @param file defines the file to load
  1425. * @param onSuccess defines the callback to call when data is loaded
  1426. * @param onProgress defines the callback to call during loading process
  1427. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1428. * @param onError defines the callback to call when an error occurs
  1429. * @returns a file request object
  1430. */
  1431. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1432. /**
  1433. * Loads a file from a url
  1434. * @param url url to load
  1435. * @param onSuccess callback called when the file successfully loads
  1436. * @param onProgress callback called while file is loading (if the server supports this mode)
  1437. * @param offlineProvider defines the offline provider for caching
  1438. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1439. * @param onError callback called when the file fails to load
  1440. * @returns a file request object
  1441. */
  1442. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1443. /**
  1444. * Loads a file
  1445. * @param url url to load
  1446. * @param onSuccess callback called when the file successfully loads
  1447. * @param onProgress callback called while file is loading (if the server supports this mode)
  1448. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1449. * @param onError callback called when the file fails to load
  1450. * @param onOpened callback called when the web request is opened
  1451. * @returns a file request object
  1452. */
  1453. static RequestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (event: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  1454. /**
  1455. * Checks if the loaded document was accessed via `file:`-Protocol.
  1456. * @returns boolean
  1457. */
  1458. static IsFileURL(): boolean;
  1459. }
  1460. }
  1461. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1462. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1463. import { WebRequest } from "babylonjs/Misc/webRequest";
  1464. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1465. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1466. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1467. /** @hidden */
  1468. export class ShaderProcessor {
  1469. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1470. private static _ProcessPrecision;
  1471. private static _ExtractOperation;
  1472. private static _BuildSubExpression;
  1473. private static _BuildExpression;
  1474. private static _MoveCursorWithinIf;
  1475. private static _MoveCursor;
  1476. private static _EvaluatePreProcessors;
  1477. private static _PreparePreProcessors;
  1478. private static _ProcessShaderConversion;
  1479. private static _ProcessIncludes;
  1480. /**
  1481. * Loads a file from a url
  1482. * @param url url to load
  1483. * @param onSuccess callback called when the file successfully loads
  1484. * @param onProgress callback called while file is loading (if the server supports this mode)
  1485. * @param offlineProvider defines the offline provider for caching
  1486. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1487. * @param onError callback called when the file fails to load
  1488. * @returns a file request object
  1489. * @hidden
  1490. */
  1491. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  1492. }
  1493. }
  1494. declare module "babylonjs/Maths/math.like" {
  1495. import { float, int, DeepImmutable } from "babylonjs/types";
  1496. /**
  1497. * @hidden
  1498. */
  1499. export interface IColor4Like {
  1500. r: float;
  1501. g: float;
  1502. b: float;
  1503. a: float;
  1504. }
  1505. /**
  1506. * @hidden
  1507. */
  1508. export interface IColor3Like {
  1509. r: float;
  1510. g: float;
  1511. b: float;
  1512. }
  1513. /**
  1514. * @hidden
  1515. */
  1516. export interface IVector4Like {
  1517. x: float;
  1518. y: float;
  1519. z: float;
  1520. w: float;
  1521. }
  1522. /**
  1523. * @hidden
  1524. */
  1525. export interface IVector3Like {
  1526. x: float;
  1527. y: float;
  1528. z: float;
  1529. }
  1530. /**
  1531. * @hidden
  1532. */
  1533. export interface IVector2Like {
  1534. x: float;
  1535. y: float;
  1536. }
  1537. /**
  1538. * @hidden
  1539. */
  1540. export interface IMatrixLike {
  1541. toArray(): DeepImmutable<Float32Array>;
  1542. updateFlag: int;
  1543. }
  1544. /**
  1545. * @hidden
  1546. */
  1547. export interface IViewportLike {
  1548. x: float;
  1549. y: float;
  1550. width: float;
  1551. height: float;
  1552. }
  1553. /**
  1554. * @hidden
  1555. */
  1556. export interface IPlaneLike {
  1557. normal: IVector3Like;
  1558. d: float;
  1559. normalize(): void;
  1560. }
  1561. }
  1562. declare module "babylonjs/Materials/iEffectFallbacks" {
  1563. import { Effect } from "babylonjs/Materials/effect";
  1564. /**
  1565. * Interface used to define common properties for effect fallbacks
  1566. */
  1567. export interface IEffectFallbacks {
  1568. /**
  1569. * Removes the defines that should be removed when falling back.
  1570. * @param currentDefines defines the current define statements for the shader.
  1571. * @param effect defines the current effect we try to compile
  1572. * @returns The resulting defines with defines of the current rank removed.
  1573. */
  1574. reduce(currentDefines: string, effect: Effect): string;
  1575. /**
  1576. * Removes the fallback from the bound mesh.
  1577. */
  1578. unBindMesh(): void;
  1579. /**
  1580. * Checks to see if more fallbacks are still availible.
  1581. */
  1582. hasMoreFallbacks: boolean;
  1583. }
  1584. }
  1585. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1586. /**
  1587. * Class used to evalaute queries containing `and` and `or` operators
  1588. */
  1589. export class AndOrNotEvaluator {
  1590. /**
  1591. * Evaluate a query
  1592. * @param query defines the query to evaluate
  1593. * @param evaluateCallback defines the callback used to filter result
  1594. * @returns true if the query matches
  1595. */
  1596. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1597. private static _HandleParenthesisContent;
  1598. private static _SimplifyNegation;
  1599. }
  1600. }
  1601. declare module "babylonjs/Misc/tags" {
  1602. /**
  1603. * Class used to store custom tags
  1604. */
  1605. export class Tags {
  1606. /**
  1607. * Adds support for tags on the given object
  1608. * @param obj defines the object to use
  1609. */
  1610. static EnableFor(obj: any): void;
  1611. /**
  1612. * Removes tags support
  1613. * @param obj defines the object to use
  1614. */
  1615. static DisableFor(obj: any): void;
  1616. /**
  1617. * Gets a boolean indicating if the given object has tags
  1618. * @param obj defines the object to use
  1619. * @returns a boolean
  1620. */
  1621. static HasTags(obj: any): boolean;
  1622. /**
  1623. * Gets the tags available on a given object
  1624. * @param obj defines the object to use
  1625. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1626. * @returns the tags
  1627. */
  1628. static GetTags(obj: any, asString?: boolean): any;
  1629. /**
  1630. * Adds tags to an object
  1631. * @param obj defines the object to use
  1632. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1633. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1634. */
  1635. static AddTagsTo(obj: any, tagsString: string): void;
  1636. /**
  1637. * @hidden
  1638. */
  1639. static _AddTagTo(obj: any, tag: string): void;
  1640. /**
  1641. * Removes specific tags from a specific object
  1642. * @param obj defines the object to use
  1643. * @param tagsString defines the tags to remove
  1644. */
  1645. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1646. /**
  1647. * @hidden
  1648. */
  1649. static _RemoveTagFrom(obj: any, tag: string): void;
  1650. /**
  1651. * Defines if tags hosted on an object match a given query
  1652. * @param obj defines the object to use
  1653. * @param tagsQuery defines the tag query
  1654. * @returns a boolean
  1655. */
  1656. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1657. }
  1658. }
  1659. declare module "babylonjs/Maths/math.scalar" {
  1660. /**
  1661. * Scalar computation library
  1662. */
  1663. export class Scalar {
  1664. /**
  1665. * Two pi constants convenient for computation.
  1666. */
  1667. static TwoPi: number;
  1668. /**
  1669. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1670. * @param a number
  1671. * @param b number
  1672. * @param epsilon (default = 1.401298E-45)
  1673. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1674. */
  1675. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1676. /**
  1677. * Returns a string : the upper case translation of the number i to hexadecimal.
  1678. * @param i number
  1679. * @returns the upper case translation of the number i to hexadecimal.
  1680. */
  1681. static ToHex(i: number): string;
  1682. /**
  1683. * Returns -1 if value is negative and +1 is value is positive.
  1684. * @param value the value
  1685. * @returns the value itself if it's equal to zero.
  1686. */
  1687. static Sign(value: number): number;
  1688. /**
  1689. * Returns the value itself if it's between min and max.
  1690. * Returns min if the value is lower than min.
  1691. * Returns max if the value is greater than max.
  1692. * @param value the value to clmap
  1693. * @param min the min value to clamp to (default: 0)
  1694. * @param max the max value to clamp to (default: 1)
  1695. * @returns the clamped value
  1696. */
  1697. static Clamp(value: number, min?: number, max?: number): number;
  1698. /**
  1699. * the log2 of value.
  1700. * @param value the value to compute log2 of
  1701. * @returns the log2 of value.
  1702. */
  1703. static Log2(value: number): number;
  1704. /**
  1705. * Loops the value, so that it is never larger than length and never smaller than 0.
  1706. *
  1707. * This is similar to the modulo operator but it works with floating point numbers.
  1708. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1709. * With t = 5 and length = 2.5, the result would be 0.0.
  1710. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1711. * @param value the value
  1712. * @param length the length
  1713. * @returns the looped value
  1714. */
  1715. static Repeat(value: number, length: number): number;
  1716. /**
  1717. * Normalize the value between 0.0 and 1.0 using min and max values
  1718. * @param value value to normalize
  1719. * @param min max to normalize between
  1720. * @param max min to normalize between
  1721. * @returns the normalized value
  1722. */
  1723. static Normalize(value: number, min: number, max: number): number;
  1724. /**
  1725. * Denormalize the value from 0.0 and 1.0 using min and max values
  1726. * @param normalized value to denormalize
  1727. * @param min max to denormalize between
  1728. * @param max min to denormalize between
  1729. * @returns the denormalized value
  1730. */
  1731. static Denormalize(normalized: number, min: number, max: number): number;
  1732. /**
  1733. * Calculates the shortest difference between two given angles given in degrees.
  1734. * @param current current angle in degrees
  1735. * @param target target angle in degrees
  1736. * @returns the delta
  1737. */
  1738. static DeltaAngle(current: number, target: number): number;
  1739. /**
  1740. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1741. * @param tx value
  1742. * @param length length
  1743. * @returns The returned value will move back and forth between 0 and length
  1744. */
  1745. static PingPong(tx: number, length: number): number;
  1746. /**
  1747. * Interpolates between min and max with smoothing at the limits.
  1748. *
  1749. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1750. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1751. * @param from from
  1752. * @param to to
  1753. * @param tx value
  1754. * @returns the smooth stepped value
  1755. */
  1756. static SmoothStep(from: number, to: number, tx: number): number;
  1757. /**
  1758. * Moves a value current towards target.
  1759. *
  1760. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1761. * Negative values of maxDelta pushes the value away from target.
  1762. * @param current current value
  1763. * @param target target value
  1764. * @param maxDelta max distance to move
  1765. * @returns resulting value
  1766. */
  1767. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1768. /**
  1769. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1770. *
  1771. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1772. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1773. * @param current current value
  1774. * @param target target value
  1775. * @param maxDelta max distance to move
  1776. * @returns resulting angle
  1777. */
  1778. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1779. /**
  1780. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1781. * @param start start value
  1782. * @param end target value
  1783. * @param amount amount to lerp between
  1784. * @returns the lerped value
  1785. */
  1786. static Lerp(start: number, end: number, amount: number): number;
  1787. /**
  1788. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1789. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1790. * @param start start value
  1791. * @param end target value
  1792. * @param amount amount to lerp between
  1793. * @returns the lerped value
  1794. */
  1795. static LerpAngle(start: number, end: number, amount: number): number;
  1796. /**
  1797. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1798. * @param a start value
  1799. * @param b target value
  1800. * @param value value between a and b
  1801. * @returns the inverseLerp value
  1802. */
  1803. static InverseLerp(a: number, b: number, value: number): number;
  1804. /**
  1805. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1806. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1807. * @param value1 spline value
  1808. * @param tangent1 spline value
  1809. * @param value2 spline value
  1810. * @param tangent2 spline value
  1811. * @param amount input value
  1812. * @returns hermite result
  1813. */
  1814. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1815. /**
  1816. * Returns a random float number between and min and max values
  1817. * @param min min value of random
  1818. * @param max max value of random
  1819. * @returns random value
  1820. */
  1821. static RandomRange(min: number, max: number): number;
  1822. /**
  1823. * This function returns percentage of a number in a given range.
  1824. *
  1825. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1826. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1827. * @param number to convert to percentage
  1828. * @param min min range
  1829. * @param max max range
  1830. * @returns the percentage
  1831. */
  1832. static RangeToPercent(number: number, min: number, max: number): number;
  1833. /**
  1834. * This function returns number that corresponds to the percentage in a given range.
  1835. *
  1836. * PercentToRange(0.34,0,100) will return 34.
  1837. * @param percent to convert to number
  1838. * @param min min range
  1839. * @param max max range
  1840. * @returns the number
  1841. */
  1842. static PercentToRange(percent: number, min: number, max: number): number;
  1843. /**
  1844. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1845. * @param angle The angle to normalize in radian.
  1846. * @return The converted angle.
  1847. */
  1848. static NormalizeRadians(angle: number): number;
  1849. }
  1850. }
  1851. declare module "babylonjs/Maths/math.constants" {
  1852. /**
  1853. * Constant used to convert a value to gamma space
  1854. * @ignorenaming
  1855. */
  1856. export const ToGammaSpace: number;
  1857. /**
  1858. * Constant used to convert a value to linear space
  1859. * @ignorenaming
  1860. */
  1861. export const ToLinearSpace = 2.2;
  1862. /**
  1863. * Constant used to define the minimal number value in Babylon.js
  1864. * @ignorenaming
  1865. */
  1866. let Epsilon: number;
  1867. export { Epsilon };
  1868. }
  1869. declare module "babylonjs/Maths/math.viewport" {
  1870. /**
  1871. * Class used to represent a viewport on screen
  1872. */
  1873. export class Viewport {
  1874. /** viewport left coordinate */
  1875. x: number;
  1876. /** viewport top coordinate */
  1877. y: number;
  1878. /**viewport width */
  1879. width: number;
  1880. /** viewport height */
  1881. height: number;
  1882. /**
  1883. * Creates a Viewport object located at (x, y) and sized (width, height)
  1884. * @param x defines viewport left coordinate
  1885. * @param y defines viewport top coordinate
  1886. * @param width defines the viewport width
  1887. * @param height defines the viewport height
  1888. */
  1889. constructor(
  1890. /** viewport left coordinate */
  1891. x: number,
  1892. /** viewport top coordinate */
  1893. y: number,
  1894. /**viewport width */
  1895. width: number,
  1896. /** viewport height */
  1897. height: number);
  1898. /**
  1899. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1900. * @param renderWidth defines the rendering width
  1901. * @param renderHeight defines the rendering height
  1902. * @returns a new Viewport
  1903. */
  1904. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1905. /**
  1906. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1907. * @param renderWidth defines the rendering width
  1908. * @param renderHeight defines the rendering height
  1909. * @param ref defines the target viewport
  1910. * @returns the current viewport
  1911. */
  1912. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1913. /**
  1914. * Returns a new Viewport copied from the current one
  1915. * @returns a new Viewport
  1916. */
  1917. clone(): Viewport;
  1918. }
  1919. }
  1920. declare module "babylonjs/Misc/arrayTools" {
  1921. /**
  1922. * Class containing a set of static utilities functions for arrays.
  1923. */
  1924. export class ArrayTools {
  1925. /**
  1926. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1927. * @param size the number of element to construct and put in the array
  1928. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1929. * @returns a new array filled with new objects
  1930. */
  1931. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1932. }
  1933. }
  1934. declare module "babylonjs/Maths/math.vector" {
  1935. import { Viewport } from "babylonjs/Maths/math.viewport";
  1936. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  1937. import { IPlaneLike } from "babylonjs/Maths/math.like";
  1938. /**
  1939. * Class representing a vector containing 2 coordinates
  1940. */
  1941. export class Vector2 {
  1942. /** defines the first coordinate */
  1943. x: number;
  1944. /** defines the second coordinate */
  1945. y: number;
  1946. /**
  1947. * Creates a new Vector2 from the given x and y coordinates
  1948. * @param x defines the first coordinate
  1949. * @param y defines the second coordinate
  1950. */
  1951. constructor(
  1952. /** defines the first coordinate */
  1953. x?: number,
  1954. /** defines the second coordinate */
  1955. y?: number);
  1956. /**
  1957. * Gets a string with the Vector2 coordinates
  1958. * @returns a string with the Vector2 coordinates
  1959. */
  1960. toString(): string;
  1961. /**
  1962. * Gets class name
  1963. * @returns the string "Vector2"
  1964. */
  1965. getClassName(): string;
  1966. /**
  1967. * Gets current vector hash code
  1968. * @returns the Vector2 hash code as a number
  1969. */
  1970. getHashCode(): number;
  1971. /**
  1972. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1973. * @param array defines the source array
  1974. * @param index defines the offset in source array
  1975. * @returns the current Vector2
  1976. */
  1977. toArray(array: FloatArray, index?: number): Vector2;
  1978. /**
  1979. * Copy the current vector to an array
  1980. * @returns a new array with 2 elements: the Vector2 coordinates.
  1981. */
  1982. asArray(): number[];
  1983. /**
  1984. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1985. * @param source defines the source Vector2
  1986. * @returns the current updated Vector2
  1987. */
  1988. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1989. /**
  1990. * Sets the Vector2 coordinates with the given floats
  1991. * @param x defines the first coordinate
  1992. * @param y defines the second coordinate
  1993. * @returns the current updated Vector2
  1994. */
  1995. copyFromFloats(x: number, y: number): Vector2;
  1996. /**
  1997. * Sets the Vector2 coordinates with the given floats
  1998. * @param x defines the first coordinate
  1999. * @param y defines the second coordinate
  2000. * @returns the current updated Vector2
  2001. */
  2002. set(x: number, y: number): Vector2;
  2003. /**
  2004. * Add another vector with the current one
  2005. * @param otherVector defines the other vector
  2006. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2007. */
  2008. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2009. /**
  2010. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2011. * @param otherVector defines the other vector
  2012. * @param result defines the target vector
  2013. * @returns the unmodified current Vector2
  2014. */
  2015. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2016. /**
  2017. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2018. * @param otherVector defines the other vector
  2019. * @returns the current updated Vector2
  2020. */
  2021. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2022. /**
  2023. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2024. * @param otherVector defines the other vector
  2025. * @returns a new Vector2
  2026. */
  2027. addVector3(otherVector: Vector3): Vector2;
  2028. /**
  2029. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2030. * @param otherVector defines the other vector
  2031. * @returns a new Vector2
  2032. */
  2033. subtract(otherVector: Vector2): Vector2;
  2034. /**
  2035. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2036. * @param otherVector defines the other vector
  2037. * @param result defines the target vector
  2038. * @returns the unmodified current Vector2
  2039. */
  2040. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2041. /**
  2042. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2043. * @param otherVector defines the other vector
  2044. * @returns the current updated Vector2
  2045. */
  2046. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2047. /**
  2048. * Multiplies in place the current Vector2 coordinates by the given ones
  2049. * @param otherVector defines the other vector
  2050. * @returns the current updated Vector2
  2051. */
  2052. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2053. /**
  2054. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2055. * @param otherVector defines the other vector
  2056. * @returns a new Vector2
  2057. */
  2058. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2059. /**
  2060. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2061. * @param otherVector defines the other vector
  2062. * @param result defines the target vector
  2063. * @returns the unmodified current Vector2
  2064. */
  2065. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2066. /**
  2067. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2068. * @param x defines the first coordinate
  2069. * @param y defines the second coordinate
  2070. * @returns a new Vector2
  2071. */
  2072. multiplyByFloats(x: number, y: number): Vector2;
  2073. /**
  2074. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2075. * @param otherVector defines the other vector
  2076. * @returns a new Vector2
  2077. */
  2078. divide(otherVector: Vector2): Vector2;
  2079. /**
  2080. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2081. * @param otherVector defines the other vector
  2082. * @param result defines the target vector
  2083. * @returns the unmodified current Vector2
  2084. */
  2085. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2086. /**
  2087. * Divides the current Vector2 coordinates by the given ones
  2088. * @param otherVector defines the other vector
  2089. * @returns the current updated Vector2
  2090. */
  2091. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2092. /**
  2093. * Gets a new Vector2 with current Vector2 negated coordinates
  2094. * @returns a new Vector2
  2095. */
  2096. negate(): Vector2;
  2097. /**
  2098. * Negate this vector in place
  2099. * @returns this
  2100. */
  2101. negateInPlace(): Vector2;
  2102. /**
  2103. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2104. * @param result defines the Vector3 object where to store the result
  2105. * @returns the current Vector2
  2106. */
  2107. negateToRef(result: Vector2): Vector2;
  2108. /**
  2109. * Multiply the Vector2 coordinates by scale
  2110. * @param scale defines the scaling factor
  2111. * @returns the current updated Vector2
  2112. */
  2113. scaleInPlace(scale: number): Vector2;
  2114. /**
  2115. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2116. * @param scale defines the scaling factor
  2117. * @returns a new Vector2
  2118. */
  2119. scale(scale: number): Vector2;
  2120. /**
  2121. * Scale the current Vector2 values by a factor to a given Vector2
  2122. * @param scale defines the scale factor
  2123. * @param result defines the Vector2 object where to store the result
  2124. * @returns the unmodified current Vector2
  2125. */
  2126. scaleToRef(scale: number, result: Vector2): Vector2;
  2127. /**
  2128. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2129. * @param scale defines the scale factor
  2130. * @param result defines the Vector2 object where to store the result
  2131. * @returns the unmodified current Vector2
  2132. */
  2133. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2134. /**
  2135. * Gets a boolean if two vectors are equals
  2136. * @param otherVector defines the other vector
  2137. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2138. */
  2139. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2140. /**
  2141. * Gets a boolean if two vectors are equals (using an epsilon value)
  2142. * @param otherVector defines the other vector
  2143. * @param epsilon defines the minimal distance to consider equality
  2144. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2145. */
  2146. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2147. /**
  2148. * Gets a new Vector2 from current Vector2 floored values
  2149. * @returns a new Vector2
  2150. */
  2151. floor(): Vector2;
  2152. /**
  2153. * Gets a new Vector2 from current Vector2 floored values
  2154. * @returns a new Vector2
  2155. */
  2156. fract(): Vector2;
  2157. /**
  2158. * Gets the length of the vector
  2159. * @returns the vector length (float)
  2160. */
  2161. length(): number;
  2162. /**
  2163. * Gets the vector squared length
  2164. * @returns the vector squared length (float)
  2165. */
  2166. lengthSquared(): number;
  2167. /**
  2168. * Normalize the vector
  2169. * @returns the current updated Vector2
  2170. */
  2171. normalize(): Vector2;
  2172. /**
  2173. * Gets a new Vector2 copied from the Vector2
  2174. * @returns a new Vector2
  2175. */
  2176. clone(): Vector2;
  2177. /**
  2178. * Gets a new Vector2(0, 0)
  2179. * @returns a new Vector2
  2180. */
  2181. static Zero(): Vector2;
  2182. /**
  2183. * Gets a new Vector2(1, 1)
  2184. * @returns a new Vector2
  2185. */
  2186. static One(): Vector2;
  2187. /**
  2188. * Gets a new Vector2 set from the given index element of the given array
  2189. * @param array defines the data source
  2190. * @param offset defines the offset in the data source
  2191. * @returns a new Vector2
  2192. */
  2193. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2194. /**
  2195. * Sets "result" from the given index element of the given array
  2196. * @param array defines the data source
  2197. * @param offset defines the offset in the data source
  2198. * @param result defines the target vector
  2199. */
  2200. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2201. /**
  2202. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2203. * @param value1 defines 1st point of control
  2204. * @param value2 defines 2nd point of control
  2205. * @param value3 defines 3rd point of control
  2206. * @param value4 defines 4th point of control
  2207. * @param amount defines the interpolation factor
  2208. * @returns a new Vector2
  2209. */
  2210. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2211. /**
  2212. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  2213. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2214. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2215. * @param value defines the value to clamp
  2216. * @param min defines the lower limit
  2217. * @param max defines the upper limit
  2218. * @returns a new Vector2
  2219. */
  2220. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2221. /**
  2222. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2223. * @param value1 defines the 1st control point
  2224. * @param tangent1 defines the outgoing tangent
  2225. * @param value2 defines the 2nd control point
  2226. * @param tangent2 defines the incoming tangent
  2227. * @param amount defines the interpolation factor
  2228. * @returns a new Vector2
  2229. */
  2230. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2231. /**
  2232. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2233. * @param start defines the start vector
  2234. * @param end defines the end vector
  2235. * @param amount defines the interpolation factor
  2236. * @returns a new Vector2
  2237. */
  2238. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2239. /**
  2240. * Gets the dot product of the vector "left" and the vector "right"
  2241. * @param left defines first vector
  2242. * @param right defines second vector
  2243. * @returns the dot product (float)
  2244. */
  2245. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2246. /**
  2247. * Returns a new Vector2 equal to the normalized given vector
  2248. * @param vector defines the vector to normalize
  2249. * @returns a new Vector2
  2250. */
  2251. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2252. /**
  2253. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2254. * @param left defines 1st vector
  2255. * @param right defines 2nd vector
  2256. * @returns a new Vector2
  2257. */
  2258. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2259. /**
  2260. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2261. * @param left defines 1st vector
  2262. * @param right defines 2nd vector
  2263. * @returns a new Vector2
  2264. */
  2265. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2266. /**
  2267. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2268. * @param vector defines the vector to transform
  2269. * @param transformation defines the matrix to apply
  2270. * @returns a new Vector2
  2271. */
  2272. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2273. /**
  2274. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2275. * @param vector defines the vector to transform
  2276. * @param transformation defines the matrix to apply
  2277. * @param result defines the target vector
  2278. */
  2279. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2280. /**
  2281. * Determines if a given vector is included in a triangle
  2282. * @param p defines the vector to test
  2283. * @param p0 defines 1st triangle point
  2284. * @param p1 defines 2nd triangle point
  2285. * @param p2 defines 3rd triangle point
  2286. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2287. */
  2288. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2289. /**
  2290. * Gets the distance between the vectors "value1" and "value2"
  2291. * @param value1 defines first vector
  2292. * @param value2 defines second vector
  2293. * @returns the distance between vectors
  2294. */
  2295. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2296. /**
  2297. * Returns the squared distance between the vectors "value1" and "value2"
  2298. * @param value1 defines first vector
  2299. * @param value2 defines second vector
  2300. * @returns the squared distance between vectors
  2301. */
  2302. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2303. /**
  2304. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2305. * @param value1 defines first vector
  2306. * @param value2 defines second vector
  2307. * @returns a new Vector2
  2308. */
  2309. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2310. /**
  2311. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2312. * @param p defines the middle point
  2313. * @param segA defines one point of the segment
  2314. * @param segB defines the other point of the segment
  2315. * @returns the shortest distance
  2316. */
  2317. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2318. }
  2319. /**
  2320. * Class used to store (x,y,z) vector representation
  2321. * A Vector3 is the main object used in 3D geometry
  2322. * It can represent etiher the coordinates of a point the space, either a direction
  2323. * Reminder: js uses a left handed forward facing system
  2324. */
  2325. export class Vector3 {
  2326. /**
  2327. * Defines the first coordinates (on X axis)
  2328. */
  2329. x: number;
  2330. /**
  2331. * Defines the second coordinates (on Y axis)
  2332. */
  2333. y: number;
  2334. /**
  2335. * Defines the third coordinates (on Z axis)
  2336. */
  2337. z: number;
  2338. private static _UpReadOnly;
  2339. private static _ZeroReadOnly;
  2340. /**
  2341. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2342. * @param x defines the first coordinates (on X axis)
  2343. * @param y defines the second coordinates (on Y axis)
  2344. * @param z defines the third coordinates (on Z axis)
  2345. */
  2346. constructor(
  2347. /**
  2348. * Defines the first coordinates (on X axis)
  2349. */
  2350. x?: number,
  2351. /**
  2352. * Defines the second coordinates (on Y axis)
  2353. */
  2354. y?: number,
  2355. /**
  2356. * Defines the third coordinates (on Z axis)
  2357. */
  2358. z?: number);
  2359. /**
  2360. * Creates a string representation of the Vector3
  2361. * @returns a string with the Vector3 coordinates.
  2362. */
  2363. toString(): string;
  2364. /**
  2365. * Gets the class name
  2366. * @returns the string "Vector3"
  2367. */
  2368. getClassName(): string;
  2369. /**
  2370. * Creates the Vector3 hash code
  2371. * @returns a number which tends to be unique between Vector3 instances
  2372. */
  2373. getHashCode(): number;
  2374. /**
  2375. * Creates an array containing three elements : the coordinates of the Vector3
  2376. * @returns a new array of numbers
  2377. */
  2378. asArray(): number[];
  2379. /**
  2380. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2381. * @param array defines the destination array
  2382. * @param index defines the offset in the destination array
  2383. * @returns the current Vector3
  2384. */
  2385. toArray(array: FloatArray, index?: number): Vector3;
  2386. /**
  2387. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2388. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2389. */
  2390. toQuaternion(): Quaternion;
  2391. /**
  2392. * Adds the given vector to the current Vector3
  2393. * @param otherVector defines the second operand
  2394. * @returns the current updated Vector3
  2395. */
  2396. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2397. /**
  2398. * Adds the given coordinates to the current Vector3
  2399. * @param x defines the x coordinate of the operand
  2400. * @param y defines the y coordinate of the operand
  2401. * @param z defines the z coordinate of the operand
  2402. * @returns the current updated Vector3
  2403. */
  2404. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2405. /**
  2406. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2407. * @param otherVector defines the second operand
  2408. * @returns the resulting Vector3
  2409. */
  2410. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2411. /**
  2412. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2413. * @param otherVector defines the second operand
  2414. * @param result defines the Vector3 object where to store the result
  2415. * @returns the current Vector3
  2416. */
  2417. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2418. /**
  2419. * Subtract the given vector from the current Vector3
  2420. * @param otherVector defines the second operand
  2421. * @returns the current updated Vector3
  2422. */
  2423. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2424. /**
  2425. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2426. * @param otherVector defines the second operand
  2427. * @returns the resulting Vector3
  2428. */
  2429. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2430. /**
  2431. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2432. * @param otherVector defines the second operand
  2433. * @param result defines the Vector3 object where to store the result
  2434. * @returns the current Vector3
  2435. */
  2436. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2437. /**
  2438. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2439. * @param x defines the x coordinate of the operand
  2440. * @param y defines the y coordinate of the operand
  2441. * @param z defines the z coordinate of the operand
  2442. * @returns the resulting Vector3
  2443. */
  2444. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2445. /**
  2446. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2447. * @param x defines the x coordinate of the operand
  2448. * @param y defines the y coordinate of the operand
  2449. * @param z defines the z coordinate of the operand
  2450. * @param result defines the Vector3 object where to store the result
  2451. * @returns the current Vector3
  2452. */
  2453. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2454. /**
  2455. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2456. * @returns a new Vector3
  2457. */
  2458. negate(): Vector3;
  2459. /**
  2460. * Negate this vector in place
  2461. * @returns this
  2462. */
  2463. negateInPlace(): Vector3;
  2464. /**
  2465. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2466. * @param result defines the Vector3 object where to store the result
  2467. * @returns the current Vector3
  2468. */
  2469. negateToRef(result: Vector3): Vector3;
  2470. /**
  2471. * Multiplies the Vector3 coordinates by the float "scale"
  2472. * @param scale defines the multiplier factor
  2473. * @returns the current updated Vector3
  2474. */
  2475. scaleInPlace(scale: number): Vector3;
  2476. /**
  2477. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2478. * @param scale defines the multiplier factor
  2479. * @returns a new Vector3
  2480. */
  2481. scale(scale: number): Vector3;
  2482. /**
  2483. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2484. * @param scale defines the multiplier factor
  2485. * @param result defines the Vector3 object where to store the result
  2486. * @returns the current Vector3
  2487. */
  2488. scaleToRef(scale: number, result: Vector3): Vector3;
  2489. /**
  2490. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2491. * @param scale defines the scale factor
  2492. * @param result defines the Vector3 object where to store the result
  2493. * @returns the unmodified current Vector3
  2494. */
  2495. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2496. /**
  2497. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2498. * @param otherVector defines the second operand
  2499. * @returns true if both vectors are equals
  2500. */
  2501. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2502. /**
  2503. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2504. * @param otherVector defines the second operand
  2505. * @param epsilon defines the minimal distance to define values as equals
  2506. * @returns true if both vectors are distant less than epsilon
  2507. */
  2508. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2509. /**
  2510. * Returns true if the current Vector3 coordinates equals the given floats
  2511. * @param x defines the x coordinate of the operand
  2512. * @param y defines the y coordinate of the operand
  2513. * @param z defines the z coordinate of the operand
  2514. * @returns true if both vectors are equals
  2515. */
  2516. equalsToFloats(x: number, y: number, z: number): boolean;
  2517. /**
  2518. * Multiplies the current Vector3 coordinates by the given ones
  2519. * @param otherVector defines the second operand
  2520. * @returns the current updated Vector3
  2521. */
  2522. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2523. /**
  2524. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2525. * @param otherVector defines the second operand
  2526. * @returns the new Vector3
  2527. */
  2528. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2529. /**
  2530. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2531. * @param otherVector defines the second operand
  2532. * @param result defines the Vector3 object where to store the result
  2533. * @returns the current Vector3
  2534. */
  2535. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2536. /**
  2537. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2538. * @param x defines the x coordinate of the operand
  2539. * @param y defines the y coordinate of the operand
  2540. * @param z defines the z coordinate of the operand
  2541. * @returns the new Vector3
  2542. */
  2543. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2544. /**
  2545. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2546. * @param otherVector defines the second operand
  2547. * @returns the new Vector3
  2548. */
  2549. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2550. /**
  2551. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2552. * @param otherVector defines the second operand
  2553. * @param result defines the Vector3 object where to store the result
  2554. * @returns the current Vector3
  2555. */
  2556. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2557. /**
  2558. * Divides the current Vector3 coordinates by the given ones.
  2559. * @param otherVector defines the second operand
  2560. * @returns the current updated Vector3
  2561. */
  2562. divideInPlace(otherVector: Vector3): Vector3;
  2563. /**
  2564. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2565. * @param other defines the second operand
  2566. * @returns the current updated Vector3
  2567. */
  2568. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2569. /**
  2570. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2571. * @param other defines the second operand
  2572. * @returns the current updated Vector3
  2573. */
  2574. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2575. /**
  2576. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2577. * @param x defines the x coordinate of the operand
  2578. * @param y defines the y coordinate of the operand
  2579. * @param z defines the z coordinate of the operand
  2580. * @returns the current updated Vector3
  2581. */
  2582. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2583. /**
  2584. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2585. * @param x defines the x coordinate of the operand
  2586. * @param y defines the y coordinate of the operand
  2587. * @param z defines the z coordinate of the operand
  2588. * @returns the current updated Vector3
  2589. */
  2590. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2591. /**
  2592. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2593. * Check if is non uniform within a certain amount of decimal places to account for this
  2594. * @param epsilon the amount the values can differ
  2595. * @returns if the the vector is non uniform to a certain number of decimal places
  2596. */
  2597. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2598. /**
  2599. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2600. */
  2601. get isNonUniform(): boolean;
  2602. /**
  2603. * Gets a new Vector3 from current Vector3 floored values
  2604. * @returns a new Vector3
  2605. */
  2606. floor(): Vector3;
  2607. /**
  2608. * Gets a new Vector3 from current Vector3 floored values
  2609. * @returns a new Vector3
  2610. */
  2611. fract(): Vector3;
  2612. /**
  2613. * Gets the length of the Vector3
  2614. * @returns the length of the Vector3
  2615. */
  2616. length(): number;
  2617. /**
  2618. * Gets the squared length of the Vector3
  2619. * @returns squared length of the Vector3
  2620. */
  2621. lengthSquared(): number;
  2622. /**
  2623. * Normalize the current Vector3.
  2624. * Please note that this is an in place operation.
  2625. * @returns the current updated Vector3
  2626. */
  2627. normalize(): Vector3;
  2628. /**
  2629. * Reorders the x y z properties of the vector in place
  2630. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2631. * @returns the current updated vector
  2632. */
  2633. reorderInPlace(order: string): this;
  2634. /**
  2635. * Rotates the vector around 0,0,0 by a quaternion
  2636. * @param quaternion the rotation quaternion
  2637. * @param result vector to store the result
  2638. * @returns the resulting vector
  2639. */
  2640. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2641. /**
  2642. * Rotates a vector around a given point
  2643. * @param quaternion the rotation quaternion
  2644. * @param point the point to rotate around
  2645. * @param result vector to store the result
  2646. * @returns the resulting vector
  2647. */
  2648. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2649. /**
  2650. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2651. * The cross product is then orthogonal to both current and "other"
  2652. * @param other defines the right operand
  2653. * @returns the cross product
  2654. */
  2655. cross(other: Vector3): Vector3;
  2656. /**
  2657. * Normalize the current Vector3 with the given input length.
  2658. * Please note that this is an in place operation.
  2659. * @param len the length of the vector
  2660. * @returns the current updated Vector3
  2661. */
  2662. normalizeFromLength(len: number): Vector3;
  2663. /**
  2664. * Normalize the current Vector3 to a new vector
  2665. * @returns the new Vector3
  2666. */
  2667. normalizeToNew(): Vector3;
  2668. /**
  2669. * Normalize the current Vector3 to the reference
  2670. * @param reference define the Vector3 to update
  2671. * @returns the updated Vector3
  2672. */
  2673. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2674. /**
  2675. * Creates a new Vector3 copied from the current Vector3
  2676. * @returns the new Vector3
  2677. */
  2678. clone(): Vector3;
  2679. /**
  2680. * Copies the given vector coordinates to the current Vector3 ones
  2681. * @param source defines the source Vector3
  2682. * @returns the current updated Vector3
  2683. */
  2684. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2685. /**
  2686. * Copies the given floats to the current Vector3 coordinates
  2687. * @param x defines the x coordinate of the operand
  2688. * @param y defines the y coordinate of the operand
  2689. * @param z defines the z coordinate of the operand
  2690. * @returns the current updated Vector3
  2691. */
  2692. copyFromFloats(x: number, y: number, z: number): Vector3;
  2693. /**
  2694. * Copies the given floats to the current Vector3 coordinates
  2695. * @param x defines the x coordinate of the operand
  2696. * @param y defines the y coordinate of the operand
  2697. * @param z defines the z coordinate of the operand
  2698. * @returns the current updated Vector3
  2699. */
  2700. set(x: number, y: number, z: number): Vector3;
  2701. /**
  2702. * Copies the given float to the current Vector3 coordinates
  2703. * @param v defines the x, y and z coordinates of the operand
  2704. * @returns the current updated Vector3
  2705. */
  2706. setAll(v: number): Vector3;
  2707. /**
  2708. * Get the clip factor between two vectors
  2709. * @param vector0 defines the first operand
  2710. * @param vector1 defines the second operand
  2711. * @param axis defines the axis to use
  2712. * @param size defines the size along the axis
  2713. * @returns the clip factor
  2714. */
  2715. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2716. /**
  2717. * Get angle between two vectors
  2718. * @param vector0 angle between vector0 and vector1
  2719. * @param vector1 angle between vector0 and vector1
  2720. * @param normal direction of the normal
  2721. * @return the angle between vector0 and vector1
  2722. */
  2723. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2724. /**
  2725. * Returns a new Vector3 set from the index "offset" of the given array
  2726. * @param array defines the source array
  2727. * @param offset defines the offset in the source array
  2728. * @returns the new Vector3
  2729. */
  2730. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2731. /**
  2732. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2733. * @param array defines the source array
  2734. * @param offset defines the offset in the source array
  2735. * @returns the new Vector3
  2736. * @deprecated Please use FromArray instead.
  2737. */
  2738. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2739. /**
  2740. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2741. * @param array defines the source array
  2742. * @param offset defines the offset in the source array
  2743. * @param result defines the Vector3 where to store the result
  2744. */
  2745. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2746. /**
  2747. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2748. * @param array defines the source array
  2749. * @param offset defines the offset in the source array
  2750. * @param result defines the Vector3 where to store the result
  2751. * @deprecated Please use FromArrayToRef instead.
  2752. */
  2753. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2754. /**
  2755. * Sets the given vector "result" with the given floats.
  2756. * @param x defines the x coordinate of the source
  2757. * @param y defines the y coordinate of the source
  2758. * @param z defines the z coordinate of the source
  2759. * @param result defines the Vector3 where to store the result
  2760. */
  2761. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2762. /**
  2763. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2764. * @returns a new empty Vector3
  2765. */
  2766. static Zero(): Vector3;
  2767. /**
  2768. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2769. * @returns a new unit Vector3
  2770. */
  2771. static One(): Vector3;
  2772. /**
  2773. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2774. * @returns a new up Vector3
  2775. */
  2776. static Up(): Vector3;
  2777. /**
  2778. * Gets a up Vector3 that must not be updated
  2779. */
  2780. static get UpReadOnly(): DeepImmutable<Vector3>;
  2781. /**
  2782. * Gets a zero Vector3 that must not be updated
  2783. */
  2784. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2785. /**
  2786. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2787. * @returns a new down Vector3
  2788. */
  2789. static Down(): Vector3;
  2790. /**
  2791. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2792. * @returns a new forward Vector3
  2793. */
  2794. static Forward(): Vector3;
  2795. /**
  2796. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2797. * @returns a new forward Vector3
  2798. */
  2799. static Backward(): Vector3;
  2800. /**
  2801. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2802. * @returns a new right Vector3
  2803. */
  2804. static Right(): Vector3;
  2805. /**
  2806. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2807. * @returns a new left Vector3
  2808. */
  2809. static Left(): Vector3;
  2810. /**
  2811. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2812. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2813. * @param vector defines the Vector3 to transform
  2814. * @param transformation defines the transformation matrix
  2815. * @returns the transformed Vector3
  2816. */
  2817. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2818. /**
  2819. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2820. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2821. * @param vector defines the Vector3 to transform
  2822. * @param transformation defines the transformation matrix
  2823. * @param result defines the Vector3 where to store the result
  2824. */
  2825. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2826. /**
  2827. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2828. * This method computes tranformed coordinates only, not transformed direction vectors
  2829. * @param x define the x coordinate of the source vector
  2830. * @param y define the y coordinate of the source vector
  2831. * @param z define the z coordinate of the source vector
  2832. * @param transformation defines the transformation matrix
  2833. * @param result defines the Vector3 where to store the result
  2834. */
  2835. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2836. /**
  2837. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2838. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2839. * @param vector defines the Vector3 to transform
  2840. * @param transformation defines the transformation matrix
  2841. * @returns the new Vector3
  2842. */
  2843. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2844. /**
  2845. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2846. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2847. * @param vector defines the Vector3 to transform
  2848. * @param transformation defines the transformation matrix
  2849. * @param result defines the Vector3 where to store the result
  2850. */
  2851. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2852. /**
  2853. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2854. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2855. * @param x define the x coordinate of the source vector
  2856. * @param y define the y coordinate of the source vector
  2857. * @param z define the z coordinate of the source vector
  2858. * @param transformation defines the transformation matrix
  2859. * @param result defines the Vector3 where to store the result
  2860. */
  2861. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2862. /**
  2863. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2864. * @param value1 defines the first control point
  2865. * @param value2 defines the second control point
  2866. * @param value3 defines the third control point
  2867. * @param value4 defines the fourth control point
  2868. * @param amount defines the amount on the spline to use
  2869. * @returns the new Vector3
  2870. */
  2871. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2872. /**
  2873. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2874. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2875. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2876. * @param value defines the current value
  2877. * @param min defines the lower range value
  2878. * @param max defines the upper range value
  2879. * @returns the new Vector3
  2880. */
  2881. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2882. /**
  2883. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  2884. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2885. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2886. * @param value defines the current value
  2887. * @param min defines the lower range value
  2888. * @param max defines the upper range value
  2889. * @param result defines the Vector3 where to store the result
  2890. */
  2891. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2892. /**
  2893. * Checks if a given vector is inside a specific range
  2894. * @param v defines the vector to test
  2895. * @param min defines the minimum range
  2896. * @param max defines the maximum range
  2897. */
  2898. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2899. /**
  2900. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2901. * @param value1 defines the first control point
  2902. * @param tangent1 defines the first tangent vector
  2903. * @param value2 defines the second control point
  2904. * @param tangent2 defines the second tangent vector
  2905. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2906. * @returns the new Vector3
  2907. */
  2908. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2909. /**
  2910. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2911. * @param start defines the start value
  2912. * @param end defines the end value
  2913. * @param amount max defines amount between both (between 0 and 1)
  2914. * @returns the new Vector3
  2915. */
  2916. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2917. /**
  2918. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2919. * @param start defines the start value
  2920. * @param end defines the end value
  2921. * @param amount max defines amount between both (between 0 and 1)
  2922. * @param result defines the Vector3 where to store the result
  2923. */
  2924. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2925. /**
  2926. * Returns the dot product (float) between the vectors "left" and "right"
  2927. * @param left defines the left operand
  2928. * @param right defines the right operand
  2929. * @returns the dot product
  2930. */
  2931. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2932. /**
  2933. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2934. * The cross product is then orthogonal to both "left" and "right"
  2935. * @param left defines the left operand
  2936. * @param right defines the right operand
  2937. * @returns the cross product
  2938. */
  2939. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2940. /**
  2941. * Sets the given vector "result" with the cross product of "left" and "right"
  2942. * The cross product is then orthogonal to both "left" and "right"
  2943. * @param left defines the left operand
  2944. * @param right defines the right operand
  2945. * @param result defines the Vector3 where to store the result
  2946. */
  2947. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2948. /**
  2949. * Returns a new Vector3 as the normalization of the given vector
  2950. * @param vector defines the Vector3 to normalize
  2951. * @returns the new Vector3
  2952. */
  2953. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2954. /**
  2955. * Sets the given vector "result" with the normalization of the given first vector
  2956. * @param vector defines the Vector3 to normalize
  2957. * @param result defines the Vector3 where to store the result
  2958. */
  2959. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2960. /**
  2961. * Project a Vector3 onto screen space
  2962. * @param vector defines the Vector3 to project
  2963. * @param world defines the world matrix to use
  2964. * @param transform defines the transform (view x projection) matrix to use
  2965. * @param viewport defines the screen viewport to use
  2966. * @returns the new Vector3
  2967. */
  2968. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2969. /** @hidden */
  2970. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2971. /**
  2972. * Unproject from screen space to object space
  2973. * @param source defines the screen space Vector3 to use
  2974. * @param viewportWidth defines the current width of the viewport
  2975. * @param viewportHeight defines the current height of the viewport
  2976. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2977. * @param transform defines the transform (view x projection) matrix to use
  2978. * @returns the new Vector3
  2979. */
  2980. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2981. /**
  2982. * Unproject from screen space to object space
  2983. * @param source defines the screen space Vector3 to use
  2984. * @param viewportWidth defines the current width of the viewport
  2985. * @param viewportHeight defines the current height of the viewport
  2986. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2987. * @param view defines the view matrix to use
  2988. * @param projection defines the projection matrix to use
  2989. * @returns the new Vector3
  2990. */
  2991. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2992. /**
  2993. * Unproject from screen space to object space
  2994. * @param source defines the screen space Vector3 to use
  2995. * @param viewportWidth defines the current width of the viewport
  2996. * @param viewportHeight defines the current height of the viewport
  2997. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2998. * @param view defines the view matrix to use
  2999. * @param projection defines the projection matrix to use
  3000. * @param result defines the Vector3 where to store the result
  3001. */
  3002. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3003. /**
  3004. * Unproject from screen space to object space
  3005. * @param sourceX defines the screen space x coordinate to use
  3006. * @param sourceY defines the screen space y coordinate to use
  3007. * @param sourceZ defines the screen space z coordinate to use
  3008. * @param viewportWidth defines the current width of the viewport
  3009. * @param viewportHeight defines the current height of the viewport
  3010. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3011. * @param view defines the view matrix to use
  3012. * @param projection defines the projection matrix to use
  3013. * @param result defines the Vector3 where to store the result
  3014. */
  3015. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3016. /**
  3017. * Gets the minimal coordinate values between two Vector3
  3018. * @param left defines the first operand
  3019. * @param right defines the second operand
  3020. * @returns the new Vector3
  3021. */
  3022. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3023. /**
  3024. * Gets the maximal coordinate values between two Vector3
  3025. * @param left defines the first operand
  3026. * @param right defines the second operand
  3027. * @returns the new Vector3
  3028. */
  3029. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3030. /**
  3031. * Returns the distance between the vectors "value1" and "value2"
  3032. * @param value1 defines the first operand
  3033. * @param value2 defines the second operand
  3034. * @returns the distance
  3035. */
  3036. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3037. /**
  3038. * Returns the squared distance between the vectors "value1" and "value2"
  3039. * @param value1 defines the first operand
  3040. * @param value2 defines the second operand
  3041. * @returns the squared distance
  3042. */
  3043. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3044. /**
  3045. * Returns a new Vector3 located at the center between "value1" and "value2"
  3046. * @param value1 defines the first operand
  3047. * @param value2 defines the second operand
  3048. * @returns the new Vector3
  3049. */
  3050. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3051. /**
  3052. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3053. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3054. * to something in order to rotate it from its local system to the given target system
  3055. * Note: axis1, axis2 and axis3 are normalized during this operation
  3056. * @param axis1 defines the first axis
  3057. * @param axis2 defines the second axis
  3058. * @param axis3 defines the third axis
  3059. * @returns a new Vector3
  3060. */
  3061. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3062. /**
  3063. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3064. * @param axis1 defines the first axis
  3065. * @param axis2 defines the second axis
  3066. * @param axis3 defines the third axis
  3067. * @param ref defines the Vector3 where to store the result
  3068. */
  3069. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3070. }
  3071. /**
  3072. * Vector4 class created for EulerAngle class conversion to Quaternion
  3073. */
  3074. export class Vector4 {
  3075. /** x value of the vector */
  3076. x: number;
  3077. /** y value of the vector */
  3078. y: number;
  3079. /** z value of the vector */
  3080. z: number;
  3081. /** w value of the vector */
  3082. w: number;
  3083. /**
  3084. * Creates a Vector4 object from the given floats.
  3085. * @param x x value of the vector
  3086. * @param y y value of the vector
  3087. * @param z z value of the vector
  3088. * @param w w value of the vector
  3089. */
  3090. constructor(
  3091. /** x value of the vector */
  3092. x: number,
  3093. /** y value of the vector */
  3094. y: number,
  3095. /** z value of the vector */
  3096. z: number,
  3097. /** w value of the vector */
  3098. w: number);
  3099. /**
  3100. * Returns the string with the Vector4 coordinates.
  3101. * @returns a string containing all the vector values
  3102. */
  3103. toString(): string;
  3104. /**
  3105. * Returns the string "Vector4".
  3106. * @returns "Vector4"
  3107. */
  3108. getClassName(): string;
  3109. /**
  3110. * Returns the Vector4 hash code.
  3111. * @returns a unique hash code
  3112. */
  3113. getHashCode(): number;
  3114. /**
  3115. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3116. * @returns the resulting array
  3117. */
  3118. asArray(): number[];
  3119. /**
  3120. * Populates the given array from the given index with the Vector4 coordinates.
  3121. * @param array array to populate
  3122. * @param index index of the array to start at (default: 0)
  3123. * @returns the Vector4.
  3124. */
  3125. toArray(array: FloatArray, index?: number): Vector4;
  3126. /**
  3127. * Adds the given vector to the current Vector4.
  3128. * @param otherVector the vector to add
  3129. * @returns the updated Vector4.
  3130. */
  3131. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3132. /**
  3133. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3134. * @param otherVector the vector to add
  3135. * @returns the resulting vector
  3136. */
  3137. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3138. /**
  3139. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3140. * @param otherVector the vector to add
  3141. * @param result the vector to store the result
  3142. * @returns the current Vector4.
  3143. */
  3144. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3145. /**
  3146. * Subtract in place the given vector from the current Vector4.
  3147. * @param otherVector the vector to subtract
  3148. * @returns the updated Vector4.
  3149. */
  3150. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3151. /**
  3152. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3153. * @param otherVector the vector to add
  3154. * @returns the new vector with the result
  3155. */
  3156. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3157. /**
  3158. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3159. * @param otherVector the vector to subtract
  3160. * @param result the vector to store the result
  3161. * @returns the current Vector4.
  3162. */
  3163. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3164. /**
  3165. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3166. */
  3167. /**
  3168. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3169. * @param x value to subtract
  3170. * @param y value to subtract
  3171. * @param z value to subtract
  3172. * @param w value to subtract
  3173. * @returns new vector containing the result
  3174. */
  3175. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3176. /**
  3177. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3178. * @param x value to subtract
  3179. * @param y value to subtract
  3180. * @param z value to subtract
  3181. * @param w value to subtract
  3182. * @param result the vector to store the result in
  3183. * @returns the current Vector4.
  3184. */
  3185. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3186. /**
  3187. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3188. * @returns a new vector with the negated values
  3189. */
  3190. negate(): Vector4;
  3191. /**
  3192. * Negate this vector in place
  3193. * @returns this
  3194. */
  3195. negateInPlace(): Vector4;
  3196. /**
  3197. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3198. * @param result defines the Vector3 object where to store the result
  3199. * @returns the current Vector4
  3200. */
  3201. negateToRef(result: Vector4): Vector4;
  3202. /**
  3203. * Multiplies the current Vector4 coordinates by scale (float).
  3204. * @param scale the number to scale with
  3205. * @returns the updated Vector4.
  3206. */
  3207. scaleInPlace(scale: number): Vector4;
  3208. /**
  3209. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3210. * @param scale the number to scale with
  3211. * @returns a new vector with the result
  3212. */
  3213. scale(scale: number): Vector4;
  3214. /**
  3215. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3216. * @param scale the number to scale with
  3217. * @param result a vector to store the result in
  3218. * @returns the current Vector4.
  3219. */
  3220. scaleToRef(scale: number, result: Vector4): Vector4;
  3221. /**
  3222. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3223. * @param scale defines the scale factor
  3224. * @param result defines the Vector4 object where to store the result
  3225. * @returns the unmodified current Vector4
  3226. */
  3227. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3228. /**
  3229. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3230. * @param otherVector the vector to compare against
  3231. * @returns true if they are equal
  3232. */
  3233. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3234. /**
  3235. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3236. * @param otherVector vector to compare against
  3237. * @param epsilon (Default: very small number)
  3238. * @returns true if they are equal
  3239. */
  3240. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3241. /**
  3242. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3243. * @param x x value to compare against
  3244. * @param y y value to compare against
  3245. * @param z z value to compare against
  3246. * @param w w value to compare against
  3247. * @returns true if equal
  3248. */
  3249. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3250. /**
  3251. * Multiplies in place the current Vector4 by the given one.
  3252. * @param otherVector vector to multiple with
  3253. * @returns the updated Vector4.
  3254. */
  3255. multiplyInPlace(otherVector: Vector4): Vector4;
  3256. /**
  3257. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3258. * @param otherVector vector to multiple with
  3259. * @returns resulting new vector
  3260. */
  3261. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3262. /**
  3263. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3264. * @param otherVector vector to multiple with
  3265. * @param result vector to store the result
  3266. * @returns the current Vector4.
  3267. */
  3268. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3269. /**
  3270. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3271. * @param x x value multiply with
  3272. * @param y y value multiply with
  3273. * @param z z value multiply with
  3274. * @param w w value multiply with
  3275. * @returns resulting new vector
  3276. */
  3277. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3278. /**
  3279. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3280. * @param otherVector vector to devide with
  3281. * @returns resulting new vector
  3282. */
  3283. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3284. /**
  3285. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3286. * @param otherVector vector to devide with
  3287. * @param result vector to store the result
  3288. * @returns the current Vector4.
  3289. */
  3290. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3291. /**
  3292. * Divides the current Vector3 coordinates by the given ones.
  3293. * @param otherVector vector to devide with
  3294. * @returns the updated Vector3.
  3295. */
  3296. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3297. /**
  3298. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3299. * @param other defines the second operand
  3300. * @returns the current updated Vector4
  3301. */
  3302. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3303. /**
  3304. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3305. * @param other defines the second operand
  3306. * @returns the current updated Vector4
  3307. */
  3308. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3309. /**
  3310. * Gets a new Vector4 from current Vector4 floored values
  3311. * @returns a new Vector4
  3312. */
  3313. floor(): Vector4;
  3314. /**
  3315. * Gets a new Vector4 from current Vector3 floored values
  3316. * @returns a new Vector4
  3317. */
  3318. fract(): Vector4;
  3319. /**
  3320. * Returns the Vector4 length (float).
  3321. * @returns the length
  3322. */
  3323. length(): number;
  3324. /**
  3325. * Returns the Vector4 squared length (float).
  3326. * @returns the length squared
  3327. */
  3328. lengthSquared(): number;
  3329. /**
  3330. * Normalizes in place the Vector4.
  3331. * @returns the updated Vector4.
  3332. */
  3333. normalize(): Vector4;
  3334. /**
  3335. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3336. * @returns this converted to a new vector3
  3337. */
  3338. toVector3(): Vector3;
  3339. /**
  3340. * Returns a new Vector4 copied from the current one.
  3341. * @returns the new cloned vector
  3342. */
  3343. clone(): Vector4;
  3344. /**
  3345. * Updates the current Vector4 with the given one coordinates.
  3346. * @param source the source vector to copy from
  3347. * @returns the updated Vector4.
  3348. */
  3349. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3350. /**
  3351. * Updates the current Vector4 coordinates with the given floats.
  3352. * @param x float to copy from
  3353. * @param y float to copy from
  3354. * @param z float to copy from
  3355. * @param w float to copy from
  3356. * @returns the updated Vector4.
  3357. */
  3358. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3359. /**
  3360. * Updates the current Vector4 coordinates with the given floats.
  3361. * @param x float to set from
  3362. * @param y float to set from
  3363. * @param z float to set from
  3364. * @param w float to set from
  3365. * @returns the updated Vector4.
  3366. */
  3367. set(x: number, y: number, z: number, w: number): Vector4;
  3368. /**
  3369. * Copies the given float to the current Vector3 coordinates
  3370. * @param v defines the x, y, z and w coordinates of the operand
  3371. * @returns the current updated Vector3
  3372. */
  3373. setAll(v: number): Vector4;
  3374. /**
  3375. * Returns a new Vector4 set from the starting index of the given array.
  3376. * @param array the array to pull values from
  3377. * @param offset the offset into the array to start at
  3378. * @returns the new vector
  3379. */
  3380. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3381. /**
  3382. * Updates the given vector "result" from the starting index of the given array.
  3383. * @param array the array to pull values from
  3384. * @param offset the offset into the array to start at
  3385. * @param result the vector to store the result in
  3386. */
  3387. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3388. /**
  3389. * Updates the given vector "result" from the starting index of the given Float32Array.
  3390. * @param array the array to pull values from
  3391. * @param offset the offset into the array to start at
  3392. * @param result the vector to store the result in
  3393. */
  3394. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3395. /**
  3396. * Updates the given vector "result" coordinates from the given floats.
  3397. * @param x float to set from
  3398. * @param y float to set from
  3399. * @param z float to set from
  3400. * @param w float to set from
  3401. * @param result the vector to the floats in
  3402. */
  3403. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3404. /**
  3405. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3406. * @returns the new vector
  3407. */
  3408. static Zero(): Vector4;
  3409. /**
  3410. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3411. * @returns the new vector
  3412. */
  3413. static One(): Vector4;
  3414. /**
  3415. * Returns a new normalized Vector4 from the given one.
  3416. * @param vector the vector to normalize
  3417. * @returns the vector
  3418. */
  3419. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3420. /**
  3421. * Updates the given vector "result" from the normalization of the given one.
  3422. * @param vector the vector to normalize
  3423. * @param result the vector to store the result in
  3424. */
  3425. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3426. /**
  3427. * Returns a vector with the minimum values from the left and right vectors
  3428. * @param left left vector to minimize
  3429. * @param right right vector to minimize
  3430. * @returns a new vector with the minimum of the left and right vector values
  3431. */
  3432. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3433. /**
  3434. * Returns a vector with the maximum values from the left and right vectors
  3435. * @param left left vector to maximize
  3436. * @param right right vector to maximize
  3437. * @returns a new vector with the maximum of the left and right vector values
  3438. */
  3439. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3440. /**
  3441. * Returns the distance (float) between the vectors "value1" and "value2".
  3442. * @param value1 value to calulate the distance between
  3443. * @param value2 value to calulate the distance between
  3444. * @return the distance between the two vectors
  3445. */
  3446. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3447. /**
  3448. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3449. * @param value1 value to calulate the distance between
  3450. * @param value2 value to calulate the distance between
  3451. * @return the distance between the two vectors squared
  3452. */
  3453. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3454. /**
  3455. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3456. * @param value1 value to calulate the center between
  3457. * @param value2 value to calulate the center between
  3458. * @return the center between the two vectors
  3459. */
  3460. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3461. /**
  3462. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3463. * This methods computes transformed normalized direction vectors only.
  3464. * @param vector the vector to transform
  3465. * @param transformation the transformation matrix to apply
  3466. * @returns the new vector
  3467. */
  3468. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3469. /**
  3470. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3471. * This methods computes transformed normalized direction vectors only.
  3472. * @param vector the vector to transform
  3473. * @param transformation the transformation matrix to apply
  3474. * @param result the vector to store the result in
  3475. */
  3476. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3477. /**
  3478. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3479. * This methods computes transformed normalized direction vectors only.
  3480. * @param x value to transform
  3481. * @param y value to transform
  3482. * @param z value to transform
  3483. * @param w value to transform
  3484. * @param transformation the transformation matrix to apply
  3485. * @param result the vector to store the results in
  3486. */
  3487. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3488. /**
  3489. * Creates a new Vector4 from a Vector3
  3490. * @param source defines the source data
  3491. * @param w defines the 4th component (default is 0)
  3492. * @returns a new Vector4
  3493. */
  3494. static FromVector3(source: Vector3, w?: number): Vector4;
  3495. }
  3496. /**
  3497. * Class used to store quaternion data
  3498. * @see https://en.wikipedia.org/wiki/Quaternion
  3499. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  3500. */
  3501. export class Quaternion {
  3502. /** defines the first component (0 by default) */
  3503. x: number;
  3504. /** defines the second component (0 by default) */
  3505. y: number;
  3506. /** defines the third component (0 by default) */
  3507. z: number;
  3508. /** defines the fourth component (1.0 by default) */
  3509. w: number;
  3510. /**
  3511. * Creates a new Quaternion from the given floats
  3512. * @param x defines the first component (0 by default)
  3513. * @param y defines the second component (0 by default)
  3514. * @param z defines the third component (0 by default)
  3515. * @param w defines the fourth component (1.0 by default)
  3516. */
  3517. constructor(
  3518. /** defines the first component (0 by default) */
  3519. x?: number,
  3520. /** defines the second component (0 by default) */
  3521. y?: number,
  3522. /** defines the third component (0 by default) */
  3523. z?: number,
  3524. /** defines the fourth component (1.0 by default) */
  3525. w?: number);
  3526. /**
  3527. * Gets a string representation for the current quaternion
  3528. * @returns a string with the Quaternion coordinates
  3529. */
  3530. toString(): string;
  3531. /**
  3532. * Gets the class name of the quaternion
  3533. * @returns the string "Quaternion"
  3534. */
  3535. getClassName(): string;
  3536. /**
  3537. * Gets a hash code for this quaternion
  3538. * @returns the quaternion hash code
  3539. */
  3540. getHashCode(): number;
  3541. /**
  3542. * Copy the quaternion to an array
  3543. * @returns a new array populated with 4 elements from the quaternion coordinates
  3544. */
  3545. asArray(): number[];
  3546. /**
  3547. * Check if two quaternions are equals
  3548. * @param otherQuaternion defines the second operand
  3549. * @return true if the current quaternion and the given one coordinates are strictly equals
  3550. */
  3551. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3552. /**
  3553. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3554. * @param otherQuaternion defines the other quaternion
  3555. * @param epsilon defines the minimal distance to consider equality
  3556. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3557. */
  3558. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3559. /**
  3560. * Clone the current quaternion
  3561. * @returns a new quaternion copied from the current one
  3562. */
  3563. clone(): Quaternion;
  3564. /**
  3565. * Copy a quaternion to the current one
  3566. * @param other defines the other quaternion
  3567. * @returns the updated current quaternion
  3568. */
  3569. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3570. /**
  3571. * Updates the current quaternion with the given float coordinates
  3572. * @param x defines the x coordinate
  3573. * @param y defines the y coordinate
  3574. * @param z defines the z coordinate
  3575. * @param w defines the w coordinate
  3576. * @returns the updated current quaternion
  3577. */
  3578. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3579. /**
  3580. * Updates the current quaternion from the given float coordinates
  3581. * @param x defines the x coordinate
  3582. * @param y defines the y coordinate
  3583. * @param z defines the z coordinate
  3584. * @param w defines the w coordinate
  3585. * @returns the updated current quaternion
  3586. */
  3587. set(x: number, y: number, z: number, w: number): Quaternion;
  3588. /**
  3589. * Adds two quaternions
  3590. * @param other defines the second operand
  3591. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3592. */
  3593. add(other: DeepImmutable<Quaternion>): Quaternion;
  3594. /**
  3595. * Add a quaternion to the current one
  3596. * @param other defines the quaternion to add
  3597. * @returns the current quaternion
  3598. */
  3599. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3600. /**
  3601. * Subtract two quaternions
  3602. * @param other defines the second operand
  3603. * @returns a new quaternion as the subtraction result of the given one from the current one
  3604. */
  3605. subtract(other: Quaternion): Quaternion;
  3606. /**
  3607. * Multiplies the current quaternion by a scale factor
  3608. * @param value defines the scale factor
  3609. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3610. */
  3611. scale(value: number): Quaternion;
  3612. /**
  3613. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3614. * @param scale defines the scale factor
  3615. * @param result defines the Quaternion object where to store the result
  3616. * @returns the unmodified current quaternion
  3617. */
  3618. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3619. /**
  3620. * Multiplies in place the current quaternion by a scale factor
  3621. * @param value defines the scale factor
  3622. * @returns the current modified quaternion
  3623. */
  3624. scaleInPlace(value: number): Quaternion;
  3625. /**
  3626. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3627. * @param scale defines the scale factor
  3628. * @param result defines the Quaternion object where to store the result
  3629. * @returns the unmodified current quaternion
  3630. */
  3631. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3632. /**
  3633. * Multiplies two quaternions
  3634. * @param q1 defines the second operand
  3635. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3636. */
  3637. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3638. /**
  3639. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3640. * @param q1 defines the second operand
  3641. * @param result defines the target quaternion
  3642. * @returns the current quaternion
  3643. */
  3644. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3645. /**
  3646. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3647. * @param q1 defines the second operand
  3648. * @returns the currentupdated quaternion
  3649. */
  3650. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3651. /**
  3652. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3653. * @param ref defines the target quaternion
  3654. * @returns the current quaternion
  3655. */
  3656. conjugateToRef(ref: Quaternion): Quaternion;
  3657. /**
  3658. * Conjugates in place (1-q) the current quaternion
  3659. * @returns the current updated quaternion
  3660. */
  3661. conjugateInPlace(): Quaternion;
  3662. /**
  3663. * Conjugates in place (1-q) the current quaternion
  3664. * @returns a new quaternion
  3665. */
  3666. conjugate(): Quaternion;
  3667. /**
  3668. * Gets length of current quaternion
  3669. * @returns the quaternion length (float)
  3670. */
  3671. length(): number;
  3672. /**
  3673. * Normalize in place the current quaternion
  3674. * @returns the current updated quaternion
  3675. */
  3676. normalize(): Quaternion;
  3677. /**
  3678. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3679. * @param order is a reserved parameter and is ignore for now
  3680. * @returns a new Vector3 containing the Euler angles
  3681. */
  3682. toEulerAngles(order?: string): Vector3;
  3683. /**
  3684. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3685. * @param result defines the vector which will be filled with the Euler angles
  3686. * @param order is a reserved parameter and is ignore for now
  3687. * @returns the current unchanged quaternion
  3688. */
  3689. toEulerAnglesToRef(result: Vector3): Quaternion;
  3690. /**
  3691. * Updates the given rotation matrix with the current quaternion values
  3692. * @param result defines the target matrix
  3693. * @returns the current unchanged quaternion
  3694. */
  3695. toRotationMatrix(result: Matrix): Quaternion;
  3696. /**
  3697. * Updates the current quaternion from the given rotation matrix values
  3698. * @param matrix defines the source matrix
  3699. * @returns the current updated quaternion
  3700. */
  3701. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3702. /**
  3703. * Creates a new quaternion from a rotation matrix
  3704. * @param matrix defines the source matrix
  3705. * @returns a new quaternion created from the given rotation matrix values
  3706. */
  3707. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3708. /**
  3709. * Updates the given quaternion with the given rotation matrix values
  3710. * @param matrix defines the source matrix
  3711. * @param result defines the target quaternion
  3712. */
  3713. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3714. /**
  3715. * Returns the dot product (float) between the quaternions "left" and "right"
  3716. * @param left defines the left operand
  3717. * @param right defines the right operand
  3718. * @returns the dot product
  3719. */
  3720. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3721. /**
  3722. * Checks if the two quaternions are close to each other
  3723. * @param quat0 defines the first quaternion to check
  3724. * @param quat1 defines the second quaternion to check
  3725. * @returns true if the two quaternions are close to each other
  3726. */
  3727. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3728. /**
  3729. * Creates an empty quaternion
  3730. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3731. */
  3732. static Zero(): Quaternion;
  3733. /**
  3734. * Inverse a given quaternion
  3735. * @param q defines the source quaternion
  3736. * @returns a new quaternion as the inverted current quaternion
  3737. */
  3738. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3739. /**
  3740. * Inverse a given quaternion
  3741. * @param q defines the source quaternion
  3742. * @param result the quaternion the result will be stored in
  3743. * @returns the result quaternion
  3744. */
  3745. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3746. /**
  3747. * Creates an identity quaternion
  3748. * @returns the identity quaternion
  3749. */
  3750. static Identity(): Quaternion;
  3751. /**
  3752. * Gets a boolean indicating if the given quaternion is identity
  3753. * @param quaternion defines the quaternion to check
  3754. * @returns true if the quaternion is identity
  3755. */
  3756. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3757. /**
  3758. * Creates a quaternion from a rotation around an axis
  3759. * @param axis defines the axis to use
  3760. * @param angle defines the angle to use
  3761. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3762. */
  3763. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3764. /**
  3765. * Creates a rotation around an axis and stores it into the given quaternion
  3766. * @param axis defines the axis to use
  3767. * @param angle defines the angle to use
  3768. * @param result defines the target quaternion
  3769. * @returns the target quaternion
  3770. */
  3771. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3772. /**
  3773. * Creates a new quaternion from data stored into an array
  3774. * @param array defines the data source
  3775. * @param offset defines the offset in the source array where the data starts
  3776. * @returns a new quaternion
  3777. */
  3778. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3779. /**
  3780. * Create a quaternion from Euler rotation angles
  3781. * @param x Pitch
  3782. * @param y Yaw
  3783. * @param z Roll
  3784. * @returns the new Quaternion
  3785. */
  3786. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3787. /**
  3788. * Updates a quaternion from Euler rotation angles
  3789. * @param x Pitch
  3790. * @param y Yaw
  3791. * @param z Roll
  3792. * @param result the quaternion to store the result
  3793. * @returns the updated quaternion
  3794. */
  3795. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3796. /**
  3797. * Create a quaternion from Euler rotation vector
  3798. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3799. * @returns the new Quaternion
  3800. */
  3801. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3802. /**
  3803. * Updates a quaternion from Euler rotation vector
  3804. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3805. * @param result the quaternion to store the result
  3806. * @returns the updated quaternion
  3807. */
  3808. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3809. /**
  3810. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3811. * @param yaw defines the rotation around Y axis
  3812. * @param pitch defines the rotation around X axis
  3813. * @param roll defines the rotation around Z axis
  3814. * @returns the new quaternion
  3815. */
  3816. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3817. /**
  3818. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3819. * @param yaw defines the rotation around Y axis
  3820. * @param pitch defines the rotation around X axis
  3821. * @param roll defines the rotation around Z axis
  3822. * @param result defines the target quaternion
  3823. */
  3824. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3825. /**
  3826. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3827. * @param alpha defines the rotation around first axis
  3828. * @param beta defines the rotation around second axis
  3829. * @param gamma defines the rotation around third axis
  3830. * @returns the new quaternion
  3831. */
  3832. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3833. /**
  3834. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3835. * @param alpha defines the rotation around first axis
  3836. * @param beta defines the rotation around second axis
  3837. * @param gamma defines the rotation around third axis
  3838. * @param result defines the target quaternion
  3839. */
  3840. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3841. /**
  3842. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  3843. * @param axis1 defines the first axis
  3844. * @param axis2 defines the second axis
  3845. * @param axis3 defines the third axis
  3846. * @returns the new quaternion
  3847. */
  3848. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3849. /**
  3850. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  3851. * @param axis1 defines the first axis
  3852. * @param axis2 defines the second axis
  3853. * @param axis3 defines the third axis
  3854. * @param ref defines the target quaternion
  3855. */
  3856. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3857. /**
  3858. * Interpolates between two quaternions
  3859. * @param left defines first quaternion
  3860. * @param right defines second quaternion
  3861. * @param amount defines the gradient to use
  3862. * @returns the new interpolated quaternion
  3863. */
  3864. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3865. /**
  3866. * Interpolates between two quaternions and stores it into a target quaternion
  3867. * @param left defines first quaternion
  3868. * @param right defines second quaternion
  3869. * @param amount defines the gradient to use
  3870. * @param result defines the target quaternion
  3871. */
  3872. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3873. /**
  3874. * Interpolate between two quaternions using Hermite interpolation
  3875. * @param value1 defines first quaternion
  3876. * @param tangent1 defines the incoming tangent
  3877. * @param value2 defines second quaternion
  3878. * @param tangent2 defines the outgoing tangent
  3879. * @param amount defines the target quaternion
  3880. * @returns the new interpolated quaternion
  3881. */
  3882. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3883. }
  3884. /**
  3885. * Class used to store matrix data (4x4)
  3886. */
  3887. export class Matrix {
  3888. private static _updateFlagSeed;
  3889. private static _identityReadOnly;
  3890. private _isIdentity;
  3891. private _isIdentityDirty;
  3892. private _isIdentity3x2;
  3893. private _isIdentity3x2Dirty;
  3894. /**
  3895. * Gets the update flag of the matrix which is an unique number for the matrix.
  3896. * It will be incremented every time the matrix data change.
  3897. * You can use it to speed the comparison between two versions of the same matrix.
  3898. */
  3899. updateFlag: number;
  3900. private readonly _m;
  3901. /**
  3902. * Gets the internal data of the matrix
  3903. */
  3904. get m(): DeepImmutable<Float32Array>;
  3905. /** @hidden */
  3906. _markAsUpdated(): void;
  3907. /** @hidden */
  3908. private _updateIdentityStatus;
  3909. /**
  3910. * Creates an empty matrix (filled with zeros)
  3911. */
  3912. constructor();
  3913. /**
  3914. * Check if the current matrix is identity
  3915. * @returns true is the matrix is the identity matrix
  3916. */
  3917. isIdentity(): boolean;
  3918. /**
  3919. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3920. * @returns true is the matrix is the identity matrix
  3921. */
  3922. isIdentityAs3x2(): boolean;
  3923. /**
  3924. * Gets the determinant of the matrix
  3925. * @returns the matrix determinant
  3926. */
  3927. determinant(): number;
  3928. /**
  3929. * Returns the matrix as a Float32Array
  3930. * @returns the matrix underlying array
  3931. */
  3932. toArray(): DeepImmutable<Float32Array>;
  3933. /**
  3934. * Returns the matrix as a Float32Array
  3935. * @returns the matrix underlying array.
  3936. */
  3937. asArray(): DeepImmutable<Float32Array>;
  3938. /**
  3939. * Inverts the current matrix in place
  3940. * @returns the current inverted matrix
  3941. */
  3942. invert(): Matrix;
  3943. /**
  3944. * Sets all the matrix elements to zero
  3945. * @returns the current matrix
  3946. */
  3947. reset(): Matrix;
  3948. /**
  3949. * Adds the current matrix with a second one
  3950. * @param other defines the matrix to add
  3951. * @returns a new matrix as the addition of the current matrix and the given one
  3952. */
  3953. add(other: DeepImmutable<Matrix>): Matrix;
  3954. /**
  3955. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3956. * @param other defines the matrix to add
  3957. * @param result defines the target matrix
  3958. * @returns the current matrix
  3959. */
  3960. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3961. /**
  3962. * Adds in place the given matrix to the current matrix
  3963. * @param other defines the second operand
  3964. * @returns the current updated matrix
  3965. */
  3966. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3967. /**
  3968. * Sets the given matrix to the current inverted Matrix
  3969. * @param other defines the target matrix
  3970. * @returns the unmodified current matrix
  3971. */
  3972. invertToRef(other: Matrix): Matrix;
  3973. /**
  3974. * add a value at the specified position in the current Matrix
  3975. * @param index the index of the value within the matrix. between 0 and 15.
  3976. * @param value the value to be added
  3977. * @returns the current updated matrix
  3978. */
  3979. addAtIndex(index: number, value: number): Matrix;
  3980. /**
  3981. * mutiply the specified position in the current Matrix by a value
  3982. * @param index the index of the value within the matrix. between 0 and 15.
  3983. * @param value the value to be added
  3984. * @returns the current updated matrix
  3985. */
  3986. multiplyAtIndex(index: number, value: number): Matrix;
  3987. /**
  3988. * Inserts the translation vector (using 3 floats) in the current matrix
  3989. * @param x defines the 1st component of the translation
  3990. * @param y defines the 2nd component of the translation
  3991. * @param z defines the 3rd component of the translation
  3992. * @returns the current updated matrix
  3993. */
  3994. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3995. /**
  3996. * Adds the translation vector (using 3 floats) in the current matrix
  3997. * @param x defines the 1st component of the translation
  3998. * @param y defines the 2nd component of the translation
  3999. * @param z defines the 3rd component of the translation
  4000. * @returns the current updated matrix
  4001. */
  4002. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4003. /**
  4004. * Inserts the translation vector in the current matrix
  4005. * @param vector3 defines the translation to insert
  4006. * @returns the current updated matrix
  4007. */
  4008. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4009. /**
  4010. * Gets the translation value of the current matrix
  4011. * @returns a new Vector3 as the extracted translation from the matrix
  4012. */
  4013. getTranslation(): Vector3;
  4014. /**
  4015. * Fill a Vector3 with the extracted translation from the matrix
  4016. * @param result defines the Vector3 where to store the translation
  4017. * @returns the current matrix
  4018. */
  4019. getTranslationToRef(result: Vector3): Matrix;
  4020. /**
  4021. * Remove rotation and scaling part from the matrix
  4022. * @returns the updated matrix
  4023. */
  4024. removeRotationAndScaling(): Matrix;
  4025. /**
  4026. * Multiply two matrices
  4027. * @param other defines the second operand
  4028. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4029. */
  4030. multiply(other: DeepImmutable<Matrix>): Matrix;
  4031. /**
  4032. * Copy the current matrix from the given one
  4033. * @param other defines the source matrix
  4034. * @returns the current updated matrix
  4035. */
  4036. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4037. /**
  4038. * Populates the given array from the starting index with the current matrix values
  4039. * @param array defines the target array
  4040. * @param offset defines the offset in the target array where to start storing values
  4041. * @returns the current matrix
  4042. */
  4043. copyToArray(array: Float32Array, offset?: number): Matrix;
  4044. /**
  4045. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4046. * @param other defines the second operand
  4047. * @param result defines the matrix where to store the multiplication
  4048. * @returns the current matrix
  4049. */
  4050. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4051. /**
  4052. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4053. * @param other defines the second operand
  4054. * @param result defines the array where to store the multiplication
  4055. * @param offset defines the offset in the target array where to start storing values
  4056. * @returns the current matrix
  4057. */
  4058. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  4059. /**
  4060. * Check equality between this matrix and a second one
  4061. * @param value defines the second matrix to compare
  4062. * @returns true is the current matrix and the given one values are strictly equal
  4063. */
  4064. equals(value: DeepImmutable<Matrix>): boolean;
  4065. /**
  4066. * Clone the current matrix
  4067. * @returns a new matrix from the current matrix
  4068. */
  4069. clone(): Matrix;
  4070. /**
  4071. * Returns the name of the current matrix class
  4072. * @returns the string "Matrix"
  4073. */
  4074. getClassName(): string;
  4075. /**
  4076. * Gets the hash code of the current matrix
  4077. * @returns the hash code
  4078. */
  4079. getHashCode(): number;
  4080. /**
  4081. * Decomposes the current Matrix into a translation, rotation and scaling components
  4082. * @param scale defines the scale vector3 given as a reference to update
  4083. * @param rotation defines the rotation quaternion given as a reference to update
  4084. * @param translation defines the translation vector3 given as a reference to update
  4085. * @returns true if operation was successful
  4086. */
  4087. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4088. /**
  4089. * Gets specific row of the matrix
  4090. * @param index defines the number of the row to get
  4091. * @returns the index-th row of the current matrix as a new Vector4
  4092. */
  4093. getRow(index: number): Nullable<Vector4>;
  4094. /**
  4095. * Sets the index-th row of the current matrix to the vector4 values
  4096. * @param index defines the number of the row to set
  4097. * @param row defines the target vector4
  4098. * @returns the updated current matrix
  4099. */
  4100. setRow(index: number, row: Vector4): Matrix;
  4101. /**
  4102. * Compute the transpose of the matrix
  4103. * @returns the new transposed matrix
  4104. */
  4105. transpose(): Matrix;
  4106. /**
  4107. * Compute the transpose of the matrix and store it in a given matrix
  4108. * @param result defines the target matrix
  4109. * @returns the current matrix
  4110. */
  4111. transposeToRef(result: Matrix): Matrix;
  4112. /**
  4113. * Sets the index-th row of the current matrix with the given 4 x float values
  4114. * @param index defines the row index
  4115. * @param x defines the x component to set
  4116. * @param y defines the y component to set
  4117. * @param z defines the z component to set
  4118. * @param w defines the w component to set
  4119. * @returns the updated current matrix
  4120. */
  4121. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4122. /**
  4123. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4124. * @param scale defines the scale factor
  4125. * @returns a new matrix
  4126. */
  4127. scale(scale: number): Matrix;
  4128. /**
  4129. * Scale the current matrix values by a factor to a given result matrix
  4130. * @param scale defines the scale factor
  4131. * @param result defines the matrix to store the result
  4132. * @returns the current matrix
  4133. */
  4134. scaleToRef(scale: number, result: Matrix): Matrix;
  4135. /**
  4136. * Scale the current matrix values by a factor and add the result to a given matrix
  4137. * @param scale defines the scale factor
  4138. * @param result defines the Matrix to store the result
  4139. * @returns the current matrix
  4140. */
  4141. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4142. /**
  4143. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4144. * @param ref matrix to store the result
  4145. */
  4146. toNormalMatrix(ref: Matrix): void;
  4147. /**
  4148. * Gets only rotation part of the current matrix
  4149. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4150. */
  4151. getRotationMatrix(): Matrix;
  4152. /**
  4153. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4154. * @param result defines the target matrix to store data to
  4155. * @returns the current matrix
  4156. */
  4157. getRotationMatrixToRef(result: Matrix): Matrix;
  4158. /**
  4159. * Toggles model matrix from being right handed to left handed in place and vice versa
  4160. */
  4161. toggleModelMatrixHandInPlace(): void;
  4162. /**
  4163. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4164. */
  4165. toggleProjectionMatrixHandInPlace(): void;
  4166. /**
  4167. * Creates a matrix from an array
  4168. * @param array defines the source array
  4169. * @param offset defines an offset in the source array
  4170. * @returns a new Matrix set from the starting index of the given array
  4171. */
  4172. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4173. /**
  4174. * Copy the content of an array into a given matrix
  4175. * @param array defines the source array
  4176. * @param offset defines an offset in the source array
  4177. * @param result defines the target matrix
  4178. */
  4179. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4180. /**
  4181. * Stores an array into a matrix after having multiplied each component by a given factor
  4182. * @param array defines the source array
  4183. * @param offset defines the offset in the source array
  4184. * @param scale defines the scaling factor
  4185. * @param result defines the target matrix
  4186. */
  4187. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  4188. /**
  4189. * Gets an identity matrix that must not be updated
  4190. */
  4191. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4192. /**
  4193. * Stores a list of values (16) inside a given matrix
  4194. * @param initialM11 defines 1st value of 1st row
  4195. * @param initialM12 defines 2nd value of 1st row
  4196. * @param initialM13 defines 3rd value of 1st row
  4197. * @param initialM14 defines 4th value of 1st row
  4198. * @param initialM21 defines 1st value of 2nd row
  4199. * @param initialM22 defines 2nd value of 2nd row
  4200. * @param initialM23 defines 3rd value of 2nd row
  4201. * @param initialM24 defines 4th value of 2nd row
  4202. * @param initialM31 defines 1st value of 3rd row
  4203. * @param initialM32 defines 2nd value of 3rd row
  4204. * @param initialM33 defines 3rd value of 3rd row
  4205. * @param initialM34 defines 4th value of 3rd row
  4206. * @param initialM41 defines 1st value of 4th row
  4207. * @param initialM42 defines 2nd value of 4th row
  4208. * @param initialM43 defines 3rd value of 4th row
  4209. * @param initialM44 defines 4th value of 4th row
  4210. * @param result defines the target matrix
  4211. */
  4212. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  4213. /**
  4214. * Creates new matrix from a list of values (16)
  4215. * @param initialM11 defines 1st value of 1st row
  4216. * @param initialM12 defines 2nd value of 1st row
  4217. * @param initialM13 defines 3rd value of 1st row
  4218. * @param initialM14 defines 4th value of 1st row
  4219. * @param initialM21 defines 1st value of 2nd row
  4220. * @param initialM22 defines 2nd value of 2nd row
  4221. * @param initialM23 defines 3rd value of 2nd row
  4222. * @param initialM24 defines 4th value of 2nd row
  4223. * @param initialM31 defines 1st value of 3rd row
  4224. * @param initialM32 defines 2nd value of 3rd row
  4225. * @param initialM33 defines 3rd value of 3rd row
  4226. * @param initialM34 defines 4th value of 3rd row
  4227. * @param initialM41 defines 1st value of 4th row
  4228. * @param initialM42 defines 2nd value of 4th row
  4229. * @param initialM43 defines 3rd value of 4th row
  4230. * @param initialM44 defines 4th value of 4th row
  4231. * @returns the new matrix
  4232. */
  4233. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  4234. /**
  4235. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4236. * @param scale defines the scale vector3
  4237. * @param rotation defines the rotation quaternion
  4238. * @param translation defines the translation vector3
  4239. * @returns a new matrix
  4240. */
  4241. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4242. /**
  4243. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4244. * @param scale defines the scale vector3
  4245. * @param rotation defines the rotation quaternion
  4246. * @param translation defines the translation vector3
  4247. * @param result defines the target matrix
  4248. */
  4249. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4250. /**
  4251. * Creates a new identity matrix
  4252. * @returns a new identity matrix
  4253. */
  4254. static Identity(): Matrix;
  4255. /**
  4256. * Creates a new identity matrix and stores the result in a given matrix
  4257. * @param result defines the target matrix
  4258. */
  4259. static IdentityToRef(result: Matrix): void;
  4260. /**
  4261. * Creates a new zero matrix
  4262. * @returns a new zero matrix
  4263. */
  4264. static Zero(): Matrix;
  4265. /**
  4266. * Creates a new rotation matrix for "angle" radians around the X axis
  4267. * @param angle defines the angle (in radians) to use
  4268. * @return the new matrix
  4269. */
  4270. static RotationX(angle: number): Matrix;
  4271. /**
  4272. * Creates a new matrix as the invert of a given matrix
  4273. * @param source defines the source matrix
  4274. * @returns the new matrix
  4275. */
  4276. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4277. /**
  4278. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4279. * @param angle defines the angle (in radians) to use
  4280. * @param result defines the target matrix
  4281. */
  4282. static RotationXToRef(angle: number, result: Matrix): void;
  4283. /**
  4284. * Creates a new rotation matrix for "angle" radians around the Y axis
  4285. * @param angle defines the angle (in radians) to use
  4286. * @return the new matrix
  4287. */
  4288. static RotationY(angle: number): Matrix;
  4289. /**
  4290. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4291. * @param angle defines the angle (in radians) to use
  4292. * @param result defines the target matrix
  4293. */
  4294. static RotationYToRef(angle: number, result: Matrix): void;
  4295. /**
  4296. * Creates a new rotation matrix for "angle" radians around the Z axis
  4297. * @param angle defines the angle (in radians) to use
  4298. * @return the new matrix
  4299. */
  4300. static RotationZ(angle: number): Matrix;
  4301. /**
  4302. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4303. * @param angle defines the angle (in radians) to use
  4304. * @param result defines the target matrix
  4305. */
  4306. static RotationZToRef(angle: number, result: Matrix): void;
  4307. /**
  4308. * Creates a new rotation matrix for "angle" radians around the given axis
  4309. * @param axis defines the axis to use
  4310. * @param angle defines the angle (in radians) to use
  4311. * @return the new matrix
  4312. */
  4313. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4314. /**
  4315. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4316. * @param axis defines the axis to use
  4317. * @param angle defines the angle (in radians) to use
  4318. * @param result defines the target matrix
  4319. */
  4320. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4321. /**
  4322. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4323. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4324. * @param from defines the vector to align
  4325. * @param to defines the vector to align to
  4326. * @param result defines the target matrix
  4327. */
  4328. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4329. /**
  4330. * Creates a rotation matrix
  4331. * @param yaw defines the yaw angle in radians (Y axis)
  4332. * @param pitch defines the pitch angle in radians (X axis)
  4333. * @param roll defines the roll angle in radians (X axis)
  4334. * @returns the new rotation matrix
  4335. */
  4336. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4337. /**
  4338. * Creates a rotation matrix and stores it in a given matrix
  4339. * @param yaw defines the yaw angle in radians (Y axis)
  4340. * @param pitch defines the pitch angle in radians (X axis)
  4341. * @param roll defines the roll angle in radians (X axis)
  4342. * @param result defines the target matrix
  4343. */
  4344. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4345. /**
  4346. * Creates a scaling matrix
  4347. * @param x defines the scale factor on X axis
  4348. * @param y defines the scale factor on Y axis
  4349. * @param z defines the scale factor on Z axis
  4350. * @returns the new matrix
  4351. */
  4352. static Scaling(x: number, y: number, z: number): Matrix;
  4353. /**
  4354. * Creates a scaling matrix and stores it in a given matrix
  4355. * @param x defines the scale factor on X axis
  4356. * @param y defines the scale factor on Y axis
  4357. * @param z defines the scale factor on Z axis
  4358. * @param result defines the target matrix
  4359. */
  4360. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4361. /**
  4362. * Creates a translation matrix
  4363. * @param x defines the translation on X axis
  4364. * @param y defines the translation on Y axis
  4365. * @param z defines the translationon Z axis
  4366. * @returns the new matrix
  4367. */
  4368. static Translation(x: number, y: number, z: number): Matrix;
  4369. /**
  4370. * Creates a translation matrix and stores it in a given matrix
  4371. * @param x defines the translation on X axis
  4372. * @param y defines the translation on Y axis
  4373. * @param z defines the translationon Z axis
  4374. * @param result defines the target matrix
  4375. */
  4376. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4377. /**
  4378. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4379. * @param startValue defines the start value
  4380. * @param endValue defines the end value
  4381. * @param gradient defines the gradient factor
  4382. * @returns the new matrix
  4383. */
  4384. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4385. /**
  4386. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4387. * @param startValue defines the start value
  4388. * @param endValue defines the end value
  4389. * @param gradient defines the gradient factor
  4390. * @param result defines the Matrix object where to store data
  4391. */
  4392. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4393. /**
  4394. * Builds a new matrix whose values are computed by:
  4395. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4396. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4397. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4398. * @param startValue defines the first matrix
  4399. * @param endValue defines the second matrix
  4400. * @param gradient defines the gradient between the two matrices
  4401. * @returns the new matrix
  4402. */
  4403. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4404. /**
  4405. * Update a matrix to values which are computed by:
  4406. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4407. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4408. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4409. * @param startValue defines the first matrix
  4410. * @param endValue defines the second matrix
  4411. * @param gradient defines the gradient between the two matrices
  4412. * @param result defines the target matrix
  4413. */
  4414. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4415. /**
  4416. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4417. * This function works in left handed mode
  4418. * @param eye defines the final position of the entity
  4419. * @param target defines where the entity should look at
  4420. * @param up defines the up vector for the entity
  4421. * @returns the new matrix
  4422. */
  4423. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4424. /**
  4425. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4426. * This function works in left handed mode
  4427. * @param eye defines the final position of the entity
  4428. * @param target defines where the entity should look at
  4429. * @param up defines the up vector for the entity
  4430. * @param result defines the target matrix
  4431. */
  4432. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4433. /**
  4434. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  4435. * This function works in right handed mode
  4436. * @param eye defines the final position of the entity
  4437. * @param target defines where the entity should look at
  4438. * @param up defines the up vector for the entity
  4439. * @returns the new matrix
  4440. */
  4441. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4442. /**
  4443. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  4444. * This function works in right handed mode
  4445. * @param eye defines the final position of the entity
  4446. * @param target defines where the entity should look at
  4447. * @param up defines the up vector for the entity
  4448. * @param result defines the target matrix
  4449. */
  4450. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4451. /**
  4452. * Create a left-handed orthographic projection matrix
  4453. * @param width defines the viewport width
  4454. * @param height defines the viewport height
  4455. * @param znear defines the near clip plane
  4456. * @param zfar defines the far clip plane
  4457. * @returns a new matrix as a left-handed orthographic projection matrix
  4458. */
  4459. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4460. /**
  4461. * Store a left-handed orthographic projection to a given matrix
  4462. * @param width defines the viewport width
  4463. * @param height defines the viewport height
  4464. * @param znear defines the near clip plane
  4465. * @param zfar defines the far clip plane
  4466. * @param result defines the target matrix
  4467. */
  4468. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4469. /**
  4470. * Create a left-handed orthographic projection matrix
  4471. * @param left defines the viewport left coordinate
  4472. * @param right defines the viewport right coordinate
  4473. * @param bottom defines the viewport bottom coordinate
  4474. * @param top defines the viewport top coordinate
  4475. * @param znear defines the near clip plane
  4476. * @param zfar defines the far clip plane
  4477. * @returns a new matrix as a left-handed orthographic projection matrix
  4478. */
  4479. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4480. /**
  4481. * Stores a left-handed orthographic projection into a given matrix
  4482. * @param left defines the viewport left coordinate
  4483. * @param right defines the viewport right coordinate
  4484. * @param bottom defines the viewport bottom coordinate
  4485. * @param top defines the viewport top coordinate
  4486. * @param znear defines the near clip plane
  4487. * @param zfar defines the far clip plane
  4488. * @param result defines the target matrix
  4489. */
  4490. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4491. /**
  4492. * Creates a right-handed orthographic projection matrix
  4493. * @param left defines the viewport left coordinate
  4494. * @param right defines the viewport right coordinate
  4495. * @param bottom defines the viewport bottom coordinate
  4496. * @param top defines the viewport top coordinate
  4497. * @param znear defines the near clip plane
  4498. * @param zfar defines the far clip plane
  4499. * @returns a new matrix as a right-handed orthographic projection matrix
  4500. */
  4501. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4502. /**
  4503. * Stores a right-handed orthographic projection into a given matrix
  4504. * @param left defines the viewport left coordinate
  4505. * @param right defines the viewport right coordinate
  4506. * @param bottom defines the viewport bottom coordinate
  4507. * @param top defines the viewport top coordinate
  4508. * @param znear defines the near clip plane
  4509. * @param zfar defines the far clip plane
  4510. * @param result defines the target matrix
  4511. */
  4512. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4513. /**
  4514. * Creates a left-handed perspective projection matrix
  4515. * @param width defines the viewport width
  4516. * @param height defines the viewport height
  4517. * @param znear defines the near clip plane
  4518. * @param zfar defines the far clip plane
  4519. * @returns a new matrix as a left-handed perspective projection matrix
  4520. */
  4521. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4522. /**
  4523. * Creates a left-handed perspective projection matrix
  4524. * @param fov defines the horizontal field of view
  4525. * @param aspect defines the aspect ratio
  4526. * @param znear defines the near clip plane
  4527. * @param zfar defines the far clip plane
  4528. * @returns a new matrix as a left-handed perspective projection matrix
  4529. */
  4530. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4531. /**
  4532. * Stores a left-handed perspective projection into a given matrix
  4533. * @param fov defines the horizontal field of view
  4534. * @param aspect defines the aspect ratio
  4535. * @param znear defines the near clip plane
  4536. * @param zfar defines the far clip plane
  4537. * @param result defines the target matrix
  4538. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4539. */
  4540. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4541. /**
  4542. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4543. * @param fov defines the horizontal field of view
  4544. * @param aspect defines the aspect ratio
  4545. * @param znear defines the near clip plane
  4546. * @param zfar not used as infinity is used as far clip
  4547. * @param result defines the target matrix
  4548. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4549. */
  4550. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4551. /**
  4552. * Creates a right-handed perspective projection matrix
  4553. * @param fov defines the horizontal field of view
  4554. * @param aspect defines the aspect ratio
  4555. * @param znear defines the near clip plane
  4556. * @param zfar defines the far clip plane
  4557. * @returns a new matrix as a right-handed perspective projection matrix
  4558. */
  4559. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4560. /**
  4561. * Stores a right-handed perspective projection into a given matrix
  4562. * @param fov defines the horizontal field of view
  4563. * @param aspect defines the aspect ratio
  4564. * @param znear defines the near clip plane
  4565. * @param zfar defines the far clip plane
  4566. * @param result defines the target matrix
  4567. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4568. */
  4569. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4570. /**
  4571. * Stores a right-handed perspective projection into a given matrix
  4572. * @param fov defines the horizontal field of view
  4573. * @param aspect defines the aspect ratio
  4574. * @param znear defines the near clip plane
  4575. * @param zfar not used as infinity is used as far clip
  4576. * @param result defines the target matrix
  4577. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4578. */
  4579. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4580. /**
  4581. * Stores a perspective projection for WebVR info a given matrix
  4582. * @param fov defines the field of view
  4583. * @param znear defines the near clip plane
  4584. * @param zfar defines the far clip plane
  4585. * @param result defines the target matrix
  4586. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4587. */
  4588. static PerspectiveFovWebVRToRef(fov: {
  4589. upDegrees: number;
  4590. downDegrees: number;
  4591. leftDegrees: number;
  4592. rightDegrees: number;
  4593. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4594. /**
  4595. * Computes a complete transformation matrix
  4596. * @param viewport defines the viewport to use
  4597. * @param world defines the world matrix
  4598. * @param view defines the view matrix
  4599. * @param projection defines the projection matrix
  4600. * @param zmin defines the near clip plane
  4601. * @param zmax defines the far clip plane
  4602. * @returns the transformation matrix
  4603. */
  4604. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4605. /**
  4606. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4607. * @param matrix defines the matrix to use
  4608. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4609. */
  4610. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  4611. /**
  4612. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4613. * @param matrix defines the matrix to use
  4614. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4615. */
  4616. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  4617. /**
  4618. * Compute the transpose of a given matrix
  4619. * @param matrix defines the matrix to transpose
  4620. * @returns the new matrix
  4621. */
  4622. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4623. /**
  4624. * Compute the transpose of a matrix and store it in a target matrix
  4625. * @param matrix defines the matrix to transpose
  4626. * @param result defines the target matrix
  4627. */
  4628. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4629. /**
  4630. * Computes a reflection matrix from a plane
  4631. * @param plane defines the reflection plane
  4632. * @returns a new matrix
  4633. */
  4634. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4635. /**
  4636. * Computes a reflection matrix from a plane
  4637. * @param plane defines the reflection plane
  4638. * @param result defines the target matrix
  4639. */
  4640. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4641. /**
  4642. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4643. * @param xaxis defines the value of the 1st axis
  4644. * @param yaxis defines the value of the 2nd axis
  4645. * @param zaxis defines the value of the 3rd axis
  4646. * @param result defines the target matrix
  4647. */
  4648. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4649. /**
  4650. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4651. * @param quat defines the quaternion to use
  4652. * @param result defines the target matrix
  4653. */
  4654. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4655. }
  4656. /**
  4657. * @hidden
  4658. */
  4659. export class TmpVectors {
  4660. static Vector2: Vector2[];
  4661. static Vector3: Vector3[];
  4662. static Vector4: Vector4[];
  4663. static Quaternion: Quaternion[];
  4664. static Matrix: Matrix[];
  4665. }
  4666. }
  4667. declare module "babylonjs/Maths/math.path" {
  4668. import { DeepImmutable, Nullable } from "babylonjs/types";
  4669. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4670. /**
  4671. * Defines potential orientation for back face culling
  4672. */
  4673. export enum Orientation {
  4674. /**
  4675. * Clockwise
  4676. */
  4677. CW = 0,
  4678. /** Counter clockwise */
  4679. CCW = 1
  4680. }
  4681. /** Class used to represent a Bezier curve */
  4682. export class BezierCurve {
  4683. /**
  4684. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4685. * @param t defines the time
  4686. * @param x1 defines the left coordinate on X axis
  4687. * @param y1 defines the left coordinate on Y axis
  4688. * @param x2 defines the right coordinate on X axis
  4689. * @param y2 defines the right coordinate on Y axis
  4690. * @returns the interpolated value
  4691. */
  4692. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4693. }
  4694. /**
  4695. * Defines angle representation
  4696. */
  4697. export class Angle {
  4698. private _radians;
  4699. /**
  4700. * Creates an Angle object of "radians" radians (float).
  4701. * @param radians the angle in radians
  4702. */
  4703. constructor(radians: number);
  4704. /**
  4705. * Get value in degrees
  4706. * @returns the Angle value in degrees (float)
  4707. */
  4708. degrees(): number;
  4709. /**
  4710. * Get value in radians
  4711. * @returns the Angle value in radians (float)
  4712. */
  4713. radians(): number;
  4714. /**
  4715. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  4716. * @param a defines first vector
  4717. * @param b defines second vector
  4718. * @returns a new Angle
  4719. */
  4720. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4721. /**
  4722. * Gets a new Angle object from the given float in radians
  4723. * @param radians defines the angle value in radians
  4724. * @returns a new Angle
  4725. */
  4726. static FromRadians(radians: number): Angle;
  4727. /**
  4728. * Gets a new Angle object from the given float in degrees
  4729. * @param degrees defines the angle value in degrees
  4730. * @returns a new Angle
  4731. */
  4732. static FromDegrees(degrees: number): Angle;
  4733. }
  4734. /**
  4735. * This represents an arc in a 2d space.
  4736. */
  4737. export class Arc2 {
  4738. /** Defines the start point of the arc */
  4739. startPoint: Vector2;
  4740. /** Defines the mid point of the arc */
  4741. midPoint: Vector2;
  4742. /** Defines the end point of the arc */
  4743. endPoint: Vector2;
  4744. /**
  4745. * Defines the center point of the arc.
  4746. */
  4747. centerPoint: Vector2;
  4748. /**
  4749. * Defines the radius of the arc.
  4750. */
  4751. radius: number;
  4752. /**
  4753. * Defines the angle of the arc (from mid point to end point).
  4754. */
  4755. angle: Angle;
  4756. /**
  4757. * Defines the start angle of the arc (from start point to middle point).
  4758. */
  4759. startAngle: Angle;
  4760. /**
  4761. * Defines the orientation of the arc (clock wise/counter clock wise).
  4762. */
  4763. orientation: Orientation;
  4764. /**
  4765. * Creates an Arc object from the three given points : start, middle and end.
  4766. * @param startPoint Defines the start point of the arc
  4767. * @param midPoint Defines the midlle point of the arc
  4768. * @param endPoint Defines the end point of the arc
  4769. */
  4770. constructor(
  4771. /** Defines the start point of the arc */
  4772. startPoint: Vector2,
  4773. /** Defines the mid point of the arc */
  4774. midPoint: Vector2,
  4775. /** Defines the end point of the arc */
  4776. endPoint: Vector2);
  4777. }
  4778. /**
  4779. * Represents a 2D path made up of multiple 2D points
  4780. */
  4781. export class Path2 {
  4782. private _points;
  4783. private _length;
  4784. /**
  4785. * If the path start and end point are the same
  4786. */
  4787. closed: boolean;
  4788. /**
  4789. * Creates a Path2 object from the starting 2D coordinates x and y.
  4790. * @param x the starting points x value
  4791. * @param y the starting points y value
  4792. */
  4793. constructor(x: number, y: number);
  4794. /**
  4795. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4796. * @param x the added points x value
  4797. * @param y the added points y value
  4798. * @returns the updated Path2.
  4799. */
  4800. addLineTo(x: number, y: number): Path2;
  4801. /**
  4802. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  4803. * @param midX middle point x value
  4804. * @param midY middle point y value
  4805. * @param endX end point x value
  4806. * @param endY end point y value
  4807. * @param numberOfSegments (default: 36)
  4808. * @returns the updated Path2.
  4809. */
  4810. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  4811. /**
  4812. * Closes the Path2.
  4813. * @returns the Path2.
  4814. */
  4815. close(): Path2;
  4816. /**
  4817. * Gets the sum of the distance between each sequential point in the path
  4818. * @returns the Path2 total length (float).
  4819. */
  4820. length(): number;
  4821. /**
  4822. * Gets the points which construct the path
  4823. * @returns the Path2 internal array of points.
  4824. */
  4825. getPoints(): Vector2[];
  4826. /**
  4827. * Retreives the point at the distance aways from the starting point
  4828. * @param normalizedLengthPosition the length along the path to retreive the point from
  4829. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  4830. */
  4831. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  4832. /**
  4833. * Creates a new path starting from an x and y position
  4834. * @param x starting x value
  4835. * @param y starting y value
  4836. * @returns a new Path2 starting at the coordinates (x, y).
  4837. */
  4838. static StartingAt(x: number, y: number): Path2;
  4839. }
  4840. /**
  4841. * Represents a 3D path made up of multiple 3D points
  4842. */
  4843. export class Path3D {
  4844. /**
  4845. * an array of Vector3, the curve axis of the Path3D
  4846. */
  4847. path: Vector3[];
  4848. private _curve;
  4849. private _distances;
  4850. private _tangents;
  4851. private _normals;
  4852. private _binormals;
  4853. private _raw;
  4854. private _alignTangentsWithPath;
  4855. private readonly _pointAtData;
  4856. /**
  4857. * new Path3D(path, normal, raw)
  4858. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4859. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4860. * @param path an array of Vector3, the curve axis of the Path3D
  4861. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4862. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4863. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  4864. */
  4865. constructor(
  4866. /**
  4867. * an array of Vector3, the curve axis of the Path3D
  4868. */
  4869. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  4870. /**
  4871. * Returns the Path3D array of successive Vector3 designing its curve.
  4872. * @returns the Path3D array of successive Vector3 designing its curve.
  4873. */
  4874. getCurve(): Vector3[];
  4875. /**
  4876. * Returns the Path3D array of successive Vector3 designing its curve.
  4877. * @returns the Path3D array of successive Vector3 designing its curve.
  4878. */
  4879. getPoints(): Vector3[];
  4880. /**
  4881. * @returns the computed length (float) of the path.
  4882. */
  4883. length(): number;
  4884. /**
  4885. * Returns an array populated with tangent vectors on each Path3D curve point.
  4886. * @returns an array populated with tangent vectors on each Path3D curve point.
  4887. */
  4888. getTangents(): Vector3[];
  4889. /**
  4890. * Returns an array populated with normal vectors on each Path3D curve point.
  4891. * @returns an array populated with normal vectors on each Path3D curve point.
  4892. */
  4893. getNormals(): Vector3[];
  4894. /**
  4895. * Returns an array populated with binormal vectors on each Path3D curve point.
  4896. * @returns an array populated with binormal vectors on each Path3D curve point.
  4897. */
  4898. getBinormals(): Vector3[];
  4899. /**
  4900. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4901. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4902. */
  4903. getDistances(): number[];
  4904. /**
  4905. * Returns an interpolated point along this path
  4906. * @param position the position of the point along this path, from 0.0 to 1.0
  4907. * @returns a new Vector3 as the point
  4908. */
  4909. getPointAt(position: number): Vector3;
  4910. /**
  4911. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4912. * @param position the position of the point along this path, from 0.0 to 1.0
  4913. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  4914. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  4915. */
  4916. getTangentAt(position: number, interpolated?: boolean): Vector3;
  4917. /**
  4918. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  4919. * @param position the position of the point along this path, from 0.0 to 1.0
  4920. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  4921. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  4922. */
  4923. getNormalAt(position: number, interpolated?: boolean): Vector3;
  4924. /**
  4925. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  4926. * @param position the position of the point along this path, from 0.0 to 1.0
  4927. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  4928. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  4929. */
  4930. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  4931. /**
  4932. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  4933. * @param position the position of the point along this path, from 0.0 to 1.0
  4934. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  4935. */
  4936. getDistanceAt(position: number): number;
  4937. /**
  4938. * Returns the array index of the previous point of an interpolated point along this path
  4939. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4940. * @returns the array index
  4941. */
  4942. getPreviousPointIndexAt(position: number): number;
  4943. /**
  4944. * Returns the position of an interpolated point relative to the two path points it lies between, from 0.0 (point A) to 1.0 (point B)
  4945. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  4946. * @returns the sub position
  4947. */
  4948. getSubPositionAt(position: number): number;
  4949. /**
  4950. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  4951. * @param target the vector of which to get the closest position to
  4952. * @returns the position of the closest virtual point on this path to the target vector
  4953. */
  4954. getClosestPositionTo(target: Vector3): number;
  4955. /**
  4956. * Returns a sub path (slice) of this path
  4957. * @param start the position of the fist path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4958. * @param end the position of the last path point, from 0.0 to 1.0, or a negative value, which will get wrapped around from the end of the path to 0.0 to 1.0 values
  4959. * @returns a sub path (slice) of this path
  4960. */
  4961. slice(start?: number, end?: number): Path3D;
  4962. /**
  4963. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4964. * @param path path which all values are copied into the curves points
  4965. * @param firstNormal which should be projected onto the curve
  4966. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  4967. * @returns the same object updated.
  4968. */
  4969. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  4970. private _compute;
  4971. private _getFirstNonNullVector;
  4972. private _getLastNonNullVector;
  4973. private _normalVector;
  4974. /**
  4975. * Updates the point at data for an interpolated point along this curve
  4976. * @param position the position of the point along this curve, from 0.0 to 1.0
  4977. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  4978. * @returns the (updated) point at data
  4979. */
  4980. private _updatePointAtData;
  4981. /**
  4982. * Updates the point at data from the specified parameters
  4983. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  4984. * @param point the interpolated point
  4985. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  4986. */
  4987. private _setPointAtData;
  4988. /**
  4989. * Updates the point at interpolation matrix for the tangents, normals and binormals
  4990. */
  4991. private _updateInterpolationMatrix;
  4992. }
  4993. /**
  4994. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4995. * A Curve3 is designed from a series of successive Vector3.
  4996. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4997. */
  4998. export class Curve3 {
  4999. private _points;
  5000. private _length;
  5001. /**
  5002. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5003. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5004. * @param v1 (Vector3) the control point
  5005. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5006. * @param nbPoints (integer) the wanted number of points in the curve
  5007. * @returns the created Curve3
  5008. */
  5009. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5010. /**
  5011. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5012. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5013. * @param v1 (Vector3) the first control point
  5014. * @param v2 (Vector3) the second control point
  5015. * @param v3 (Vector3) the end point of the Cubic Bezier
  5016. * @param nbPoints (integer) the wanted number of points in the curve
  5017. * @returns the created Curve3
  5018. */
  5019. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5020. /**
  5021. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5022. * @param p1 (Vector3) the origin point of the Hermite Spline
  5023. * @param t1 (Vector3) the tangent vector at the origin point
  5024. * @param p2 (Vector3) the end point of the Hermite Spline
  5025. * @param t2 (Vector3) the tangent vector at the end point
  5026. * @param nbPoints (integer) the wanted number of points in the curve
  5027. * @returns the created Curve3
  5028. */
  5029. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5030. /**
  5031. * Returns a Curve3 object along a CatmullRom Spline curve :
  5032. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5033. * @param nbPoints (integer) the wanted number of points between each curve control points
  5034. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5035. * @returns the created Curve3
  5036. */
  5037. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5038. /**
  5039. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5040. * A Curve3 is designed from a series of successive Vector3.
  5041. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5042. * @param points points which make up the curve
  5043. */
  5044. constructor(points: Vector3[]);
  5045. /**
  5046. * @returns the Curve3 stored array of successive Vector3
  5047. */
  5048. getPoints(): Vector3[];
  5049. /**
  5050. * @returns the computed length (float) of the curve.
  5051. */
  5052. length(): number;
  5053. /**
  5054. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5055. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5056. * curveA and curveB keep unchanged.
  5057. * @param curve the curve to continue from this curve
  5058. * @returns the newly constructed curve
  5059. */
  5060. continue(curve: DeepImmutable<Curve3>): Curve3;
  5061. private _computeLength;
  5062. }
  5063. }
  5064. declare module "babylonjs/Animations/easing" {
  5065. /**
  5066. * This represents the main contract an easing function should follow.
  5067. * Easing functions are used throughout the animation system.
  5068. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5069. */
  5070. export interface IEasingFunction {
  5071. /**
  5072. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5073. * of the easing function.
  5074. * The link below provides some of the most common examples of easing functions.
  5075. * @see https://easings.net/
  5076. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5077. * @returns the corresponding value on the curve defined by the easing function
  5078. */
  5079. ease(gradient: number): number;
  5080. }
  5081. /**
  5082. * Base class used for every default easing function.
  5083. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5084. */
  5085. export class EasingFunction implements IEasingFunction {
  5086. /**
  5087. * Interpolation follows the mathematical formula associated with the easing function.
  5088. */
  5089. static readonly EASINGMODE_EASEIN: number;
  5090. /**
  5091. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5092. */
  5093. static readonly EASINGMODE_EASEOUT: number;
  5094. /**
  5095. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5096. */
  5097. static readonly EASINGMODE_EASEINOUT: number;
  5098. private _easingMode;
  5099. /**
  5100. * Sets the easing mode of the current function.
  5101. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5102. */
  5103. setEasingMode(easingMode: number): void;
  5104. /**
  5105. * Gets the current easing mode.
  5106. * @returns the easing mode
  5107. */
  5108. getEasingMode(): number;
  5109. /**
  5110. * @hidden
  5111. */
  5112. easeInCore(gradient: number): number;
  5113. /**
  5114. * Given an input gradient between 0 and 1, this returns the corresponding value
  5115. * of the easing function.
  5116. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5117. * @returns the corresponding value on the curve defined by the easing function
  5118. */
  5119. ease(gradient: number): number;
  5120. }
  5121. /**
  5122. * Easing function with a circle shape (see link below).
  5123. * @see https://easings.net/#easeInCirc
  5124. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5125. */
  5126. export class CircleEase extends EasingFunction implements IEasingFunction {
  5127. /** @hidden */
  5128. easeInCore(gradient: number): number;
  5129. }
  5130. /**
  5131. * Easing function with a ease back shape (see link below).
  5132. * @see https://easings.net/#easeInBack
  5133. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5134. */
  5135. export class BackEase extends EasingFunction implements IEasingFunction {
  5136. /** Defines the amplitude of the function */
  5137. amplitude: number;
  5138. /**
  5139. * Instantiates a back ease easing
  5140. * @see https://easings.net/#easeInBack
  5141. * @param amplitude Defines the amplitude of the function
  5142. */
  5143. constructor(
  5144. /** Defines the amplitude of the function */
  5145. amplitude?: number);
  5146. /** @hidden */
  5147. easeInCore(gradient: number): number;
  5148. }
  5149. /**
  5150. * Easing function with a bouncing shape (see link below).
  5151. * @see https://easings.net/#easeInBounce
  5152. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5153. */
  5154. export class BounceEase extends EasingFunction implements IEasingFunction {
  5155. /** Defines the number of bounces */
  5156. bounces: number;
  5157. /** Defines the amplitude of the bounce */
  5158. bounciness: number;
  5159. /**
  5160. * Instantiates a bounce easing
  5161. * @see https://easings.net/#easeInBounce
  5162. * @param bounces Defines the number of bounces
  5163. * @param bounciness Defines the amplitude of the bounce
  5164. */
  5165. constructor(
  5166. /** Defines the number of bounces */
  5167. bounces?: number,
  5168. /** Defines the amplitude of the bounce */
  5169. bounciness?: number);
  5170. /** @hidden */
  5171. easeInCore(gradient: number): number;
  5172. }
  5173. /**
  5174. * Easing function with a power of 3 shape (see link below).
  5175. * @see https://easings.net/#easeInCubic
  5176. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5177. */
  5178. export class CubicEase extends EasingFunction implements IEasingFunction {
  5179. /** @hidden */
  5180. easeInCore(gradient: number): number;
  5181. }
  5182. /**
  5183. * Easing function with an elastic shape (see link below).
  5184. * @see https://easings.net/#easeInElastic
  5185. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5186. */
  5187. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5188. /** Defines the number of oscillations*/
  5189. oscillations: number;
  5190. /** Defines the amplitude of the oscillations*/
  5191. springiness: number;
  5192. /**
  5193. * Instantiates an elastic easing function
  5194. * @see https://easings.net/#easeInElastic
  5195. * @param oscillations Defines the number of oscillations
  5196. * @param springiness Defines the amplitude of the oscillations
  5197. */
  5198. constructor(
  5199. /** Defines the number of oscillations*/
  5200. oscillations?: number,
  5201. /** Defines the amplitude of the oscillations*/
  5202. springiness?: number);
  5203. /** @hidden */
  5204. easeInCore(gradient: number): number;
  5205. }
  5206. /**
  5207. * Easing function with an exponential shape (see link below).
  5208. * @see https://easings.net/#easeInExpo
  5209. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5210. */
  5211. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5212. /** Defines the exponent of the function */
  5213. exponent: number;
  5214. /**
  5215. * Instantiates an exponential easing function
  5216. * @see https://easings.net/#easeInExpo
  5217. * @param exponent Defines the exponent of the function
  5218. */
  5219. constructor(
  5220. /** Defines the exponent of the function */
  5221. exponent?: number);
  5222. /** @hidden */
  5223. easeInCore(gradient: number): number;
  5224. }
  5225. /**
  5226. * Easing function with a power shape (see link below).
  5227. * @see https://easings.net/#easeInQuad
  5228. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5229. */
  5230. export class PowerEase extends EasingFunction implements IEasingFunction {
  5231. /** Defines the power of the function */
  5232. power: number;
  5233. /**
  5234. * Instantiates an power base easing function
  5235. * @see https://easings.net/#easeInQuad
  5236. * @param power Defines the power of the function
  5237. */
  5238. constructor(
  5239. /** Defines the power of the function */
  5240. power?: number);
  5241. /** @hidden */
  5242. easeInCore(gradient: number): number;
  5243. }
  5244. /**
  5245. * Easing function with a power of 2 shape (see link below).
  5246. * @see https://easings.net/#easeInQuad
  5247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5248. */
  5249. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5250. /** @hidden */
  5251. easeInCore(gradient: number): number;
  5252. }
  5253. /**
  5254. * Easing function with a power of 4 shape (see link below).
  5255. * @see https://easings.net/#easeInQuart
  5256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5257. */
  5258. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5259. /** @hidden */
  5260. easeInCore(gradient: number): number;
  5261. }
  5262. /**
  5263. * Easing function with a power of 5 shape (see link below).
  5264. * @see https://easings.net/#easeInQuint
  5265. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5266. */
  5267. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5268. /** @hidden */
  5269. easeInCore(gradient: number): number;
  5270. }
  5271. /**
  5272. * Easing function with a sin shape (see link below).
  5273. * @see https://easings.net/#easeInSine
  5274. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5275. */
  5276. export class SineEase extends EasingFunction implements IEasingFunction {
  5277. /** @hidden */
  5278. easeInCore(gradient: number): number;
  5279. }
  5280. /**
  5281. * Easing function with a bezier shape (see link below).
  5282. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5283. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5284. */
  5285. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5286. /** Defines the x component of the start tangent in the bezier curve */
  5287. x1: number;
  5288. /** Defines the y component of the start tangent in the bezier curve */
  5289. y1: number;
  5290. /** Defines the x component of the end tangent in the bezier curve */
  5291. x2: number;
  5292. /** Defines the y component of the end tangent in the bezier curve */
  5293. y2: number;
  5294. /**
  5295. * Instantiates a bezier function
  5296. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5297. * @param x1 Defines the x component of the start tangent in the bezier curve
  5298. * @param y1 Defines the y component of the start tangent in the bezier curve
  5299. * @param x2 Defines the x component of the end tangent in the bezier curve
  5300. * @param y2 Defines the y component of the end tangent in the bezier curve
  5301. */
  5302. constructor(
  5303. /** Defines the x component of the start tangent in the bezier curve */
  5304. x1?: number,
  5305. /** Defines the y component of the start tangent in the bezier curve */
  5306. y1?: number,
  5307. /** Defines the x component of the end tangent in the bezier curve */
  5308. x2?: number,
  5309. /** Defines the y component of the end tangent in the bezier curve */
  5310. y2?: number);
  5311. /** @hidden */
  5312. easeInCore(gradient: number): number;
  5313. }
  5314. }
  5315. declare module "babylonjs/Maths/math.color" {
  5316. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5317. /**
  5318. * Class used to hold a RBG color
  5319. */
  5320. export class Color3 {
  5321. /**
  5322. * Defines the red component (between 0 and 1, default is 0)
  5323. */
  5324. r: number;
  5325. /**
  5326. * Defines the green component (between 0 and 1, default is 0)
  5327. */
  5328. g: number;
  5329. /**
  5330. * Defines the blue component (between 0 and 1, default is 0)
  5331. */
  5332. b: number;
  5333. /**
  5334. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5335. * @param r defines the red component (between 0 and 1, default is 0)
  5336. * @param g defines the green component (between 0 and 1, default is 0)
  5337. * @param b defines the blue component (between 0 and 1, default is 0)
  5338. */
  5339. constructor(
  5340. /**
  5341. * Defines the red component (between 0 and 1, default is 0)
  5342. */
  5343. r?: number,
  5344. /**
  5345. * Defines the green component (between 0 and 1, default is 0)
  5346. */
  5347. g?: number,
  5348. /**
  5349. * Defines the blue component (between 0 and 1, default is 0)
  5350. */
  5351. b?: number);
  5352. /**
  5353. * Creates a string with the Color3 current values
  5354. * @returns the string representation of the Color3 object
  5355. */
  5356. toString(): string;
  5357. /**
  5358. * Returns the string "Color3"
  5359. * @returns "Color3"
  5360. */
  5361. getClassName(): string;
  5362. /**
  5363. * Compute the Color3 hash code
  5364. * @returns an unique number that can be used to hash Color3 objects
  5365. */
  5366. getHashCode(): number;
  5367. /**
  5368. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5369. * @param array defines the array where to store the r,g,b components
  5370. * @param index defines an optional index in the target array to define where to start storing values
  5371. * @returns the current Color3 object
  5372. */
  5373. toArray(array: FloatArray, index?: number): Color3;
  5374. /**
  5375. * Returns a new Color4 object from the current Color3 and the given alpha
  5376. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5377. * @returns a new Color4 object
  5378. */
  5379. toColor4(alpha?: number): Color4;
  5380. /**
  5381. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5382. * @returns the new array
  5383. */
  5384. asArray(): number[];
  5385. /**
  5386. * Returns the luminance value
  5387. * @returns a float value
  5388. */
  5389. toLuminance(): number;
  5390. /**
  5391. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5392. * @param otherColor defines the second operand
  5393. * @returns the new Color3 object
  5394. */
  5395. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5396. /**
  5397. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5398. * @param otherColor defines the second operand
  5399. * @param result defines the Color3 object where to store the result
  5400. * @returns the current Color3
  5401. */
  5402. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5403. /**
  5404. * Determines equality between Color3 objects
  5405. * @param otherColor defines the second operand
  5406. * @returns true if the rgb values are equal to the given ones
  5407. */
  5408. equals(otherColor: DeepImmutable<Color3>): boolean;
  5409. /**
  5410. * Determines equality between the current Color3 object and a set of r,b,g values
  5411. * @param r defines the red component to check
  5412. * @param g defines the green component to check
  5413. * @param b defines the blue component to check
  5414. * @returns true if the rgb values are equal to the given ones
  5415. */
  5416. equalsFloats(r: number, g: number, b: number): boolean;
  5417. /**
  5418. * Multiplies in place each rgb value by scale
  5419. * @param scale defines the scaling factor
  5420. * @returns the updated Color3
  5421. */
  5422. scale(scale: number): Color3;
  5423. /**
  5424. * Multiplies the rgb values by scale and stores the result into "result"
  5425. * @param scale defines the scaling factor
  5426. * @param result defines the Color3 object where to store the result
  5427. * @returns the unmodified current Color3
  5428. */
  5429. scaleToRef(scale: number, result: Color3): Color3;
  5430. /**
  5431. * Scale the current Color3 values by a factor and add the result to a given Color3
  5432. * @param scale defines the scale factor
  5433. * @param result defines color to store the result into
  5434. * @returns the unmodified current Color3
  5435. */
  5436. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5437. /**
  5438. * Clamps the rgb values by the min and max values and stores the result into "result"
  5439. * @param min defines minimum clamping value (default is 0)
  5440. * @param max defines maximum clamping value (default is 1)
  5441. * @param result defines color to store the result into
  5442. * @returns the original Color3
  5443. */
  5444. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5445. /**
  5446. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5447. * @param otherColor defines the second operand
  5448. * @returns the new Color3
  5449. */
  5450. add(otherColor: DeepImmutable<Color3>): Color3;
  5451. /**
  5452. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5453. * @param otherColor defines the second operand
  5454. * @param result defines Color3 object to store the result into
  5455. * @returns the unmodified current Color3
  5456. */
  5457. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5458. /**
  5459. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5460. * @param otherColor defines the second operand
  5461. * @returns the new Color3
  5462. */
  5463. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5464. /**
  5465. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5466. * @param otherColor defines the second operand
  5467. * @param result defines Color3 object to store the result into
  5468. * @returns the unmodified current Color3
  5469. */
  5470. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5471. /**
  5472. * Copy the current object
  5473. * @returns a new Color3 copied the current one
  5474. */
  5475. clone(): Color3;
  5476. /**
  5477. * Copies the rgb values from the source in the current Color3
  5478. * @param source defines the source Color3 object
  5479. * @returns the updated Color3 object
  5480. */
  5481. copyFrom(source: DeepImmutable<Color3>): Color3;
  5482. /**
  5483. * Updates the Color3 rgb values from the given floats
  5484. * @param r defines the red component to read from
  5485. * @param g defines the green component to read from
  5486. * @param b defines the blue component to read from
  5487. * @returns the current Color3 object
  5488. */
  5489. copyFromFloats(r: number, g: number, b: number): Color3;
  5490. /**
  5491. * Updates the Color3 rgb values from the given floats
  5492. * @param r defines the red component to read from
  5493. * @param g defines the green component to read from
  5494. * @param b defines the blue component to read from
  5495. * @returns the current Color3 object
  5496. */
  5497. set(r: number, g: number, b: number): Color3;
  5498. /**
  5499. * Compute the Color3 hexadecimal code as a string
  5500. * @returns a string containing the hexadecimal representation of the Color3 object
  5501. */
  5502. toHexString(): string;
  5503. /**
  5504. * Computes a new Color3 converted from the current one to linear space
  5505. * @returns a new Color3 object
  5506. */
  5507. toLinearSpace(): Color3;
  5508. /**
  5509. * Converts current color in rgb space to HSV values
  5510. * @returns a new color3 representing the HSV values
  5511. */
  5512. toHSV(): Color3;
  5513. /**
  5514. * Converts current color in rgb space to HSV values
  5515. * @param result defines the Color3 where to store the HSV values
  5516. */
  5517. toHSVToRef(result: Color3): void;
  5518. /**
  5519. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5520. * @param convertedColor defines the Color3 object where to store the linear space version
  5521. * @returns the unmodified Color3
  5522. */
  5523. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5524. /**
  5525. * Computes a new Color3 converted from the current one to gamma space
  5526. * @returns a new Color3 object
  5527. */
  5528. toGammaSpace(): Color3;
  5529. /**
  5530. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5531. * @param convertedColor defines the Color3 object where to store the gamma space version
  5532. * @returns the unmodified Color3
  5533. */
  5534. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5535. private static _BlackReadOnly;
  5536. /**
  5537. * Convert Hue, saturation and value to a Color3 (RGB)
  5538. * @param hue defines the hue
  5539. * @param saturation defines the saturation
  5540. * @param value defines the value
  5541. * @param result defines the Color3 where to store the RGB values
  5542. */
  5543. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5544. /**
  5545. * Creates a new Color3 from the string containing valid hexadecimal values
  5546. * @param hex defines a string containing valid hexadecimal values
  5547. * @returns a new Color3 object
  5548. */
  5549. static FromHexString(hex: string): Color3;
  5550. /**
  5551. * Creates a new Color3 from the starting index of the given array
  5552. * @param array defines the source array
  5553. * @param offset defines an offset in the source array
  5554. * @returns a new Color3 object
  5555. */
  5556. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5557. /**
  5558. * Creates a new Color3 from integer values (< 256)
  5559. * @param r defines the red component to read from (value between 0 and 255)
  5560. * @param g defines the green component to read from (value between 0 and 255)
  5561. * @param b defines the blue component to read from (value between 0 and 255)
  5562. * @returns a new Color3 object
  5563. */
  5564. static FromInts(r: number, g: number, b: number): Color3;
  5565. /**
  5566. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5567. * @param start defines the start Color3 value
  5568. * @param end defines the end Color3 value
  5569. * @param amount defines the gradient value between start and end
  5570. * @returns a new Color3 object
  5571. */
  5572. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5573. /**
  5574. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5575. * @param left defines the start value
  5576. * @param right defines the end value
  5577. * @param amount defines the gradient factor
  5578. * @param result defines the Color3 object where to store the result
  5579. */
  5580. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5581. /**
  5582. * Returns a Color3 value containing a red color
  5583. * @returns a new Color3 object
  5584. */
  5585. static Red(): Color3;
  5586. /**
  5587. * Returns a Color3 value containing a green color
  5588. * @returns a new Color3 object
  5589. */
  5590. static Green(): Color3;
  5591. /**
  5592. * Returns a Color3 value containing a blue color
  5593. * @returns a new Color3 object
  5594. */
  5595. static Blue(): Color3;
  5596. /**
  5597. * Returns a Color3 value containing a black color
  5598. * @returns a new Color3 object
  5599. */
  5600. static Black(): Color3;
  5601. /**
  5602. * Gets a Color3 value containing a black color that must not be updated
  5603. */
  5604. static get BlackReadOnly(): DeepImmutable<Color3>;
  5605. /**
  5606. * Returns a Color3 value containing a white color
  5607. * @returns a new Color3 object
  5608. */
  5609. static White(): Color3;
  5610. /**
  5611. * Returns a Color3 value containing a purple color
  5612. * @returns a new Color3 object
  5613. */
  5614. static Purple(): Color3;
  5615. /**
  5616. * Returns a Color3 value containing a magenta color
  5617. * @returns a new Color3 object
  5618. */
  5619. static Magenta(): Color3;
  5620. /**
  5621. * Returns a Color3 value containing a yellow color
  5622. * @returns a new Color3 object
  5623. */
  5624. static Yellow(): Color3;
  5625. /**
  5626. * Returns a Color3 value containing a gray color
  5627. * @returns a new Color3 object
  5628. */
  5629. static Gray(): Color3;
  5630. /**
  5631. * Returns a Color3 value containing a teal color
  5632. * @returns a new Color3 object
  5633. */
  5634. static Teal(): Color3;
  5635. /**
  5636. * Returns a Color3 value containing a random color
  5637. * @returns a new Color3 object
  5638. */
  5639. static Random(): Color3;
  5640. }
  5641. /**
  5642. * Class used to hold a RBGA color
  5643. */
  5644. export class Color4 {
  5645. /**
  5646. * Defines the red component (between 0 and 1, default is 0)
  5647. */
  5648. r: number;
  5649. /**
  5650. * Defines the green component (between 0 and 1, default is 0)
  5651. */
  5652. g: number;
  5653. /**
  5654. * Defines the blue component (between 0 and 1, default is 0)
  5655. */
  5656. b: number;
  5657. /**
  5658. * Defines the alpha component (between 0 and 1, default is 1)
  5659. */
  5660. a: number;
  5661. /**
  5662. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5663. * @param r defines the red component (between 0 and 1, default is 0)
  5664. * @param g defines the green component (between 0 and 1, default is 0)
  5665. * @param b defines the blue component (between 0 and 1, default is 0)
  5666. * @param a defines the alpha component (between 0 and 1, default is 1)
  5667. */
  5668. constructor(
  5669. /**
  5670. * Defines the red component (between 0 and 1, default is 0)
  5671. */
  5672. r?: number,
  5673. /**
  5674. * Defines the green component (between 0 and 1, default is 0)
  5675. */
  5676. g?: number,
  5677. /**
  5678. * Defines the blue component (between 0 and 1, default is 0)
  5679. */
  5680. b?: number,
  5681. /**
  5682. * Defines the alpha component (between 0 and 1, default is 1)
  5683. */
  5684. a?: number);
  5685. /**
  5686. * Adds in place the given Color4 values to the current Color4 object
  5687. * @param right defines the second operand
  5688. * @returns the current updated Color4 object
  5689. */
  5690. addInPlace(right: DeepImmutable<Color4>): Color4;
  5691. /**
  5692. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5693. * @returns the new array
  5694. */
  5695. asArray(): number[];
  5696. /**
  5697. * Stores from the starting index in the given array the Color4 successive values
  5698. * @param array defines the array where to store the r,g,b components
  5699. * @param index defines an optional index in the target array to define where to start storing values
  5700. * @returns the current Color4 object
  5701. */
  5702. toArray(array: number[], index?: number): Color4;
  5703. /**
  5704. * Determines equality between Color4 objects
  5705. * @param otherColor defines the second operand
  5706. * @returns true if the rgba values are equal to the given ones
  5707. */
  5708. equals(otherColor: DeepImmutable<Color4>): boolean;
  5709. /**
  5710. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5711. * @param right defines the second operand
  5712. * @returns a new Color4 object
  5713. */
  5714. add(right: DeepImmutable<Color4>): Color4;
  5715. /**
  5716. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5717. * @param right defines the second operand
  5718. * @returns a new Color4 object
  5719. */
  5720. subtract(right: DeepImmutable<Color4>): Color4;
  5721. /**
  5722. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5723. * @param right defines the second operand
  5724. * @param result defines the Color4 object where to store the result
  5725. * @returns the current Color4 object
  5726. */
  5727. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5728. /**
  5729. * Creates a new Color4 with the current Color4 values multiplied by scale
  5730. * @param scale defines the scaling factor to apply
  5731. * @returns a new Color4 object
  5732. */
  5733. scale(scale: number): Color4;
  5734. /**
  5735. * Multiplies the current Color4 values by scale and stores the result in "result"
  5736. * @param scale defines the scaling factor to apply
  5737. * @param result defines the Color4 object where to store the result
  5738. * @returns the current unmodified Color4
  5739. */
  5740. scaleToRef(scale: number, result: Color4): Color4;
  5741. /**
  5742. * Scale the current Color4 values by a factor and add the result to a given Color4
  5743. * @param scale defines the scale factor
  5744. * @param result defines the Color4 object where to store the result
  5745. * @returns the unmodified current Color4
  5746. */
  5747. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5748. /**
  5749. * Clamps the rgb values by the min and max values and stores the result into "result"
  5750. * @param min defines minimum clamping value (default is 0)
  5751. * @param max defines maximum clamping value (default is 1)
  5752. * @param result defines color to store the result into.
  5753. * @returns the cuurent Color4
  5754. */
  5755. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5756. /**
  5757. * Multipy an Color4 value by another and return a new Color4 object
  5758. * @param color defines the Color4 value to multiply by
  5759. * @returns a new Color4 object
  5760. */
  5761. multiply(color: Color4): Color4;
  5762. /**
  5763. * Multipy a Color4 value by another and push the result in a reference value
  5764. * @param color defines the Color4 value to multiply by
  5765. * @param result defines the Color4 to fill the result in
  5766. * @returns the result Color4
  5767. */
  5768. multiplyToRef(color: Color4, result: Color4): Color4;
  5769. /**
  5770. * Creates a string with the Color4 current values
  5771. * @returns the string representation of the Color4 object
  5772. */
  5773. toString(): string;
  5774. /**
  5775. * Returns the string "Color4"
  5776. * @returns "Color4"
  5777. */
  5778. getClassName(): string;
  5779. /**
  5780. * Compute the Color4 hash code
  5781. * @returns an unique number that can be used to hash Color4 objects
  5782. */
  5783. getHashCode(): number;
  5784. /**
  5785. * Creates a new Color4 copied from the current one
  5786. * @returns a new Color4 object
  5787. */
  5788. clone(): Color4;
  5789. /**
  5790. * Copies the given Color4 values into the current one
  5791. * @param source defines the source Color4 object
  5792. * @returns the current updated Color4 object
  5793. */
  5794. copyFrom(source: Color4): Color4;
  5795. /**
  5796. * Copies the given float values into the current one
  5797. * @param r defines the red component to read from
  5798. * @param g defines the green component to read from
  5799. * @param b defines the blue component to read from
  5800. * @param a defines the alpha component to read from
  5801. * @returns the current updated Color4 object
  5802. */
  5803. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5804. /**
  5805. * Copies the given float values into the current one
  5806. * @param r defines the red component to read from
  5807. * @param g defines the green component to read from
  5808. * @param b defines the blue component to read from
  5809. * @param a defines the alpha component to read from
  5810. * @returns the current updated Color4 object
  5811. */
  5812. set(r: number, g: number, b: number, a: number): Color4;
  5813. /**
  5814. * Compute the Color4 hexadecimal code as a string
  5815. * @returns a string containing the hexadecimal representation of the Color4 object
  5816. */
  5817. toHexString(): string;
  5818. /**
  5819. * Computes a new Color4 converted from the current one to linear space
  5820. * @returns a new Color4 object
  5821. */
  5822. toLinearSpace(): Color4;
  5823. /**
  5824. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5825. * @param convertedColor defines the Color4 object where to store the linear space version
  5826. * @returns the unmodified Color4
  5827. */
  5828. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5829. /**
  5830. * Computes a new Color4 converted from the current one to gamma space
  5831. * @returns a new Color4 object
  5832. */
  5833. toGammaSpace(): Color4;
  5834. /**
  5835. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5836. * @param convertedColor defines the Color4 object where to store the gamma space version
  5837. * @returns the unmodified Color4
  5838. */
  5839. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5840. /**
  5841. * Creates a new Color4 from the string containing valid hexadecimal values
  5842. * @param hex defines a string containing valid hexadecimal values
  5843. * @returns a new Color4 object
  5844. */
  5845. static FromHexString(hex: string): Color4;
  5846. /**
  5847. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5848. * @param left defines the start value
  5849. * @param right defines the end value
  5850. * @param amount defines the gradient factor
  5851. * @returns a new Color4 object
  5852. */
  5853. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5854. /**
  5855. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5856. * @param left defines the start value
  5857. * @param right defines the end value
  5858. * @param amount defines the gradient factor
  5859. * @param result defines the Color4 object where to store data
  5860. */
  5861. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5862. /**
  5863. * Creates a new Color4 from a Color3 and an alpha value
  5864. * @param color3 defines the source Color3 to read from
  5865. * @param alpha defines the alpha component (1.0 by default)
  5866. * @returns a new Color4 object
  5867. */
  5868. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5869. /**
  5870. * Creates a new Color4 from the starting index element of the given array
  5871. * @param array defines the source array to read from
  5872. * @param offset defines the offset in the source array
  5873. * @returns a new Color4 object
  5874. */
  5875. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5876. /**
  5877. * Creates a new Color3 from integer values (< 256)
  5878. * @param r defines the red component to read from (value between 0 and 255)
  5879. * @param g defines the green component to read from (value between 0 and 255)
  5880. * @param b defines the blue component to read from (value between 0 and 255)
  5881. * @param a defines the alpha component to read from (value between 0 and 255)
  5882. * @returns a new Color3 object
  5883. */
  5884. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5885. /**
  5886. * Check the content of a given array and convert it to an array containing RGBA data
  5887. * If the original array was already containing count * 4 values then it is returned directly
  5888. * @param colors defines the array to check
  5889. * @param count defines the number of RGBA data to expect
  5890. * @returns an array containing count * 4 values (RGBA)
  5891. */
  5892. static CheckColors4(colors: number[], count: number): number[];
  5893. }
  5894. /**
  5895. * @hidden
  5896. */
  5897. export class TmpColors {
  5898. static Color3: Color3[];
  5899. static Color4: Color4[];
  5900. }
  5901. }
  5902. declare module "babylonjs/Animations/animationKey" {
  5903. /**
  5904. * Defines an interface which represents an animation key frame
  5905. */
  5906. export interface IAnimationKey {
  5907. /**
  5908. * Frame of the key frame
  5909. */
  5910. frame: number;
  5911. /**
  5912. * Value at the specifies key frame
  5913. */
  5914. value: any;
  5915. /**
  5916. * The input tangent for the cubic hermite spline
  5917. */
  5918. inTangent?: any;
  5919. /**
  5920. * The output tangent for the cubic hermite spline
  5921. */
  5922. outTangent?: any;
  5923. /**
  5924. * The animation interpolation type
  5925. */
  5926. interpolation?: AnimationKeyInterpolation;
  5927. }
  5928. /**
  5929. * Enum for the animation key frame interpolation type
  5930. */
  5931. export enum AnimationKeyInterpolation {
  5932. /**
  5933. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5934. */
  5935. STEP = 1
  5936. }
  5937. }
  5938. declare module "babylonjs/Animations/animationRange" {
  5939. /**
  5940. * Represents the range of an animation
  5941. */
  5942. export class AnimationRange {
  5943. /**The name of the animation range**/
  5944. name: string;
  5945. /**The starting frame of the animation */
  5946. from: number;
  5947. /**The ending frame of the animation*/
  5948. to: number;
  5949. /**
  5950. * Initializes the range of an animation
  5951. * @param name The name of the animation range
  5952. * @param from The starting frame of the animation
  5953. * @param to The ending frame of the animation
  5954. */
  5955. constructor(
  5956. /**The name of the animation range**/
  5957. name: string,
  5958. /**The starting frame of the animation */
  5959. from: number,
  5960. /**The ending frame of the animation*/
  5961. to: number);
  5962. /**
  5963. * Makes a copy of the animation range
  5964. * @returns A copy of the animation range
  5965. */
  5966. clone(): AnimationRange;
  5967. }
  5968. }
  5969. declare module "babylonjs/Animations/animationEvent" {
  5970. /**
  5971. * Composed of a frame, and an action function
  5972. */
  5973. export class AnimationEvent {
  5974. /** The frame for which the event is triggered **/
  5975. frame: number;
  5976. /** The event to perform when triggered **/
  5977. action: (currentFrame: number) => void;
  5978. /** Specifies if the event should be triggered only once**/
  5979. onlyOnce?: boolean | undefined;
  5980. /**
  5981. * Specifies if the animation event is done
  5982. */
  5983. isDone: boolean;
  5984. /**
  5985. * Initializes the animation event
  5986. * @param frame The frame for which the event is triggered
  5987. * @param action The event to perform when triggered
  5988. * @param onlyOnce Specifies if the event should be triggered only once
  5989. */
  5990. constructor(
  5991. /** The frame for which the event is triggered **/
  5992. frame: number,
  5993. /** The event to perform when triggered **/
  5994. action: (currentFrame: number) => void,
  5995. /** Specifies if the event should be triggered only once**/
  5996. onlyOnce?: boolean | undefined);
  5997. /** @hidden */
  5998. _clone(): AnimationEvent;
  5999. }
  6000. }
  6001. declare module "babylonjs/Behaviors/behavior" {
  6002. import { Nullable } from "babylonjs/types";
  6003. /**
  6004. * Interface used to define a behavior
  6005. */
  6006. export interface Behavior<T> {
  6007. /** gets or sets behavior's name */
  6008. name: string;
  6009. /**
  6010. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6011. */
  6012. init(): void;
  6013. /**
  6014. * Called when the behavior is attached to a target
  6015. * @param target defines the target where the behavior is attached to
  6016. */
  6017. attach(target: T): void;
  6018. /**
  6019. * Called when the behavior is detached from its target
  6020. */
  6021. detach(): void;
  6022. }
  6023. /**
  6024. * Interface implemented by classes supporting behaviors
  6025. */
  6026. export interface IBehaviorAware<T> {
  6027. /**
  6028. * Attach a behavior
  6029. * @param behavior defines the behavior to attach
  6030. * @returns the current host
  6031. */
  6032. addBehavior(behavior: Behavior<T>): T;
  6033. /**
  6034. * Remove a behavior from the current object
  6035. * @param behavior defines the behavior to detach
  6036. * @returns the current host
  6037. */
  6038. removeBehavior(behavior: Behavior<T>): T;
  6039. /**
  6040. * Gets a behavior using its name to search
  6041. * @param name defines the name to search
  6042. * @returns the behavior or null if not found
  6043. */
  6044. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6045. }
  6046. }
  6047. declare module "babylonjs/Misc/smartArray" {
  6048. /**
  6049. * Defines an array and its length.
  6050. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6051. */
  6052. export interface ISmartArrayLike<T> {
  6053. /**
  6054. * The data of the array.
  6055. */
  6056. data: Array<T>;
  6057. /**
  6058. * The active length of the array.
  6059. */
  6060. length: number;
  6061. }
  6062. /**
  6063. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6064. */
  6065. export class SmartArray<T> implements ISmartArrayLike<T> {
  6066. /**
  6067. * The full set of data from the array.
  6068. */
  6069. data: Array<T>;
  6070. /**
  6071. * The active length of the array.
  6072. */
  6073. length: number;
  6074. protected _id: number;
  6075. /**
  6076. * Instantiates a Smart Array.
  6077. * @param capacity defines the default capacity of the array.
  6078. */
  6079. constructor(capacity: number);
  6080. /**
  6081. * Pushes a value at the end of the active data.
  6082. * @param value defines the object to push in the array.
  6083. */
  6084. push(value: T): void;
  6085. /**
  6086. * Iterates over the active data and apply the lambda to them.
  6087. * @param func defines the action to apply on each value.
  6088. */
  6089. forEach(func: (content: T) => void): void;
  6090. /**
  6091. * Sorts the full sets of data.
  6092. * @param compareFn defines the comparison function to apply.
  6093. */
  6094. sort(compareFn: (a: T, b: T) => number): void;
  6095. /**
  6096. * Resets the active data to an empty array.
  6097. */
  6098. reset(): void;
  6099. /**
  6100. * Releases all the data from the array as well as the array.
  6101. */
  6102. dispose(): void;
  6103. /**
  6104. * Concats the active data with a given array.
  6105. * @param array defines the data to concatenate with.
  6106. */
  6107. concat(array: any): void;
  6108. /**
  6109. * Returns the position of a value in the active data.
  6110. * @param value defines the value to find the index for
  6111. * @returns the index if found in the active data otherwise -1
  6112. */
  6113. indexOf(value: T): number;
  6114. /**
  6115. * Returns whether an element is part of the active data.
  6116. * @param value defines the value to look for
  6117. * @returns true if found in the active data otherwise false
  6118. */
  6119. contains(value: T): boolean;
  6120. private static _GlobalId;
  6121. }
  6122. /**
  6123. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6124. * The data in this array can only be present once
  6125. */
  6126. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6127. private _duplicateId;
  6128. /**
  6129. * Pushes a value at the end of the active data.
  6130. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6131. * @param value defines the object to push in the array.
  6132. */
  6133. push(value: T): void;
  6134. /**
  6135. * Pushes a value at the end of the active data.
  6136. * If the data is already present, it won t be added again
  6137. * @param value defines the object to push in the array.
  6138. * @returns true if added false if it was already present
  6139. */
  6140. pushNoDuplicate(value: T): boolean;
  6141. /**
  6142. * Resets the active data to an empty array.
  6143. */
  6144. reset(): void;
  6145. /**
  6146. * Concats the active data with a given array.
  6147. * This ensures no dupplicate will be present in the result.
  6148. * @param array defines the data to concatenate with.
  6149. */
  6150. concatWithNoDuplicate(array: any): void;
  6151. }
  6152. }
  6153. declare module "babylonjs/Cameras/cameraInputsManager" {
  6154. import { Nullable } from "babylonjs/types";
  6155. import { Camera } from "babylonjs/Cameras/camera";
  6156. /**
  6157. * @ignore
  6158. * This is a list of all the different input types that are available in the application.
  6159. * Fo instance: ArcRotateCameraGamepadInput...
  6160. */
  6161. export var CameraInputTypes: {};
  6162. /**
  6163. * This is the contract to implement in order to create a new input class.
  6164. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6165. */
  6166. export interface ICameraInput<TCamera extends Camera> {
  6167. /**
  6168. * Defines the camera the input is attached to.
  6169. */
  6170. camera: Nullable<TCamera>;
  6171. /**
  6172. * Gets the class name of the current intput.
  6173. * @returns the class name
  6174. */
  6175. getClassName(): string;
  6176. /**
  6177. * Get the friendly name associated with the input class.
  6178. * @returns the input friendly name
  6179. */
  6180. getSimpleName(): string;
  6181. /**
  6182. * Attach the input controls to a specific dom element to get the input from.
  6183. * @param element Defines the element the controls should be listened from
  6184. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6185. */
  6186. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6187. /**
  6188. * Detach the current controls from the specified dom element.
  6189. * @param element Defines the element to stop listening the inputs from
  6190. */
  6191. detachControl(element: Nullable<HTMLElement>): void;
  6192. /**
  6193. * Update the current camera state depending on the inputs that have been used this frame.
  6194. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6195. */
  6196. checkInputs?: () => void;
  6197. }
  6198. /**
  6199. * Represents a map of input types to input instance or input index to input instance.
  6200. */
  6201. export interface CameraInputsMap<TCamera extends Camera> {
  6202. /**
  6203. * Accessor to the input by input type.
  6204. */
  6205. [name: string]: ICameraInput<TCamera>;
  6206. /**
  6207. * Accessor to the input by input index.
  6208. */
  6209. [idx: number]: ICameraInput<TCamera>;
  6210. }
  6211. /**
  6212. * This represents the input manager used within a camera.
  6213. * It helps dealing with all the different kind of input attached to a camera.
  6214. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6215. */
  6216. export class CameraInputsManager<TCamera extends Camera> {
  6217. /**
  6218. * Defines the list of inputs attahed to the camera.
  6219. */
  6220. attached: CameraInputsMap<TCamera>;
  6221. /**
  6222. * Defines the dom element the camera is collecting inputs from.
  6223. * This is null if the controls have not been attached.
  6224. */
  6225. attachedElement: Nullable<HTMLElement>;
  6226. /**
  6227. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6228. */
  6229. noPreventDefault: boolean;
  6230. /**
  6231. * Defined the camera the input manager belongs to.
  6232. */
  6233. camera: TCamera;
  6234. /**
  6235. * Update the current camera state depending on the inputs that have been used this frame.
  6236. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6237. */
  6238. checkInputs: () => void;
  6239. /**
  6240. * Instantiate a new Camera Input Manager.
  6241. * @param camera Defines the camera the input manager blongs to
  6242. */
  6243. constructor(camera: TCamera);
  6244. /**
  6245. * Add an input method to a camera
  6246. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6247. * @param input camera input method
  6248. */
  6249. add(input: ICameraInput<TCamera>): void;
  6250. /**
  6251. * Remove a specific input method from a camera
  6252. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6253. * @param inputToRemove camera input method
  6254. */
  6255. remove(inputToRemove: ICameraInput<TCamera>): void;
  6256. /**
  6257. * Remove a specific input type from a camera
  6258. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6259. * @param inputType the type of the input to remove
  6260. */
  6261. removeByType(inputType: string): void;
  6262. private _addCheckInputs;
  6263. /**
  6264. * Attach the input controls to the currently attached dom element to listen the events from.
  6265. * @param input Defines the input to attach
  6266. */
  6267. attachInput(input: ICameraInput<TCamera>): void;
  6268. /**
  6269. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6270. * @param element Defines the dom element to collect the events from
  6271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6272. */
  6273. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6274. /**
  6275. * Detach the current manager inputs controls from a specific dom element.
  6276. * @param element Defines the dom element to collect the events from
  6277. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6278. */
  6279. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6280. /**
  6281. * Rebuild the dynamic inputCheck function from the current list of
  6282. * defined inputs in the manager.
  6283. */
  6284. rebuildInputCheck(): void;
  6285. /**
  6286. * Remove all attached input methods from a camera
  6287. */
  6288. clear(): void;
  6289. /**
  6290. * Serialize the current input manager attached to a camera.
  6291. * This ensures than once parsed,
  6292. * the input associated to the camera will be identical to the current ones
  6293. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6294. */
  6295. serialize(serializedCamera: any): void;
  6296. /**
  6297. * Parses an input manager serialized JSON to restore the previous list of inputs
  6298. * and states associated to a camera.
  6299. * @param parsedCamera Defines the JSON to parse
  6300. */
  6301. parse(parsedCamera: any): void;
  6302. }
  6303. }
  6304. declare module "babylonjs/Meshes/buffer" {
  6305. import { Nullable, DataArray } from "babylonjs/types";
  6306. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6307. /**
  6308. * Class used to store data that will be store in GPU memory
  6309. */
  6310. export class Buffer {
  6311. private _engine;
  6312. private _buffer;
  6313. /** @hidden */
  6314. _data: Nullable<DataArray>;
  6315. private _updatable;
  6316. private _instanced;
  6317. private _divisor;
  6318. /**
  6319. * Gets the byte stride.
  6320. */
  6321. readonly byteStride: number;
  6322. /**
  6323. * Constructor
  6324. * @param engine the engine
  6325. * @param data the data to use for this buffer
  6326. * @param updatable whether the data is updatable
  6327. * @param stride the stride (optional)
  6328. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6329. * @param instanced whether the buffer is instanced (optional)
  6330. * @param useBytes set to true if the stride in in bytes (optional)
  6331. * @param divisor sets an optional divisor for instances (1 by default)
  6332. */
  6333. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6334. /**
  6335. * Create a new VertexBuffer based on the current buffer
  6336. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6337. * @param offset defines offset in the buffer (0 by default)
  6338. * @param size defines the size in floats of attributes (position is 3 for instance)
  6339. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6340. * @param instanced defines if the vertex buffer contains indexed data
  6341. * @param useBytes defines if the offset and stride are in bytes *
  6342. * @param divisor sets an optional divisor for instances (1 by default)
  6343. * @returns the new vertex buffer
  6344. */
  6345. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6346. /**
  6347. * Gets a boolean indicating if the Buffer is updatable?
  6348. * @returns true if the buffer is updatable
  6349. */
  6350. isUpdatable(): boolean;
  6351. /**
  6352. * Gets current buffer's data
  6353. * @returns a DataArray or null
  6354. */
  6355. getData(): Nullable<DataArray>;
  6356. /**
  6357. * Gets underlying native buffer
  6358. * @returns underlying native buffer
  6359. */
  6360. getBuffer(): Nullable<DataBuffer>;
  6361. /**
  6362. * Gets the stride in float32 units (i.e. byte stride / 4).
  6363. * May not be an integer if the byte stride is not divisible by 4.
  6364. * @returns the stride in float32 units
  6365. * @deprecated Please use byteStride instead.
  6366. */
  6367. getStrideSize(): number;
  6368. /**
  6369. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6370. * @param data defines the data to store
  6371. */
  6372. create(data?: Nullable<DataArray>): void;
  6373. /** @hidden */
  6374. _rebuild(): void;
  6375. /**
  6376. * Update current buffer data
  6377. * @param data defines the data to store
  6378. */
  6379. update(data: DataArray): void;
  6380. /**
  6381. * Updates the data directly.
  6382. * @param data the new data
  6383. * @param offset the new offset
  6384. * @param vertexCount the vertex count (optional)
  6385. * @param useBytes set to true if the offset is in bytes
  6386. */
  6387. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6388. /**
  6389. * Release all resources
  6390. */
  6391. dispose(): void;
  6392. }
  6393. /**
  6394. * Specialized buffer used to store vertex data
  6395. */
  6396. export class VertexBuffer {
  6397. /** @hidden */
  6398. _buffer: Buffer;
  6399. private _kind;
  6400. private _size;
  6401. private _ownsBuffer;
  6402. private _instanced;
  6403. private _instanceDivisor;
  6404. /**
  6405. * The byte type.
  6406. */
  6407. static readonly BYTE: number;
  6408. /**
  6409. * The unsigned byte type.
  6410. */
  6411. static readonly UNSIGNED_BYTE: number;
  6412. /**
  6413. * The short type.
  6414. */
  6415. static readonly SHORT: number;
  6416. /**
  6417. * The unsigned short type.
  6418. */
  6419. static readonly UNSIGNED_SHORT: number;
  6420. /**
  6421. * The integer type.
  6422. */
  6423. static readonly INT: number;
  6424. /**
  6425. * The unsigned integer type.
  6426. */
  6427. static readonly UNSIGNED_INT: number;
  6428. /**
  6429. * The float type.
  6430. */
  6431. static readonly FLOAT: number;
  6432. /**
  6433. * Gets or sets the instance divisor when in instanced mode
  6434. */
  6435. get instanceDivisor(): number;
  6436. set instanceDivisor(value: number);
  6437. /**
  6438. * Gets the byte stride.
  6439. */
  6440. readonly byteStride: number;
  6441. /**
  6442. * Gets the byte offset.
  6443. */
  6444. readonly byteOffset: number;
  6445. /**
  6446. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6447. */
  6448. readonly normalized: boolean;
  6449. /**
  6450. * Gets the data type of each component in the array.
  6451. */
  6452. readonly type: number;
  6453. /**
  6454. * Constructor
  6455. * @param engine the engine
  6456. * @param data the data to use for this vertex buffer
  6457. * @param kind the vertex buffer kind
  6458. * @param updatable whether the data is updatable
  6459. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6460. * @param stride the stride (optional)
  6461. * @param instanced whether the buffer is instanced (optional)
  6462. * @param offset the offset of the data (optional)
  6463. * @param size the number of components (optional)
  6464. * @param type the type of the component (optional)
  6465. * @param normalized whether the data contains normalized data (optional)
  6466. * @param useBytes set to true if stride and offset are in bytes (optional)
  6467. * @param divisor defines the instance divisor to use (1 by default)
  6468. */
  6469. constructor(engine: any, data: DataArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number, type?: number, normalized?: boolean, useBytes?: boolean, divisor?: number);
  6470. /** @hidden */
  6471. _rebuild(): void;
  6472. /**
  6473. * Returns the kind of the VertexBuffer (string)
  6474. * @returns a string
  6475. */
  6476. getKind(): string;
  6477. /**
  6478. * Gets a boolean indicating if the VertexBuffer is updatable?
  6479. * @returns true if the buffer is updatable
  6480. */
  6481. isUpdatable(): boolean;
  6482. /**
  6483. * Gets current buffer's data
  6484. * @returns a DataArray or null
  6485. */
  6486. getData(): Nullable<DataArray>;
  6487. /**
  6488. * Gets underlying native buffer
  6489. * @returns underlying native buffer
  6490. */
  6491. getBuffer(): Nullable<DataBuffer>;
  6492. /**
  6493. * Gets the stride in float32 units (i.e. byte stride / 4).
  6494. * May not be an integer if the byte stride is not divisible by 4.
  6495. * @returns the stride in float32 units
  6496. * @deprecated Please use byteStride instead.
  6497. */
  6498. getStrideSize(): number;
  6499. /**
  6500. * Returns the offset as a multiple of the type byte length.
  6501. * @returns the offset in bytes
  6502. * @deprecated Please use byteOffset instead.
  6503. */
  6504. getOffset(): number;
  6505. /**
  6506. * Returns the number of components per vertex attribute (integer)
  6507. * @returns the size in float
  6508. */
  6509. getSize(): number;
  6510. /**
  6511. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6512. * @returns true if this buffer is instanced
  6513. */
  6514. getIsInstanced(): boolean;
  6515. /**
  6516. * Returns the instancing divisor, zero for non-instanced (integer).
  6517. * @returns a number
  6518. */
  6519. getInstanceDivisor(): number;
  6520. /**
  6521. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6522. * @param data defines the data to store
  6523. */
  6524. create(data?: DataArray): void;
  6525. /**
  6526. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6527. * This function will create a new buffer if the current one is not updatable
  6528. * @param data defines the data to store
  6529. */
  6530. update(data: DataArray): void;
  6531. /**
  6532. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6533. * Returns the directly updated WebGLBuffer.
  6534. * @param data the new data
  6535. * @param offset the new offset
  6536. * @param useBytes set to true if the offset is in bytes
  6537. */
  6538. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6539. /**
  6540. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6541. */
  6542. dispose(): void;
  6543. /**
  6544. * Enumerates each value of this vertex buffer as numbers.
  6545. * @param count the number of values to enumerate
  6546. * @param callback the callback function called for each value
  6547. */
  6548. forEach(count: number, callback: (value: number, index: number) => void): void;
  6549. /**
  6550. * Positions
  6551. */
  6552. static readonly PositionKind: string;
  6553. /**
  6554. * Normals
  6555. */
  6556. static readonly NormalKind: string;
  6557. /**
  6558. * Tangents
  6559. */
  6560. static readonly TangentKind: string;
  6561. /**
  6562. * Texture coordinates
  6563. */
  6564. static readonly UVKind: string;
  6565. /**
  6566. * Texture coordinates 2
  6567. */
  6568. static readonly UV2Kind: string;
  6569. /**
  6570. * Texture coordinates 3
  6571. */
  6572. static readonly UV3Kind: string;
  6573. /**
  6574. * Texture coordinates 4
  6575. */
  6576. static readonly UV4Kind: string;
  6577. /**
  6578. * Texture coordinates 5
  6579. */
  6580. static readonly UV5Kind: string;
  6581. /**
  6582. * Texture coordinates 6
  6583. */
  6584. static readonly UV6Kind: string;
  6585. /**
  6586. * Colors
  6587. */
  6588. static readonly ColorKind: string;
  6589. /**
  6590. * Matrix indices (for bones)
  6591. */
  6592. static readonly MatricesIndicesKind: string;
  6593. /**
  6594. * Matrix weights (for bones)
  6595. */
  6596. static readonly MatricesWeightsKind: string;
  6597. /**
  6598. * Additional matrix indices (for bones)
  6599. */
  6600. static readonly MatricesIndicesExtraKind: string;
  6601. /**
  6602. * Additional matrix weights (for bones)
  6603. */
  6604. static readonly MatricesWeightsExtraKind: string;
  6605. /**
  6606. * Deduces the stride given a kind.
  6607. * @param kind The kind string to deduce
  6608. * @returns The deduced stride
  6609. */
  6610. static DeduceStride(kind: string): number;
  6611. /**
  6612. * Gets the byte length of the given type.
  6613. * @param type the type
  6614. * @returns the number of bytes
  6615. */
  6616. static GetTypeByteLength(type: number): number;
  6617. /**
  6618. * Enumerates each value of the given parameters as numbers.
  6619. * @param data the data to enumerate
  6620. * @param byteOffset the byte offset of the data
  6621. * @param byteStride the byte stride of the data
  6622. * @param componentCount the number of components per element
  6623. * @param componentType the type of the component
  6624. * @param count the number of values to enumerate
  6625. * @param normalized whether the data is normalized
  6626. * @param callback the callback function called for each value
  6627. */
  6628. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6629. private static _GetFloatValue;
  6630. }
  6631. }
  6632. declare module "babylonjs/Collisions/intersectionInfo" {
  6633. import { Nullable } from "babylonjs/types";
  6634. /**
  6635. * @hidden
  6636. */
  6637. export class IntersectionInfo {
  6638. bu: Nullable<number>;
  6639. bv: Nullable<number>;
  6640. distance: number;
  6641. faceId: number;
  6642. subMeshId: number;
  6643. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6644. }
  6645. }
  6646. declare module "babylonjs/Maths/math.plane" {
  6647. import { DeepImmutable } from "babylonjs/types";
  6648. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6649. /**
  6650. * Represens a plane by the equation ax + by + cz + d = 0
  6651. */
  6652. export class Plane {
  6653. private static _TmpMatrix;
  6654. /**
  6655. * Normal of the plane (a,b,c)
  6656. */
  6657. normal: Vector3;
  6658. /**
  6659. * d component of the plane
  6660. */
  6661. d: number;
  6662. /**
  6663. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6664. * @param a a component of the plane
  6665. * @param b b component of the plane
  6666. * @param c c component of the plane
  6667. * @param d d component of the plane
  6668. */
  6669. constructor(a: number, b: number, c: number, d: number);
  6670. /**
  6671. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6672. */
  6673. asArray(): number[];
  6674. /**
  6675. * @returns a new plane copied from the current Plane.
  6676. */
  6677. clone(): Plane;
  6678. /**
  6679. * @returns the string "Plane".
  6680. */
  6681. getClassName(): string;
  6682. /**
  6683. * @returns the Plane hash code.
  6684. */
  6685. getHashCode(): number;
  6686. /**
  6687. * Normalize the current Plane in place.
  6688. * @returns the updated Plane.
  6689. */
  6690. normalize(): Plane;
  6691. /**
  6692. * Applies a transformation the plane and returns the result
  6693. * @param transformation the transformation matrix to be applied to the plane
  6694. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6695. */
  6696. transform(transformation: DeepImmutable<Matrix>): Plane;
  6697. /**
  6698. * Calcualtte the dot product between the point and the plane normal
  6699. * @param point point to calculate the dot product with
  6700. * @returns the dot product (float) of the point coordinates and the plane normal.
  6701. */
  6702. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6703. /**
  6704. * Updates the current Plane from the plane defined by the three given points.
  6705. * @param point1 one of the points used to contruct the plane
  6706. * @param point2 one of the points used to contruct the plane
  6707. * @param point3 one of the points used to contruct the plane
  6708. * @returns the updated Plane.
  6709. */
  6710. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6711. /**
  6712. * Checks if the plane is facing a given direction
  6713. * @param direction the direction to check if the plane is facing
  6714. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6715. * @returns True is the vector "direction" is the same side than the plane normal.
  6716. */
  6717. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6718. /**
  6719. * Calculates the distance to a point
  6720. * @param point point to calculate distance to
  6721. * @returns the signed distance (float) from the given point to the Plane.
  6722. */
  6723. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6724. /**
  6725. * Creates a plane from an array
  6726. * @param array the array to create a plane from
  6727. * @returns a new Plane from the given array.
  6728. */
  6729. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6730. /**
  6731. * Creates a plane from three points
  6732. * @param point1 point used to create the plane
  6733. * @param point2 point used to create the plane
  6734. * @param point3 point used to create the plane
  6735. * @returns a new Plane defined by the three given points.
  6736. */
  6737. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6738. /**
  6739. * Creates a plane from an origin point and a normal
  6740. * @param origin origin of the plane to be constructed
  6741. * @param normal normal of the plane to be constructed
  6742. * @returns a new Plane the normal vector to this plane at the given origin point.
  6743. * Note : the vector "normal" is updated because normalized.
  6744. */
  6745. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6746. /**
  6747. * Calculates the distance from a plane and a point
  6748. * @param origin origin of the plane to be constructed
  6749. * @param normal normal of the plane to be constructed
  6750. * @param point point to calculate distance to
  6751. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6752. */
  6753. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6754. }
  6755. }
  6756. declare module "babylonjs/Culling/boundingSphere" {
  6757. import { DeepImmutable } from "babylonjs/types";
  6758. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6759. import { Plane } from "babylonjs/Maths/math.plane";
  6760. /**
  6761. * Class used to store bounding sphere information
  6762. */
  6763. export class BoundingSphere {
  6764. /**
  6765. * Gets the center of the bounding sphere in local space
  6766. */
  6767. readonly center: Vector3;
  6768. /**
  6769. * Radius of the bounding sphere in local space
  6770. */
  6771. radius: number;
  6772. /**
  6773. * Gets the center of the bounding sphere in world space
  6774. */
  6775. readonly centerWorld: Vector3;
  6776. /**
  6777. * Radius of the bounding sphere in world space
  6778. */
  6779. radiusWorld: number;
  6780. /**
  6781. * Gets the minimum vector in local space
  6782. */
  6783. readonly minimum: Vector3;
  6784. /**
  6785. * Gets the maximum vector in local space
  6786. */
  6787. readonly maximum: Vector3;
  6788. private _worldMatrix;
  6789. private static readonly TmpVector3;
  6790. /**
  6791. * Creates a new bounding sphere
  6792. * @param min defines the minimum vector (in local space)
  6793. * @param max defines the maximum vector (in local space)
  6794. * @param worldMatrix defines the new world matrix
  6795. */
  6796. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6797. /**
  6798. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6799. * @param min defines the new minimum vector (in local space)
  6800. * @param max defines the new maximum vector (in local space)
  6801. * @param worldMatrix defines the new world matrix
  6802. */
  6803. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6804. /**
  6805. * Scale the current bounding sphere by applying a scale factor
  6806. * @param factor defines the scale factor to apply
  6807. * @returns the current bounding box
  6808. */
  6809. scale(factor: number): BoundingSphere;
  6810. /**
  6811. * Gets the world matrix of the bounding box
  6812. * @returns a matrix
  6813. */
  6814. getWorldMatrix(): DeepImmutable<Matrix>;
  6815. /** @hidden */
  6816. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6817. /**
  6818. * Tests if the bounding sphere is intersecting the frustum planes
  6819. * @param frustumPlanes defines the frustum planes to test
  6820. * @returns true if there is an intersection
  6821. */
  6822. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6823. /**
  6824. * Tests if the bounding sphere center is in between the frustum planes.
  6825. * Used for optimistic fast inclusion.
  6826. * @param frustumPlanes defines the frustum planes to test
  6827. * @returns true if the sphere center is in between the frustum planes
  6828. */
  6829. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6830. /**
  6831. * Tests if a point is inside the bounding sphere
  6832. * @param point defines the point to test
  6833. * @returns true if the point is inside the bounding sphere
  6834. */
  6835. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6836. /**
  6837. * Checks if two sphere intersct
  6838. * @param sphere0 sphere 0
  6839. * @param sphere1 sphere 1
  6840. * @returns true if the speres intersect
  6841. */
  6842. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6843. }
  6844. }
  6845. declare module "babylonjs/Culling/boundingBox" {
  6846. import { DeepImmutable } from "babylonjs/types";
  6847. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6848. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6849. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6850. import { Plane } from "babylonjs/Maths/math.plane";
  6851. /**
  6852. * Class used to store bounding box information
  6853. */
  6854. export class BoundingBox implements ICullable {
  6855. /**
  6856. * Gets the 8 vectors representing the bounding box in local space
  6857. */
  6858. readonly vectors: Vector3[];
  6859. /**
  6860. * Gets the center of the bounding box in local space
  6861. */
  6862. readonly center: Vector3;
  6863. /**
  6864. * Gets the center of the bounding box in world space
  6865. */
  6866. readonly centerWorld: Vector3;
  6867. /**
  6868. * Gets the extend size in local space
  6869. */
  6870. readonly extendSize: Vector3;
  6871. /**
  6872. * Gets the extend size in world space
  6873. */
  6874. readonly extendSizeWorld: Vector3;
  6875. /**
  6876. * Gets the OBB (object bounding box) directions
  6877. */
  6878. readonly directions: Vector3[];
  6879. /**
  6880. * Gets the 8 vectors representing the bounding box in world space
  6881. */
  6882. readonly vectorsWorld: Vector3[];
  6883. /**
  6884. * Gets the minimum vector in world space
  6885. */
  6886. readonly minimumWorld: Vector3;
  6887. /**
  6888. * Gets the maximum vector in world space
  6889. */
  6890. readonly maximumWorld: Vector3;
  6891. /**
  6892. * Gets the minimum vector in local space
  6893. */
  6894. readonly minimum: Vector3;
  6895. /**
  6896. * Gets the maximum vector in local space
  6897. */
  6898. readonly maximum: Vector3;
  6899. private _worldMatrix;
  6900. private static readonly TmpVector3;
  6901. /**
  6902. * @hidden
  6903. */
  6904. _tag: number;
  6905. /**
  6906. * Creates a new bounding box
  6907. * @param min defines the minimum vector (in local space)
  6908. * @param max defines the maximum vector (in local space)
  6909. * @param worldMatrix defines the new world matrix
  6910. */
  6911. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6912. /**
  6913. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6914. * @param min defines the new minimum vector (in local space)
  6915. * @param max defines the new maximum vector (in local space)
  6916. * @param worldMatrix defines the new world matrix
  6917. */
  6918. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6919. /**
  6920. * Scale the current bounding box by applying a scale factor
  6921. * @param factor defines the scale factor to apply
  6922. * @returns the current bounding box
  6923. */
  6924. scale(factor: number): BoundingBox;
  6925. /**
  6926. * Gets the world matrix of the bounding box
  6927. * @returns a matrix
  6928. */
  6929. getWorldMatrix(): DeepImmutable<Matrix>;
  6930. /** @hidden */
  6931. _update(world: DeepImmutable<Matrix>): void;
  6932. /**
  6933. * Tests if the bounding box is intersecting the frustum planes
  6934. * @param frustumPlanes defines the frustum planes to test
  6935. * @returns true if there is an intersection
  6936. */
  6937. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6938. /**
  6939. * Tests if the bounding box is entirely inside the frustum planes
  6940. * @param frustumPlanes defines the frustum planes to test
  6941. * @returns true if there is an inclusion
  6942. */
  6943. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6944. /**
  6945. * Tests if a point is inside the bounding box
  6946. * @param point defines the point to test
  6947. * @returns true if the point is inside the bounding box
  6948. */
  6949. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6950. /**
  6951. * Tests if the bounding box intersects with a bounding sphere
  6952. * @param sphere defines the sphere to test
  6953. * @returns true if there is an intersection
  6954. */
  6955. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6956. /**
  6957. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6958. * @param min defines the min vector to use
  6959. * @param max defines the max vector to use
  6960. * @returns true if there is an intersection
  6961. */
  6962. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6963. /**
  6964. * Tests if two bounding boxes are intersections
  6965. * @param box0 defines the first box to test
  6966. * @param box1 defines the second box to test
  6967. * @returns true if there is an intersection
  6968. */
  6969. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6970. /**
  6971. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6972. * @param minPoint defines the minimum vector of the bounding box
  6973. * @param maxPoint defines the maximum vector of the bounding box
  6974. * @param sphereCenter defines the sphere center
  6975. * @param sphereRadius defines the sphere radius
  6976. * @returns true if there is an intersection
  6977. */
  6978. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6979. /**
  6980. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6981. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6982. * @param frustumPlanes defines the frustum planes to test
  6983. * @return true if there is an inclusion
  6984. */
  6985. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6986. /**
  6987. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6988. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6989. * @param frustumPlanes defines the frustum planes to test
  6990. * @return true if there is an intersection
  6991. */
  6992. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6993. }
  6994. }
  6995. declare module "babylonjs/Collisions/collider" {
  6996. import { Nullable, IndicesArray } from "babylonjs/types";
  6997. import { Vector3 } from "babylonjs/Maths/math.vector";
  6998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6999. import { Plane } from "babylonjs/Maths/math.plane";
  7000. /** @hidden */
  7001. export class Collider {
  7002. /** Define if a collision was found */
  7003. collisionFound: boolean;
  7004. /**
  7005. * Define last intersection point in local space
  7006. */
  7007. intersectionPoint: Vector3;
  7008. /**
  7009. * Define last collided mesh
  7010. */
  7011. collidedMesh: Nullable<AbstractMesh>;
  7012. private _collisionPoint;
  7013. private _planeIntersectionPoint;
  7014. private _tempVector;
  7015. private _tempVector2;
  7016. private _tempVector3;
  7017. private _tempVector4;
  7018. private _edge;
  7019. private _baseToVertex;
  7020. private _destinationPoint;
  7021. private _slidePlaneNormal;
  7022. private _displacementVector;
  7023. /** @hidden */
  7024. _radius: Vector3;
  7025. /** @hidden */
  7026. _retry: number;
  7027. private _velocity;
  7028. private _basePoint;
  7029. private _epsilon;
  7030. /** @hidden */
  7031. _velocityWorldLength: number;
  7032. /** @hidden */
  7033. _basePointWorld: Vector3;
  7034. private _velocityWorld;
  7035. private _normalizedVelocity;
  7036. /** @hidden */
  7037. _initialVelocity: Vector3;
  7038. /** @hidden */
  7039. _initialPosition: Vector3;
  7040. private _nearestDistance;
  7041. private _collisionMask;
  7042. get collisionMask(): number;
  7043. set collisionMask(mask: number);
  7044. /**
  7045. * Gets the plane normal used to compute the sliding response (in local space)
  7046. */
  7047. get slidePlaneNormal(): Vector3;
  7048. /** @hidden */
  7049. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7050. /** @hidden */
  7051. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7052. /** @hidden */
  7053. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7054. /** @hidden */
  7055. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7056. /** @hidden */
  7057. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7058. /** @hidden */
  7059. _getResponse(pos: Vector3, vel: Vector3): void;
  7060. }
  7061. }
  7062. declare module "babylonjs/Culling/boundingInfo" {
  7063. import { DeepImmutable } from "babylonjs/types";
  7064. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7065. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7066. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7067. import { Plane } from "babylonjs/Maths/math.plane";
  7068. import { Collider } from "babylonjs/Collisions/collider";
  7069. /**
  7070. * Interface for cullable objects
  7071. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7072. */
  7073. export interface ICullable {
  7074. /**
  7075. * Checks if the object or part of the object is in the frustum
  7076. * @param frustumPlanes Camera near/planes
  7077. * @returns true if the object is in frustum otherwise false
  7078. */
  7079. isInFrustum(frustumPlanes: Plane[]): boolean;
  7080. /**
  7081. * Checks if a cullable object (mesh...) is in the camera frustum
  7082. * Unlike isInFrustum this cheks the full bounding box
  7083. * @param frustumPlanes Camera near/planes
  7084. * @returns true if the object is in frustum otherwise false
  7085. */
  7086. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7087. }
  7088. /**
  7089. * Info for a bounding data of a mesh
  7090. */
  7091. export class BoundingInfo implements ICullable {
  7092. /**
  7093. * Bounding box for the mesh
  7094. */
  7095. readonly boundingBox: BoundingBox;
  7096. /**
  7097. * Bounding sphere for the mesh
  7098. */
  7099. readonly boundingSphere: BoundingSphere;
  7100. private _isLocked;
  7101. private static readonly TmpVector3;
  7102. /**
  7103. * Constructs bounding info
  7104. * @param minimum min vector of the bounding box/sphere
  7105. * @param maximum max vector of the bounding box/sphere
  7106. * @param worldMatrix defines the new world matrix
  7107. */
  7108. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7109. /**
  7110. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7111. * @param min defines the new minimum vector (in local space)
  7112. * @param max defines the new maximum vector (in local space)
  7113. * @param worldMatrix defines the new world matrix
  7114. */
  7115. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7116. /**
  7117. * min vector of the bounding box/sphere
  7118. */
  7119. get minimum(): Vector3;
  7120. /**
  7121. * max vector of the bounding box/sphere
  7122. */
  7123. get maximum(): Vector3;
  7124. /**
  7125. * If the info is locked and won't be updated to avoid perf overhead
  7126. */
  7127. get isLocked(): boolean;
  7128. set isLocked(value: boolean);
  7129. /**
  7130. * Updates the bounding sphere and box
  7131. * @param world world matrix to be used to update
  7132. */
  7133. update(world: DeepImmutable<Matrix>): void;
  7134. /**
  7135. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7136. * @param center New center of the bounding info
  7137. * @param extend New extend of the bounding info
  7138. * @returns the current bounding info
  7139. */
  7140. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7141. /**
  7142. * Scale the current bounding info by applying a scale factor
  7143. * @param factor defines the scale factor to apply
  7144. * @returns the current bounding info
  7145. */
  7146. scale(factor: number): BoundingInfo;
  7147. /**
  7148. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7149. * @param frustumPlanes defines the frustum to test
  7150. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7151. * @returns true if the bounding info is in the frustum planes
  7152. */
  7153. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7154. /**
  7155. * Gets the world distance between the min and max points of the bounding box
  7156. */
  7157. get diagonalLength(): number;
  7158. /**
  7159. * Checks if a cullable object (mesh...) is in the camera frustum
  7160. * Unlike isInFrustum this cheks the full bounding box
  7161. * @param frustumPlanes Camera near/planes
  7162. * @returns true if the object is in frustum otherwise false
  7163. */
  7164. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7165. /** @hidden */
  7166. _checkCollision(collider: Collider): boolean;
  7167. /**
  7168. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7169. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7170. * @param point the point to check intersection with
  7171. * @returns if the point intersects
  7172. */
  7173. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7174. /**
  7175. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7176. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7177. * @param boundingInfo the bounding info to check intersection with
  7178. * @param precise if the intersection should be done using OBB
  7179. * @returns if the bounding info intersects
  7180. */
  7181. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7182. }
  7183. }
  7184. declare module "babylonjs/Maths/math.functions" {
  7185. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7186. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7187. /**
  7188. * Extracts minimum and maximum values from a list of indexed positions
  7189. * @param positions defines the positions to use
  7190. * @param indices defines the indices to the positions
  7191. * @param indexStart defines the start index
  7192. * @param indexCount defines the end index
  7193. * @param bias defines bias value to add to the result
  7194. * @return minimum and maximum values
  7195. */
  7196. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7197. minimum: Vector3;
  7198. maximum: Vector3;
  7199. };
  7200. /**
  7201. * Extracts minimum and maximum values from a list of positions
  7202. * @param positions defines the positions to use
  7203. * @param start defines the start index in the positions array
  7204. * @param count defines the number of positions to handle
  7205. * @param bias defines bias value to add to the result
  7206. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7207. * @return minimum and maximum values
  7208. */
  7209. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7210. minimum: Vector3;
  7211. maximum: Vector3;
  7212. };
  7213. }
  7214. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7215. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7216. /** @hidden */
  7217. export class WebGLDataBuffer extends DataBuffer {
  7218. private _buffer;
  7219. constructor(resource: WebGLBuffer);
  7220. get underlyingResource(): any;
  7221. }
  7222. }
  7223. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7224. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7225. import { Nullable } from "babylonjs/types";
  7226. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7227. /** @hidden */
  7228. export class WebGLPipelineContext implements IPipelineContext {
  7229. engine: ThinEngine;
  7230. program: Nullable<WebGLProgram>;
  7231. context?: WebGLRenderingContext;
  7232. vertexShader?: WebGLShader;
  7233. fragmentShader?: WebGLShader;
  7234. isParallelCompiled: boolean;
  7235. onCompiled?: () => void;
  7236. transformFeedback?: WebGLTransformFeedback | null;
  7237. vertexCompilationError: Nullable<string>;
  7238. fragmentCompilationError: Nullable<string>;
  7239. programLinkError: Nullable<string>;
  7240. programValidationError: Nullable<string>;
  7241. get isAsync(): boolean;
  7242. get isReady(): boolean;
  7243. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7244. }
  7245. }
  7246. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7247. import { FloatArray, Nullable } from "babylonjs/types";
  7248. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7249. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7250. module "babylonjs/Engines/thinEngine" {
  7251. interface ThinEngine {
  7252. /**
  7253. * Create an uniform buffer
  7254. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7255. * @param elements defines the content of the uniform buffer
  7256. * @returns the webGL uniform buffer
  7257. */
  7258. createUniformBuffer(elements: FloatArray): DataBuffer;
  7259. /**
  7260. * Create a dynamic uniform buffer
  7261. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7262. * @param elements defines the content of the uniform buffer
  7263. * @returns the webGL uniform buffer
  7264. */
  7265. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7266. /**
  7267. * Update an existing uniform buffer
  7268. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7269. * @param uniformBuffer defines the target uniform buffer
  7270. * @param elements defines the content to update
  7271. * @param offset defines the offset in the uniform buffer where update should start
  7272. * @param count defines the size of the data to update
  7273. */
  7274. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7275. /**
  7276. * Bind an uniform buffer to the current webGL context
  7277. * @param buffer defines the buffer to bind
  7278. */
  7279. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7280. /**
  7281. * Bind a buffer to the current webGL context at a given location
  7282. * @param buffer defines the buffer to bind
  7283. * @param location defines the index where to bind the buffer
  7284. */
  7285. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7286. /**
  7287. * Bind a specific block at a given index in a specific shader program
  7288. * @param pipelineContext defines the pipeline context to use
  7289. * @param blockName defines the block name
  7290. * @param index defines the index where to bind the block
  7291. */
  7292. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7293. }
  7294. }
  7295. }
  7296. declare module "babylonjs/Materials/uniformBuffer" {
  7297. import { Nullable, FloatArray } from "babylonjs/types";
  7298. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7299. import { Engine } from "babylonjs/Engines/engine";
  7300. import { Effect } from "babylonjs/Materials/effect";
  7301. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7302. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7303. import { Color3 } from "babylonjs/Maths/math.color";
  7304. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7305. /**
  7306. * Uniform buffer objects.
  7307. *
  7308. * Handles blocks of uniform on the GPU.
  7309. *
  7310. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7311. *
  7312. * For more information, please refer to :
  7313. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7314. */
  7315. export class UniformBuffer {
  7316. private _engine;
  7317. private _buffer;
  7318. private _data;
  7319. private _bufferData;
  7320. private _dynamic?;
  7321. private _uniformLocations;
  7322. private _uniformSizes;
  7323. private _uniformLocationPointer;
  7324. private _needSync;
  7325. private _noUBO;
  7326. private _currentEffect;
  7327. /** @hidden */
  7328. _alreadyBound: boolean;
  7329. private static _MAX_UNIFORM_SIZE;
  7330. private static _tempBuffer;
  7331. /**
  7332. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7333. * This is dynamic to allow compat with webgl 1 and 2.
  7334. * You will need to pass the name of the uniform as well as the value.
  7335. */
  7336. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7337. /**
  7338. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7339. * This is dynamic to allow compat with webgl 1 and 2.
  7340. * You will need to pass the name of the uniform as well as the value.
  7341. */
  7342. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7343. /**
  7344. * Lambda to Update a single float in a uniform buffer.
  7345. * This is dynamic to allow compat with webgl 1 and 2.
  7346. * You will need to pass the name of the uniform as well as the value.
  7347. */
  7348. updateFloat: (name: string, x: number) => void;
  7349. /**
  7350. * Lambda to Update a vec2 of float in a uniform buffer.
  7351. * This is dynamic to allow compat with webgl 1 and 2.
  7352. * You will need to pass the name of the uniform as well as the value.
  7353. */
  7354. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7355. /**
  7356. * Lambda to Update a vec3 of float in a uniform buffer.
  7357. * This is dynamic to allow compat with webgl 1 and 2.
  7358. * You will need to pass the name of the uniform as well as the value.
  7359. */
  7360. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7361. /**
  7362. * Lambda to Update a vec4 of float in a uniform buffer.
  7363. * This is dynamic to allow compat with webgl 1 and 2.
  7364. * You will need to pass the name of the uniform as well as the value.
  7365. */
  7366. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7367. /**
  7368. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7369. * This is dynamic to allow compat with webgl 1 and 2.
  7370. * You will need to pass the name of the uniform as well as the value.
  7371. */
  7372. updateMatrix: (name: string, mat: Matrix) => void;
  7373. /**
  7374. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7375. * This is dynamic to allow compat with webgl 1 and 2.
  7376. * You will need to pass the name of the uniform as well as the value.
  7377. */
  7378. updateVector3: (name: string, vector: Vector3) => void;
  7379. /**
  7380. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7381. * This is dynamic to allow compat with webgl 1 and 2.
  7382. * You will need to pass the name of the uniform as well as the value.
  7383. */
  7384. updateVector4: (name: string, vector: Vector4) => void;
  7385. /**
  7386. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7387. * This is dynamic to allow compat with webgl 1 and 2.
  7388. * You will need to pass the name of the uniform as well as the value.
  7389. */
  7390. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7391. /**
  7392. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7393. * This is dynamic to allow compat with webgl 1 and 2.
  7394. * You will need to pass the name of the uniform as well as the value.
  7395. */
  7396. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7397. /**
  7398. * Instantiates a new Uniform buffer objects.
  7399. *
  7400. * Handles blocks of uniform on the GPU.
  7401. *
  7402. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7403. *
  7404. * For more information, please refer to :
  7405. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7406. * @param engine Define the engine the buffer is associated with
  7407. * @param data Define the data contained in the buffer
  7408. * @param dynamic Define if the buffer is updatable
  7409. */
  7410. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7411. /**
  7412. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7413. * or just falling back on setUniformXXX calls.
  7414. */
  7415. get useUbo(): boolean;
  7416. /**
  7417. * Indicates if the WebGL underlying uniform buffer is in sync
  7418. * with the javascript cache data.
  7419. */
  7420. get isSync(): boolean;
  7421. /**
  7422. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7423. * Also, a dynamic UniformBuffer will disable cache verification and always
  7424. * update the underlying WebGL uniform buffer to the GPU.
  7425. * @returns if Dynamic, otherwise false
  7426. */
  7427. isDynamic(): boolean;
  7428. /**
  7429. * The data cache on JS side.
  7430. * @returns the underlying data as a float array
  7431. */
  7432. getData(): Float32Array;
  7433. /**
  7434. * The underlying WebGL Uniform buffer.
  7435. * @returns the webgl buffer
  7436. */
  7437. getBuffer(): Nullable<DataBuffer>;
  7438. /**
  7439. * std140 layout specifies how to align data within an UBO structure.
  7440. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7441. * for specs.
  7442. */
  7443. private _fillAlignment;
  7444. /**
  7445. * Adds an uniform in the buffer.
  7446. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7447. * for the layout to be correct !
  7448. * @param name Name of the uniform, as used in the uniform block in the shader.
  7449. * @param size Data size, or data directly.
  7450. */
  7451. addUniform(name: string, size: number | number[]): void;
  7452. /**
  7453. * Adds a Matrix 4x4 to the uniform buffer.
  7454. * @param name Name of the uniform, as used in the uniform block in the shader.
  7455. * @param mat A 4x4 matrix.
  7456. */
  7457. addMatrix(name: string, mat: Matrix): void;
  7458. /**
  7459. * Adds a vec2 to the uniform buffer.
  7460. * @param name Name of the uniform, as used in the uniform block in the shader.
  7461. * @param x Define the x component value of the vec2
  7462. * @param y Define the y component value of the vec2
  7463. */
  7464. addFloat2(name: string, x: number, y: number): void;
  7465. /**
  7466. * Adds a vec3 to the uniform buffer.
  7467. * @param name Name of the uniform, as used in the uniform block in the shader.
  7468. * @param x Define the x component value of the vec3
  7469. * @param y Define the y component value of the vec3
  7470. * @param z Define the z component value of the vec3
  7471. */
  7472. addFloat3(name: string, x: number, y: number, z: number): void;
  7473. /**
  7474. * Adds a vec3 to the uniform buffer.
  7475. * @param name Name of the uniform, as used in the uniform block in the shader.
  7476. * @param color Define the vec3 from a Color
  7477. */
  7478. addColor3(name: string, color: Color3): void;
  7479. /**
  7480. * Adds a vec4 to the uniform buffer.
  7481. * @param name Name of the uniform, as used in the uniform block in the shader.
  7482. * @param color Define the rgb components from a Color
  7483. * @param alpha Define the a component of the vec4
  7484. */
  7485. addColor4(name: string, color: Color3, alpha: number): void;
  7486. /**
  7487. * Adds a vec3 to the uniform buffer.
  7488. * @param name Name of the uniform, as used in the uniform block in the shader.
  7489. * @param vector Define the vec3 components from a Vector
  7490. */
  7491. addVector3(name: string, vector: Vector3): void;
  7492. /**
  7493. * Adds a Matrix 3x3 to the uniform buffer.
  7494. * @param name Name of the uniform, as used in the uniform block in the shader.
  7495. */
  7496. addMatrix3x3(name: string): void;
  7497. /**
  7498. * Adds a Matrix 2x2 to the uniform buffer.
  7499. * @param name Name of the uniform, as used in the uniform block in the shader.
  7500. */
  7501. addMatrix2x2(name: string): void;
  7502. /**
  7503. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7504. */
  7505. create(): void;
  7506. /** @hidden */
  7507. _rebuild(): void;
  7508. /**
  7509. * Updates the WebGL Uniform Buffer on the GPU.
  7510. * If the `dynamic` flag is set to true, no cache comparison is done.
  7511. * Otherwise, the buffer will be updated only if the cache differs.
  7512. */
  7513. update(): void;
  7514. /**
  7515. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7516. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7517. * @param data Define the flattened data
  7518. * @param size Define the size of the data.
  7519. */
  7520. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7521. private _valueCache;
  7522. private _cacheMatrix;
  7523. private _updateMatrix3x3ForUniform;
  7524. private _updateMatrix3x3ForEffect;
  7525. private _updateMatrix2x2ForEffect;
  7526. private _updateMatrix2x2ForUniform;
  7527. private _updateFloatForEffect;
  7528. private _updateFloatForUniform;
  7529. private _updateFloat2ForEffect;
  7530. private _updateFloat2ForUniform;
  7531. private _updateFloat3ForEffect;
  7532. private _updateFloat3ForUniform;
  7533. private _updateFloat4ForEffect;
  7534. private _updateFloat4ForUniform;
  7535. private _updateMatrixForEffect;
  7536. private _updateMatrixForUniform;
  7537. private _updateVector3ForEffect;
  7538. private _updateVector3ForUniform;
  7539. private _updateVector4ForEffect;
  7540. private _updateVector4ForUniform;
  7541. private _updateColor3ForEffect;
  7542. private _updateColor3ForUniform;
  7543. private _updateColor4ForEffect;
  7544. private _updateColor4ForUniform;
  7545. /**
  7546. * Sets a sampler uniform on the effect.
  7547. * @param name Define the name of the sampler.
  7548. * @param texture Define the texture to set in the sampler
  7549. */
  7550. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7551. /**
  7552. * Directly updates the value of the uniform in the cache AND on the GPU.
  7553. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7554. * @param data Define the flattened data
  7555. */
  7556. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7557. /**
  7558. * Binds this uniform buffer to an effect.
  7559. * @param effect Define the effect to bind the buffer to
  7560. * @param name Name of the uniform block in the shader.
  7561. */
  7562. bindToEffect(effect: Effect, name: string): void;
  7563. /**
  7564. * Disposes the uniform buffer.
  7565. */
  7566. dispose(): void;
  7567. }
  7568. }
  7569. declare module "babylonjs/Misc/iInspectable" {
  7570. /**
  7571. * Enum that determines the text-wrapping mode to use.
  7572. */
  7573. export enum InspectableType {
  7574. /**
  7575. * Checkbox for booleans
  7576. */
  7577. Checkbox = 0,
  7578. /**
  7579. * Sliders for numbers
  7580. */
  7581. Slider = 1,
  7582. /**
  7583. * Vector3
  7584. */
  7585. Vector3 = 2,
  7586. /**
  7587. * Quaternions
  7588. */
  7589. Quaternion = 3,
  7590. /**
  7591. * Color3
  7592. */
  7593. Color3 = 4,
  7594. /**
  7595. * String
  7596. */
  7597. String = 5
  7598. }
  7599. /**
  7600. * Interface used to define custom inspectable properties.
  7601. * This interface is used by the inspector to display custom property grids
  7602. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7603. */
  7604. export interface IInspectable {
  7605. /**
  7606. * Gets the label to display
  7607. */
  7608. label: string;
  7609. /**
  7610. * Gets the name of the property to edit
  7611. */
  7612. propertyName: string;
  7613. /**
  7614. * Gets the type of the editor to use
  7615. */
  7616. type: InspectableType;
  7617. /**
  7618. * Gets the minimum value of the property when using in "slider" mode
  7619. */
  7620. min?: number;
  7621. /**
  7622. * Gets the maximum value of the property when using in "slider" mode
  7623. */
  7624. max?: number;
  7625. /**
  7626. * Gets the setp to use when using in "slider" mode
  7627. */
  7628. step?: number;
  7629. }
  7630. }
  7631. declare module "babylonjs/Misc/timingTools" {
  7632. /**
  7633. * Class used to provide helper for timing
  7634. */
  7635. export class TimingTools {
  7636. /**
  7637. * Polyfill for setImmediate
  7638. * @param action defines the action to execute after the current execution block
  7639. */
  7640. static SetImmediate(action: () => void): void;
  7641. }
  7642. }
  7643. declare module "babylonjs/Misc/instantiationTools" {
  7644. /**
  7645. * Class used to enable instatition of objects by class name
  7646. */
  7647. export class InstantiationTools {
  7648. /**
  7649. * Use this object to register external classes like custom textures or material
  7650. * to allow the laoders to instantiate them
  7651. */
  7652. static RegisteredExternalClasses: {
  7653. [key: string]: Object;
  7654. };
  7655. /**
  7656. * Tries to instantiate a new object from a given class name
  7657. * @param className defines the class name to instantiate
  7658. * @returns the new object or null if the system was not able to do the instantiation
  7659. */
  7660. static Instantiate(className: string): any;
  7661. }
  7662. }
  7663. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7664. /**
  7665. * Define options used to create a depth texture
  7666. */
  7667. export class DepthTextureCreationOptions {
  7668. /** Specifies whether or not a stencil should be allocated in the texture */
  7669. generateStencil?: boolean;
  7670. /** Specifies whether or not bilinear filtering is enable on the texture */
  7671. bilinearFiltering?: boolean;
  7672. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7673. comparisonFunction?: number;
  7674. /** Specifies if the created texture is a cube texture */
  7675. isCube?: boolean;
  7676. }
  7677. }
  7678. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7679. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7680. import { Nullable } from "babylonjs/types";
  7681. import { Scene } from "babylonjs/scene";
  7682. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7683. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7684. module "babylonjs/Engines/thinEngine" {
  7685. interface ThinEngine {
  7686. /**
  7687. * Creates a depth stencil cube texture.
  7688. * This is only available in WebGL 2.
  7689. * @param size The size of face edge in the cube texture.
  7690. * @param options The options defining the cube texture.
  7691. * @returns The cube texture
  7692. */
  7693. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7694. /**
  7695. * Creates a cube texture
  7696. * @param rootUrl defines the url where the files to load is located
  7697. * @param scene defines the current scene
  7698. * @param files defines the list of files to load (1 per face)
  7699. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7700. * @param onLoad defines an optional callback raised when the texture is loaded
  7701. * @param onError defines an optional callback raised if there is an issue to load the texture
  7702. * @param format defines the format of the data
  7703. * @param forcedExtension defines the extension to use to pick the right loader
  7704. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7705. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7706. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7707. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7708. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7709. * @returns the cube texture as an InternalTexture
  7710. */
  7711. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  7712. /**
  7713. * Creates a cube texture
  7714. * @param rootUrl defines the url where the files to load is located
  7715. * @param scene defines the current scene
  7716. * @param files defines the list of files to load (1 per face)
  7717. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7718. * @param onLoad defines an optional callback raised when the texture is loaded
  7719. * @param onError defines an optional callback raised if there is an issue to load the texture
  7720. * @param format defines the format of the data
  7721. * @param forcedExtension defines the extension to use to pick the right loader
  7722. * @returns the cube texture as an InternalTexture
  7723. */
  7724. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any): InternalTexture;
  7725. /**
  7726. * Creates a cube texture
  7727. * @param rootUrl defines the url where the files to load is located
  7728. * @param scene defines the current scene
  7729. * @param files defines the list of files to load (1 per face)
  7730. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7731. * @param onLoad defines an optional callback raised when the texture is loaded
  7732. * @param onError defines an optional callback raised if there is an issue to load the texture
  7733. * @param format defines the format of the data
  7734. * @param forcedExtension defines the extension to use to pick the right loader
  7735. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7736. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7737. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7738. * @returns the cube texture as an InternalTexture
  7739. */
  7740. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number): InternalTexture;
  7741. /** @hidden */
  7742. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7743. /** @hidden */
  7744. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7745. /** @hidden */
  7746. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7747. /** @hidden */
  7748. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7749. /**
  7750. * @hidden
  7751. */
  7752. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7753. }
  7754. }
  7755. }
  7756. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7757. import { Nullable } from "babylonjs/types";
  7758. import { Scene } from "babylonjs/scene";
  7759. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7760. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7761. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7762. import { Observable } from "babylonjs/Misc/observable";
  7763. /**
  7764. * Class for creating a cube texture
  7765. */
  7766. export class CubeTexture extends BaseTexture {
  7767. private _delayedOnLoad;
  7768. /**
  7769. * Observable triggered once the texture has been loaded.
  7770. */
  7771. onLoadObservable: Observable<CubeTexture>;
  7772. /**
  7773. * The url of the texture
  7774. */
  7775. url: string;
  7776. /**
  7777. * Gets or sets the center of the bounding box associated with the cube texture.
  7778. * It must define where the camera used to render the texture was set
  7779. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7780. */
  7781. boundingBoxPosition: Vector3;
  7782. private _boundingBoxSize;
  7783. /**
  7784. * Gets or sets the size of the bounding box associated with the cube texture
  7785. * When defined, the cubemap will switch to local mode
  7786. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7787. * @example https://www.babylonjs-playground.com/#RNASML
  7788. */
  7789. set boundingBoxSize(value: Vector3);
  7790. /**
  7791. * Returns the bounding box size
  7792. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7793. */
  7794. get boundingBoxSize(): Vector3;
  7795. protected _rotationY: number;
  7796. /**
  7797. * Sets texture matrix rotation angle around Y axis in radians.
  7798. */
  7799. set rotationY(value: number);
  7800. /**
  7801. * Gets texture matrix rotation angle around Y axis radians.
  7802. */
  7803. get rotationY(): number;
  7804. /**
  7805. * Are mip maps generated for this texture or not.
  7806. */
  7807. get noMipmap(): boolean;
  7808. private _noMipmap;
  7809. private _files;
  7810. protected _forcedExtension: Nullable<string>;
  7811. private _extensions;
  7812. private _textureMatrix;
  7813. private _format;
  7814. private _createPolynomials;
  7815. /** @hidden */
  7816. _prefiltered: boolean;
  7817. /**
  7818. * Creates a cube texture from an array of image urls
  7819. * @param files defines an array of image urls
  7820. * @param scene defines the hosting scene
  7821. * @param noMipmap specifies if mip maps are not used
  7822. * @returns a cube texture
  7823. */
  7824. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7825. /**
  7826. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7827. * @param url defines the url of the prefiltered texture
  7828. * @param scene defines the scene the texture is attached to
  7829. * @param forcedExtension defines the extension of the file if different from the url
  7830. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7831. * @return the prefiltered texture
  7832. */
  7833. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7834. /**
  7835. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7836. * as prefiltered data.
  7837. * @param rootUrl defines the url of the texture or the root name of the six images
  7838. * @param scene defines the scene the texture is attached to
  7839. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7840. * @param noMipmap defines if mipmaps should be created or not
  7841. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7842. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7843. * @param onError defines a callback triggered in case of error during load
  7844. * @param format defines the internal format to use for the texture once loaded
  7845. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7846. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7847. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7848. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7849. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7850. * @return the cube texture
  7851. */
  7852. constructor(rootUrl: string, scene: Scene, extensions?: Nullable<string[]>, noMipmap?: boolean, files?: Nullable<string[]>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, prefiltered?: boolean, forcedExtension?: any, createPolynomials?: boolean, lodScale?: number, lodOffset?: number);
  7853. /**
  7854. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7855. */
  7856. get isPrefiltered(): boolean;
  7857. /**
  7858. * Get the current class name of the texture useful for serialization or dynamic coding.
  7859. * @returns "CubeTexture"
  7860. */
  7861. getClassName(): string;
  7862. /**
  7863. * Update the url (and optional buffer) of this texture if url was null during construction.
  7864. * @param url the url of the texture
  7865. * @param forcedExtension defines the extension to use
  7866. * @param onLoad callback called when the texture is loaded (defaults to null)
  7867. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7868. */
  7869. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7870. /**
  7871. * Delays loading of the cube texture
  7872. * @param forcedExtension defines the extension to use
  7873. */
  7874. delayLoad(forcedExtension?: string): void;
  7875. /**
  7876. * Returns the reflection texture matrix
  7877. * @returns the reflection texture matrix
  7878. */
  7879. getReflectionTextureMatrix(): Matrix;
  7880. /**
  7881. * Sets the reflection texture matrix
  7882. * @param value Reflection texture matrix
  7883. */
  7884. setReflectionTextureMatrix(value: Matrix): void;
  7885. /**
  7886. * Parses text to create a cube texture
  7887. * @param parsedTexture define the serialized text to read from
  7888. * @param scene defines the hosting scene
  7889. * @param rootUrl defines the root url of the cube texture
  7890. * @returns a cube texture
  7891. */
  7892. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7893. /**
  7894. * Makes a clone, or deep copy, of the cube texture
  7895. * @returns a new cube texture
  7896. */
  7897. clone(): CubeTexture;
  7898. }
  7899. }
  7900. declare module "babylonjs/Materials/materialDefines" {
  7901. /**
  7902. * Manages the defines for the Material
  7903. */
  7904. export class MaterialDefines {
  7905. /** @hidden */
  7906. protected _keys: string[];
  7907. private _isDirty;
  7908. /** @hidden */
  7909. _renderId: number;
  7910. /** @hidden */
  7911. _areLightsDirty: boolean;
  7912. /** @hidden */
  7913. _areLightsDisposed: boolean;
  7914. /** @hidden */
  7915. _areAttributesDirty: boolean;
  7916. /** @hidden */
  7917. _areTexturesDirty: boolean;
  7918. /** @hidden */
  7919. _areFresnelDirty: boolean;
  7920. /** @hidden */
  7921. _areMiscDirty: boolean;
  7922. /** @hidden */
  7923. _areImageProcessingDirty: boolean;
  7924. /** @hidden */
  7925. _normals: boolean;
  7926. /** @hidden */
  7927. _uvs: boolean;
  7928. /** @hidden */
  7929. _needNormals: boolean;
  7930. /** @hidden */
  7931. _needUVs: boolean;
  7932. [id: string]: any;
  7933. /**
  7934. * Specifies if the material needs to be re-calculated
  7935. */
  7936. get isDirty(): boolean;
  7937. /**
  7938. * Marks the material to indicate that it has been re-calculated
  7939. */
  7940. markAsProcessed(): void;
  7941. /**
  7942. * Marks the material to indicate that it needs to be re-calculated
  7943. */
  7944. markAsUnprocessed(): void;
  7945. /**
  7946. * Marks the material to indicate all of its defines need to be re-calculated
  7947. */
  7948. markAllAsDirty(): void;
  7949. /**
  7950. * Marks the material to indicate that image processing needs to be re-calculated
  7951. */
  7952. markAsImageProcessingDirty(): void;
  7953. /**
  7954. * Marks the material to indicate the lights need to be re-calculated
  7955. * @param disposed Defines whether the light is dirty due to dispose or not
  7956. */
  7957. markAsLightDirty(disposed?: boolean): void;
  7958. /**
  7959. * Marks the attribute state as changed
  7960. */
  7961. markAsAttributesDirty(): void;
  7962. /**
  7963. * Marks the texture state as changed
  7964. */
  7965. markAsTexturesDirty(): void;
  7966. /**
  7967. * Marks the fresnel state as changed
  7968. */
  7969. markAsFresnelDirty(): void;
  7970. /**
  7971. * Marks the misc state as changed
  7972. */
  7973. markAsMiscDirty(): void;
  7974. /**
  7975. * Rebuilds the material defines
  7976. */
  7977. rebuild(): void;
  7978. /**
  7979. * Specifies if two material defines are equal
  7980. * @param other - A material define instance to compare to
  7981. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7982. */
  7983. isEqual(other: MaterialDefines): boolean;
  7984. /**
  7985. * Clones this instance's defines to another instance
  7986. * @param other - material defines to clone values to
  7987. */
  7988. cloneTo(other: MaterialDefines): void;
  7989. /**
  7990. * Resets the material define values
  7991. */
  7992. reset(): void;
  7993. /**
  7994. * Converts the material define values to a string
  7995. * @returns - String of material define information
  7996. */
  7997. toString(): string;
  7998. }
  7999. }
  8000. declare module "babylonjs/Materials/colorCurves" {
  8001. import { Effect } from "babylonjs/Materials/effect";
  8002. /**
  8003. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8004. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8005. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  8006. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8007. */
  8008. export class ColorCurves {
  8009. private _dirty;
  8010. private _tempColor;
  8011. private _globalCurve;
  8012. private _highlightsCurve;
  8013. private _midtonesCurve;
  8014. private _shadowsCurve;
  8015. private _positiveCurve;
  8016. private _negativeCurve;
  8017. private _globalHue;
  8018. private _globalDensity;
  8019. private _globalSaturation;
  8020. private _globalExposure;
  8021. /**
  8022. * Gets the global Hue value.
  8023. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8024. */
  8025. get globalHue(): number;
  8026. /**
  8027. * Sets the global Hue value.
  8028. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8029. */
  8030. set globalHue(value: number);
  8031. /**
  8032. * Gets the global Density value.
  8033. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8034. * Values less than zero provide a filter of opposite hue.
  8035. */
  8036. get globalDensity(): number;
  8037. /**
  8038. * Sets the global Density value.
  8039. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8040. * Values less than zero provide a filter of opposite hue.
  8041. */
  8042. set globalDensity(value: number);
  8043. /**
  8044. * Gets the global Saturation value.
  8045. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8046. */
  8047. get globalSaturation(): number;
  8048. /**
  8049. * Sets the global Saturation value.
  8050. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8051. */
  8052. set globalSaturation(value: number);
  8053. /**
  8054. * Gets the global Exposure value.
  8055. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8056. */
  8057. get globalExposure(): number;
  8058. /**
  8059. * Sets the global Exposure value.
  8060. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8061. */
  8062. set globalExposure(value: number);
  8063. private _highlightsHue;
  8064. private _highlightsDensity;
  8065. private _highlightsSaturation;
  8066. private _highlightsExposure;
  8067. /**
  8068. * Gets the highlights Hue value.
  8069. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8070. */
  8071. get highlightsHue(): number;
  8072. /**
  8073. * Sets the highlights Hue value.
  8074. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8075. */
  8076. set highlightsHue(value: number);
  8077. /**
  8078. * Gets the highlights Density value.
  8079. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8080. * Values less than zero provide a filter of opposite hue.
  8081. */
  8082. get highlightsDensity(): number;
  8083. /**
  8084. * Sets the highlights Density value.
  8085. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8086. * Values less than zero provide a filter of opposite hue.
  8087. */
  8088. set highlightsDensity(value: number);
  8089. /**
  8090. * Gets the highlights Saturation value.
  8091. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8092. */
  8093. get highlightsSaturation(): number;
  8094. /**
  8095. * Sets the highlights Saturation value.
  8096. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8097. */
  8098. set highlightsSaturation(value: number);
  8099. /**
  8100. * Gets the highlights Exposure value.
  8101. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8102. */
  8103. get highlightsExposure(): number;
  8104. /**
  8105. * Sets the highlights Exposure value.
  8106. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8107. */
  8108. set highlightsExposure(value: number);
  8109. private _midtonesHue;
  8110. private _midtonesDensity;
  8111. private _midtonesSaturation;
  8112. private _midtonesExposure;
  8113. /**
  8114. * Gets the midtones Hue value.
  8115. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8116. */
  8117. get midtonesHue(): number;
  8118. /**
  8119. * Sets the midtones Hue value.
  8120. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8121. */
  8122. set midtonesHue(value: number);
  8123. /**
  8124. * Gets the midtones Density value.
  8125. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8126. * Values less than zero provide a filter of opposite hue.
  8127. */
  8128. get midtonesDensity(): number;
  8129. /**
  8130. * Sets the midtones Density value.
  8131. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8132. * Values less than zero provide a filter of opposite hue.
  8133. */
  8134. set midtonesDensity(value: number);
  8135. /**
  8136. * Gets the midtones Saturation value.
  8137. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8138. */
  8139. get midtonesSaturation(): number;
  8140. /**
  8141. * Sets the midtones Saturation value.
  8142. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8143. */
  8144. set midtonesSaturation(value: number);
  8145. /**
  8146. * Gets the midtones Exposure value.
  8147. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8148. */
  8149. get midtonesExposure(): number;
  8150. /**
  8151. * Sets the midtones Exposure value.
  8152. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8153. */
  8154. set midtonesExposure(value: number);
  8155. private _shadowsHue;
  8156. private _shadowsDensity;
  8157. private _shadowsSaturation;
  8158. private _shadowsExposure;
  8159. /**
  8160. * Gets the shadows Hue value.
  8161. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8162. */
  8163. get shadowsHue(): number;
  8164. /**
  8165. * Sets the shadows Hue value.
  8166. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  8167. */
  8168. set shadowsHue(value: number);
  8169. /**
  8170. * Gets the shadows Density value.
  8171. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8172. * Values less than zero provide a filter of opposite hue.
  8173. */
  8174. get shadowsDensity(): number;
  8175. /**
  8176. * Sets the shadows Density value.
  8177. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  8178. * Values less than zero provide a filter of opposite hue.
  8179. */
  8180. set shadowsDensity(value: number);
  8181. /**
  8182. * Gets the shadows Saturation value.
  8183. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8184. */
  8185. get shadowsSaturation(): number;
  8186. /**
  8187. * Sets the shadows Saturation value.
  8188. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  8189. */
  8190. set shadowsSaturation(value: number);
  8191. /**
  8192. * Gets the shadows Exposure value.
  8193. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8194. */
  8195. get shadowsExposure(): number;
  8196. /**
  8197. * Sets the shadows Exposure value.
  8198. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8199. */
  8200. set shadowsExposure(value: number);
  8201. /**
  8202. * Returns the class name
  8203. * @returns The class name
  8204. */
  8205. getClassName(): string;
  8206. /**
  8207. * Binds the color curves to the shader.
  8208. * @param colorCurves The color curve to bind
  8209. * @param effect The effect to bind to
  8210. * @param positiveUniform The positive uniform shader parameter
  8211. * @param neutralUniform The neutral uniform shader parameter
  8212. * @param negativeUniform The negative uniform shader parameter
  8213. */
  8214. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8215. /**
  8216. * Prepare the list of uniforms associated with the ColorCurves effects.
  8217. * @param uniformsList The list of uniforms used in the effect
  8218. */
  8219. static PrepareUniforms(uniformsList: string[]): void;
  8220. /**
  8221. * Returns color grading data based on a hue, density, saturation and exposure value.
  8222. * @param filterHue The hue of the color filter.
  8223. * @param filterDensity The density of the color filter.
  8224. * @param saturation The saturation.
  8225. * @param exposure The exposure.
  8226. * @param result The result data container.
  8227. */
  8228. private getColorGradingDataToRef;
  8229. /**
  8230. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8231. * @param value The input slider value in range [-100,100].
  8232. * @returns Adjusted value.
  8233. */
  8234. private static applyColorGradingSliderNonlinear;
  8235. /**
  8236. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8237. * @param hue The hue (H) input.
  8238. * @param saturation The saturation (S) input.
  8239. * @param brightness The brightness (B) input.
  8240. * @result An RGBA color represented as Vector4.
  8241. */
  8242. private static fromHSBToRef;
  8243. /**
  8244. * Returns a value clamped between min and max
  8245. * @param value The value to clamp
  8246. * @param min The minimum of value
  8247. * @param max The maximum of value
  8248. * @returns The clamped value.
  8249. */
  8250. private static clamp;
  8251. /**
  8252. * Clones the current color curve instance.
  8253. * @return The cloned curves
  8254. */
  8255. clone(): ColorCurves;
  8256. /**
  8257. * Serializes the current color curve instance to a json representation.
  8258. * @return a JSON representation
  8259. */
  8260. serialize(): any;
  8261. /**
  8262. * Parses the color curve from a json representation.
  8263. * @param source the JSON source to parse
  8264. * @return The parsed curves
  8265. */
  8266. static Parse(source: any): ColorCurves;
  8267. }
  8268. }
  8269. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8270. import { Observable } from "babylonjs/Misc/observable";
  8271. import { Nullable } from "babylonjs/types";
  8272. import { Color4 } from "babylonjs/Maths/math.color";
  8273. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8274. import { Effect } from "babylonjs/Materials/effect";
  8275. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8276. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8277. /**
  8278. * Interface to follow in your material defines to integrate easily the
  8279. * Image proccessing functions.
  8280. * @hidden
  8281. */
  8282. export interface IImageProcessingConfigurationDefines {
  8283. IMAGEPROCESSING: boolean;
  8284. VIGNETTE: boolean;
  8285. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8286. VIGNETTEBLENDMODEOPAQUE: boolean;
  8287. TONEMAPPING: boolean;
  8288. TONEMAPPING_ACES: boolean;
  8289. CONTRAST: boolean;
  8290. EXPOSURE: boolean;
  8291. COLORCURVES: boolean;
  8292. COLORGRADING: boolean;
  8293. COLORGRADING3D: boolean;
  8294. SAMPLER3DGREENDEPTH: boolean;
  8295. SAMPLER3DBGRMAP: boolean;
  8296. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8297. }
  8298. /**
  8299. * @hidden
  8300. */
  8301. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8302. IMAGEPROCESSING: boolean;
  8303. VIGNETTE: boolean;
  8304. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8305. VIGNETTEBLENDMODEOPAQUE: boolean;
  8306. TONEMAPPING: boolean;
  8307. TONEMAPPING_ACES: boolean;
  8308. CONTRAST: boolean;
  8309. COLORCURVES: boolean;
  8310. COLORGRADING: boolean;
  8311. COLORGRADING3D: boolean;
  8312. SAMPLER3DGREENDEPTH: boolean;
  8313. SAMPLER3DBGRMAP: boolean;
  8314. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8315. EXPOSURE: boolean;
  8316. constructor();
  8317. }
  8318. /**
  8319. * This groups together the common properties used for image processing either in direct forward pass
  8320. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8321. * or not.
  8322. */
  8323. export class ImageProcessingConfiguration {
  8324. /**
  8325. * Default tone mapping applied in BabylonJS.
  8326. */
  8327. static readonly TONEMAPPING_STANDARD: number;
  8328. /**
  8329. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8330. * to other engines rendering to increase portability.
  8331. */
  8332. static readonly TONEMAPPING_ACES: number;
  8333. /**
  8334. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8335. */
  8336. colorCurves: Nullable<ColorCurves>;
  8337. private _colorCurvesEnabled;
  8338. /**
  8339. * Gets wether the color curves effect is enabled.
  8340. */
  8341. get colorCurvesEnabled(): boolean;
  8342. /**
  8343. * Sets wether the color curves effect is enabled.
  8344. */
  8345. set colorCurvesEnabled(value: boolean);
  8346. private _colorGradingTexture;
  8347. /**
  8348. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8349. */
  8350. get colorGradingTexture(): Nullable<BaseTexture>;
  8351. /**
  8352. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8353. */
  8354. set colorGradingTexture(value: Nullable<BaseTexture>);
  8355. private _colorGradingEnabled;
  8356. /**
  8357. * Gets wether the color grading effect is enabled.
  8358. */
  8359. get colorGradingEnabled(): boolean;
  8360. /**
  8361. * Sets wether the color grading effect is enabled.
  8362. */
  8363. set colorGradingEnabled(value: boolean);
  8364. private _colorGradingWithGreenDepth;
  8365. /**
  8366. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8367. */
  8368. get colorGradingWithGreenDepth(): boolean;
  8369. /**
  8370. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8371. */
  8372. set colorGradingWithGreenDepth(value: boolean);
  8373. private _colorGradingBGR;
  8374. /**
  8375. * Gets wether the color grading texture contains BGR values.
  8376. */
  8377. get colorGradingBGR(): boolean;
  8378. /**
  8379. * Sets wether the color grading texture contains BGR values.
  8380. */
  8381. set colorGradingBGR(value: boolean);
  8382. /** @hidden */
  8383. _exposure: number;
  8384. /**
  8385. * Gets the Exposure used in the effect.
  8386. */
  8387. get exposure(): number;
  8388. /**
  8389. * Sets the Exposure used in the effect.
  8390. */
  8391. set exposure(value: number);
  8392. private _toneMappingEnabled;
  8393. /**
  8394. * Gets wether the tone mapping effect is enabled.
  8395. */
  8396. get toneMappingEnabled(): boolean;
  8397. /**
  8398. * Sets wether the tone mapping effect is enabled.
  8399. */
  8400. set toneMappingEnabled(value: boolean);
  8401. private _toneMappingType;
  8402. /**
  8403. * Gets the type of tone mapping effect.
  8404. */
  8405. get toneMappingType(): number;
  8406. /**
  8407. * Sets the type of tone mapping effect used in BabylonJS.
  8408. */
  8409. set toneMappingType(value: number);
  8410. protected _contrast: number;
  8411. /**
  8412. * Gets the contrast used in the effect.
  8413. */
  8414. get contrast(): number;
  8415. /**
  8416. * Sets the contrast used in the effect.
  8417. */
  8418. set contrast(value: number);
  8419. /**
  8420. * Vignette stretch size.
  8421. */
  8422. vignetteStretch: number;
  8423. /**
  8424. * Vignette centre X Offset.
  8425. */
  8426. vignetteCentreX: number;
  8427. /**
  8428. * Vignette centre Y Offset.
  8429. */
  8430. vignetteCentreY: number;
  8431. /**
  8432. * Vignette weight or intensity of the vignette effect.
  8433. */
  8434. vignetteWeight: number;
  8435. /**
  8436. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8437. * if vignetteEnabled is set to true.
  8438. */
  8439. vignetteColor: Color4;
  8440. /**
  8441. * Camera field of view used by the Vignette effect.
  8442. */
  8443. vignetteCameraFov: number;
  8444. private _vignetteBlendMode;
  8445. /**
  8446. * Gets the vignette blend mode allowing different kind of effect.
  8447. */
  8448. get vignetteBlendMode(): number;
  8449. /**
  8450. * Sets the vignette blend mode allowing different kind of effect.
  8451. */
  8452. set vignetteBlendMode(value: number);
  8453. private _vignetteEnabled;
  8454. /**
  8455. * Gets wether the vignette effect is enabled.
  8456. */
  8457. get vignetteEnabled(): boolean;
  8458. /**
  8459. * Sets wether the vignette effect is enabled.
  8460. */
  8461. set vignetteEnabled(value: boolean);
  8462. private _applyByPostProcess;
  8463. /**
  8464. * Gets wether the image processing is applied through a post process or not.
  8465. */
  8466. get applyByPostProcess(): boolean;
  8467. /**
  8468. * Sets wether the image processing is applied through a post process or not.
  8469. */
  8470. set applyByPostProcess(value: boolean);
  8471. private _isEnabled;
  8472. /**
  8473. * Gets wether the image processing is enabled or not.
  8474. */
  8475. get isEnabled(): boolean;
  8476. /**
  8477. * Sets wether the image processing is enabled or not.
  8478. */
  8479. set isEnabled(value: boolean);
  8480. /**
  8481. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8482. */
  8483. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8484. /**
  8485. * Method called each time the image processing information changes requires to recompile the effect.
  8486. */
  8487. protected _updateParameters(): void;
  8488. /**
  8489. * Gets the current class name.
  8490. * @return "ImageProcessingConfiguration"
  8491. */
  8492. getClassName(): string;
  8493. /**
  8494. * Prepare the list of uniforms associated with the Image Processing effects.
  8495. * @param uniforms The list of uniforms used in the effect
  8496. * @param defines the list of defines currently in use
  8497. */
  8498. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8499. /**
  8500. * Prepare the list of samplers associated with the Image Processing effects.
  8501. * @param samplersList The list of uniforms used in the effect
  8502. * @param defines the list of defines currently in use
  8503. */
  8504. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8505. /**
  8506. * Prepare the list of defines associated to the shader.
  8507. * @param defines the list of defines to complete
  8508. * @param forPostProcess Define if we are currently in post process mode or not
  8509. */
  8510. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8511. /**
  8512. * Returns true if all the image processing information are ready.
  8513. * @returns True if ready, otherwise, false
  8514. */
  8515. isReady(): boolean;
  8516. /**
  8517. * Binds the image processing to the shader.
  8518. * @param effect The effect to bind to
  8519. * @param overrideAspectRatio Override the aspect ratio of the effect
  8520. */
  8521. bind(effect: Effect, overrideAspectRatio?: number): void;
  8522. /**
  8523. * Clones the current image processing instance.
  8524. * @return The cloned image processing
  8525. */
  8526. clone(): ImageProcessingConfiguration;
  8527. /**
  8528. * Serializes the current image processing instance to a json representation.
  8529. * @return a JSON representation
  8530. */
  8531. serialize(): any;
  8532. /**
  8533. * Parses the image processing from a json representation.
  8534. * @param source the JSON source to parse
  8535. * @return The parsed image processing
  8536. */
  8537. static Parse(source: any): ImageProcessingConfiguration;
  8538. private static _VIGNETTEMODE_MULTIPLY;
  8539. private static _VIGNETTEMODE_OPAQUE;
  8540. /**
  8541. * Used to apply the vignette as a mix with the pixel color.
  8542. */
  8543. static get VIGNETTEMODE_MULTIPLY(): number;
  8544. /**
  8545. * Used to apply the vignette as a replacement of the pixel color.
  8546. */
  8547. static get VIGNETTEMODE_OPAQUE(): number;
  8548. }
  8549. }
  8550. declare module "babylonjs/Shaders/postprocess.vertex" {
  8551. /** @hidden */
  8552. export var postprocessVertexShader: {
  8553. name: string;
  8554. shader: string;
  8555. };
  8556. }
  8557. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8558. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8559. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8560. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8561. module "babylonjs/Engines/thinEngine" {
  8562. interface ThinEngine {
  8563. /**
  8564. * Creates a new render target texture
  8565. * @param size defines the size of the texture
  8566. * @param options defines the options used to create the texture
  8567. * @returns a new render target texture stored in an InternalTexture
  8568. */
  8569. createRenderTargetTexture(size: number | {
  8570. width: number;
  8571. height: number;
  8572. layers?: number;
  8573. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8574. /**
  8575. * Creates a depth stencil texture.
  8576. * This is only available in WebGL 2 or with the depth texture extension available.
  8577. * @param size The size of face edge in the texture.
  8578. * @param options The options defining the texture.
  8579. * @returns The texture
  8580. */
  8581. createDepthStencilTexture(size: number | {
  8582. width: number;
  8583. height: number;
  8584. layers?: number;
  8585. }, options: DepthTextureCreationOptions): InternalTexture;
  8586. /** @hidden */
  8587. _createDepthStencilTexture(size: number | {
  8588. width: number;
  8589. height: number;
  8590. layers?: number;
  8591. }, options: DepthTextureCreationOptions): InternalTexture;
  8592. }
  8593. }
  8594. }
  8595. declare module "babylonjs/Maths/math.axis" {
  8596. import { Vector3 } from "babylonjs/Maths/math.vector";
  8597. /** Defines supported spaces */
  8598. export enum Space {
  8599. /** Local (object) space */
  8600. LOCAL = 0,
  8601. /** World space */
  8602. WORLD = 1,
  8603. /** Bone space */
  8604. BONE = 2
  8605. }
  8606. /** Defines the 3 main axes */
  8607. export class Axis {
  8608. /** X axis */
  8609. static X: Vector3;
  8610. /** Y axis */
  8611. static Y: Vector3;
  8612. /** Z axis */
  8613. static Z: Vector3;
  8614. }
  8615. }
  8616. declare module "babylonjs/Cameras/targetCamera" {
  8617. import { Nullable } from "babylonjs/types";
  8618. import { Camera } from "babylonjs/Cameras/camera";
  8619. import { Scene } from "babylonjs/scene";
  8620. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8621. /**
  8622. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8623. * This is the base of the follow, arc rotate cameras and Free camera
  8624. * @see http://doc.babylonjs.com/features/cameras
  8625. */
  8626. export class TargetCamera extends Camera {
  8627. private static _RigCamTransformMatrix;
  8628. private static _TargetTransformMatrix;
  8629. private static _TargetFocalPoint;
  8630. /**
  8631. * Define the current direction the camera is moving to
  8632. */
  8633. cameraDirection: Vector3;
  8634. /**
  8635. * Define the current rotation the camera is rotating to
  8636. */
  8637. cameraRotation: Vector2;
  8638. /**
  8639. * When set, the up vector of the camera will be updated by the rotation of the camera
  8640. */
  8641. updateUpVectorFromRotation: boolean;
  8642. private _tmpQuaternion;
  8643. /**
  8644. * Define the current rotation of the camera
  8645. */
  8646. rotation: Vector3;
  8647. /**
  8648. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8649. */
  8650. rotationQuaternion: Quaternion;
  8651. /**
  8652. * Define the current speed of the camera
  8653. */
  8654. speed: number;
  8655. /**
  8656. * Add constraint to the camera to prevent it to move freely in all directions and
  8657. * around all axis.
  8658. */
  8659. noRotationConstraint: boolean;
  8660. /**
  8661. * Define the current target of the camera as an object or a position.
  8662. */
  8663. lockedTarget: any;
  8664. /** @hidden */
  8665. _currentTarget: Vector3;
  8666. /** @hidden */
  8667. _initialFocalDistance: number;
  8668. /** @hidden */
  8669. _viewMatrix: Matrix;
  8670. /** @hidden */
  8671. _camMatrix: Matrix;
  8672. /** @hidden */
  8673. _cameraTransformMatrix: Matrix;
  8674. /** @hidden */
  8675. _cameraRotationMatrix: Matrix;
  8676. /** @hidden */
  8677. _referencePoint: Vector3;
  8678. /** @hidden */
  8679. _transformedReferencePoint: Vector3;
  8680. protected _globalCurrentTarget: Vector3;
  8681. protected _globalCurrentUpVector: Vector3;
  8682. /** @hidden */
  8683. _reset: () => void;
  8684. private _defaultUp;
  8685. /**
  8686. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8687. * This is the base of the follow, arc rotate cameras and Free camera
  8688. * @see http://doc.babylonjs.com/features/cameras
  8689. * @param name Defines the name of the camera in the scene
  8690. * @param position Defines the start position of the camera in the scene
  8691. * @param scene Defines the scene the camera belongs to
  8692. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8693. */
  8694. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8695. /**
  8696. * Gets the position in front of the camera at a given distance.
  8697. * @param distance The distance from the camera we want the position to be
  8698. * @returns the position
  8699. */
  8700. getFrontPosition(distance: number): Vector3;
  8701. /** @hidden */
  8702. _getLockedTargetPosition(): Nullable<Vector3>;
  8703. private _storedPosition;
  8704. private _storedRotation;
  8705. private _storedRotationQuaternion;
  8706. /**
  8707. * Store current camera state of the camera (fov, position, rotation, etc..)
  8708. * @returns the camera
  8709. */
  8710. storeState(): Camera;
  8711. /**
  8712. * Restored camera state. You must call storeState() first
  8713. * @returns whether it was successful or not
  8714. * @hidden
  8715. */
  8716. _restoreStateValues(): boolean;
  8717. /** @hidden */
  8718. _initCache(): void;
  8719. /** @hidden */
  8720. _updateCache(ignoreParentClass?: boolean): void;
  8721. /** @hidden */
  8722. _isSynchronizedViewMatrix(): boolean;
  8723. /** @hidden */
  8724. _computeLocalCameraSpeed(): number;
  8725. /**
  8726. * Defines the target the camera should look at.
  8727. * @param target Defines the new target as a Vector or a mesh
  8728. */
  8729. setTarget(target: Vector3): void;
  8730. /**
  8731. * Return the current target position of the camera. This value is expressed in local space.
  8732. * @returns the target position
  8733. */
  8734. getTarget(): Vector3;
  8735. /** @hidden */
  8736. _decideIfNeedsToMove(): boolean;
  8737. /** @hidden */
  8738. _updatePosition(): void;
  8739. /** @hidden */
  8740. _checkInputs(): void;
  8741. protected _updateCameraRotationMatrix(): void;
  8742. /**
  8743. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  8744. * @returns the current camera
  8745. */
  8746. private _rotateUpVectorWithCameraRotationMatrix;
  8747. private _cachedRotationZ;
  8748. private _cachedQuaternionRotationZ;
  8749. /** @hidden */
  8750. _getViewMatrix(): Matrix;
  8751. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8752. /**
  8753. * @hidden
  8754. */
  8755. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8756. /**
  8757. * @hidden
  8758. */
  8759. _updateRigCameras(): void;
  8760. private _getRigCamPositionAndTarget;
  8761. /**
  8762. * Gets the current object class name.
  8763. * @return the class name
  8764. */
  8765. getClassName(): string;
  8766. }
  8767. }
  8768. declare module "babylonjs/Events/keyboardEvents" {
  8769. /**
  8770. * Gather the list of keyboard event types as constants.
  8771. */
  8772. export class KeyboardEventTypes {
  8773. /**
  8774. * The keydown event is fired when a key becomes active (pressed).
  8775. */
  8776. static readonly KEYDOWN: number;
  8777. /**
  8778. * The keyup event is fired when a key has been released.
  8779. */
  8780. static readonly KEYUP: number;
  8781. }
  8782. /**
  8783. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8784. */
  8785. export class KeyboardInfo {
  8786. /**
  8787. * Defines the type of event (KeyboardEventTypes)
  8788. */
  8789. type: number;
  8790. /**
  8791. * Defines the related dom event
  8792. */
  8793. event: KeyboardEvent;
  8794. /**
  8795. * Instantiates a new keyboard info.
  8796. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8797. * @param type Defines the type of event (KeyboardEventTypes)
  8798. * @param event Defines the related dom event
  8799. */
  8800. constructor(
  8801. /**
  8802. * Defines the type of event (KeyboardEventTypes)
  8803. */
  8804. type: number,
  8805. /**
  8806. * Defines the related dom event
  8807. */
  8808. event: KeyboardEvent);
  8809. }
  8810. /**
  8811. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8812. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8813. */
  8814. export class KeyboardInfoPre extends KeyboardInfo {
  8815. /**
  8816. * Defines the type of event (KeyboardEventTypes)
  8817. */
  8818. type: number;
  8819. /**
  8820. * Defines the related dom event
  8821. */
  8822. event: KeyboardEvent;
  8823. /**
  8824. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8825. */
  8826. skipOnPointerObservable: boolean;
  8827. /**
  8828. * Instantiates a new keyboard pre info.
  8829. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8830. * @param type Defines the type of event (KeyboardEventTypes)
  8831. * @param event Defines the related dom event
  8832. */
  8833. constructor(
  8834. /**
  8835. * Defines the type of event (KeyboardEventTypes)
  8836. */
  8837. type: number,
  8838. /**
  8839. * Defines the related dom event
  8840. */
  8841. event: KeyboardEvent);
  8842. }
  8843. }
  8844. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8845. import { Nullable } from "babylonjs/types";
  8846. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8847. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8848. /**
  8849. * Manage the keyboard inputs to control the movement of a free camera.
  8850. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8851. */
  8852. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8853. /**
  8854. * Defines the camera the input is attached to.
  8855. */
  8856. camera: FreeCamera;
  8857. /**
  8858. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8859. */
  8860. keysUp: number[];
  8861. /**
  8862. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8863. */
  8864. keysDown: number[];
  8865. /**
  8866. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8867. */
  8868. keysLeft: number[];
  8869. /**
  8870. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8871. */
  8872. keysRight: number[];
  8873. private _keys;
  8874. private _onCanvasBlurObserver;
  8875. private _onKeyboardObserver;
  8876. private _engine;
  8877. private _scene;
  8878. /**
  8879. * Attach the input controls to a specific dom element to get the input from.
  8880. * @param element Defines the element the controls should be listened from
  8881. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8882. */
  8883. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8884. /**
  8885. * Detach the current controls from the specified dom element.
  8886. * @param element Defines the element to stop listening the inputs from
  8887. */
  8888. detachControl(element: Nullable<HTMLElement>): void;
  8889. /**
  8890. * Update the current camera state depending on the inputs that have been used this frame.
  8891. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8892. */
  8893. checkInputs(): void;
  8894. /**
  8895. * Gets the class name of the current intput.
  8896. * @returns the class name
  8897. */
  8898. getClassName(): string;
  8899. /** @hidden */
  8900. _onLostFocus(): void;
  8901. /**
  8902. * Get the friendly name associated with the input class.
  8903. * @returns the input friendly name
  8904. */
  8905. getSimpleName(): string;
  8906. }
  8907. }
  8908. declare module "babylonjs/Lights/shadowLight" {
  8909. import { Camera } from "babylonjs/Cameras/camera";
  8910. import { Scene } from "babylonjs/scene";
  8911. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8912. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8913. import { Light } from "babylonjs/Lights/light";
  8914. /**
  8915. * Interface describing all the common properties and methods a shadow light needs to implement.
  8916. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8917. * as well as binding the different shadow properties to the effects.
  8918. */
  8919. export interface IShadowLight extends Light {
  8920. /**
  8921. * The light id in the scene (used in scene.findLighById for instance)
  8922. */
  8923. id: string;
  8924. /**
  8925. * The position the shdow will be casted from.
  8926. */
  8927. position: Vector3;
  8928. /**
  8929. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8930. */
  8931. direction: Vector3;
  8932. /**
  8933. * The transformed position. Position of the light in world space taking parenting in account.
  8934. */
  8935. transformedPosition: Vector3;
  8936. /**
  8937. * The transformed direction. Direction of the light in world space taking parenting in account.
  8938. */
  8939. transformedDirection: Vector3;
  8940. /**
  8941. * The friendly name of the light in the scene.
  8942. */
  8943. name: string;
  8944. /**
  8945. * Defines the shadow projection clipping minimum z value.
  8946. */
  8947. shadowMinZ: number;
  8948. /**
  8949. * Defines the shadow projection clipping maximum z value.
  8950. */
  8951. shadowMaxZ: number;
  8952. /**
  8953. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8954. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8955. */
  8956. computeTransformedInformation(): boolean;
  8957. /**
  8958. * Gets the scene the light belongs to.
  8959. * @returns The scene
  8960. */
  8961. getScene(): Scene;
  8962. /**
  8963. * Callback defining a custom Projection Matrix Builder.
  8964. * This can be used to override the default projection matrix computation.
  8965. */
  8966. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8967. /**
  8968. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8969. * @param matrix The materix to updated with the projection information
  8970. * @param viewMatrix The transform matrix of the light
  8971. * @param renderList The list of mesh to render in the map
  8972. * @returns The current light
  8973. */
  8974. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8975. /**
  8976. * Gets the current depth scale used in ESM.
  8977. * @returns The scale
  8978. */
  8979. getDepthScale(): number;
  8980. /**
  8981. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8982. * @returns true if a cube texture needs to be use
  8983. */
  8984. needCube(): boolean;
  8985. /**
  8986. * Detects if the projection matrix requires to be recomputed this frame.
  8987. * @returns true if it requires to be recomputed otherwise, false.
  8988. */
  8989. needProjectionMatrixCompute(): boolean;
  8990. /**
  8991. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8992. */
  8993. forceProjectionMatrixCompute(): void;
  8994. /**
  8995. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8996. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8997. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8998. */
  8999. getShadowDirection(faceIndex?: number): Vector3;
  9000. /**
  9001. * Gets the minZ used for shadow according to both the scene and the light.
  9002. * @param activeCamera The camera we are returning the min for
  9003. * @returns the depth min z
  9004. */
  9005. getDepthMinZ(activeCamera: Camera): number;
  9006. /**
  9007. * Gets the maxZ used for shadow according to both the scene and the light.
  9008. * @param activeCamera The camera we are returning the max for
  9009. * @returns the depth max z
  9010. */
  9011. getDepthMaxZ(activeCamera: Camera): number;
  9012. }
  9013. /**
  9014. * Base implementation IShadowLight
  9015. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9016. */
  9017. export abstract class ShadowLight extends Light implements IShadowLight {
  9018. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9019. protected _position: Vector3;
  9020. protected _setPosition(value: Vector3): void;
  9021. /**
  9022. * Sets the position the shadow will be casted from. Also use as the light position for both
  9023. * point and spot lights.
  9024. */
  9025. get position(): Vector3;
  9026. /**
  9027. * Sets the position the shadow will be casted from. Also use as the light position for both
  9028. * point and spot lights.
  9029. */
  9030. set position(value: Vector3);
  9031. protected _direction: Vector3;
  9032. protected _setDirection(value: Vector3): void;
  9033. /**
  9034. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9035. * Also use as the light direction on spot and directional lights.
  9036. */
  9037. get direction(): Vector3;
  9038. /**
  9039. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9040. * Also use as the light direction on spot and directional lights.
  9041. */
  9042. set direction(value: Vector3);
  9043. protected _shadowMinZ: number;
  9044. /**
  9045. * Gets the shadow projection clipping minimum z value.
  9046. */
  9047. get shadowMinZ(): number;
  9048. /**
  9049. * Sets the shadow projection clipping minimum z value.
  9050. */
  9051. set shadowMinZ(value: number);
  9052. protected _shadowMaxZ: number;
  9053. /**
  9054. * Sets the shadow projection clipping maximum z value.
  9055. */
  9056. get shadowMaxZ(): number;
  9057. /**
  9058. * Gets the shadow projection clipping maximum z value.
  9059. */
  9060. set shadowMaxZ(value: number);
  9061. /**
  9062. * Callback defining a custom Projection Matrix Builder.
  9063. * This can be used to override the default projection matrix computation.
  9064. */
  9065. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9066. /**
  9067. * The transformed position. Position of the light in world space taking parenting in account.
  9068. */
  9069. transformedPosition: Vector3;
  9070. /**
  9071. * The transformed direction. Direction of the light in world space taking parenting in account.
  9072. */
  9073. transformedDirection: Vector3;
  9074. private _needProjectionMatrixCompute;
  9075. /**
  9076. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9077. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9078. */
  9079. computeTransformedInformation(): boolean;
  9080. /**
  9081. * Return the depth scale used for the shadow map.
  9082. * @returns the depth scale.
  9083. */
  9084. getDepthScale(): number;
  9085. /**
  9086. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9087. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9088. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9089. */
  9090. getShadowDirection(faceIndex?: number): Vector3;
  9091. /**
  9092. * Returns the ShadowLight absolute position in the World.
  9093. * @returns the position vector in world space
  9094. */
  9095. getAbsolutePosition(): Vector3;
  9096. /**
  9097. * Sets the ShadowLight direction toward the passed target.
  9098. * @param target The point to target in local space
  9099. * @returns the updated ShadowLight direction
  9100. */
  9101. setDirectionToTarget(target: Vector3): Vector3;
  9102. /**
  9103. * Returns the light rotation in euler definition.
  9104. * @returns the x y z rotation in local space.
  9105. */
  9106. getRotation(): Vector3;
  9107. /**
  9108. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9109. * @returns true if a cube texture needs to be use
  9110. */
  9111. needCube(): boolean;
  9112. /**
  9113. * Detects if the projection matrix requires to be recomputed this frame.
  9114. * @returns true if it requires to be recomputed otherwise, false.
  9115. */
  9116. needProjectionMatrixCompute(): boolean;
  9117. /**
  9118. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9119. */
  9120. forceProjectionMatrixCompute(): void;
  9121. /** @hidden */
  9122. _initCache(): void;
  9123. /** @hidden */
  9124. _isSynchronized(): boolean;
  9125. /**
  9126. * Computes the world matrix of the node
  9127. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9128. * @returns the world matrix
  9129. */
  9130. computeWorldMatrix(force?: boolean): Matrix;
  9131. /**
  9132. * Gets the minZ used for shadow according to both the scene and the light.
  9133. * @param activeCamera The camera we are returning the min for
  9134. * @returns the depth min z
  9135. */
  9136. getDepthMinZ(activeCamera: Camera): number;
  9137. /**
  9138. * Gets the maxZ used for shadow according to both the scene and the light.
  9139. * @param activeCamera The camera we are returning the max for
  9140. * @returns the depth max z
  9141. */
  9142. getDepthMaxZ(activeCamera: Camera): number;
  9143. /**
  9144. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9145. * @param matrix The materix to updated with the projection information
  9146. * @param viewMatrix The transform matrix of the light
  9147. * @param renderList The list of mesh to render in the map
  9148. * @returns The current light
  9149. */
  9150. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9151. }
  9152. }
  9153. declare module "babylonjs/Materials/effectFallbacks" {
  9154. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9155. import { Effect } from "babylonjs/Materials/effect";
  9156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9157. /**
  9158. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9159. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9160. */
  9161. export class EffectFallbacks implements IEffectFallbacks {
  9162. private _defines;
  9163. private _currentRank;
  9164. private _maxRank;
  9165. private _mesh;
  9166. /**
  9167. * Removes the fallback from the bound mesh.
  9168. */
  9169. unBindMesh(): void;
  9170. /**
  9171. * Adds a fallback on the specified property.
  9172. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9173. * @param define The name of the define in the shader
  9174. */
  9175. addFallback(rank: number, define: string): void;
  9176. /**
  9177. * Sets the mesh to use CPU skinning when needing to fallback.
  9178. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9179. * @param mesh The mesh to use the fallbacks.
  9180. */
  9181. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9182. /**
  9183. * Checks to see if more fallbacks are still availible.
  9184. */
  9185. get hasMoreFallbacks(): boolean;
  9186. /**
  9187. * Removes the defines that should be removed when falling back.
  9188. * @param currentDefines defines the current define statements for the shader.
  9189. * @param effect defines the current effect we try to compile
  9190. * @returns The resulting defines with defines of the current rank removed.
  9191. */
  9192. reduce(currentDefines: string, effect: Effect): string;
  9193. }
  9194. }
  9195. declare module "babylonjs/Materials/materialHelper" {
  9196. import { Nullable } from "babylonjs/types";
  9197. import { Scene } from "babylonjs/scene";
  9198. import { Engine } from "babylonjs/Engines/engine";
  9199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9200. import { Light } from "babylonjs/Lights/light";
  9201. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9202. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  9203. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9204. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9205. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9206. /**
  9207. * "Static Class" containing the most commonly used helper while dealing with material for
  9208. * rendering purpose.
  9209. *
  9210. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9211. *
  9212. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9213. */
  9214. export class MaterialHelper {
  9215. /**
  9216. * Bind the current view position to an effect.
  9217. * @param effect The effect to be bound
  9218. * @param scene The scene the eyes position is used from
  9219. */
  9220. static BindEyePosition(effect: Effect, scene: Scene): void;
  9221. /**
  9222. * Helps preparing the defines values about the UVs in used in the effect.
  9223. * UVs are shared as much as we can accross channels in the shaders.
  9224. * @param texture The texture we are preparing the UVs for
  9225. * @param defines The defines to update
  9226. * @param key The channel key "diffuse", "specular"... used in the shader
  9227. */
  9228. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9229. /**
  9230. * Binds a texture matrix value to its corrsponding uniform
  9231. * @param texture The texture to bind the matrix for
  9232. * @param uniformBuffer The uniform buffer receivin the data
  9233. * @param key The channel key "diffuse", "specular"... used in the shader
  9234. */
  9235. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9236. /**
  9237. * Gets the current status of the fog (should it be enabled?)
  9238. * @param mesh defines the mesh to evaluate for fog support
  9239. * @param scene defines the hosting scene
  9240. * @returns true if fog must be enabled
  9241. */
  9242. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9243. /**
  9244. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9245. * @param mesh defines the current mesh
  9246. * @param scene defines the current scene
  9247. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9248. * @param pointsCloud defines if point cloud rendering has to be turned on
  9249. * @param fogEnabled defines if fog has to be turned on
  9250. * @param alphaTest defines if alpha testing has to be turned on
  9251. * @param defines defines the current list of defines
  9252. */
  9253. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9254. /**
  9255. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9256. * @param scene defines the current scene
  9257. * @param engine defines the current engine
  9258. * @param defines specifies the list of active defines
  9259. * @param useInstances defines if instances have to be turned on
  9260. * @param useClipPlane defines if clip plane have to be turned on
  9261. */
  9262. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9263. /**
  9264. * Prepares the defines for bones
  9265. * @param mesh The mesh containing the geometry data we will draw
  9266. * @param defines The defines to update
  9267. */
  9268. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9269. /**
  9270. * Prepares the defines for morph targets
  9271. * @param mesh The mesh containing the geometry data we will draw
  9272. * @param defines The defines to update
  9273. */
  9274. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9275. /**
  9276. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9277. * @param mesh The mesh containing the geometry data we will draw
  9278. * @param defines The defines to update
  9279. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9280. * @param useBones Precise whether bones should be used or not (override mesh info)
  9281. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9282. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9283. * @returns false if defines are considered not dirty and have not been checked
  9284. */
  9285. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9286. /**
  9287. * Prepares the defines related to multiview
  9288. * @param scene The scene we are intending to draw
  9289. * @param defines The defines to update
  9290. */
  9291. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9292. /**
  9293. * Prepares the defines related to the light information passed in parameter
  9294. * @param scene The scene we are intending to draw
  9295. * @param mesh The mesh the effect is compiling for
  9296. * @param light The light the effect is compiling for
  9297. * @param lightIndex The index of the light
  9298. * @param defines The defines to update
  9299. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9300. * @param state Defines the current state regarding what is needed (normals, etc...)
  9301. */
  9302. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9303. needNormals: boolean;
  9304. needRebuild: boolean;
  9305. shadowEnabled: boolean;
  9306. specularEnabled: boolean;
  9307. lightmapMode: boolean;
  9308. }): void;
  9309. /**
  9310. * Prepares the defines related to the light information passed in parameter
  9311. * @param scene The scene we are intending to draw
  9312. * @param mesh The mesh the effect is compiling for
  9313. * @param defines The defines to update
  9314. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9315. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9316. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9317. * @returns true if normals will be required for the rest of the effect
  9318. */
  9319. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9320. /**
  9321. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9322. * @param lightIndex defines the light index
  9323. * @param uniformsList The uniform list
  9324. * @param samplersList The sampler list
  9325. * @param projectedLightTexture defines if projected texture must be used
  9326. * @param uniformBuffersList defines an optional list of uniform buffers
  9327. */
  9328. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9329. /**
  9330. * Prepares the uniforms and samplers list to be used in the effect
  9331. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9332. * @param samplersList The sampler list
  9333. * @param defines The defines helping in the list generation
  9334. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9335. */
  9336. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9337. /**
  9338. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9339. * @param defines The defines to update while falling back
  9340. * @param fallbacks The authorized effect fallbacks
  9341. * @param maxSimultaneousLights The maximum number of lights allowed
  9342. * @param rank the current rank of the Effect
  9343. * @returns The newly affected rank
  9344. */
  9345. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9346. private static _TmpMorphInfluencers;
  9347. /**
  9348. * Prepares the list of attributes required for morph targets according to the effect defines.
  9349. * @param attribs The current list of supported attribs
  9350. * @param mesh The mesh to prepare the morph targets attributes for
  9351. * @param influencers The number of influencers
  9352. */
  9353. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9354. /**
  9355. * Prepares the list of attributes required for morph targets according to the effect defines.
  9356. * @param attribs The current list of supported attribs
  9357. * @param mesh The mesh to prepare the morph targets attributes for
  9358. * @param defines The current Defines of the effect
  9359. */
  9360. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9361. /**
  9362. * Prepares the list of attributes required for bones according to the effect defines.
  9363. * @param attribs The current list of supported attribs
  9364. * @param mesh The mesh to prepare the bones attributes for
  9365. * @param defines The current Defines of the effect
  9366. * @param fallbacks The current efffect fallback strategy
  9367. */
  9368. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9369. /**
  9370. * Check and prepare the list of attributes required for instances according to the effect defines.
  9371. * @param attribs The current list of supported attribs
  9372. * @param defines The current MaterialDefines of the effect
  9373. */
  9374. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9375. /**
  9376. * Add the list of attributes required for instances to the attribs array.
  9377. * @param attribs The current list of supported attribs
  9378. */
  9379. static PushAttributesForInstances(attribs: string[]): void;
  9380. /**
  9381. * Binds the light information to the effect.
  9382. * @param light The light containing the generator
  9383. * @param effect The effect we are binding the data to
  9384. * @param lightIndex The light index in the effect used to render
  9385. */
  9386. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9387. /**
  9388. * Binds the lights information from the scene to the effect for the given mesh.
  9389. * @param light Light to bind
  9390. * @param lightIndex Light index
  9391. * @param scene The scene where the light belongs to
  9392. * @param effect The effect we are binding the data to
  9393. * @param useSpecular Defines if specular is supported
  9394. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9395. */
  9396. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  9397. /**
  9398. * Binds the lights information from the scene to the effect for the given mesh.
  9399. * @param scene The scene the lights belongs to
  9400. * @param mesh The mesh we are binding the information to render
  9401. * @param effect The effect we are binding the data to
  9402. * @param defines The generated defines for the effect
  9403. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9404. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9405. */
  9406. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  9407. private static _tempFogColor;
  9408. /**
  9409. * Binds the fog information from the scene to the effect for the given mesh.
  9410. * @param scene The scene the lights belongs to
  9411. * @param mesh The mesh we are binding the information to render
  9412. * @param effect The effect we are binding the data to
  9413. * @param linearSpace Defines if the fog effect is applied in linear space
  9414. */
  9415. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9416. /**
  9417. * Binds the bones information from the mesh to the effect.
  9418. * @param mesh The mesh we are binding the information to render
  9419. * @param effect The effect we are binding the data to
  9420. */
  9421. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9422. /**
  9423. * Binds the morph targets information from the mesh to the effect.
  9424. * @param abstractMesh The mesh we are binding the information to render
  9425. * @param effect The effect we are binding the data to
  9426. */
  9427. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9428. /**
  9429. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9430. * @param defines The generated defines used in the effect
  9431. * @param effect The effect we are binding the data to
  9432. * @param scene The scene we are willing to render with logarithmic scale for
  9433. */
  9434. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9435. /**
  9436. * Binds the clip plane information from the scene to the effect.
  9437. * @param scene The scene the clip plane information are extracted from
  9438. * @param effect The effect we are binding the data to
  9439. */
  9440. static BindClipPlane(effect: Effect, scene: Scene): void;
  9441. }
  9442. }
  9443. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9444. /** @hidden */
  9445. export var packingFunctions: {
  9446. name: string;
  9447. shader: string;
  9448. };
  9449. }
  9450. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9451. /** @hidden */
  9452. export var clipPlaneFragmentDeclaration: {
  9453. name: string;
  9454. shader: string;
  9455. };
  9456. }
  9457. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9458. /** @hidden */
  9459. export var clipPlaneFragment: {
  9460. name: string;
  9461. shader: string;
  9462. };
  9463. }
  9464. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9465. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9466. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9467. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9468. /** @hidden */
  9469. export var shadowMapPixelShader: {
  9470. name: string;
  9471. shader: string;
  9472. };
  9473. }
  9474. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9475. /** @hidden */
  9476. export var bonesDeclaration: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9482. /** @hidden */
  9483. export var morphTargetsVertexGlobalDeclaration: {
  9484. name: string;
  9485. shader: string;
  9486. };
  9487. }
  9488. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9489. /** @hidden */
  9490. export var morphTargetsVertexDeclaration: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9496. /** @hidden */
  9497. export var instancesDeclaration: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9503. /** @hidden */
  9504. export var helperFunctions: {
  9505. name: string;
  9506. shader: string;
  9507. };
  9508. }
  9509. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9510. /** @hidden */
  9511. export var clipPlaneVertexDeclaration: {
  9512. name: string;
  9513. shader: string;
  9514. };
  9515. }
  9516. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9517. /** @hidden */
  9518. export var morphTargetsVertex: {
  9519. name: string;
  9520. shader: string;
  9521. };
  9522. }
  9523. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9524. /** @hidden */
  9525. export var instancesVertex: {
  9526. name: string;
  9527. shader: string;
  9528. };
  9529. }
  9530. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9531. /** @hidden */
  9532. export var bonesVertex: {
  9533. name: string;
  9534. shader: string;
  9535. };
  9536. }
  9537. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9538. /** @hidden */
  9539. export var clipPlaneVertex: {
  9540. name: string;
  9541. shader: string;
  9542. };
  9543. }
  9544. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9545. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9546. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9547. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9548. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9549. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9550. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9551. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9552. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9553. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9554. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9555. /** @hidden */
  9556. export var shadowMapVertexShader: {
  9557. name: string;
  9558. shader: string;
  9559. };
  9560. }
  9561. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9562. /** @hidden */
  9563. export var depthBoxBlurPixelShader: {
  9564. name: string;
  9565. shader: string;
  9566. };
  9567. }
  9568. declare module "babylonjs/Culling/ray" {
  9569. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  9570. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9572. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9573. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  9574. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  9575. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  9576. import { Plane } from "babylonjs/Maths/math.plane";
  9577. /**
  9578. * Class representing a ray with position and direction
  9579. */
  9580. export class Ray {
  9581. /** origin point */
  9582. origin: Vector3;
  9583. /** direction */
  9584. direction: Vector3;
  9585. /** length of the ray */
  9586. length: number;
  9587. private static readonly TmpVector3;
  9588. private _tmpRay;
  9589. /**
  9590. * Creates a new ray
  9591. * @param origin origin point
  9592. * @param direction direction
  9593. * @param length length of the ray
  9594. */
  9595. constructor(
  9596. /** origin point */
  9597. origin: Vector3,
  9598. /** direction */
  9599. direction: Vector3,
  9600. /** length of the ray */
  9601. length?: number);
  9602. /**
  9603. * Checks if the ray intersects a box
  9604. * @param minimum bound of the box
  9605. * @param maximum bound of the box
  9606. * @param intersectionTreshold extra extend to be added to the box in all direction
  9607. * @returns if the box was hit
  9608. */
  9609. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  9610. /**
  9611. * Checks if the ray intersects a box
  9612. * @param box the bounding box to check
  9613. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  9614. * @returns if the box was hit
  9615. */
  9616. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  9617. /**
  9618. * If the ray hits a sphere
  9619. * @param sphere the bounding sphere to check
  9620. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  9621. * @returns true if it hits the sphere
  9622. */
  9623. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  9624. /**
  9625. * If the ray hits a triange
  9626. * @param vertex0 triangle vertex
  9627. * @param vertex1 triangle vertex
  9628. * @param vertex2 triangle vertex
  9629. * @returns intersection information if hit
  9630. */
  9631. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  9632. /**
  9633. * Checks if ray intersects a plane
  9634. * @param plane the plane to check
  9635. * @returns the distance away it was hit
  9636. */
  9637. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  9638. /**
  9639. * Calculate the intercept of a ray on a given axis
  9640. * @param axis to check 'x' | 'y' | 'z'
  9641. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  9642. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  9643. */
  9644. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  9645. /**
  9646. * Checks if ray intersects a mesh
  9647. * @param mesh the mesh to check
  9648. * @param fastCheck if only the bounding box should checked
  9649. * @returns picking info of the intersecton
  9650. */
  9651. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  9652. /**
  9653. * Checks if ray intersects a mesh
  9654. * @param meshes the meshes to check
  9655. * @param fastCheck if only the bounding box should checked
  9656. * @param results array to store result in
  9657. * @returns Array of picking infos
  9658. */
  9659. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  9660. private _comparePickingInfo;
  9661. private static smallnum;
  9662. private static rayl;
  9663. /**
  9664. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  9665. * @param sega the first point of the segment to test the intersection against
  9666. * @param segb the second point of the segment to test the intersection against
  9667. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  9668. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  9669. */
  9670. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  9671. /**
  9672. * Update the ray from viewport position
  9673. * @param x position
  9674. * @param y y position
  9675. * @param viewportWidth viewport width
  9676. * @param viewportHeight viewport height
  9677. * @param world world matrix
  9678. * @param view view matrix
  9679. * @param projection projection matrix
  9680. * @returns this ray updated
  9681. */
  9682. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9683. /**
  9684. * Creates a ray with origin and direction of 0,0,0
  9685. * @returns the new ray
  9686. */
  9687. static Zero(): Ray;
  9688. /**
  9689. * Creates a new ray from screen space and viewport
  9690. * @param x position
  9691. * @param y y position
  9692. * @param viewportWidth viewport width
  9693. * @param viewportHeight viewport height
  9694. * @param world world matrix
  9695. * @param view view matrix
  9696. * @param projection projection matrix
  9697. * @returns new ray
  9698. */
  9699. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  9700. /**
  9701. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  9702. * transformed to the given world matrix.
  9703. * @param origin The origin point
  9704. * @param end The end point
  9705. * @param world a matrix to transform the ray to. Default is the identity matrix.
  9706. * @returns the new ray
  9707. */
  9708. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  9709. /**
  9710. * Transforms a ray by a matrix
  9711. * @param ray ray to transform
  9712. * @param matrix matrix to apply
  9713. * @returns the resulting new ray
  9714. */
  9715. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  9716. /**
  9717. * Transforms a ray by a matrix
  9718. * @param ray ray to transform
  9719. * @param matrix matrix to apply
  9720. * @param result ray to store result in
  9721. */
  9722. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  9723. /**
  9724. * Unproject a ray from screen space to object space
  9725. * @param sourceX defines the screen space x coordinate to use
  9726. * @param sourceY defines the screen space y coordinate to use
  9727. * @param viewportWidth defines the current width of the viewport
  9728. * @param viewportHeight defines the current height of the viewport
  9729. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  9730. * @param view defines the view matrix to use
  9731. * @param projection defines the projection matrix to use
  9732. */
  9733. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  9734. }
  9735. /**
  9736. * Type used to define predicate used to select faces when a mesh intersection is detected
  9737. */
  9738. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  9739. module "babylonjs/scene" {
  9740. interface Scene {
  9741. /** @hidden */
  9742. _tempPickingRay: Nullable<Ray>;
  9743. /** @hidden */
  9744. _cachedRayForTransform: Ray;
  9745. /** @hidden */
  9746. _pickWithRayInverseMatrix: Matrix;
  9747. /** @hidden */
  9748. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  9749. /** @hidden */
  9750. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  9751. }
  9752. }
  9753. }
  9754. declare module "babylonjs/sceneComponent" {
  9755. import { Scene } from "babylonjs/scene";
  9756. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9757. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9758. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  9759. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  9760. import { Nullable } from "babylonjs/types";
  9761. import { Camera } from "babylonjs/Cameras/camera";
  9762. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9763. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9764. import { AbstractScene } from "babylonjs/abstractScene";
  9765. import { Mesh } from "babylonjs/Meshes/mesh";
  9766. /**
  9767. * Groups all the scene component constants in one place to ease maintenance.
  9768. * @hidden
  9769. */
  9770. export class SceneComponentConstants {
  9771. static readonly NAME_EFFECTLAYER: string;
  9772. static readonly NAME_LAYER: string;
  9773. static readonly NAME_LENSFLARESYSTEM: string;
  9774. static readonly NAME_BOUNDINGBOXRENDERER: string;
  9775. static readonly NAME_PARTICLESYSTEM: string;
  9776. static readonly NAME_GAMEPAD: string;
  9777. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  9778. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  9779. static readonly NAME_DEPTHRENDERER: string;
  9780. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  9781. static readonly NAME_SPRITE: string;
  9782. static readonly NAME_OUTLINERENDERER: string;
  9783. static readonly NAME_PROCEDURALTEXTURE: string;
  9784. static readonly NAME_SHADOWGENERATOR: string;
  9785. static readonly NAME_OCTREE: string;
  9786. static readonly NAME_PHYSICSENGINE: string;
  9787. static readonly NAME_AUDIO: string;
  9788. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  9789. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9790. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  9791. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  9792. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  9793. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  9794. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  9795. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  9796. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  9797. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  9798. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  9799. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  9800. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  9801. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  9802. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  9803. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  9804. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  9805. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  9806. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  9807. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  9808. static readonly STEP_AFTERRENDER_AUDIO: number;
  9809. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  9810. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  9811. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  9812. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  9813. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  9814. static readonly STEP_POINTERMOVE_SPRITE: number;
  9815. static readonly STEP_POINTERDOWN_SPRITE: number;
  9816. static readonly STEP_POINTERUP_SPRITE: number;
  9817. }
  9818. /**
  9819. * This represents a scene component.
  9820. *
  9821. * This is used to decouple the dependency the scene is having on the different workloads like
  9822. * layers, post processes...
  9823. */
  9824. export interface ISceneComponent {
  9825. /**
  9826. * The name of the component. Each component must have a unique name.
  9827. */
  9828. name: string;
  9829. /**
  9830. * The scene the component belongs to.
  9831. */
  9832. scene: Scene;
  9833. /**
  9834. * Register the component to one instance of a scene.
  9835. */
  9836. register(): void;
  9837. /**
  9838. * Rebuilds the elements related to this component in case of
  9839. * context lost for instance.
  9840. */
  9841. rebuild(): void;
  9842. /**
  9843. * Disposes the component and the associated ressources.
  9844. */
  9845. dispose(): void;
  9846. }
  9847. /**
  9848. * This represents a SERIALIZABLE scene component.
  9849. *
  9850. * This extends Scene Component to add Serialization methods on top.
  9851. */
  9852. export interface ISceneSerializableComponent extends ISceneComponent {
  9853. /**
  9854. * Adds all the elements from the container to the scene
  9855. * @param container the container holding the elements
  9856. */
  9857. addFromContainer(container: AbstractScene): void;
  9858. /**
  9859. * Removes all the elements in the container from the scene
  9860. * @param container contains the elements to remove
  9861. * @param dispose if the removed element should be disposed (default: false)
  9862. */
  9863. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  9864. /**
  9865. * Serializes the component data to the specified json object
  9866. * @param serializationObject The object to serialize to
  9867. */
  9868. serialize(serializationObject: any): void;
  9869. }
  9870. /**
  9871. * Strong typing of a Mesh related stage step action
  9872. */
  9873. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  9874. /**
  9875. * Strong typing of a Evaluate Sub Mesh related stage step action
  9876. */
  9877. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  9878. /**
  9879. * Strong typing of a Active Mesh related stage step action
  9880. */
  9881. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  9882. /**
  9883. * Strong typing of a Camera related stage step action
  9884. */
  9885. export type CameraStageAction = (camera: Camera) => void;
  9886. /**
  9887. * Strong typing of a Camera Frame buffer related stage step action
  9888. */
  9889. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  9890. /**
  9891. * Strong typing of a Render Target related stage step action
  9892. */
  9893. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  9894. /**
  9895. * Strong typing of a RenderingGroup related stage step action
  9896. */
  9897. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  9898. /**
  9899. * Strong typing of a Mesh Render related stage step action
  9900. */
  9901. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  9902. /**
  9903. * Strong typing of a simple stage step action
  9904. */
  9905. export type SimpleStageAction = () => void;
  9906. /**
  9907. * Strong typing of a render target action.
  9908. */
  9909. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  9910. /**
  9911. * Strong typing of a pointer move action.
  9912. */
  9913. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  9914. /**
  9915. * Strong typing of a pointer up/down action.
  9916. */
  9917. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  9918. /**
  9919. * Representation of a stage in the scene (Basically a list of ordered steps)
  9920. * @hidden
  9921. */
  9922. export class Stage<T extends Function> extends Array<{
  9923. index: number;
  9924. component: ISceneComponent;
  9925. action: T;
  9926. }> {
  9927. /**
  9928. * Hide ctor from the rest of the world.
  9929. * @param items The items to add.
  9930. */
  9931. private constructor();
  9932. /**
  9933. * Creates a new Stage.
  9934. * @returns A new instance of a Stage
  9935. */
  9936. static Create<T extends Function>(): Stage<T>;
  9937. /**
  9938. * Registers a step in an ordered way in the targeted stage.
  9939. * @param index Defines the position to register the step in
  9940. * @param component Defines the component attached to the step
  9941. * @param action Defines the action to launch during the step
  9942. */
  9943. registerStep(index: number, component: ISceneComponent, action: T): void;
  9944. /**
  9945. * Clears all the steps from the stage.
  9946. */
  9947. clear(): void;
  9948. }
  9949. }
  9950. declare module "babylonjs/Sprites/spriteSceneComponent" {
  9951. import { Nullable } from "babylonjs/types";
  9952. import { Observable } from "babylonjs/Misc/observable";
  9953. import { Scene } from "babylonjs/scene";
  9954. import { Sprite } from "babylonjs/Sprites/sprite";
  9955. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  9956. import { Ray } from "babylonjs/Culling/ray";
  9957. import { Camera } from "babylonjs/Cameras/camera";
  9958. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  9959. import { ISceneComponent } from "babylonjs/sceneComponent";
  9960. module "babylonjs/scene" {
  9961. interface Scene {
  9962. /** @hidden */
  9963. _pointerOverSprite: Nullable<Sprite>;
  9964. /** @hidden */
  9965. _pickedDownSprite: Nullable<Sprite>;
  9966. /** @hidden */
  9967. _tempSpritePickingRay: Nullable<Ray>;
  9968. /**
  9969. * All of the sprite managers added to this scene
  9970. * @see http://doc.babylonjs.com/babylon101/sprites
  9971. */
  9972. spriteManagers: Array<ISpriteManager>;
  9973. /**
  9974. * An event triggered when sprites rendering is about to start
  9975. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9976. */
  9977. onBeforeSpritesRenderingObservable: Observable<Scene>;
  9978. /**
  9979. * An event triggered when sprites rendering is done
  9980. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  9981. */
  9982. onAfterSpritesRenderingObservable: Observable<Scene>;
  9983. /** @hidden */
  9984. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9985. /** Launch a ray to try to pick a sprite in the scene
  9986. * @param x position on screen
  9987. * @param y position on screen
  9988. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9989. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9990. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  9991. * @returns a PickingInfo
  9992. */
  9993. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  9994. /** Use the given ray to pick a sprite in the scene
  9995. * @param ray The ray (in world space) to use to pick meshes
  9996. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  9997. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  9998. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  9999. * @returns a PickingInfo
  10000. */
  10001. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10002. /** @hidden */
  10003. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10004. /** Launch a ray to try to pick sprites in the scene
  10005. * @param x position on screen
  10006. * @param y position on screen
  10007. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10008. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10009. * @returns a PickingInfo array
  10010. */
  10011. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10012. /** Use the given ray to pick sprites in the scene
  10013. * @param ray The ray (in world space) to use to pick meshes
  10014. * @param predicate Predicate function used to determine eligible sprites. Can be set to null. In this case, a sprite must have isPickable set to true
  10015. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10016. * @returns a PickingInfo array
  10017. */
  10018. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10019. /**
  10020. * Force the sprite under the pointer
  10021. * @param sprite defines the sprite to use
  10022. */
  10023. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10024. /**
  10025. * Gets the sprite under the pointer
  10026. * @returns a Sprite or null if no sprite is under the pointer
  10027. */
  10028. getPointerOverSprite(): Nullable<Sprite>;
  10029. }
  10030. }
  10031. /**
  10032. * Defines the sprite scene component responsible to manage sprites
  10033. * in a given scene.
  10034. */
  10035. export class SpriteSceneComponent implements ISceneComponent {
  10036. /**
  10037. * The component name helpfull to identify the component in the list of scene components.
  10038. */
  10039. readonly name: string;
  10040. /**
  10041. * The scene the component belongs to.
  10042. */
  10043. scene: Scene;
  10044. /** @hidden */
  10045. private _spritePredicate;
  10046. /**
  10047. * Creates a new instance of the component for the given scene
  10048. * @param scene Defines the scene to register the component in
  10049. */
  10050. constructor(scene: Scene);
  10051. /**
  10052. * Registers the component in a given scene
  10053. */
  10054. register(): void;
  10055. /**
  10056. * Rebuilds the elements related to this component in case of
  10057. * context lost for instance.
  10058. */
  10059. rebuild(): void;
  10060. /**
  10061. * Disposes the component and the associated ressources.
  10062. */
  10063. dispose(): void;
  10064. private _pickSpriteButKeepRay;
  10065. private _pointerMove;
  10066. private _pointerDown;
  10067. private _pointerUp;
  10068. }
  10069. }
  10070. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  10071. /** @hidden */
  10072. export var fogFragmentDeclaration: {
  10073. name: string;
  10074. shader: string;
  10075. };
  10076. }
  10077. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  10078. /** @hidden */
  10079. export var fogFragment: {
  10080. name: string;
  10081. shader: string;
  10082. };
  10083. }
  10084. declare module "babylonjs/Shaders/sprites.fragment" {
  10085. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  10086. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  10087. /** @hidden */
  10088. export var spritesPixelShader: {
  10089. name: string;
  10090. shader: string;
  10091. };
  10092. }
  10093. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  10094. /** @hidden */
  10095. export var fogVertexDeclaration: {
  10096. name: string;
  10097. shader: string;
  10098. };
  10099. }
  10100. declare module "babylonjs/Shaders/sprites.vertex" {
  10101. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  10102. /** @hidden */
  10103. export var spritesVertexShader: {
  10104. name: string;
  10105. shader: string;
  10106. };
  10107. }
  10108. declare module "babylonjs/Sprites/spriteManager" {
  10109. import { IDisposable, Scene } from "babylonjs/scene";
  10110. import { Nullable } from "babylonjs/types";
  10111. import { Observable } from "babylonjs/Misc/observable";
  10112. import { Sprite } from "babylonjs/Sprites/sprite";
  10113. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10114. import { Camera } from "babylonjs/Cameras/camera";
  10115. import { Texture } from "babylonjs/Materials/Textures/texture";
  10116. import "babylonjs/Shaders/sprites.fragment";
  10117. import "babylonjs/Shaders/sprites.vertex";
  10118. import { Ray } from "babylonjs/Culling/ray";
  10119. /**
  10120. * Defines the minimum interface to fullfil in order to be a sprite manager.
  10121. */
  10122. export interface ISpriteManager extends IDisposable {
  10123. /**
  10124. * Restricts the camera to viewing objects with the same layerMask.
  10125. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  10126. */
  10127. layerMask: number;
  10128. /**
  10129. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  10130. */
  10131. isPickable: boolean;
  10132. /**
  10133. * Specifies the rendering group id for this mesh (0 by default)
  10134. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  10135. */
  10136. renderingGroupId: number;
  10137. /**
  10138. * Defines the list of sprites managed by the manager.
  10139. */
  10140. sprites: Array<Sprite>;
  10141. /**
  10142. * Tests the intersection of a sprite with a specific ray.
  10143. * @param ray The ray we are sending to test the collision
  10144. * @param camera The camera space we are sending rays in
  10145. * @param predicate A predicate allowing excluding sprites from the list of object to test
  10146. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  10147. * @returns picking info or null.
  10148. */
  10149. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10150. /**
  10151. * Intersects the sprites with a ray
  10152. * @param ray defines the ray to intersect with
  10153. * @param camera defines the current active camera
  10154. * @param predicate defines a predicate used to select candidate sprites
  10155. * @returns null if no hit or a PickingInfo array
  10156. */
  10157. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10158. /**
  10159. * Renders the list of sprites on screen.
  10160. */
  10161. render(): void;
  10162. }
  10163. /**
  10164. * Class used to manage multiple sprites on the same spritesheet
  10165. * @see http://doc.babylonjs.com/babylon101/sprites
  10166. */
  10167. export class SpriteManager implements ISpriteManager {
  10168. /** defines the manager's name */
  10169. name: string;
  10170. /** Gets the list of sprites */
  10171. sprites: Sprite[];
  10172. /** Gets or sets the rendering group id (0 by default) */
  10173. renderingGroupId: number;
  10174. /** Gets or sets camera layer mask */
  10175. layerMask: number;
  10176. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  10177. fogEnabled: boolean;
  10178. /** Gets or sets a boolean indicating if the sprites are pickable */
  10179. isPickable: boolean;
  10180. /** Defines the default width of a cell in the spritesheet */
  10181. cellWidth: number;
  10182. /** Defines the default height of a cell in the spritesheet */
  10183. cellHeight: number;
  10184. /** Associative array from JSON sprite data file */
  10185. private _cellData;
  10186. /** Array of sprite names from JSON sprite data file */
  10187. private _spriteMap;
  10188. /** True when packed cell data from JSON file is ready*/
  10189. private _packedAndReady;
  10190. /**
  10191. * An event triggered when the manager is disposed.
  10192. */
  10193. onDisposeObservable: Observable<SpriteManager>;
  10194. private _onDisposeObserver;
  10195. /**
  10196. * Callback called when the manager is disposed
  10197. */
  10198. set onDispose(callback: () => void);
  10199. private _capacity;
  10200. private _fromPacked;
  10201. private _spriteTexture;
  10202. private _epsilon;
  10203. private _scene;
  10204. private _vertexData;
  10205. private _buffer;
  10206. private _vertexBuffers;
  10207. private _indexBuffer;
  10208. private _effectBase;
  10209. private _effectFog;
  10210. /**
  10211. * Gets or sets the spritesheet texture
  10212. */
  10213. get texture(): Texture;
  10214. set texture(value: Texture);
  10215. /**
  10216. * Creates a new sprite manager
  10217. * @param name defines the manager's name
  10218. * @param imgUrl defines the sprite sheet url
  10219. * @param capacity defines the maximum allowed number of sprites
  10220. * @param cellSize defines the size of a sprite cell
  10221. * @param scene defines the hosting scene
  10222. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  10223. * @param samplingMode defines the smapling mode to use with spritesheet
  10224. * @param fromPacked set to false; do not alter
  10225. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  10226. */
  10227. constructor(
  10228. /** defines the manager's name */
  10229. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  10230. private _makePacked;
  10231. private _appendSpriteVertex;
  10232. /**
  10233. * Intersects the sprites with a ray
  10234. * @param ray defines the ray to intersect with
  10235. * @param camera defines the current active camera
  10236. * @param predicate defines a predicate used to select candidate sprites
  10237. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  10238. * @returns null if no hit or a PickingInfo
  10239. */
  10240. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  10241. /**
  10242. * Intersects the sprites with a ray
  10243. * @param ray defines the ray to intersect with
  10244. * @param camera defines the current active camera
  10245. * @param predicate defines a predicate used to select candidate sprites
  10246. * @returns null if no hit or a PickingInfo array
  10247. */
  10248. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  10249. /**
  10250. * Render all child sprites
  10251. */
  10252. render(): void;
  10253. /**
  10254. * Release associated resources
  10255. */
  10256. dispose(): void;
  10257. }
  10258. }
  10259. declare module "babylonjs/Misc/gradients" {
  10260. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  10261. /** Interface used by value gradients (color, factor, ...) */
  10262. export interface IValueGradient {
  10263. /**
  10264. * Gets or sets the gradient value (between 0 and 1)
  10265. */
  10266. gradient: number;
  10267. }
  10268. /** Class used to store color4 gradient */
  10269. export class ColorGradient implements IValueGradient {
  10270. /**
  10271. * Gets or sets the gradient value (between 0 and 1)
  10272. */
  10273. gradient: number;
  10274. /**
  10275. * Gets or sets first associated color
  10276. */
  10277. color1: Color4;
  10278. /**
  10279. * Gets or sets second associated color
  10280. */
  10281. color2?: Color4;
  10282. /**
  10283. * Will get a color picked randomly between color1 and color2.
  10284. * If color2 is undefined then color1 will be used
  10285. * @param result defines the target Color4 to store the result in
  10286. */
  10287. getColorToRef(result: Color4): void;
  10288. }
  10289. /** Class used to store color 3 gradient */
  10290. export class Color3Gradient implements IValueGradient {
  10291. /**
  10292. * Gets or sets the gradient value (between 0 and 1)
  10293. */
  10294. gradient: number;
  10295. /**
  10296. * Gets or sets the associated color
  10297. */
  10298. color: Color3;
  10299. }
  10300. /** Class used to store factor gradient */
  10301. export class FactorGradient implements IValueGradient {
  10302. /**
  10303. * Gets or sets the gradient value (between 0 and 1)
  10304. */
  10305. gradient: number;
  10306. /**
  10307. * Gets or sets first associated factor
  10308. */
  10309. factor1: number;
  10310. /**
  10311. * Gets or sets second associated factor
  10312. */
  10313. factor2?: number;
  10314. /**
  10315. * Will get a number picked randomly between factor1 and factor2.
  10316. * If factor2 is undefined then factor1 will be used
  10317. * @returns the picked number
  10318. */
  10319. getFactor(): number;
  10320. }
  10321. /**
  10322. * Helper used to simplify some generic gradient tasks
  10323. */
  10324. export class GradientHelper {
  10325. /**
  10326. * Gets the current gradient from an array of IValueGradient
  10327. * @param ratio defines the current ratio to get
  10328. * @param gradients defines the array of IValueGradient
  10329. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  10330. */
  10331. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  10332. }
  10333. }
  10334. declare module "babylonjs/Maths/math.size" {
  10335. /**
  10336. * Interface for the size containing width and height
  10337. */
  10338. export interface ISize {
  10339. /**
  10340. * Width
  10341. */
  10342. width: number;
  10343. /**
  10344. * Heighht
  10345. */
  10346. height: number;
  10347. }
  10348. /**
  10349. * Size containing widht and height
  10350. */
  10351. export class Size implements ISize {
  10352. /**
  10353. * Width
  10354. */
  10355. width: number;
  10356. /**
  10357. * Height
  10358. */
  10359. height: number;
  10360. /**
  10361. * Creates a Size object from the given width and height (floats).
  10362. * @param width width of the new size
  10363. * @param height height of the new size
  10364. */
  10365. constructor(width: number, height: number);
  10366. /**
  10367. * Returns a string with the Size width and height
  10368. * @returns a string with the Size width and height
  10369. */
  10370. toString(): string;
  10371. /**
  10372. * "Size"
  10373. * @returns the string "Size"
  10374. */
  10375. getClassName(): string;
  10376. /**
  10377. * Returns the Size hash code.
  10378. * @returns a hash code for a unique width and height
  10379. */
  10380. getHashCode(): number;
  10381. /**
  10382. * Updates the current size from the given one.
  10383. * @param src the given size
  10384. */
  10385. copyFrom(src: Size): void;
  10386. /**
  10387. * Updates in place the current Size from the given floats.
  10388. * @param width width of the new size
  10389. * @param height height of the new size
  10390. * @returns the updated Size.
  10391. */
  10392. copyFromFloats(width: number, height: number): Size;
  10393. /**
  10394. * Updates in place the current Size from the given floats.
  10395. * @param width width to set
  10396. * @param height height to set
  10397. * @returns the updated Size.
  10398. */
  10399. set(width: number, height: number): Size;
  10400. /**
  10401. * Multiplies the width and height by numbers
  10402. * @param w factor to multiple the width by
  10403. * @param h factor to multiple the height by
  10404. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  10405. */
  10406. multiplyByFloats(w: number, h: number): Size;
  10407. /**
  10408. * Clones the size
  10409. * @returns a new Size copied from the given one.
  10410. */
  10411. clone(): Size;
  10412. /**
  10413. * True if the current Size and the given one width and height are strictly equal.
  10414. * @param other the other size to compare against
  10415. * @returns True if the current Size and the given one width and height are strictly equal.
  10416. */
  10417. equals(other: Size): boolean;
  10418. /**
  10419. * The surface of the Size : width * height (float).
  10420. */
  10421. get surface(): number;
  10422. /**
  10423. * Create a new size of zero
  10424. * @returns a new Size set to (0.0, 0.0)
  10425. */
  10426. static Zero(): Size;
  10427. /**
  10428. * Sums the width and height of two sizes
  10429. * @param otherSize size to add to this size
  10430. * @returns a new Size set as the addition result of the current Size and the given one.
  10431. */
  10432. add(otherSize: Size): Size;
  10433. /**
  10434. * Subtracts the width and height of two
  10435. * @param otherSize size to subtract to this size
  10436. * @returns a new Size set as the subtraction result of the given one from the current Size.
  10437. */
  10438. subtract(otherSize: Size): Size;
  10439. /**
  10440. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  10441. * @param start starting size to lerp between
  10442. * @param end end size to lerp between
  10443. * @param amount amount to lerp between the start and end values
  10444. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  10445. */
  10446. static Lerp(start: Size, end: Size, amount: number): Size;
  10447. }
  10448. }
  10449. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  10450. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10451. import { Nullable } from "babylonjs/types";
  10452. module "babylonjs/Engines/thinEngine" {
  10453. interface ThinEngine {
  10454. /**
  10455. * Creates a dynamic texture
  10456. * @param width defines the width of the texture
  10457. * @param height defines the height of the texture
  10458. * @param generateMipMaps defines if the engine should generate the mip levels
  10459. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10460. * @returns the dynamic texture inside an InternalTexture
  10461. */
  10462. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  10463. /**
  10464. * Update the content of a dynamic texture
  10465. * @param texture defines the texture to update
  10466. * @param canvas defines the canvas containing the source
  10467. * @param invertY defines if data must be stored with Y axis inverted
  10468. * @param premulAlpha defines if alpha is stored as premultiplied
  10469. * @param format defines the format of the data
  10470. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  10471. */
  10472. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  10473. }
  10474. }
  10475. }
  10476. declare module "babylonjs/Misc/canvasGenerator" {
  10477. /**
  10478. * Helper class used to generate a canvas to manipulate images
  10479. */
  10480. export class CanvasGenerator {
  10481. /**
  10482. * Create a new canvas (or offscreen canvas depending on the context)
  10483. * @param width defines the expected width
  10484. * @param height defines the expected height
  10485. * @return a new canvas or offscreen canvas
  10486. */
  10487. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  10488. }
  10489. }
  10490. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  10491. import { Scene } from "babylonjs/scene";
  10492. import { Texture } from "babylonjs/Materials/Textures/texture";
  10493. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  10494. /**
  10495. * A class extending Texture allowing drawing on a texture
  10496. * @see http://doc.babylonjs.com/how_to/dynamictexture
  10497. */
  10498. export class DynamicTexture extends Texture {
  10499. private _generateMipMaps;
  10500. private _canvas;
  10501. private _context;
  10502. private _engine;
  10503. /**
  10504. * Creates a DynamicTexture
  10505. * @param name defines the name of the texture
  10506. * @param options provides 3 alternatives for width and height of texture, a canvas, object with width and height properties, number for both width and height
  10507. * @param scene defines the scene where you want the texture
  10508. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  10509. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  10510. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  10511. */
  10512. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  10513. /**
  10514. * Get the current class name of the texture useful for serialization or dynamic coding.
  10515. * @returns "DynamicTexture"
  10516. */
  10517. getClassName(): string;
  10518. /**
  10519. * Gets the current state of canRescale
  10520. */
  10521. get canRescale(): boolean;
  10522. private _recreate;
  10523. /**
  10524. * Scales the texture
  10525. * @param ratio the scale factor to apply to both width and height
  10526. */
  10527. scale(ratio: number): void;
  10528. /**
  10529. * Resizes the texture
  10530. * @param width the new width
  10531. * @param height the new height
  10532. */
  10533. scaleTo(width: number, height: number): void;
  10534. /**
  10535. * Gets the context of the canvas used by the texture
  10536. * @returns the canvas context of the dynamic texture
  10537. */
  10538. getContext(): CanvasRenderingContext2D;
  10539. /**
  10540. * Clears the texture
  10541. */
  10542. clear(): void;
  10543. /**
  10544. * Updates the texture
  10545. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10546. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  10547. */
  10548. update(invertY?: boolean, premulAlpha?: boolean): void;
  10549. /**
  10550. * Draws text onto the texture
  10551. * @param text defines the text to be drawn
  10552. * @param x defines the placement of the text from the left
  10553. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  10554. * @param font defines the font to be used with font-style, font-size, font-name
  10555. * @param color defines the color used for the text
  10556. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  10557. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  10558. * @param update defines whether texture is immediately update (default is true)
  10559. */
  10560. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  10561. /**
  10562. * Clones the texture
  10563. * @returns the clone of the texture.
  10564. */
  10565. clone(): DynamicTexture;
  10566. /**
  10567. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  10568. * @returns a serialized dynamic texture object
  10569. */
  10570. serialize(): any;
  10571. /** @hidden */
  10572. _rebuild(): void;
  10573. }
  10574. }
  10575. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  10576. import { Nullable } from "babylonjs/types";
  10577. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10578. import { Scene } from "babylonjs/scene";
  10579. module "babylonjs/Engines/engine" {
  10580. interface Engine {
  10581. /**
  10582. * Creates a raw texture
  10583. * @param data defines the data to store in the texture
  10584. * @param width defines the width of the texture
  10585. * @param height defines the height of the texture
  10586. * @param format defines the format of the data
  10587. * @param generateMipMaps defines if the engine should generate the mip levels
  10588. * @param invertY defines if data must be stored with Y axis inverted
  10589. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  10590. * @param compression defines the compression used (null by default)
  10591. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10592. * @returns the raw texture inside an InternalTexture
  10593. */
  10594. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  10595. /**
  10596. * Update a raw texture
  10597. * @param texture defines the texture to update
  10598. * @param data defines the data to store in the texture
  10599. * @param format defines the format of the data
  10600. * @param invertY defines if data must be stored with Y axis inverted
  10601. */
  10602. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10603. /**
  10604. * Update a raw texture
  10605. * @param texture defines the texture to update
  10606. * @param data defines the data to store in the texture
  10607. * @param format defines the format of the data
  10608. * @param invertY defines if data must be stored with Y axis inverted
  10609. * @param compression defines the compression used (null by default)
  10610. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10611. */
  10612. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  10613. /**
  10614. * Creates a new raw cube texture
  10615. * @param data defines the array of data to use to create each face
  10616. * @param size defines the size of the textures
  10617. * @param format defines the format of the data
  10618. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10619. * @param generateMipMaps defines if the engine should generate the mip levels
  10620. * @param invertY defines if data must be stored with Y axis inverted
  10621. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10622. * @param compression defines the compression used (null by default)
  10623. * @returns the cube texture as an InternalTexture
  10624. */
  10625. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  10626. /**
  10627. * Update a raw cube texture
  10628. * @param texture defines the texture to udpdate
  10629. * @param data defines the data to store
  10630. * @param format defines the data format
  10631. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10632. * @param invertY defines if data must be stored with Y axis inverted
  10633. */
  10634. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  10635. /**
  10636. * Update a raw cube texture
  10637. * @param texture defines the texture to udpdate
  10638. * @param data defines the data to store
  10639. * @param format defines the data format
  10640. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10641. * @param invertY defines if data must be stored with Y axis inverted
  10642. * @param compression defines the compression used (null by default)
  10643. */
  10644. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  10645. /**
  10646. * Update a raw cube texture
  10647. * @param texture defines the texture to udpdate
  10648. * @param data defines the data to store
  10649. * @param format defines the data format
  10650. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  10651. * @param invertY defines if data must be stored with Y axis inverted
  10652. * @param compression defines the compression used (null by default)
  10653. * @param level defines which level of the texture to update
  10654. */
  10655. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  10656. /**
  10657. * Creates a new raw cube texture from a specified url
  10658. * @param url defines the url where the data is located
  10659. * @param scene defines the current scene
  10660. * @param size defines the size of the textures
  10661. * @param format defines the format of the data
  10662. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10663. * @param noMipmap defines if the engine should avoid generating the mip levels
  10664. * @param callback defines a callback used to extract texture data from loaded data
  10665. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10666. * @param onLoad defines a callback called when texture is loaded
  10667. * @param onError defines a callback called if there is an error
  10668. * @returns the cube texture as an InternalTexture
  10669. */
  10670. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  10671. /**
  10672. * Creates a new raw cube texture from a specified url
  10673. * @param url defines the url where the data is located
  10674. * @param scene defines the current scene
  10675. * @param size defines the size of the textures
  10676. * @param format defines the format of the data
  10677. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  10678. * @param noMipmap defines if the engine should avoid generating the mip levels
  10679. * @param callback defines a callback used to extract texture data from loaded data
  10680. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  10681. * @param onLoad defines a callback called when texture is loaded
  10682. * @param onError defines a callback called if there is an error
  10683. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10684. * @param invertY defines if data must be stored with Y axis inverted
  10685. * @returns the cube texture as an InternalTexture
  10686. */
  10687. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>, samplingMode: number, invertY: boolean): InternalTexture;
  10688. /**
  10689. * Creates a new raw 3D texture
  10690. * @param data defines the data used to create the texture
  10691. * @param width defines the width of the texture
  10692. * @param height defines the height of the texture
  10693. * @param depth defines the depth of the texture
  10694. * @param format defines the format of the texture
  10695. * @param generateMipMaps defines if the engine must generate mip levels
  10696. * @param invertY defines if data must be stored with Y axis inverted
  10697. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10698. * @param compression defines the compressed used (can be null)
  10699. * @param textureType defines the compressed used (can be null)
  10700. * @returns a new raw 3D texture (stored in an InternalTexture)
  10701. */
  10702. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10703. /**
  10704. * Update a raw 3D texture
  10705. * @param texture defines the texture to update
  10706. * @param data defines the data to store
  10707. * @param format defines the data format
  10708. * @param invertY defines if data must be stored with Y axis inverted
  10709. */
  10710. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10711. /**
  10712. * Update a raw 3D texture
  10713. * @param texture defines the texture to update
  10714. * @param data defines the data to store
  10715. * @param format defines the data format
  10716. * @param invertY defines if data must be stored with Y axis inverted
  10717. * @param compression defines the used compression (can be null)
  10718. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10719. */
  10720. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10721. /**
  10722. * Creates a new raw 2D array texture
  10723. * @param data defines the data used to create the texture
  10724. * @param width defines the width of the texture
  10725. * @param height defines the height of the texture
  10726. * @param depth defines the number of layers of the texture
  10727. * @param format defines the format of the texture
  10728. * @param generateMipMaps defines if the engine must generate mip levels
  10729. * @param invertY defines if data must be stored with Y axis inverted
  10730. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  10731. * @param compression defines the compressed used (can be null)
  10732. * @param textureType defines the compressed used (can be null)
  10733. * @returns a new raw 2D array texture (stored in an InternalTexture)
  10734. */
  10735. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  10736. /**
  10737. * Update a raw 2D array texture
  10738. * @param texture defines the texture to update
  10739. * @param data defines the data to store
  10740. * @param format defines the data format
  10741. * @param invertY defines if data must be stored with Y axis inverted
  10742. */
  10743. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  10744. /**
  10745. * Update a raw 2D array texture
  10746. * @param texture defines the texture to update
  10747. * @param data defines the data to store
  10748. * @param format defines the data format
  10749. * @param invertY defines if data must be stored with Y axis inverted
  10750. * @param compression defines the used compression (can be null)
  10751. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  10752. */
  10753. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  10754. }
  10755. }
  10756. }
  10757. declare module "babylonjs/Materials/Textures/rawTexture" {
  10758. import { Scene } from "babylonjs/scene";
  10759. import { Texture } from "babylonjs/Materials/Textures/texture";
  10760. import "babylonjs/Engines/Extensions/engine.rawTexture";
  10761. /**
  10762. * Raw texture can help creating a texture directly from an array of data.
  10763. * This can be super useful if you either get the data from an uncompressed source or
  10764. * if you wish to create your texture pixel by pixel.
  10765. */
  10766. export class RawTexture extends Texture {
  10767. /**
  10768. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10769. */
  10770. format: number;
  10771. private _engine;
  10772. /**
  10773. * Instantiates a new RawTexture.
  10774. * Raw texture can help creating a texture directly from an array of data.
  10775. * This can be super useful if you either get the data from an uncompressed source or
  10776. * if you wish to create your texture pixel by pixel.
  10777. * @param data define the array of data to use to create the texture
  10778. * @param width define the width of the texture
  10779. * @param height define the height of the texture
  10780. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10781. * @param scene define the scene the texture belongs to
  10782. * @param generateMipMaps define whether mip maps should be generated or not
  10783. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10784. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10785. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10786. */
  10787. constructor(data: ArrayBufferView, width: number, height: number,
  10788. /**
  10789. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  10790. */
  10791. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  10792. /**
  10793. * Updates the texture underlying data.
  10794. * @param data Define the new data of the texture
  10795. */
  10796. update(data: ArrayBufferView): void;
  10797. /**
  10798. * Creates a luminance texture from some data.
  10799. * @param data Define the texture data
  10800. * @param width Define the width of the texture
  10801. * @param height Define the height of the texture
  10802. * @param scene Define the scene the texture belongs to
  10803. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10804. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10805. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10806. * @returns the luminance texture
  10807. */
  10808. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10809. /**
  10810. * Creates a luminance alpha texture from some data.
  10811. * @param data Define the texture data
  10812. * @param width Define the width of the texture
  10813. * @param height Define the height of the texture
  10814. * @param scene Define the scene the texture belongs to
  10815. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10816. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10817. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10818. * @returns the luminance alpha texture
  10819. */
  10820. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10821. /**
  10822. * Creates an alpha texture from some data.
  10823. * @param data Define the texture data
  10824. * @param width Define the width of the texture
  10825. * @param height Define the height of the texture
  10826. * @param scene Define the scene the texture belongs to
  10827. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10828. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10829. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10830. * @returns the alpha texture
  10831. */
  10832. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  10833. /**
  10834. * Creates a RGB texture from some data.
  10835. * @param data Define the texture data
  10836. * @param width Define the width of the texture
  10837. * @param height Define the height of the texture
  10838. * @param scene Define the scene the texture belongs to
  10839. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10840. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10841. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10842. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10843. * @returns the RGB alpha texture
  10844. */
  10845. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10846. /**
  10847. * Creates a RGBA texture from some data.
  10848. * @param data Define the texture data
  10849. * @param width Define the width of the texture
  10850. * @param height Define the height of the texture
  10851. * @param scene Define the scene the texture belongs to
  10852. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10853. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10854. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10855. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10856. * @returns the RGBA texture
  10857. */
  10858. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10859. /**
  10860. * Creates a R texture from some data.
  10861. * @param data Define the texture data
  10862. * @param width Define the width of the texture
  10863. * @param height Define the height of the texture
  10864. * @param scene Define the scene the texture belongs to
  10865. * @param generateMipMaps Define whether or not to create mip maps for the texture
  10866. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  10867. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  10868. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  10869. * @returns the R texture
  10870. */
  10871. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  10872. }
  10873. }
  10874. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  10875. import { Scene } from "babylonjs/scene";
  10876. import { ISceneComponent } from "babylonjs/sceneComponent";
  10877. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  10878. module "babylonjs/abstractScene" {
  10879. interface AbstractScene {
  10880. /**
  10881. * The list of procedural textures added to the scene
  10882. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10883. */
  10884. proceduralTextures: Array<ProceduralTexture>;
  10885. }
  10886. }
  10887. /**
  10888. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  10889. * in a given scene.
  10890. */
  10891. export class ProceduralTextureSceneComponent implements ISceneComponent {
  10892. /**
  10893. * The component name helpfull to identify the component in the list of scene components.
  10894. */
  10895. readonly name: string;
  10896. /**
  10897. * The scene the component belongs to.
  10898. */
  10899. scene: Scene;
  10900. /**
  10901. * Creates a new instance of the component for the given scene
  10902. * @param scene Defines the scene to register the component in
  10903. */
  10904. constructor(scene: Scene);
  10905. /**
  10906. * Registers the component in a given scene
  10907. */
  10908. register(): void;
  10909. /**
  10910. * Rebuilds the elements related to this component in case of
  10911. * context lost for instance.
  10912. */
  10913. rebuild(): void;
  10914. /**
  10915. * Disposes the component and the associated ressources.
  10916. */
  10917. dispose(): void;
  10918. private _beforeClear;
  10919. }
  10920. }
  10921. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  10922. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  10923. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  10924. module "babylonjs/Engines/thinEngine" {
  10925. interface ThinEngine {
  10926. /**
  10927. * Creates a new render target cube texture
  10928. * @param size defines the size of the texture
  10929. * @param options defines the options used to create the texture
  10930. * @returns a new render target cube texture stored in an InternalTexture
  10931. */
  10932. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  10933. }
  10934. }
  10935. }
  10936. declare module "babylonjs/Shaders/procedural.vertex" {
  10937. /** @hidden */
  10938. export var proceduralVertexShader: {
  10939. name: string;
  10940. shader: string;
  10941. };
  10942. }
  10943. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  10944. import { Observable } from "babylonjs/Misc/observable";
  10945. import { Nullable } from "babylonjs/types";
  10946. import { Scene } from "babylonjs/scene";
  10947. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10948. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  10949. import { Effect } from "babylonjs/Materials/effect";
  10950. import { Texture } from "babylonjs/Materials/Textures/texture";
  10951. import "babylonjs/Engines/Extensions/engine.renderTarget";
  10952. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  10953. import "babylonjs/Shaders/procedural.vertex";
  10954. /**
  10955. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes calmpler' images.
  10956. * This is the base class of any Procedural texture and contains most of the shareable code.
  10957. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  10958. */
  10959. export class ProceduralTexture extends Texture {
  10960. isCube: boolean;
  10961. /**
  10962. * Define if the texture is enabled or not (disabled texture will not render)
  10963. */
  10964. isEnabled: boolean;
  10965. /**
  10966. * Define if the texture must be cleared before rendering (default is true)
  10967. */
  10968. autoClear: boolean;
  10969. /**
  10970. * Callback called when the texture is generated
  10971. */
  10972. onGenerated: () => void;
  10973. /**
  10974. * Event raised when the texture is generated
  10975. */
  10976. onGeneratedObservable: Observable<ProceduralTexture>;
  10977. /** @hidden */
  10978. _generateMipMaps: boolean;
  10979. /** @hidden **/
  10980. _effect: Effect;
  10981. /** @hidden */
  10982. _textures: {
  10983. [key: string]: Texture;
  10984. };
  10985. private _size;
  10986. private _currentRefreshId;
  10987. private _frameId;
  10988. private _refreshRate;
  10989. private _vertexBuffers;
  10990. private _indexBuffer;
  10991. private _uniforms;
  10992. private _samplers;
  10993. private _fragment;
  10994. private _floats;
  10995. private _ints;
  10996. private _floatsArrays;
  10997. private _colors3;
  10998. private _colors4;
  10999. private _vectors2;
  11000. private _vectors3;
  11001. private _matrices;
  11002. private _fallbackTexture;
  11003. private _fallbackTextureUsed;
  11004. private _engine;
  11005. private _cachedDefines;
  11006. private _contentUpdateId;
  11007. private _contentData;
  11008. /**
  11009. * Instantiates a new procedural texture.
  11010. * Procedural texturing is a way to programmatically create a texture. There are 2 types of procedural textures: code-only, and code that references some classic 2D images, sometimes called 'refMaps' or 'sampler' images.
  11011. * This is the base class of any Procedural texture and contains most of the shareable code.
  11012. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11013. * @param name Define the name of the texture
  11014. * @param size Define the size of the texture to create
  11015. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11016. * @param scene Define the scene the texture belongs to
  11017. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11018. * @param generateMipMaps Define if the texture should creates mip maps or not
  11019. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11020. */
  11021. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  11022. /**
  11023. * The effect that is created when initializing the post process.
  11024. * @returns The created effect corresponding the the postprocess.
  11025. */
  11026. getEffect(): Effect;
  11027. /**
  11028. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11029. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11030. */
  11031. getContent(): Nullable<ArrayBufferView>;
  11032. private _createIndexBuffer;
  11033. /** @hidden */
  11034. _rebuild(): void;
  11035. /**
  11036. * Resets the texture in order to recreate its associated resources.
  11037. * This can be called in case of context loss
  11038. */
  11039. reset(): void;
  11040. protected _getDefines(): string;
  11041. /**
  11042. * Is the texture ready to be used ? (rendered at least once)
  11043. * @returns true if ready, otherwise, false.
  11044. */
  11045. isReady(): boolean;
  11046. /**
  11047. * Resets the refresh counter of the texture and start bak from scratch.
  11048. * Could be useful to regenerate the texture if it is setup to render only once.
  11049. */
  11050. resetRefreshCounter(): void;
  11051. /**
  11052. * Set the fragment shader to use in order to render the texture.
  11053. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11054. */
  11055. setFragment(fragment: any): void;
  11056. /**
  11057. * Define the refresh rate of the texture or the rendering frequency.
  11058. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11059. */
  11060. get refreshRate(): number;
  11061. set refreshRate(value: number);
  11062. /** @hidden */
  11063. _shouldRender(): boolean;
  11064. /**
  11065. * Get the size the texture is rendering at.
  11066. * @returns the size (texture is always squared)
  11067. */
  11068. getRenderSize(): number;
  11069. /**
  11070. * Resize the texture to new value.
  11071. * @param size Define the new size the texture should have
  11072. * @param generateMipMaps Define whether the new texture should create mip maps
  11073. */
  11074. resize(size: number, generateMipMaps: boolean): void;
  11075. private _checkUniform;
  11076. /**
  11077. * Set a texture in the shader program used to render.
  11078. * @param name Define the name of the uniform samplers as defined in the shader
  11079. * @param texture Define the texture to bind to this sampler
  11080. * @return the texture itself allowing "fluent" like uniform updates
  11081. */
  11082. setTexture(name: string, texture: Texture): ProceduralTexture;
  11083. /**
  11084. * Set a float in the shader.
  11085. * @param name Define the name of the uniform as defined in the shader
  11086. * @param value Define the value to give to the uniform
  11087. * @return the texture itself allowing "fluent" like uniform updates
  11088. */
  11089. setFloat(name: string, value: number): ProceduralTexture;
  11090. /**
  11091. * Set a int in the shader.
  11092. * @param name Define the name of the uniform as defined in the shader
  11093. * @param value Define the value to give to the uniform
  11094. * @return the texture itself allowing "fluent" like uniform updates
  11095. */
  11096. setInt(name: string, value: number): ProceduralTexture;
  11097. /**
  11098. * Set an array of floats in the shader.
  11099. * @param name Define the name of the uniform as defined in the shader
  11100. * @param value Define the value to give to the uniform
  11101. * @return the texture itself allowing "fluent" like uniform updates
  11102. */
  11103. setFloats(name: string, value: number[]): ProceduralTexture;
  11104. /**
  11105. * Set a vec3 in the shader from a Color3.
  11106. * @param name Define the name of the uniform as defined in the shader
  11107. * @param value Define the value to give to the uniform
  11108. * @return the texture itself allowing "fluent" like uniform updates
  11109. */
  11110. setColor3(name: string, value: Color3): ProceduralTexture;
  11111. /**
  11112. * Set a vec4 in the shader from a Color4.
  11113. * @param name Define the name of the uniform as defined in the shader
  11114. * @param value Define the value to give to the uniform
  11115. * @return the texture itself allowing "fluent" like uniform updates
  11116. */
  11117. setColor4(name: string, value: Color4): ProceduralTexture;
  11118. /**
  11119. * Set a vec2 in the shader from a Vector2.
  11120. * @param name Define the name of the uniform as defined in the shader
  11121. * @param value Define the value to give to the uniform
  11122. * @return the texture itself allowing "fluent" like uniform updates
  11123. */
  11124. setVector2(name: string, value: Vector2): ProceduralTexture;
  11125. /**
  11126. * Set a vec3 in the shader from a Vector3.
  11127. * @param name Define the name of the uniform as defined in the shader
  11128. * @param value Define the value to give to the uniform
  11129. * @return the texture itself allowing "fluent" like uniform updates
  11130. */
  11131. setVector3(name: string, value: Vector3): ProceduralTexture;
  11132. /**
  11133. * Set a mat4 in the shader from a MAtrix.
  11134. * @param name Define the name of the uniform as defined in the shader
  11135. * @param value Define the value to give to the uniform
  11136. * @return the texture itself allowing "fluent" like uniform updates
  11137. */
  11138. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11139. /**
  11140. * Render the texture to its associated render target.
  11141. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11142. */
  11143. render(useCameraPostProcess?: boolean): void;
  11144. /**
  11145. * Clone the texture.
  11146. * @returns the cloned texture
  11147. */
  11148. clone(): ProceduralTexture;
  11149. /**
  11150. * Dispose the texture and release its asoociated resources.
  11151. */
  11152. dispose(): void;
  11153. }
  11154. }
  11155. declare module "babylonjs/Particles/baseParticleSystem" {
  11156. import { Nullable } from "babylonjs/types";
  11157. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  11158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11159. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  11160. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11161. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  11162. import { Scene } from "babylonjs/scene";
  11163. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  11164. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  11165. import { Texture } from "babylonjs/Materials/Textures/texture";
  11166. import { Color4 } from "babylonjs/Maths/math.color";
  11167. import { Animation } from "babylonjs/Animations/animation";
  11168. /**
  11169. * This represents the base class for particle system in Babylon.
  11170. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11171. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11172. * @example https://doc.babylonjs.com/babylon101/particles
  11173. */
  11174. export class BaseParticleSystem {
  11175. /**
  11176. * Source color is added to the destination color without alpha affecting the result
  11177. */
  11178. static BLENDMODE_ONEONE: number;
  11179. /**
  11180. * Blend current color and particle color using particle’s alpha
  11181. */
  11182. static BLENDMODE_STANDARD: number;
  11183. /**
  11184. * Add current color and particle color multiplied by particle’s alpha
  11185. */
  11186. static BLENDMODE_ADD: number;
  11187. /**
  11188. * Multiply current color with particle color
  11189. */
  11190. static BLENDMODE_MULTIPLY: number;
  11191. /**
  11192. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11193. */
  11194. static BLENDMODE_MULTIPLYADD: number;
  11195. /**
  11196. * List of animations used by the particle system.
  11197. */
  11198. animations: Animation[];
  11199. /**
  11200. * The id of the Particle system.
  11201. */
  11202. id: string;
  11203. /**
  11204. * The friendly name of the Particle system.
  11205. */
  11206. name: string;
  11207. /**
  11208. * The rendering group used by the Particle system to chose when to render.
  11209. */
  11210. renderingGroupId: number;
  11211. /**
  11212. * The emitter represents the Mesh or position we are attaching the particle system to.
  11213. */
  11214. emitter: Nullable<AbstractMesh | Vector3>;
  11215. /**
  11216. * The maximum number of particles to emit per frame
  11217. */
  11218. emitRate: number;
  11219. /**
  11220. * If you want to launch only a few particles at once, that can be done, as well.
  11221. */
  11222. manualEmitCount: number;
  11223. /**
  11224. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  11225. */
  11226. updateSpeed: number;
  11227. /**
  11228. * The amount of time the particle system is running (depends of the overall update speed).
  11229. */
  11230. targetStopDuration: number;
  11231. /**
  11232. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  11233. */
  11234. disposeOnStop: boolean;
  11235. /**
  11236. * Minimum power of emitting particles.
  11237. */
  11238. minEmitPower: number;
  11239. /**
  11240. * Maximum power of emitting particles.
  11241. */
  11242. maxEmitPower: number;
  11243. /**
  11244. * Minimum life time of emitting particles.
  11245. */
  11246. minLifeTime: number;
  11247. /**
  11248. * Maximum life time of emitting particles.
  11249. */
  11250. maxLifeTime: number;
  11251. /**
  11252. * Minimum Size of emitting particles.
  11253. */
  11254. minSize: number;
  11255. /**
  11256. * Maximum Size of emitting particles.
  11257. */
  11258. maxSize: number;
  11259. /**
  11260. * Minimum scale of emitting particles on X axis.
  11261. */
  11262. minScaleX: number;
  11263. /**
  11264. * Maximum scale of emitting particles on X axis.
  11265. */
  11266. maxScaleX: number;
  11267. /**
  11268. * Minimum scale of emitting particles on Y axis.
  11269. */
  11270. minScaleY: number;
  11271. /**
  11272. * Maximum scale of emitting particles on Y axis.
  11273. */
  11274. maxScaleY: number;
  11275. /**
  11276. * Gets or sets the minimal initial rotation in radians.
  11277. */
  11278. minInitialRotation: number;
  11279. /**
  11280. * Gets or sets the maximal initial rotation in radians.
  11281. */
  11282. maxInitialRotation: number;
  11283. /**
  11284. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  11285. */
  11286. minAngularSpeed: number;
  11287. /**
  11288. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  11289. */
  11290. maxAngularSpeed: number;
  11291. /**
  11292. * The texture used to render each particle. (this can be a spritesheet)
  11293. */
  11294. particleTexture: Nullable<Texture>;
  11295. /**
  11296. * The layer mask we are rendering the particles through.
  11297. */
  11298. layerMask: number;
  11299. /**
  11300. * This can help using your own shader to render the particle system.
  11301. * The according effect will be created
  11302. */
  11303. customShader: any;
  11304. /**
  11305. * By default particle system starts as soon as they are created. This prevents the
  11306. * automatic start to happen and let you decide when to start emitting particles.
  11307. */
  11308. preventAutoStart: boolean;
  11309. private _noiseTexture;
  11310. /**
  11311. * Gets or sets a texture used to add random noise to particle positions
  11312. */
  11313. get noiseTexture(): Nullable<ProceduralTexture>;
  11314. set noiseTexture(value: Nullable<ProceduralTexture>);
  11315. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  11316. noiseStrength: Vector3;
  11317. /**
  11318. * Callback triggered when the particle animation is ending.
  11319. */
  11320. onAnimationEnd: Nullable<() => void>;
  11321. /**
  11322. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  11323. */
  11324. blendMode: number;
  11325. /**
  11326. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  11327. * to override the particles.
  11328. */
  11329. forceDepthWrite: boolean;
  11330. /** Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0 */
  11331. preWarmCycles: number;
  11332. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  11333. preWarmStepOffset: number;
  11334. /**
  11335. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  11336. */
  11337. spriteCellChangeSpeed: number;
  11338. /**
  11339. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  11340. */
  11341. startSpriteCellID: number;
  11342. /**
  11343. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  11344. */
  11345. endSpriteCellID: number;
  11346. /**
  11347. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  11348. */
  11349. spriteCellWidth: number;
  11350. /**
  11351. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  11352. */
  11353. spriteCellHeight: number;
  11354. /**
  11355. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  11356. */
  11357. spriteRandomStartCell: boolean;
  11358. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  11359. translationPivot: Vector2;
  11360. /** @hidden */
  11361. protected _isAnimationSheetEnabled: boolean;
  11362. /**
  11363. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  11364. */
  11365. beginAnimationOnStart: boolean;
  11366. /**
  11367. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  11368. */
  11369. beginAnimationFrom: number;
  11370. /**
  11371. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  11372. */
  11373. beginAnimationTo: number;
  11374. /**
  11375. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  11376. */
  11377. beginAnimationLoop: boolean;
  11378. /**
  11379. * Gets or sets a world offset applied to all particles
  11380. */
  11381. worldOffset: Vector3;
  11382. /**
  11383. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  11384. */
  11385. get isAnimationSheetEnabled(): boolean;
  11386. set isAnimationSheetEnabled(value: boolean);
  11387. /**
  11388. * Get hosting scene
  11389. * @returns the scene
  11390. */
  11391. getScene(): Scene;
  11392. /**
  11393. * You can use gravity if you want to give an orientation to your particles.
  11394. */
  11395. gravity: Vector3;
  11396. protected _colorGradients: Nullable<Array<ColorGradient>>;
  11397. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  11398. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  11399. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  11400. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  11401. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  11402. protected _dragGradients: Nullable<Array<FactorGradient>>;
  11403. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  11404. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  11405. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  11406. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  11407. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  11408. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  11409. /**
  11410. * Defines the delay in milliseconds before starting the system (0 by default)
  11411. */
  11412. startDelay: number;
  11413. /**
  11414. * Gets the current list of drag gradients.
  11415. * You must use addDragGradient and removeDragGradient to udpate this list
  11416. * @returns the list of drag gradients
  11417. */
  11418. getDragGradients(): Nullable<Array<FactorGradient>>;
  11419. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  11420. limitVelocityDamping: number;
  11421. /**
  11422. * Gets the current list of limit velocity gradients.
  11423. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  11424. * @returns the list of limit velocity gradients
  11425. */
  11426. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  11427. /**
  11428. * Gets the current list of color gradients.
  11429. * You must use addColorGradient and removeColorGradient to udpate this list
  11430. * @returns the list of color gradients
  11431. */
  11432. getColorGradients(): Nullable<Array<ColorGradient>>;
  11433. /**
  11434. * Gets the current list of size gradients.
  11435. * You must use addSizeGradient and removeSizeGradient to udpate this list
  11436. * @returns the list of size gradients
  11437. */
  11438. getSizeGradients(): Nullable<Array<FactorGradient>>;
  11439. /**
  11440. * Gets the current list of color remap gradients.
  11441. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  11442. * @returns the list of color remap gradients
  11443. */
  11444. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  11445. /**
  11446. * Gets the current list of alpha remap gradients.
  11447. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  11448. * @returns the list of alpha remap gradients
  11449. */
  11450. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  11451. /**
  11452. * Gets the current list of life time gradients.
  11453. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  11454. * @returns the list of life time gradients
  11455. */
  11456. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  11457. /**
  11458. * Gets the current list of angular speed gradients.
  11459. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  11460. * @returns the list of angular speed gradients
  11461. */
  11462. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  11463. /**
  11464. * Gets the current list of velocity gradients.
  11465. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  11466. * @returns the list of velocity gradients
  11467. */
  11468. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  11469. /**
  11470. * Gets the current list of start size gradients.
  11471. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  11472. * @returns the list of start size gradients
  11473. */
  11474. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  11475. /**
  11476. * Gets the current list of emit rate gradients.
  11477. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  11478. * @returns the list of emit rate gradients
  11479. */
  11480. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  11481. /**
  11482. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11483. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11484. */
  11485. get direction1(): Vector3;
  11486. set direction1(value: Vector3);
  11487. /**
  11488. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  11489. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11490. */
  11491. get direction2(): Vector3;
  11492. set direction2(value: Vector3);
  11493. /**
  11494. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11495. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11496. */
  11497. get minEmitBox(): Vector3;
  11498. set minEmitBox(value: Vector3);
  11499. /**
  11500. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  11501. * This only works when particleEmitterTyps is a BoxParticleEmitter
  11502. */
  11503. get maxEmitBox(): Vector3;
  11504. set maxEmitBox(value: Vector3);
  11505. /**
  11506. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11507. */
  11508. color1: Color4;
  11509. /**
  11510. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  11511. */
  11512. color2: Color4;
  11513. /**
  11514. * Color the particle will have at the end of its lifetime
  11515. */
  11516. colorDead: Color4;
  11517. /**
  11518. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  11519. */
  11520. textureMask: Color4;
  11521. /**
  11522. * The particle emitter type defines the emitter used by the particle system.
  11523. * It can be for example box, sphere, or cone...
  11524. */
  11525. particleEmitterType: IParticleEmitterType;
  11526. /** @hidden */
  11527. _isSubEmitter: boolean;
  11528. /**
  11529. * Gets or sets the billboard mode to use when isBillboardBased = true.
  11530. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  11531. */
  11532. billboardMode: number;
  11533. protected _isBillboardBased: boolean;
  11534. /**
  11535. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  11536. */
  11537. get isBillboardBased(): boolean;
  11538. set isBillboardBased(value: boolean);
  11539. /**
  11540. * The scene the particle system belongs to.
  11541. */
  11542. protected _scene: Scene;
  11543. /**
  11544. * Local cache of defines for image processing.
  11545. */
  11546. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  11547. /**
  11548. * Default configuration related to image processing available in the standard Material.
  11549. */
  11550. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  11551. /**
  11552. * Gets the image processing configuration used either in this material.
  11553. */
  11554. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  11555. /**
  11556. * Sets the Default image processing configuration used either in the this material.
  11557. *
  11558. * If sets to null, the scene one is in use.
  11559. */
  11560. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  11561. /**
  11562. * Attaches a new image processing configuration to the Standard Material.
  11563. * @param configuration
  11564. */
  11565. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  11566. /** @hidden */
  11567. protected _reset(): void;
  11568. /** @hidden */
  11569. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  11570. /**
  11571. * Instantiates a particle system.
  11572. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11573. * @param name The name of the particle system
  11574. */
  11575. constructor(name: string);
  11576. /**
  11577. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  11578. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11579. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11580. * @returns the emitter
  11581. */
  11582. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  11583. /**
  11584. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  11585. * @param radius The radius of the hemisphere to emit from
  11586. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11587. * @returns the emitter
  11588. */
  11589. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  11590. /**
  11591. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  11592. * @param radius The radius of the sphere to emit from
  11593. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  11594. * @returns the emitter
  11595. */
  11596. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  11597. /**
  11598. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  11599. * @param radius The radius of the sphere to emit from
  11600. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  11601. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  11602. * @returns the emitter
  11603. */
  11604. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  11605. /**
  11606. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  11607. * @param radius The radius of the emission cylinder
  11608. * @param height The height of the emission cylinder
  11609. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  11610. * @param directionRandomizer How much to randomize the particle direction [0-1]
  11611. * @returns the emitter
  11612. */
  11613. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  11614. /**
  11615. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  11616. * @param radius The radius of the cylinder to emit from
  11617. * @param height The height of the emission cylinder
  11618. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  11619. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  11620. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  11621. * @returns the emitter
  11622. */
  11623. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  11624. /**
  11625. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  11626. * @param radius The radius of the cone to emit from
  11627. * @param angle The base angle of the cone
  11628. * @returns the emitter
  11629. */
  11630. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  11631. /**
  11632. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  11633. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  11634. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  11635. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11636. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  11637. * @returns the emitter
  11638. */
  11639. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  11640. }
  11641. }
  11642. declare module "babylonjs/Particles/subEmitter" {
  11643. import { Scene } from "babylonjs/scene";
  11644. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  11645. /**
  11646. * Type of sub emitter
  11647. */
  11648. export enum SubEmitterType {
  11649. /**
  11650. * Attached to the particle over it's lifetime
  11651. */
  11652. ATTACHED = 0,
  11653. /**
  11654. * Created when the particle dies
  11655. */
  11656. END = 1
  11657. }
  11658. /**
  11659. * Sub emitter class used to emit particles from an existing particle
  11660. */
  11661. export class SubEmitter {
  11662. /**
  11663. * the particle system to be used by the sub emitter
  11664. */
  11665. particleSystem: ParticleSystem;
  11666. /**
  11667. * Type of the submitter (Default: END)
  11668. */
  11669. type: SubEmitterType;
  11670. /**
  11671. * If the particle should inherit the direction from the particle it's attached to. (+Y will face the direction the particle is moving) (Default: false)
  11672. * Note: This only is supported when using an emitter of type Mesh
  11673. */
  11674. inheritDirection: boolean;
  11675. /**
  11676. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  11677. */
  11678. inheritedVelocityAmount: number;
  11679. /**
  11680. * Creates a sub emitter
  11681. * @param particleSystem the particle system to be used by the sub emitter
  11682. */
  11683. constructor(
  11684. /**
  11685. * the particle system to be used by the sub emitter
  11686. */
  11687. particleSystem: ParticleSystem);
  11688. /**
  11689. * Clones the sub emitter
  11690. * @returns the cloned sub emitter
  11691. */
  11692. clone(): SubEmitter;
  11693. /**
  11694. * Serialize current object to a JSON object
  11695. * @returns the serialized object
  11696. */
  11697. serialize(): any;
  11698. /** @hidden */
  11699. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  11700. /**
  11701. * Creates a new SubEmitter from a serialized JSON version
  11702. * @param serializationObject defines the JSON object to read from
  11703. * @param scene defines the hosting scene
  11704. * @param rootUrl defines the rootUrl for data loading
  11705. * @returns a new SubEmitter
  11706. */
  11707. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  11708. /** Release associated resources */
  11709. dispose(): void;
  11710. }
  11711. }
  11712. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  11713. /** @hidden */
  11714. export var imageProcessingDeclaration: {
  11715. name: string;
  11716. shader: string;
  11717. };
  11718. }
  11719. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  11720. /** @hidden */
  11721. export var imageProcessingFunctions: {
  11722. name: string;
  11723. shader: string;
  11724. };
  11725. }
  11726. declare module "babylonjs/Shaders/particles.fragment" {
  11727. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  11728. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  11729. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  11730. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  11731. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  11732. /** @hidden */
  11733. export var particlesPixelShader: {
  11734. name: string;
  11735. shader: string;
  11736. };
  11737. }
  11738. declare module "babylonjs/Shaders/particles.vertex" {
  11739. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  11740. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  11741. /** @hidden */
  11742. export var particlesVertexShader: {
  11743. name: string;
  11744. shader: string;
  11745. };
  11746. }
  11747. declare module "babylonjs/Particles/particleSystem" {
  11748. import { Nullable } from "babylonjs/types";
  11749. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  11750. import { Observable } from "babylonjs/Misc/observable";
  11751. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  11752. import { Effect } from "babylonjs/Materials/effect";
  11753. import { Scene, IDisposable } from "babylonjs/scene";
  11754. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  11755. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  11756. import { Particle } from "babylonjs/Particles/particle";
  11757. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  11758. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  11759. import "babylonjs/Shaders/particles.fragment";
  11760. import "babylonjs/Shaders/particles.vertex";
  11761. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11762. /**
  11763. * This represents a particle system in Babylon.
  11764. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11765. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11766. * @example https://doc.babylonjs.com/babylon101/particles
  11767. */
  11768. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  11769. /**
  11770. * Billboard mode will only apply to Y axis
  11771. */
  11772. static readonly BILLBOARDMODE_Y: number;
  11773. /**
  11774. * Billboard mode will apply to all axes
  11775. */
  11776. static readonly BILLBOARDMODE_ALL: number;
  11777. /**
  11778. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  11779. */
  11780. static readonly BILLBOARDMODE_STRETCHED: number;
  11781. /**
  11782. * This function can be defined to provide custom update for active particles.
  11783. * This function will be called instead of regular update (age, position, color, etc.).
  11784. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  11785. */
  11786. updateFunction: (particles: Particle[]) => void;
  11787. private _emitterWorldMatrix;
  11788. /**
  11789. * This function can be defined to specify initial direction for every new particle.
  11790. * It by default use the emitterType defined function
  11791. */
  11792. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  11793. /**
  11794. * This function can be defined to specify initial position for every new particle.
  11795. * It by default use the emitterType defined function
  11796. */
  11797. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  11798. /**
  11799. * @hidden
  11800. */
  11801. _inheritedVelocityOffset: Vector3;
  11802. /**
  11803. * An event triggered when the system is disposed
  11804. */
  11805. onDisposeObservable: Observable<ParticleSystem>;
  11806. private _onDisposeObserver;
  11807. /**
  11808. * Sets a callback that will be triggered when the system is disposed
  11809. */
  11810. set onDispose(callback: () => void);
  11811. private _particles;
  11812. private _epsilon;
  11813. private _capacity;
  11814. private _stockParticles;
  11815. private _newPartsExcess;
  11816. private _vertexData;
  11817. private _vertexBuffer;
  11818. private _vertexBuffers;
  11819. private _spriteBuffer;
  11820. private _indexBuffer;
  11821. private _effect;
  11822. private _customEffect;
  11823. private _cachedDefines;
  11824. private _scaledColorStep;
  11825. private _colorDiff;
  11826. private _scaledDirection;
  11827. private _scaledGravity;
  11828. private _currentRenderId;
  11829. private _alive;
  11830. private _useInstancing;
  11831. private _started;
  11832. private _stopped;
  11833. private _actualFrame;
  11834. private _scaledUpdateSpeed;
  11835. private _vertexBufferSize;
  11836. /** @hidden */
  11837. _currentEmitRateGradient: Nullable<FactorGradient>;
  11838. /** @hidden */
  11839. _currentEmitRate1: number;
  11840. /** @hidden */
  11841. _currentEmitRate2: number;
  11842. /** @hidden */
  11843. _currentStartSizeGradient: Nullable<FactorGradient>;
  11844. /** @hidden */
  11845. _currentStartSize1: number;
  11846. /** @hidden */
  11847. _currentStartSize2: number;
  11848. private readonly _rawTextureWidth;
  11849. private _rampGradientsTexture;
  11850. private _useRampGradients;
  11851. /** Gets or sets a boolean indicating that ramp gradients must be used
  11852. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  11853. */
  11854. get useRampGradients(): boolean;
  11855. set useRampGradients(value: boolean);
  11856. /**
  11857. * The Sub-emitters templates that will be used to generate the sub particle system to be associated with the system, this property is used by the root particle system only.
  11858. * When a particle is spawned, an array will be chosen at random and all the emitters in that array will be attached to the particle. (Default: [])
  11859. */
  11860. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  11861. private _subEmitters;
  11862. /**
  11863. * @hidden
  11864. * If the particle systems emitter should be disposed when the particle system is disposed
  11865. */
  11866. _disposeEmitterOnDispose: boolean;
  11867. /**
  11868. * The current active Sub-systems, this property is used by the root particle system only.
  11869. */
  11870. activeSubSystems: Array<ParticleSystem>;
  11871. private _rootParticleSystem;
  11872. /**
  11873. * Gets the current list of active particles
  11874. */
  11875. get particles(): Particle[];
  11876. /**
  11877. * Returns the string "ParticleSystem"
  11878. * @returns a string containing the class name
  11879. */
  11880. getClassName(): string;
  11881. /**
  11882. * Instantiates a particle system.
  11883. * Particles are often small sprites used to simulate hard-to-reproduce phenomena like fire, smoke, water, or abstract visual effects like magic glitter and faery dust.
  11884. * @param name The name of the particle system
  11885. * @param capacity The max number of particles alive at the same time
  11886. * @param scene The scene the particle system belongs to
  11887. * @param customEffect a custom effect used to change the way particles are rendered by default
  11888. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  11889. * @param epsilon Offset used to render the particles
  11890. */
  11891. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  11892. private _addFactorGradient;
  11893. private _removeFactorGradient;
  11894. /**
  11895. * Adds a new life time gradient
  11896. * @param gradient defines the gradient to use (between 0 and 1)
  11897. * @param factor defines the life time factor to affect to the specified gradient
  11898. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11899. * @returns the current particle system
  11900. */
  11901. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11902. /**
  11903. * Remove a specific life time gradient
  11904. * @param gradient defines the gradient to remove
  11905. * @returns the current particle system
  11906. */
  11907. removeLifeTimeGradient(gradient: number): IParticleSystem;
  11908. /**
  11909. * Adds a new size gradient
  11910. * @param gradient defines the gradient to use (between 0 and 1)
  11911. * @param factor defines the size factor to affect to the specified gradient
  11912. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11913. * @returns the current particle system
  11914. */
  11915. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11916. /**
  11917. * Remove a specific size gradient
  11918. * @param gradient defines the gradient to remove
  11919. * @returns the current particle system
  11920. */
  11921. removeSizeGradient(gradient: number): IParticleSystem;
  11922. /**
  11923. * Adds a new color remap gradient
  11924. * @param gradient defines the gradient to use (between 0 and 1)
  11925. * @param min defines the color remap minimal range
  11926. * @param max defines the color remap maximal range
  11927. * @returns the current particle system
  11928. */
  11929. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11930. /**
  11931. * Remove a specific color remap gradient
  11932. * @param gradient defines the gradient to remove
  11933. * @returns the current particle system
  11934. */
  11935. removeColorRemapGradient(gradient: number): IParticleSystem;
  11936. /**
  11937. * Adds a new alpha remap gradient
  11938. * @param gradient defines the gradient to use (between 0 and 1)
  11939. * @param min defines the alpha remap minimal range
  11940. * @param max defines the alpha remap maximal range
  11941. * @returns the current particle system
  11942. */
  11943. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  11944. /**
  11945. * Remove a specific alpha remap gradient
  11946. * @param gradient defines the gradient to remove
  11947. * @returns the current particle system
  11948. */
  11949. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  11950. /**
  11951. * Adds a new angular speed gradient
  11952. * @param gradient defines the gradient to use (between 0 and 1)
  11953. * @param factor defines the angular speed to affect to the specified gradient
  11954. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11955. * @returns the current particle system
  11956. */
  11957. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11958. /**
  11959. * Remove a specific angular speed gradient
  11960. * @param gradient defines the gradient to remove
  11961. * @returns the current particle system
  11962. */
  11963. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  11964. /**
  11965. * Adds a new velocity gradient
  11966. * @param gradient defines the gradient to use (between 0 and 1)
  11967. * @param factor defines the velocity to affect to the specified gradient
  11968. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11969. * @returns the current particle system
  11970. */
  11971. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11972. /**
  11973. * Remove a specific velocity gradient
  11974. * @param gradient defines the gradient to remove
  11975. * @returns the current particle system
  11976. */
  11977. removeVelocityGradient(gradient: number): IParticleSystem;
  11978. /**
  11979. * Adds a new limit velocity gradient
  11980. * @param gradient defines the gradient to use (between 0 and 1)
  11981. * @param factor defines the limit velocity value to affect to the specified gradient
  11982. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11983. * @returns the current particle system
  11984. */
  11985. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  11986. /**
  11987. * Remove a specific limit velocity gradient
  11988. * @param gradient defines the gradient to remove
  11989. * @returns the current particle system
  11990. */
  11991. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  11992. /**
  11993. * Adds a new drag gradient
  11994. * @param gradient defines the gradient to use (between 0 and 1)
  11995. * @param factor defines the drag value to affect to the specified gradient
  11996. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  11997. * @returns the current particle system
  11998. */
  11999. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12000. /**
  12001. * Remove a specific drag gradient
  12002. * @param gradient defines the gradient to remove
  12003. * @returns the current particle system
  12004. */
  12005. removeDragGradient(gradient: number): IParticleSystem;
  12006. /**
  12007. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12008. * @param gradient defines the gradient to use (between 0 and 1)
  12009. * @param factor defines the emit rate value to affect to the specified gradient
  12010. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12011. * @returns the current particle system
  12012. */
  12013. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12014. /**
  12015. * Remove a specific emit rate gradient
  12016. * @param gradient defines the gradient to remove
  12017. * @returns the current particle system
  12018. */
  12019. removeEmitRateGradient(gradient: number): IParticleSystem;
  12020. /**
  12021. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12022. * @param gradient defines the gradient to use (between 0 and 1)
  12023. * @param factor defines the start size value to affect to the specified gradient
  12024. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12025. * @returns the current particle system
  12026. */
  12027. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12028. /**
  12029. * Remove a specific start size gradient
  12030. * @param gradient defines the gradient to remove
  12031. * @returns the current particle system
  12032. */
  12033. removeStartSizeGradient(gradient: number): IParticleSystem;
  12034. private _createRampGradientTexture;
  12035. /**
  12036. * Gets the current list of ramp gradients.
  12037. * You must use addRampGradient and removeRampGradient to udpate this list
  12038. * @returns the list of ramp gradients
  12039. */
  12040. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12041. /**
  12042. * Adds a new ramp gradient used to remap particle colors
  12043. * @param gradient defines the gradient to use (between 0 and 1)
  12044. * @param color defines the color to affect to the specified gradient
  12045. * @returns the current particle system
  12046. */
  12047. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12048. /**
  12049. * Remove a specific ramp gradient
  12050. * @param gradient defines the gradient to remove
  12051. * @returns the current particle system
  12052. */
  12053. removeRampGradient(gradient: number): ParticleSystem;
  12054. /**
  12055. * Adds a new color gradient
  12056. * @param gradient defines the gradient to use (between 0 and 1)
  12057. * @param color1 defines the color to affect to the specified gradient
  12058. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12059. * @returns this particle system
  12060. */
  12061. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12062. /**
  12063. * Remove a specific color gradient
  12064. * @param gradient defines the gradient to remove
  12065. * @returns this particle system
  12066. */
  12067. removeColorGradient(gradient: number): IParticleSystem;
  12068. private _fetchR;
  12069. protected _reset(): void;
  12070. private _resetEffect;
  12071. private _createVertexBuffers;
  12072. private _createIndexBuffer;
  12073. /**
  12074. * Gets the maximum number of particles active at the same time.
  12075. * @returns The max number of active particles.
  12076. */
  12077. getCapacity(): number;
  12078. /**
  12079. * Gets whether there are still active particles in the system.
  12080. * @returns True if it is alive, otherwise false.
  12081. */
  12082. isAlive(): boolean;
  12083. /**
  12084. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12085. * @returns True if it has been started, otherwise false.
  12086. */
  12087. isStarted(): boolean;
  12088. private _prepareSubEmitterInternalArray;
  12089. /**
  12090. * Starts the particle system and begins to emit
  12091. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12092. */
  12093. start(delay?: number): void;
  12094. /**
  12095. * Stops the particle system.
  12096. * @param stopSubEmitters if true it will stop the current system and all created sub-Systems if false it will stop the current root system only, this param is used by the root particle system only. the default value is true.
  12097. */
  12098. stop(stopSubEmitters?: boolean): void;
  12099. /**
  12100. * Remove all active particles
  12101. */
  12102. reset(): void;
  12103. /**
  12104. * @hidden (for internal use only)
  12105. */
  12106. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  12107. /**
  12108. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  12109. * Its lifetime will start back at 0.
  12110. */
  12111. recycleParticle: (particle: Particle) => void;
  12112. private _stopSubEmitters;
  12113. private _createParticle;
  12114. private _removeFromRoot;
  12115. private _emitFromParticle;
  12116. private _update;
  12117. /** @hidden */
  12118. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  12119. /** @hidden */
  12120. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  12121. /** @hidden */
  12122. private _getEffect;
  12123. /**
  12124. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  12125. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  12126. */
  12127. animate(preWarmOnly?: boolean): void;
  12128. private _appendParticleVertices;
  12129. /**
  12130. * Rebuilds the particle system.
  12131. */
  12132. rebuild(): void;
  12133. /**
  12134. * Is this system ready to be used/rendered
  12135. * @return true if the system is ready
  12136. */
  12137. isReady(): boolean;
  12138. private _render;
  12139. /**
  12140. * Renders the particle system in its current state.
  12141. * @returns the current number of particles
  12142. */
  12143. render(): number;
  12144. /**
  12145. * Disposes the particle system and free the associated resources
  12146. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  12147. */
  12148. dispose(disposeTexture?: boolean): void;
  12149. /**
  12150. * Clones the particle system.
  12151. * @param name The name of the cloned object
  12152. * @param newEmitter The new emitter to use
  12153. * @returns the cloned particle system
  12154. */
  12155. clone(name: string, newEmitter: any): ParticleSystem;
  12156. /**
  12157. * Serializes the particle system to a JSON object.
  12158. * @returns the JSON object
  12159. */
  12160. serialize(): any;
  12161. /** @hidden */
  12162. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  12163. /** @hidden */
  12164. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  12165. /**
  12166. * Parses a JSON object to create a particle system.
  12167. * @param parsedParticleSystem The JSON object to parse
  12168. * @param scene The scene to create the particle system in
  12169. * @param rootUrl The root url to use to load external dependencies like texture
  12170. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  12171. * @returns the Parsed particle system
  12172. */
  12173. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  12174. }
  12175. }
  12176. declare module "babylonjs/Particles/particle" {
  12177. import { Nullable } from "babylonjs/types";
  12178. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  12179. import { Color4 } from "babylonjs/Maths/math.color";
  12180. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12181. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12182. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  12183. /**
  12184. * A particle represents one of the element emitted by a particle system.
  12185. * This is mainly define by its coordinates, direction, velocity and age.
  12186. */
  12187. export class Particle {
  12188. /**
  12189. * The particle system the particle belongs to.
  12190. */
  12191. particleSystem: ParticleSystem;
  12192. private static _Count;
  12193. /**
  12194. * Unique ID of the particle
  12195. */
  12196. id: number;
  12197. /**
  12198. * The world position of the particle in the scene.
  12199. */
  12200. position: Vector3;
  12201. /**
  12202. * The world direction of the particle in the scene.
  12203. */
  12204. direction: Vector3;
  12205. /**
  12206. * The color of the particle.
  12207. */
  12208. color: Color4;
  12209. /**
  12210. * The color change of the particle per step.
  12211. */
  12212. colorStep: Color4;
  12213. /**
  12214. * Defines how long will the life of the particle be.
  12215. */
  12216. lifeTime: number;
  12217. /**
  12218. * The current age of the particle.
  12219. */
  12220. age: number;
  12221. /**
  12222. * The current size of the particle.
  12223. */
  12224. size: number;
  12225. /**
  12226. * The current scale of the particle.
  12227. */
  12228. scale: Vector2;
  12229. /**
  12230. * The current angle of the particle.
  12231. */
  12232. angle: number;
  12233. /**
  12234. * Defines how fast is the angle changing.
  12235. */
  12236. angularSpeed: number;
  12237. /**
  12238. * Defines the cell index used by the particle to be rendered from a sprite.
  12239. */
  12240. cellIndex: number;
  12241. /**
  12242. * The information required to support color remapping
  12243. */
  12244. remapData: Vector4;
  12245. /** @hidden */
  12246. _randomCellOffset?: number;
  12247. /** @hidden */
  12248. _initialDirection: Nullable<Vector3>;
  12249. /** @hidden */
  12250. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  12251. /** @hidden */
  12252. _initialStartSpriteCellID: number;
  12253. /** @hidden */
  12254. _initialEndSpriteCellID: number;
  12255. /** @hidden */
  12256. _currentColorGradient: Nullable<ColorGradient>;
  12257. /** @hidden */
  12258. _currentColor1: Color4;
  12259. /** @hidden */
  12260. _currentColor2: Color4;
  12261. /** @hidden */
  12262. _currentSizeGradient: Nullable<FactorGradient>;
  12263. /** @hidden */
  12264. _currentSize1: number;
  12265. /** @hidden */
  12266. _currentSize2: number;
  12267. /** @hidden */
  12268. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  12269. /** @hidden */
  12270. _currentAngularSpeed1: number;
  12271. /** @hidden */
  12272. _currentAngularSpeed2: number;
  12273. /** @hidden */
  12274. _currentVelocityGradient: Nullable<FactorGradient>;
  12275. /** @hidden */
  12276. _currentVelocity1: number;
  12277. /** @hidden */
  12278. _currentVelocity2: number;
  12279. /** @hidden */
  12280. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  12281. /** @hidden */
  12282. _currentLimitVelocity1: number;
  12283. /** @hidden */
  12284. _currentLimitVelocity2: number;
  12285. /** @hidden */
  12286. _currentDragGradient: Nullable<FactorGradient>;
  12287. /** @hidden */
  12288. _currentDrag1: number;
  12289. /** @hidden */
  12290. _currentDrag2: number;
  12291. /** @hidden */
  12292. _randomNoiseCoordinates1: Vector3;
  12293. /** @hidden */
  12294. _randomNoiseCoordinates2: Vector3;
  12295. /**
  12296. * Creates a new instance Particle
  12297. * @param particleSystem the particle system the particle belongs to
  12298. */
  12299. constructor(
  12300. /**
  12301. * The particle system the particle belongs to.
  12302. */
  12303. particleSystem: ParticleSystem);
  12304. private updateCellInfoFromSystem;
  12305. /**
  12306. * Defines how the sprite cell index is updated for the particle
  12307. */
  12308. updateCellIndex(): void;
  12309. /** @hidden */
  12310. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  12311. /** @hidden */
  12312. _inheritParticleInfoToSubEmitters(): void;
  12313. /** @hidden */
  12314. _reset(): void;
  12315. /**
  12316. * Copy the properties of particle to another one.
  12317. * @param other the particle to copy the information to.
  12318. */
  12319. copyTo(other: Particle): void;
  12320. }
  12321. }
  12322. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  12323. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12324. import { Effect } from "babylonjs/Materials/effect";
  12325. import { Particle } from "babylonjs/Particles/particle";
  12326. import { Scene } from "babylonjs/scene";
  12327. /**
  12328. * Particle emitter represents a volume emitting particles.
  12329. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  12330. */
  12331. export interface IParticleEmitterType {
  12332. /**
  12333. * Called by the particle System when the direction is computed for the created particle.
  12334. * @param worldMatrix is the world matrix of the particle system
  12335. * @param directionToUpdate is the direction vector to update with the result
  12336. * @param particle is the particle we are computed the direction for
  12337. */
  12338. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12339. /**
  12340. * Called by the particle System when the position is computed for the created particle.
  12341. * @param worldMatrix is the world matrix of the particle system
  12342. * @param positionToUpdate is the position vector to update with the result
  12343. * @param particle is the particle we are computed the position for
  12344. */
  12345. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12346. /**
  12347. * Clones the current emitter and returns a copy of it
  12348. * @returns the new emitter
  12349. */
  12350. clone(): IParticleEmitterType;
  12351. /**
  12352. * Called by the GPUParticleSystem to setup the update shader
  12353. * @param effect defines the update shader
  12354. */
  12355. applyToShader(effect: Effect): void;
  12356. /**
  12357. * Returns a string to use to update the GPU particles update shader
  12358. * @returns the effect defines string
  12359. */
  12360. getEffectDefines(): string;
  12361. /**
  12362. * Returns a string representing the class name
  12363. * @returns a string containing the class name
  12364. */
  12365. getClassName(): string;
  12366. /**
  12367. * Serializes the particle system to a JSON object.
  12368. * @returns the JSON object
  12369. */
  12370. serialize(): any;
  12371. /**
  12372. * Parse properties from a JSON object
  12373. * @param serializationObject defines the JSON object
  12374. * @param scene defines the hosting scene
  12375. */
  12376. parse(serializationObject: any, scene: Scene): void;
  12377. }
  12378. }
  12379. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  12380. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12381. import { Effect } from "babylonjs/Materials/effect";
  12382. import { Particle } from "babylonjs/Particles/particle";
  12383. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12384. /**
  12385. * Particle emitter emitting particles from the inside of a box.
  12386. * It emits the particles randomly between 2 given directions.
  12387. */
  12388. export class BoxParticleEmitter implements IParticleEmitterType {
  12389. /**
  12390. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12391. */
  12392. direction1: Vector3;
  12393. /**
  12394. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12395. */
  12396. direction2: Vector3;
  12397. /**
  12398. * Minimum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12399. */
  12400. minEmitBox: Vector3;
  12401. /**
  12402. * Maximum box point around our emitter. Our emitter is the center of particles source, but if you want your particles to emit from more than one point, then you can tell it to do so.
  12403. */
  12404. maxEmitBox: Vector3;
  12405. /**
  12406. * Creates a new instance BoxParticleEmitter
  12407. */
  12408. constructor();
  12409. /**
  12410. * Called by the particle System when the direction is computed for the created particle.
  12411. * @param worldMatrix is the world matrix of the particle system
  12412. * @param directionToUpdate is the direction vector to update with the result
  12413. * @param particle is the particle we are computed the direction for
  12414. */
  12415. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12416. /**
  12417. * Called by the particle System when the position is computed for the created particle.
  12418. * @param worldMatrix is the world matrix of the particle system
  12419. * @param positionToUpdate is the position vector to update with the result
  12420. * @param particle is the particle we are computed the position for
  12421. */
  12422. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12423. /**
  12424. * Clones the current emitter and returns a copy of it
  12425. * @returns the new emitter
  12426. */
  12427. clone(): BoxParticleEmitter;
  12428. /**
  12429. * Called by the GPUParticleSystem to setup the update shader
  12430. * @param effect defines the update shader
  12431. */
  12432. applyToShader(effect: Effect): void;
  12433. /**
  12434. * Returns a string to use to update the GPU particles update shader
  12435. * @returns a string containng the defines string
  12436. */
  12437. getEffectDefines(): string;
  12438. /**
  12439. * Returns the string "BoxParticleEmitter"
  12440. * @returns a string containing the class name
  12441. */
  12442. getClassName(): string;
  12443. /**
  12444. * Serializes the particle system to a JSON object.
  12445. * @returns the JSON object
  12446. */
  12447. serialize(): any;
  12448. /**
  12449. * Parse properties from a JSON object
  12450. * @param serializationObject defines the JSON object
  12451. */
  12452. parse(serializationObject: any): void;
  12453. }
  12454. }
  12455. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  12456. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12457. import { Effect } from "babylonjs/Materials/effect";
  12458. import { Particle } from "babylonjs/Particles/particle";
  12459. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12460. /**
  12461. * Particle emitter emitting particles from the inside of a cone.
  12462. * It emits the particles alongside the cone volume from the base to the particle.
  12463. * The emission direction might be randomized.
  12464. */
  12465. export class ConeParticleEmitter implements IParticleEmitterType {
  12466. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12467. directionRandomizer: number;
  12468. private _radius;
  12469. private _angle;
  12470. private _height;
  12471. /**
  12472. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  12473. */
  12474. radiusRange: number;
  12475. /**
  12476. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  12477. */
  12478. heightRange: number;
  12479. /**
  12480. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  12481. */
  12482. emitFromSpawnPointOnly: boolean;
  12483. /**
  12484. * Gets or sets the radius of the emission cone
  12485. */
  12486. get radius(): number;
  12487. set radius(value: number);
  12488. /**
  12489. * Gets or sets the angle of the emission cone
  12490. */
  12491. get angle(): number;
  12492. set angle(value: number);
  12493. private _buildHeight;
  12494. /**
  12495. * Creates a new instance ConeParticleEmitter
  12496. * @param radius the radius of the emission cone (1 by default)
  12497. * @param angle the cone base angle (PI by default)
  12498. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  12499. */
  12500. constructor(radius?: number, angle?: number,
  12501. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  12502. directionRandomizer?: number);
  12503. /**
  12504. * Called by the particle System when the direction is computed for the created particle.
  12505. * @param worldMatrix is the world matrix of the particle system
  12506. * @param directionToUpdate is the direction vector to update with the result
  12507. * @param particle is the particle we are computed the direction for
  12508. */
  12509. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12510. /**
  12511. * Called by the particle System when the position is computed for the created particle.
  12512. * @param worldMatrix is the world matrix of the particle system
  12513. * @param positionToUpdate is the position vector to update with the result
  12514. * @param particle is the particle we are computed the position for
  12515. */
  12516. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12517. /**
  12518. * Clones the current emitter and returns a copy of it
  12519. * @returns the new emitter
  12520. */
  12521. clone(): ConeParticleEmitter;
  12522. /**
  12523. * Called by the GPUParticleSystem to setup the update shader
  12524. * @param effect defines the update shader
  12525. */
  12526. applyToShader(effect: Effect): void;
  12527. /**
  12528. * Returns a string to use to update the GPU particles update shader
  12529. * @returns a string containng the defines string
  12530. */
  12531. getEffectDefines(): string;
  12532. /**
  12533. * Returns the string "ConeParticleEmitter"
  12534. * @returns a string containing the class name
  12535. */
  12536. getClassName(): string;
  12537. /**
  12538. * Serializes the particle system to a JSON object.
  12539. * @returns the JSON object
  12540. */
  12541. serialize(): any;
  12542. /**
  12543. * Parse properties from a JSON object
  12544. * @param serializationObject defines the JSON object
  12545. */
  12546. parse(serializationObject: any): void;
  12547. }
  12548. }
  12549. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  12550. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12551. import { Effect } from "babylonjs/Materials/effect";
  12552. import { Particle } from "babylonjs/Particles/particle";
  12553. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12554. /**
  12555. * Particle emitter emitting particles from the inside of a cylinder.
  12556. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  12557. */
  12558. export class CylinderParticleEmitter implements IParticleEmitterType {
  12559. /**
  12560. * The radius of the emission cylinder.
  12561. */
  12562. radius: number;
  12563. /**
  12564. * The height of the emission cylinder.
  12565. */
  12566. height: number;
  12567. /**
  12568. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12569. */
  12570. radiusRange: number;
  12571. /**
  12572. * How much to randomize the particle direction [0-1].
  12573. */
  12574. directionRandomizer: number;
  12575. /**
  12576. * Creates a new instance CylinderParticleEmitter
  12577. * @param radius the radius of the emission cylinder (1 by default)
  12578. * @param height the height of the emission cylinder (1 by default)
  12579. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12580. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12581. */
  12582. constructor(
  12583. /**
  12584. * The radius of the emission cylinder.
  12585. */
  12586. radius?: number,
  12587. /**
  12588. * The height of the emission cylinder.
  12589. */
  12590. height?: number,
  12591. /**
  12592. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12593. */
  12594. radiusRange?: number,
  12595. /**
  12596. * How much to randomize the particle direction [0-1].
  12597. */
  12598. directionRandomizer?: number);
  12599. /**
  12600. * Called by the particle System when the direction is computed for the created particle.
  12601. * @param worldMatrix is the world matrix of the particle system
  12602. * @param directionToUpdate is the direction vector to update with the result
  12603. * @param particle is the particle we are computed the direction for
  12604. */
  12605. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12606. /**
  12607. * Called by the particle System when the position is computed for the created particle.
  12608. * @param worldMatrix is the world matrix of the particle system
  12609. * @param positionToUpdate is the position vector to update with the result
  12610. * @param particle is the particle we are computed the position for
  12611. */
  12612. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12613. /**
  12614. * Clones the current emitter and returns a copy of it
  12615. * @returns the new emitter
  12616. */
  12617. clone(): CylinderParticleEmitter;
  12618. /**
  12619. * Called by the GPUParticleSystem to setup the update shader
  12620. * @param effect defines the update shader
  12621. */
  12622. applyToShader(effect: Effect): void;
  12623. /**
  12624. * Returns a string to use to update the GPU particles update shader
  12625. * @returns a string containng the defines string
  12626. */
  12627. getEffectDefines(): string;
  12628. /**
  12629. * Returns the string "CylinderParticleEmitter"
  12630. * @returns a string containing the class name
  12631. */
  12632. getClassName(): string;
  12633. /**
  12634. * Serializes the particle system to a JSON object.
  12635. * @returns the JSON object
  12636. */
  12637. serialize(): any;
  12638. /**
  12639. * Parse properties from a JSON object
  12640. * @param serializationObject defines the JSON object
  12641. */
  12642. parse(serializationObject: any): void;
  12643. }
  12644. /**
  12645. * Particle emitter emitting particles from the inside of a cylinder.
  12646. * It emits the particles randomly between two vectors.
  12647. */
  12648. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  12649. /**
  12650. * The min limit of the emission direction.
  12651. */
  12652. direction1: Vector3;
  12653. /**
  12654. * The max limit of the emission direction.
  12655. */
  12656. direction2: Vector3;
  12657. /**
  12658. * Creates a new instance CylinderDirectedParticleEmitter
  12659. * @param radius the radius of the emission cylinder (1 by default)
  12660. * @param height the height of the emission cylinder (1 by default)
  12661. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12662. * @param direction1 the min limit of the emission direction (up vector by default)
  12663. * @param direction2 the max limit of the emission direction (up vector by default)
  12664. */
  12665. constructor(radius?: number, height?: number, radiusRange?: number,
  12666. /**
  12667. * The min limit of the emission direction.
  12668. */
  12669. direction1?: Vector3,
  12670. /**
  12671. * The max limit of the emission direction.
  12672. */
  12673. direction2?: Vector3);
  12674. /**
  12675. * Called by the particle System when the direction is computed for the created particle.
  12676. * @param worldMatrix is the world matrix of the particle system
  12677. * @param directionToUpdate is the direction vector to update with the result
  12678. * @param particle is the particle we are computed the direction for
  12679. */
  12680. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12681. /**
  12682. * Clones the current emitter and returns a copy of it
  12683. * @returns the new emitter
  12684. */
  12685. clone(): CylinderDirectedParticleEmitter;
  12686. /**
  12687. * Called by the GPUParticleSystem to setup the update shader
  12688. * @param effect defines the update shader
  12689. */
  12690. applyToShader(effect: Effect): void;
  12691. /**
  12692. * Returns a string to use to update the GPU particles update shader
  12693. * @returns a string containng the defines string
  12694. */
  12695. getEffectDefines(): string;
  12696. /**
  12697. * Returns the string "CylinderDirectedParticleEmitter"
  12698. * @returns a string containing the class name
  12699. */
  12700. getClassName(): string;
  12701. /**
  12702. * Serializes the particle system to a JSON object.
  12703. * @returns the JSON object
  12704. */
  12705. serialize(): any;
  12706. /**
  12707. * Parse properties from a JSON object
  12708. * @param serializationObject defines the JSON object
  12709. */
  12710. parse(serializationObject: any): void;
  12711. }
  12712. }
  12713. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  12714. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12715. import { Effect } from "babylonjs/Materials/effect";
  12716. import { Particle } from "babylonjs/Particles/particle";
  12717. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12718. /**
  12719. * Particle emitter emitting particles from the inside of a hemisphere.
  12720. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  12721. */
  12722. export class HemisphericParticleEmitter implements IParticleEmitterType {
  12723. /**
  12724. * The radius of the emission hemisphere.
  12725. */
  12726. radius: number;
  12727. /**
  12728. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12729. */
  12730. radiusRange: number;
  12731. /**
  12732. * How much to randomize the particle direction [0-1].
  12733. */
  12734. directionRandomizer: number;
  12735. /**
  12736. * Creates a new instance HemisphericParticleEmitter
  12737. * @param radius the radius of the emission hemisphere (1 by default)
  12738. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12739. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12740. */
  12741. constructor(
  12742. /**
  12743. * The radius of the emission hemisphere.
  12744. */
  12745. radius?: number,
  12746. /**
  12747. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12748. */
  12749. radiusRange?: number,
  12750. /**
  12751. * How much to randomize the particle direction [0-1].
  12752. */
  12753. directionRandomizer?: number);
  12754. /**
  12755. * Called by the particle System when the direction is computed for the created particle.
  12756. * @param worldMatrix is the world matrix of the particle system
  12757. * @param directionToUpdate is the direction vector to update with the result
  12758. * @param particle is the particle we are computed the direction for
  12759. */
  12760. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12761. /**
  12762. * Called by the particle System when the position is computed for the created particle.
  12763. * @param worldMatrix is the world matrix of the particle system
  12764. * @param positionToUpdate is the position vector to update with the result
  12765. * @param particle is the particle we are computed the position for
  12766. */
  12767. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12768. /**
  12769. * Clones the current emitter and returns a copy of it
  12770. * @returns the new emitter
  12771. */
  12772. clone(): HemisphericParticleEmitter;
  12773. /**
  12774. * Called by the GPUParticleSystem to setup the update shader
  12775. * @param effect defines the update shader
  12776. */
  12777. applyToShader(effect: Effect): void;
  12778. /**
  12779. * Returns a string to use to update the GPU particles update shader
  12780. * @returns a string containng the defines string
  12781. */
  12782. getEffectDefines(): string;
  12783. /**
  12784. * Returns the string "HemisphericParticleEmitter"
  12785. * @returns a string containing the class name
  12786. */
  12787. getClassName(): string;
  12788. /**
  12789. * Serializes the particle system to a JSON object.
  12790. * @returns the JSON object
  12791. */
  12792. serialize(): any;
  12793. /**
  12794. * Parse properties from a JSON object
  12795. * @param serializationObject defines the JSON object
  12796. */
  12797. parse(serializationObject: any): void;
  12798. }
  12799. }
  12800. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  12801. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12802. import { Effect } from "babylonjs/Materials/effect";
  12803. import { Particle } from "babylonjs/Particles/particle";
  12804. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12805. /**
  12806. * Particle emitter emitting particles from a point.
  12807. * It emits the particles randomly between 2 given directions.
  12808. */
  12809. export class PointParticleEmitter implements IParticleEmitterType {
  12810. /**
  12811. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12812. */
  12813. direction1: Vector3;
  12814. /**
  12815. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12816. */
  12817. direction2: Vector3;
  12818. /**
  12819. * Creates a new instance PointParticleEmitter
  12820. */
  12821. constructor();
  12822. /**
  12823. * Called by the particle System when the direction is computed for the created particle.
  12824. * @param worldMatrix is the world matrix of the particle system
  12825. * @param directionToUpdate is the direction vector to update with the result
  12826. * @param particle is the particle we are computed the direction for
  12827. */
  12828. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12829. /**
  12830. * Called by the particle System when the position is computed for the created particle.
  12831. * @param worldMatrix is the world matrix of the particle system
  12832. * @param positionToUpdate is the position vector to update with the result
  12833. * @param particle is the particle we are computed the position for
  12834. */
  12835. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12836. /**
  12837. * Clones the current emitter and returns a copy of it
  12838. * @returns the new emitter
  12839. */
  12840. clone(): PointParticleEmitter;
  12841. /**
  12842. * Called by the GPUParticleSystem to setup the update shader
  12843. * @param effect defines the update shader
  12844. */
  12845. applyToShader(effect: Effect): void;
  12846. /**
  12847. * Returns a string to use to update the GPU particles update shader
  12848. * @returns a string containng the defines string
  12849. */
  12850. getEffectDefines(): string;
  12851. /**
  12852. * Returns the string "PointParticleEmitter"
  12853. * @returns a string containing the class name
  12854. */
  12855. getClassName(): string;
  12856. /**
  12857. * Serializes the particle system to a JSON object.
  12858. * @returns the JSON object
  12859. */
  12860. serialize(): any;
  12861. /**
  12862. * Parse properties from a JSON object
  12863. * @param serializationObject defines the JSON object
  12864. */
  12865. parse(serializationObject: any): void;
  12866. }
  12867. }
  12868. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  12869. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12870. import { Effect } from "babylonjs/Materials/effect";
  12871. import { Particle } from "babylonjs/Particles/particle";
  12872. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  12873. /**
  12874. * Particle emitter emitting particles from the inside of a sphere.
  12875. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  12876. */
  12877. export class SphereParticleEmitter implements IParticleEmitterType {
  12878. /**
  12879. * The radius of the emission sphere.
  12880. */
  12881. radius: number;
  12882. /**
  12883. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12884. */
  12885. radiusRange: number;
  12886. /**
  12887. * How much to randomize the particle direction [0-1].
  12888. */
  12889. directionRandomizer: number;
  12890. /**
  12891. * Creates a new instance SphereParticleEmitter
  12892. * @param radius the radius of the emission sphere (1 by default)
  12893. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12894. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  12895. */
  12896. constructor(
  12897. /**
  12898. * The radius of the emission sphere.
  12899. */
  12900. radius?: number,
  12901. /**
  12902. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  12903. */
  12904. radiusRange?: number,
  12905. /**
  12906. * How much to randomize the particle direction [0-1].
  12907. */
  12908. directionRandomizer?: number);
  12909. /**
  12910. * Called by the particle System when the direction is computed for the created particle.
  12911. * @param worldMatrix is the world matrix of the particle system
  12912. * @param directionToUpdate is the direction vector to update with the result
  12913. * @param particle is the particle we are computed the direction for
  12914. */
  12915. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12916. /**
  12917. * Called by the particle System when the position is computed for the created particle.
  12918. * @param worldMatrix is the world matrix of the particle system
  12919. * @param positionToUpdate is the position vector to update with the result
  12920. * @param particle is the particle we are computed the position for
  12921. */
  12922. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  12923. /**
  12924. * Clones the current emitter and returns a copy of it
  12925. * @returns the new emitter
  12926. */
  12927. clone(): SphereParticleEmitter;
  12928. /**
  12929. * Called by the GPUParticleSystem to setup the update shader
  12930. * @param effect defines the update shader
  12931. */
  12932. applyToShader(effect: Effect): void;
  12933. /**
  12934. * Returns a string to use to update the GPU particles update shader
  12935. * @returns a string containng the defines string
  12936. */
  12937. getEffectDefines(): string;
  12938. /**
  12939. * Returns the string "SphereParticleEmitter"
  12940. * @returns a string containing the class name
  12941. */
  12942. getClassName(): string;
  12943. /**
  12944. * Serializes the particle system to a JSON object.
  12945. * @returns the JSON object
  12946. */
  12947. serialize(): any;
  12948. /**
  12949. * Parse properties from a JSON object
  12950. * @param serializationObject defines the JSON object
  12951. */
  12952. parse(serializationObject: any): void;
  12953. }
  12954. /**
  12955. * Particle emitter emitting particles from the inside of a sphere.
  12956. * It emits the particles randomly between two vectors.
  12957. */
  12958. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  12959. /**
  12960. * The min limit of the emission direction.
  12961. */
  12962. direction1: Vector3;
  12963. /**
  12964. * The max limit of the emission direction.
  12965. */
  12966. direction2: Vector3;
  12967. /**
  12968. * Creates a new instance SphereDirectedParticleEmitter
  12969. * @param radius the radius of the emission sphere (1 by default)
  12970. * @param direction1 the min limit of the emission direction (up vector by default)
  12971. * @param direction2 the max limit of the emission direction (up vector by default)
  12972. */
  12973. constructor(radius?: number,
  12974. /**
  12975. * The min limit of the emission direction.
  12976. */
  12977. direction1?: Vector3,
  12978. /**
  12979. * The max limit of the emission direction.
  12980. */
  12981. direction2?: Vector3);
  12982. /**
  12983. * Called by the particle System when the direction is computed for the created particle.
  12984. * @param worldMatrix is the world matrix of the particle system
  12985. * @param directionToUpdate is the direction vector to update with the result
  12986. * @param particle is the particle we are computed the direction for
  12987. */
  12988. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  12989. /**
  12990. * Clones the current emitter and returns a copy of it
  12991. * @returns the new emitter
  12992. */
  12993. clone(): SphereDirectedParticleEmitter;
  12994. /**
  12995. * Called by the GPUParticleSystem to setup the update shader
  12996. * @param effect defines the update shader
  12997. */
  12998. applyToShader(effect: Effect): void;
  12999. /**
  13000. * Returns a string to use to update the GPU particles update shader
  13001. * @returns a string containng the defines string
  13002. */
  13003. getEffectDefines(): string;
  13004. /**
  13005. * Returns the string "SphereDirectedParticleEmitter"
  13006. * @returns a string containing the class name
  13007. */
  13008. getClassName(): string;
  13009. /**
  13010. * Serializes the particle system to a JSON object.
  13011. * @returns the JSON object
  13012. */
  13013. serialize(): any;
  13014. /**
  13015. * Parse properties from a JSON object
  13016. * @param serializationObject defines the JSON object
  13017. */
  13018. parse(serializationObject: any): void;
  13019. }
  13020. }
  13021. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  13022. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13023. import { Effect } from "babylonjs/Materials/effect";
  13024. import { Particle } from "babylonjs/Particles/particle";
  13025. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13026. import { Nullable } from "babylonjs/types";
  13027. /**
  13028. * Particle emitter emitting particles from a custom list of positions.
  13029. */
  13030. export class CustomParticleEmitter implements IParticleEmitterType {
  13031. /**
  13032. * Gets or sets the position generator that will create the inital position of each particle.
  13033. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13034. */
  13035. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13036. /**
  13037. * Gets or sets the destination generator that will create the final destination of each particle.
  13038. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13039. */
  13040. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13041. /**
  13042. * Creates a new instance CustomParticleEmitter
  13043. */
  13044. constructor();
  13045. /**
  13046. * Called by the particle System when the direction is computed for the created particle.
  13047. * @param worldMatrix is the world matrix of the particle system
  13048. * @param directionToUpdate is the direction vector to update with the result
  13049. * @param particle is the particle we are computed the direction for
  13050. */
  13051. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13052. /**
  13053. * Called by the particle System when the position is computed for the created particle.
  13054. * @param worldMatrix is the world matrix of the particle system
  13055. * @param positionToUpdate is the position vector to update with the result
  13056. * @param particle is the particle we are computed the position for
  13057. */
  13058. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  13059. /**
  13060. * Clones the current emitter and returns a copy of it
  13061. * @returns the new emitter
  13062. */
  13063. clone(): CustomParticleEmitter;
  13064. /**
  13065. * Called by the GPUParticleSystem to setup the update shader
  13066. * @param effect defines the update shader
  13067. */
  13068. applyToShader(effect: Effect): void;
  13069. /**
  13070. * Returns a string to use to update the GPU particles update shader
  13071. * @returns a string containng the defines string
  13072. */
  13073. getEffectDefines(): string;
  13074. /**
  13075. * Returns the string "PointParticleEmitter"
  13076. * @returns a string containing the class name
  13077. */
  13078. getClassName(): string;
  13079. /**
  13080. * Serializes the particle system to a JSON object.
  13081. * @returns the JSON object
  13082. */
  13083. serialize(): any;
  13084. /**
  13085. * Parse properties from a JSON object
  13086. * @param serializationObject defines the JSON object
  13087. */
  13088. parse(serializationObject: any): void;
  13089. }
  13090. }
  13091. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  13092. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13093. import { Effect } from "babylonjs/Materials/effect";
  13094. import { Particle } from "babylonjs/Particles/particle";
  13095. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13096. import { Scene } from "babylonjs/scene";
  13097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13098. /**
  13099. * Particle emitter emitting particles from the inside of a box.
  13100. * It emits the particles randomly between 2 given directions.
  13101. */
  13102. export class MeshParticleEmitter implements IParticleEmitterType {
  13103. /** Defines the mesh to use as source */
  13104. mesh?: AbstractMesh | undefined;
  13105. private _indices;
  13106. private _positions;
  13107. private _normals;
  13108. private _storedNormal;
  13109. /**
  13110. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13111. */
  13112. direction1: Vector3;
  13113. /**
  13114. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13115. */
  13116. direction2: Vector3;
  13117. /**
  13118. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  13119. */
  13120. useMeshNormalsForDirection: boolean;
  13121. /**
  13122. * Creates a new instance MeshParticleEmitter
  13123. * @param mesh defines the mesh to use as source
  13124. */
  13125. constructor(
  13126. /** Defines the mesh to use as source */
  13127. mesh?: AbstractMesh | undefined);
  13128. /**
  13129. * Called by the particle System when the direction is computed for the created particle.
  13130. * @param worldMatrix is the world matrix of the particle system
  13131. * @param directionToUpdate is the direction vector to update with the result
  13132. * @param particle is the particle we are computed the direction for
  13133. */
  13134. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13135. /**
  13136. * Called by the particle System when the position is computed for the created particle.
  13137. * @param worldMatrix is the world matrix of the particle system
  13138. * @param positionToUpdate is the position vector to update with the result
  13139. * @param particle is the particle we are computed the position for
  13140. */
  13141. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  13142. /**
  13143. * Clones the current emitter and returns a copy of it
  13144. * @returns the new emitter
  13145. */
  13146. clone(): MeshParticleEmitter;
  13147. /**
  13148. * Called by the GPUParticleSystem to setup the update shader
  13149. * @param effect defines the update shader
  13150. */
  13151. applyToShader(effect: Effect): void;
  13152. /**
  13153. * Returns a string to use to update the GPU particles update shader
  13154. * @returns a string containng the defines string
  13155. */
  13156. getEffectDefines(): string;
  13157. /**
  13158. * Returns the string "BoxParticleEmitter"
  13159. * @returns a string containing the class name
  13160. */
  13161. getClassName(): string;
  13162. /**
  13163. * Serializes the particle system to a JSON object.
  13164. * @returns the JSON object
  13165. */
  13166. serialize(): any;
  13167. /**
  13168. * Parse properties from a JSON object
  13169. * @param serializationObject defines the JSON object
  13170. * @param scene defines the hosting scene
  13171. */
  13172. parse(serializationObject: any, scene: Scene): void;
  13173. }
  13174. }
  13175. declare module "babylonjs/Particles/EmitterTypes/index" {
  13176. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  13177. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  13178. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  13179. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  13180. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13181. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  13182. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  13183. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  13184. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  13185. }
  13186. declare module "babylonjs/Particles/IParticleSystem" {
  13187. import { Nullable } from "babylonjs/types";
  13188. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  13189. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  13190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13191. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  13192. import { Texture } from "babylonjs/Materials/Textures/texture";
  13193. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  13194. import { Scene } from "babylonjs/scene";
  13195. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  13196. import { Animation } from "babylonjs/Animations/animation";
  13197. /**
  13198. * Interface representing a particle system in Babylon.js.
  13199. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13200. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  13201. */
  13202. export interface IParticleSystem {
  13203. /**
  13204. * List of animations used by the particle system.
  13205. */
  13206. animations: Animation[];
  13207. /**
  13208. * The id of the Particle system.
  13209. */
  13210. id: string;
  13211. /**
  13212. * The name of the Particle system.
  13213. */
  13214. name: string;
  13215. /**
  13216. * The emitter represents the Mesh or position we are attaching the particle system to.
  13217. */
  13218. emitter: Nullable<AbstractMesh | Vector3>;
  13219. /**
  13220. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  13221. */
  13222. isBillboardBased: boolean;
  13223. /**
  13224. * The rendering group used by the Particle system to chose when to render.
  13225. */
  13226. renderingGroupId: number;
  13227. /**
  13228. * The layer mask we are rendering the particles through.
  13229. */
  13230. layerMask: number;
  13231. /**
  13232. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  13233. */
  13234. updateSpeed: number;
  13235. /**
  13236. * The amount of time the particle system is running (depends of the overall update speed).
  13237. */
  13238. targetStopDuration: number;
  13239. /**
  13240. * The texture used to render each particle. (this can be a spritesheet)
  13241. */
  13242. particleTexture: Nullable<Texture>;
  13243. /**
  13244. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  13245. */
  13246. blendMode: number;
  13247. /**
  13248. * Minimum life time of emitting particles.
  13249. */
  13250. minLifeTime: number;
  13251. /**
  13252. * Maximum life time of emitting particles.
  13253. */
  13254. maxLifeTime: number;
  13255. /**
  13256. * Minimum Size of emitting particles.
  13257. */
  13258. minSize: number;
  13259. /**
  13260. * Maximum Size of emitting particles.
  13261. */
  13262. maxSize: number;
  13263. /**
  13264. * Minimum scale of emitting particles on X axis.
  13265. */
  13266. minScaleX: number;
  13267. /**
  13268. * Maximum scale of emitting particles on X axis.
  13269. */
  13270. maxScaleX: number;
  13271. /**
  13272. * Minimum scale of emitting particles on Y axis.
  13273. */
  13274. minScaleY: number;
  13275. /**
  13276. * Maximum scale of emitting particles on Y axis.
  13277. */
  13278. maxScaleY: number;
  13279. /**
  13280. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13281. */
  13282. color1: Color4;
  13283. /**
  13284. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  13285. */
  13286. color2: Color4;
  13287. /**
  13288. * Color the particle will have at the end of its lifetime.
  13289. */
  13290. colorDead: Color4;
  13291. /**
  13292. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  13293. */
  13294. emitRate: number;
  13295. /**
  13296. * You can use gravity if you want to give an orientation to your particles.
  13297. */
  13298. gravity: Vector3;
  13299. /**
  13300. * Minimum power of emitting particles.
  13301. */
  13302. minEmitPower: number;
  13303. /**
  13304. * Maximum power of emitting particles.
  13305. */
  13306. maxEmitPower: number;
  13307. /**
  13308. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  13309. */
  13310. minAngularSpeed: number;
  13311. /**
  13312. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  13313. */
  13314. maxAngularSpeed: number;
  13315. /**
  13316. * Gets or sets the minimal initial rotation in radians.
  13317. */
  13318. minInitialRotation: number;
  13319. /**
  13320. * Gets or sets the maximal initial rotation in radians.
  13321. */
  13322. maxInitialRotation: number;
  13323. /**
  13324. * The particle emitter type defines the emitter used by the particle system.
  13325. * It can be for example box, sphere, or cone...
  13326. */
  13327. particleEmitterType: Nullable<IParticleEmitterType>;
  13328. /**
  13329. * Defines the delay in milliseconds before starting the system (0 by default)
  13330. */
  13331. startDelay: number;
  13332. /**
  13333. * Gets or sets a value indicating how many cycles (or frames) must be executed before first rendering (this value has to be set before starting the system). Default is 0
  13334. */
  13335. preWarmCycles: number;
  13336. /**
  13337. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  13338. */
  13339. preWarmStepOffset: number;
  13340. /**
  13341. * If using a spritesheet (isAnimationSheetEnabled) defines the speed of the sprite loop (default is 1 meaning the animation will play once during the entire particle lifetime)
  13342. */
  13343. spriteCellChangeSpeed: number;
  13344. /**
  13345. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  13346. */
  13347. startSpriteCellID: number;
  13348. /**
  13349. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  13350. */
  13351. endSpriteCellID: number;
  13352. /**
  13353. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  13354. */
  13355. spriteCellWidth: number;
  13356. /**
  13357. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  13358. */
  13359. spriteCellHeight: number;
  13360. /**
  13361. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  13362. */
  13363. spriteRandomStartCell: boolean;
  13364. /**
  13365. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  13366. */
  13367. isAnimationSheetEnabled: boolean;
  13368. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  13369. translationPivot: Vector2;
  13370. /**
  13371. * Gets or sets a texture used to add random noise to particle positions
  13372. */
  13373. noiseTexture: Nullable<BaseTexture>;
  13374. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  13375. noiseStrength: Vector3;
  13376. /**
  13377. * Gets or sets the billboard mode to use when isBillboardBased = true.
  13378. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  13379. */
  13380. billboardMode: number;
  13381. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  13382. limitVelocityDamping: number;
  13383. /**
  13384. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  13385. */
  13386. beginAnimationOnStart: boolean;
  13387. /**
  13388. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  13389. */
  13390. beginAnimationFrom: number;
  13391. /**
  13392. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  13393. */
  13394. beginAnimationTo: number;
  13395. /**
  13396. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  13397. */
  13398. beginAnimationLoop: boolean;
  13399. /**
  13400. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  13401. */
  13402. disposeOnStop: boolean;
  13403. /**
  13404. * Gets the maximum number of particles active at the same time.
  13405. * @returns The max number of active particles.
  13406. */
  13407. getCapacity(): number;
  13408. /**
  13409. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13410. * @returns True if it has been started, otherwise false.
  13411. */
  13412. isStarted(): boolean;
  13413. /**
  13414. * Animates the particle system for this frame.
  13415. */
  13416. animate(): void;
  13417. /**
  13418. * Renders the particle system in its current state.
  13419. * @returns the current number of particles
  13420. */
  13421. render(): number;
  13422. /**
  13423. * Dispose the particle system and frees its associated resources.
  13424. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13425. */
  13426. dispose(disposeTexture?: boolean): void;
  13427. /**
  13428. * Clones the particle system.
  13429. * @param name The name of the cloned object
  13430. * @param newEmitter The new emitter to use
  13431. * @returns the cloned particle system
  13432. */
  13433. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  13434. /**
  13435. * Serializes the particle system to a JSON object.
  13436. * @returns the JSON object
  13437. */
  13438. serialize(): any;
  13439. /**
  13440. * Rebuild the particle system
  13441. */
  13442. rebuild(): void;
  13443. /**
  13444. * Starts the particle system and begins to emit
  13445. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  13446. */
  13447. start(delay?: number): void;
  13448. /**
  13449. * Stops the particle system.
  13450. */
  13451. stop(): void;
  13452. /**
  13453. * Remove all active particles
  13454. */
  13455. reset(): void;
  13456. /**
  13457. * Is this system ready to be used/rendered
  13458. * @return true if the system is ready
  13459. */
  13460. isReady(): boolean;
  13461. /**
  13462. * Adds a new color gradient
  13463. * @param gradient defines the gradient to use (between 0 and 1)
  13464. * @param color1 defines the color to affect to the specified gradient
  13465. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13466. * @returns the current particle system
  13467. */
  13468. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13469. /**
  13470. * Remove a specific color gradient
  13471. * @param gradient defines the gradient to remove
  13472. * @returns the current particle system
  13473. */
  13474. removeColorGradient(gradient: number): IParticleSystem;
  13475. /**
  13476. * Adds a new size gradient
  13477. * @param gradient defines the gradient to use (between 0 and 1)
  13478. * @param factor defines the size factor to affect to the specified gradient
  13479. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13480. * @returns the current particle system
  13481. */
  13482. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13483. /**
  13484. * Remove a specific size gradient
  13485. * @param gradient defines the gradient to remove
  13486. * @returns the current particle system
  13487. */
  13488. removeSizeGradient(gradient: number): IParticleSystem;
  13489. /**
  13490. * Gets the current list of color gradients.
  13491. * You must use addColorGradient and removeColorGradient to udpate this list
  13492. * @returns the list of color gradients
  13493. */
  13494. getColorGradients(): Nullable<Array<ColorGradient>>;
  13495. /**
  13496. * Gets the current list of size gradients.
  13497. * You must use addSizeGradient and removeSizeGradient to udpate this list
  13498. * @returns the list of size gradients
  13499. */
  13500. getSizeGradients(): Nullable<Array<FactorGradient>>;
  13501. /**
  13502. * Gets the current list of angular speed gradients.
  13503. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  13504. * @returns the list of angular speed gradients
  13505. */
  13506. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  13507. /**
  13508. * Adds a new angular speed gradient
  13509. * @param gradient defines the gradient to use (between 0 and 1)
  13510. * @param factor defines the angular speed to affect to the specified gradient
  13511. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13512. * @returns the current particle system
  13513. */
  13514. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13515. /**
  13516. * Remove a specific angular speed gradient
  13517. * @param gradient defines the gradient to remove
  13518. * @returns the current particle system
  13519. */
  13520. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13521. /**
  13522. * Gets the current list of velocity gradients.
  13523. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  13524. * @returns the list of velocity gradients
  13525. */
  13526. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  13527. /**
  13528. * Adds a new velocity gradient
  13529. * @param gradient defines the gradient to use (between 0 and 1)
  13530. * @param factor defines the velocity to affect to the specified gradient
  13531. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13532. * @returns the current particle system
  13533. */
  13534. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13535. /**
  13536. * Remove a specific velocity gradient
  13537. * @param gradient defines the gradient to remove
  13538. * @returns the current particle system
  13539. */
  13540. removeVelocityGradient(gradient: number): IParticleSystem;
  13541. /**
  13542. * Gets the current list of limit velocity gradients.
  13543. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  13544. * @returns the list of limit velocity gradients
  13545. */
  13546. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  13547. /**
  13548. * Adds a new limit velocity gradient
  13549. * @param gradient defines the gradient to use (between 0 and 1)
  13550. * @param factor defines the limit velocity to affect to the specified gradient
  13551. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13552. * @returns the current particle system
  13553. */
  13554. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13555. /**
  13556. * Remove a specific limit velocity gradient
  13557. * @param gradient defines the gradient to remove
  13558. * @returns the current particle system
  13559. */
  13560. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13561. /**
  13562. * Adds a new drag gradient
  13563. * @param gradient defines the gradient to use (between 0 and 1)
  13564. * @param factor defines the drag to affect to the specified gradient
  13565. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13566. * @returns the current particle system
  13567. */
  13568. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13569. /**
  13570. * Remove a specific drag gradient
  13571. * @param gradient defines the gradient to remove
  13572. * @returns the current particle system
  13573. */
  13574. removeDragGradient(gradient: number): IParticleSystem;
  13575. /**
  13576. * Gets the current list of drag gradients.
  13577. * You must use addDragGradient and removeDragGradient to udpate this list
  13578. * @returns the list of drag gradients
  13579. */
  13580. getDragGradients(): Nullable<Array<FactorGradient>>;
  13581. /**
  13582. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13583. * @param gradient defines the gradient to use (between 0 and 1)
  13584. * @param factor defines the emit rate to affect to the specified gradient
  13585. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13586. * @returns the current particle system
  13587. */
  13588. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13589. /**
  13590. * Remove a specific emit rate gradient
  13591. * @param gradient defines the gradient to remove
  13592. * @returns the current particle system
  13593. */
  13594. removeEmitRateGradient(gradient: number): IParticleSystem;
  13595. /**
  13596. * Gets the current list of emit rate gradients.
  13597. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  13598. * @returns the list of emit rate gradients
  13599. */
  13600. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  13601. /**
  13602. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13603. * @param gradient defines the gradient to use (between 0 and 1)
  13604. * @param factor defines the start size to affect to the specified gradient
  13605. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13606. * @returns the current particle system
  13607. */
  13608. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13609. /**
  13610. * Remove a specific start size gradient
  13611. * @param gradient defines the gradient to remove
  13612. * @returns the current particle system
  13613. */
  13614. removeStartSizeGradient(gradient: number): IParticleSystem;
  13615. /**
  13616. * Gets the current list of start size gradients.
  13617. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  13618. * @returns the list of start size gradients
  13619. */
  13620. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  13621. /**
  13622. * Adds a new life time gradient
  13623. * @param gradient defines the gradient to use (between 0 and 1)
  13624. * @param factor defines the life time factor to affect to the specified gradient
  13625. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13626. * @returns the current particle system
  13627. */
  13628. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13629. /**
  13630. * Remove a specific life time gradient
  13631. * @param gradient defines the gradient to remove
  13632. * @returns the current particle system
  13633. */
  13634. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13635. /**
  13636. * Gets the current list of life time gradients.
  13637. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  13638. * @returns the list of life time gradients
  13639. */
  13640. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  13641. /**
  13642. * Gets the current list of color gradients.
  13643. * You must use addColorGradient and removeColorGradient to udpate this list
  13644. * @returns the list of color gradients
  13645. */
  13646. getColorGradients(): Nullable<Array<ColorGradient>>;
  13647. /**
  13648. * Adds a new ramp gradient used to remap particle colors
  13649. * @param gradient defines the gradient to use (between 0 and 1)
  13650. * @param color defines the color to affect to the specified gradient
  13651. * @returns the current particle system
  13652. */
  13653. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  13654. /**
  13655. * Gets the current list of ramp gradients.
  13656. * You must use addRampGradient and removeRampGradient to udpate this list
  13657. * @returns the list of ramp gradients
  13658. */
  13659. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13660. /** Gets or sets a boolean indicating that ramp gradients must be used
  13661. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13662. */
  13663. useRampGradients: boolean;
  13664. /**
  13665. * Adds a new color remap gradient
  13666. * @param gradient defines the gradient to use (between 0 and 1)
  13667. * @param min defines the color remap minimal range
  13668. * @param max defines the color remap maximal range
  13669. * @returns the current particle system
  13670. */
  13671. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13672. /**
  13673. * Gets the current list of color remap gradients.
  13674. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  13675. * @returns the list of color remap gradients
  13676. */
  13677. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  13678. /**
  13679. * Adds a new alpha remap gradient
  13680. * @param gradient defines the gradient to use (between 0 and 1)
  13681. * @param min defines the alpha remap minimal range
  13682. * @param max defines the alpha remap maximal range
  13683. * @returns the current particle system
  13684. */
  13685. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13686. /**
  13687. * Gets the current list of alpha remap gradients.
  13688. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  13689. * @returns the list of alpha remap gradients
  13690. */
  13691. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  13692. /**
  13693. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  13694. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13695. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13696. * @returns the emitter
  13697. */
  13698. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  13699. /**
  13700. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  13701. * @param radius The radius of the hemisphere to emit from
  13702. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13703. * @returns the emitter
  13704. */
  13705. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  13706. /**
  13707. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  13708. * @param radius The radius of the sphere to emit from
  13709. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  13710. * @returns the emitter
  13711. */
  13712. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  13713. /**
  13714. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  13715. * @param radius The radius of the sphere to emit from
  13716. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  13717. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  13718. * @returns the emitter
  13719. */
  13720. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13721. /**
  13722. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  13723. * @param radius The radius of the emission cylinder
  13724. * @param height The height of the emission cylinder
  13725. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  13726. * @param directionRandomizer How much to randomize the particle direction [0-1]
  13727. * @returns the emitter
  13728. */
  13729. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  13730. /**
  13731. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  13732. * @param radius The radius of the cylinder to emit from
  13733. * @param height The height of the emission cylinder
  13734. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13735. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  13736. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  13737. * @returns the emitter
  13738. */
  13739. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  13740. /**
  13741. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  13742. * @param radius The radius of the cone to emit from
  13743. * @param angle The base angle of the cone
  13744. * @returns the emitter
  13745. */
  13746. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  13747. /**
  13748. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  13749. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  13750. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  13751. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13752. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  13753. * @returns the emitter
  13754. */
  13755. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  13756. /**
  13757. * Get hosting scene
  13758. * @returns the scene
  13759. */
  13760. getScene(): Scene;
  13761. }
  13762. }
  13763. declare module "babylonjs/Meshes/transformNode" {
  13764. import { DeepImmutable } from "babylonjs/types";
  13765. import { Observable } from "babylonjs/Misc/observable";
  13766. import { Nullable } from "babylonjs/types";
  13767. import { Camera } from "babylonjs/Cameras/camera";
  13768. import { Scene } from "babylonjs/scene";
  13769. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  13770. import { Node } from "babylonjs/node";
  13771. import { Bone } from "babylonjs/Bones/bone";
  13772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13773. import { Space } from "babylonjs/Maths/math.axis";
  13774. /**
  13775. * A TransformNode is an object that is not rendered but can be used as a center of transformation. This can decrease memory usage and increase rendering speed compared to using an empty mesh as a parent and is less complicated than using a pivot matrix.
  13776. * @see https://doc.babylonjs.com/how_to/transformnode
  13777. */
  13778. export class TransformNode extends Node {
  13779. /**
  13780. * Object will not rotate to face the camera
  13781. */
  13782. static BILLBOARDMODE_NONE: number;
  13783. /**
  13784. * Object will rotate to face the camera but only on the x axis
  13785. */
  13786. static BILLBOARDMODE_X: number;
  13787. /**
  13788. * Object will rotate to face the camera but only on the y axis
  13789. */
  13790. static BILLBOARDMODE_Y: number;
  13791. /**
  13792. * Object will rotate to face the camera but only on the z axis
  13793. */
  13794. static BILLBOARDMODE_Z: number;
  13795. /**
  13796. * Object will rotate to face the camera
  13797. */
  13798. static BILLBOARDMODE_ALL: number;
  13799. /**
  13800. * Object will rotate to face the camera's position instead of orientation
  13801. */
  13802. static BILLBOARDMODE_USE_POSITION: number;
  13803. private _forward;
  13804. private _forwardInverted;
  13805. private _up;
  13806. private _right;
  13807. private _rightInverted;
  13808. private _position;
  13809. private _rotation;
  13810. private _rotationQuaternion;
  13811. protected _scaling: Vector3;
  13812. protected _isDirty: boolean;
  13813. private _transformToBoneReferal;
  13814. private _isAbsoluteSynced;
  13815. private _billboardMode;
  13816. /**
  13817. * Gets or sets the billboard mode. Default is 0.
  13818. *
  13819. * | Value | Type | Description |
  13820. * | --- | --- | --- |
  13821. * | 0 | BILLBOARDMODE_NONE | |
  13822. * | 1 | BILLBOARDMODE_X | |
  13823. * | 2 | BILLBOARDMODE_Y | |
  13824. * | 4 | BILLBOARDMODE_Z | |
  13825. * | 7 | BILLBOARDMODE_ALL | |
  13826. *
  13827. */
  13828. get billboardMode(): number;
  13829. set billboardMode(value: number);
  13830. private _preserveParentRotationForBillboard;
  13831. /**
  13832. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13833. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13834. */
  13835. get preserveParentRotationForBillboard(): boolean;
  13836. set preserveParentRotationForBillboard(value: boolean);
  13837. /**
  13838. * Multiplication factor on scale x/y/z when computing the world matrix. Eg. for a 1x1x1 cube setting this to 2 will make it a 2x2x2 cube
  13839. */
  13840. scalingDeterminant: number;
  13841. private _infiniteDistance;
  13842. /**
  13843. * Gets or sets the distance of the object to max, often used by skybox
  13844. */
  13845. get infiniteDistance(): boolean;
  13846. set infiniteDistance(value: boolean);
  13847. /**
  13848. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13849. * By default the system will update normals to compensate
  13850. */
  13851. ignoreNonUniformScaling: boolean;
  13852. /**
  13853. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  13854. */
  13855. reIntegrateRotationIntoRotationQuaternion: boolean;
  13856. /** @hidden */
  13857. _poseMatrix: Nullable<Matrix>;
  13858. /** @hidden */
  13859. _localMatrix: Matrix;
  13860. private _usePivotMatrix;
  13861. private _absolutePosition;
  13862. private _absoluteScaling;
  13863. private _absoluteRotationQuaternion;
  13864. private _pivotMatrix;
  13865. private _pivotMatrixInverse;
  13866. protected _postMultiplyPivotMatrix: boolean;
  13867. protected _isWorldMatrixFrozen: boolean;
  13868. /** @hidden */
  13869. _indexInSceneTransformNodesArray: number;
  13870. /**
  13871. * An event triggered after the world matrix is updated
  13872. */
  13873. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13874. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13875. /**
  13876. * Gets a string identifying the name of the class
  13877. * @returns "TransformNode" string
  13878. */
  13879. getClassName(): string;
  13880. /**
  13881. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13882. */
  13883. get position(): Vector3;
  13884. set position(newPosition: Vector3);
  13885. /**
  13886. * Gets or sets the rotation property : a Vector3 defining the rotation value in radians around each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  13887. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13888. */
  13889. get rotation(): Vector3;
  13890. set rotation(newRotation: Vector3);
  13891. /**
  13892. * Gets or sets the scaling property : a Vector3 defining the node scaling along each local axis X, Y, Z (default is (0.0, 0.0, 0.0)).
  13893. */
  13894. get scaling(): Vector3;
  13895. set scaling(newScaling: Vector3);
  13896. /**
  13897. * Gets or sets the rotation Quaternion property : this a Quaternion object defining the node rotation by using a unit quaternion (undefined by default, but can be null).
  13898. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13899. */
  13900. get rotationQuaternion(): Nullable<Quaternion>;
  13901. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  13902. /**
  13903. * The forward direction of that transform in world space.
  13904. */
  13905. get forward(): Vector3;
  13906. /**
  13907. * The up direction of that transform in world space.
  13908. */
  13909. get up(): Vector3;
  13910. /**
  13911. * The right direction of that transform in world space.
  13912. */
  13913. get right(): Vector3;
  13914. /**
  13915. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13916. * @param matrix the matrix to copy the pose from
  13917. * @returns this TransformNode.
  13918. */
  13919. updatePoseMatrix(matrix: Matrix): TransformNode;
  13920. /**
  13921. * Returns the mesh Pose matrix.
  13922. * @returns the pose matrix
  13923. */
  13924. getPoseMatrix(): Matrix;
  13925. /** @hidden */
  13926. _isSynchronized(): boolean;
  13927. /** @hidden */
  13928. _initCache(): void;
  13929. /**
  13930. * Flag the transform node as dirty (Forcing it to update everything)
  13931. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13932. * @returns this transform node
  13933. */
  13934. markAsDirty(property: string): TransformNode;
  13935. /**
  13936. * Returns the current mesh absolute position.
  13937. * Returns a Vector3.
  13938. */
  13939. get absolutePosition(): Vector3;
  13940. /**
  13941. * Returns the current mesh absolute scaling.
  13942. * Returns a Vector3.
  13943. */
  13944. get absoluteScaling(): Vector3;
  13945. /**
  13946. * Returns the current mesh absolute rotation.
  13947. * Returns a Quaternion.
  13948. */
  13949. get absoluteRotationQuaternion(): Quaternion;
  13950. /**
  13951. * Sets a new matrix to apply before all other transformation
  13952. * @param matrix defines the transform matrix
  13953. * @returns the current TransformNode
  13954. */
  13955. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13956. /**
  13957. * Sets a new pivot matrix to the current node
  13958. * @param matrix defines the new pivot matrix to use
  13959. * @param postMultiplyPivotMatrix defines if the pivot matrix must be cancelled in the world matrix. When this parameter is set to true (default), the inverse of the pivot matrix is also applied at the end to cancel the transformation effect
  13960. * @returns the current TransformNode
  13961. */
  13962. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13963. /**
  13964. * Returns the mesh pivot matrix.
  13965. * Default : Identity.
  13966. * @returns the matrix
  13967. */
  13968. getPivotMatrix(): Matrix;
  13969. /**
  13970. * Instantiate (when possible) or clone that node with its hierarchy
  13971. * @param newParent defines the new parent to use for the instance (or clone)
  13972. * @param options defines options to configure how copy is done
  13973. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  13974. * @returns an instance (or a clone) of the current node with its hiearchy
  13975. */
  13976. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  13977. doNotInstantiate: boolean;
  13978. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  13979. /**
  13980. * Prevents the World matrix to be computed any longer
  13981. * @param newWorldMatrix defines an optional matrix to use as world matrix
  13982. * @returns the TransformNode.
  13983. */
  13984. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  13985. /**
  13986. * Allows back the World matrix computation.
  13987. * @returns the TransformNode.
  13988. */
  13989. unfreezeWorldMatrix(): this;
  13990. /**
  13991. * True if the World matrix has been frozen.
  13992. */
  13993. get isWorldMatrixFrozen(): boolean;
  13994. /**
  13995. * Retuns the mesh absolute position in the World.
  13996. * @returns a Vector3.
  13997. */
  13998. getAbsolutePosition(): Vector3;
  13999. /**
  14000. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14001. * @param absolutePosition the absolute position to set
  14002. * @returns the TransformNode.
  14003. */
  14004. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14005. /**
  14006. * Sets the mesh position in its local space.
  14007. * @param vector3 the position to set in localspace
  14008. * @returns the TransformNode.
  14009. */
  14010. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14011. /**
  14012. * Returns the mesh position in the local space from the current World matrix values.
  14013. * @returns a new Vector3.
  14014. */
  14015. getPositionExpressedInLocalSpace(): Vector3;
  14016. /**
  14017. * Translates the mesh along the passed Vector3 in its local space.
  14018. * @param vector3 the distance to translate in localspace
  14019. * @returns the TransformNode.
  14020. */
  14021. locallyTranslate(vector3: Vector3): TransformNode;
  14022. private static _lookAtVectorCache;
  14023. /**
  14024. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14025. * @param targetPoint the position (must be in same space as current mesh) to look at
  14026. * @param yawCor optional yaw (y-axis) correction in radians
  14027. * @param pitchCor optional pitch (x-axis) correction in radians
  14028. * @param rollCor optional roll (z-axis) correction in radians
  14029. * @param space the choosen space of the target
  14030. * @returns the TransformNode.
  14031. */
  14032. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14033. /**
  14034. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14035. * This Vector3 is expressed in the World space.
  14036. * @param localAxis axis to rotate
  14037. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14038. */
  14039. getDirection(localAxis: Vector3): Vector3;
  14040. /**
  14041. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14042. * localAxis is expressed in the mesh local space.
  14043. * result is computed in the Wordl space from the mesh World matrix.
  14044. * @param localAxis axis to rotate
  14045. * @param result the resulting transformnode
  14046. * @returns this TransformNode.
  14047. */
  14048. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14049. /**
  14050. * Sets this transform node rotation to the given local axis.
  14051. * @param localAxis the axis in local space
  14052. * @param yawCor optional yaw (y-axis) correction in radians
  14053. * @param pitchCor optional pitch (x-axis) correction in radians
  14054. * @param rollCor optional roll (z-axis) correction in radians
  14055. * @returns this TransformNode
  14056. */
  14057. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14058. /**
  14059. * Sets a new pivot point to the current node
  14060. * @param point defines the new pivot point to use
  14061. * @param space defines if the point is in world or local space (local by default)
  14062. * @returns the current TransformNode
  14063. */
  14064. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14065. /**
  14066. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14067. * @returns the pivot point
  14068. */
  14069. getPivotPoint(): Vector3;
  14070. /**
  14071. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14072. * @param result the vector3 to store the result
  14073. * @returns this TransformNode.
  14074. */
  14075. getPivotPointToRef(result: Vector3): TransformNode;
  14076. /**
  14077. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14078. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14079. */
  14080. getAbsolutePivotPoint(): Vector3;
  14081. /**
  14082. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14083. * @param result vector3 to store the result
  14084. * @returns this TransformNode.
  14085. */
  14086. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14087. /**
  14088. * Defines the passed node as the parent of the current node.
  14089. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14090. * @see https://doc.babylonjs.com/how_to/parenting
  14091. * @param node the node ot set as the parent
  14092. * @returns this TransformNode.
  14093. */
  14094. setParent(node: Nullable<Node>): TransformNode;
  14095. private _nonUniformScaling;
  14096. /**
  14097. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14098. */
  14099. get nonUniformScaling(): boolean;
  14100. /** @hidden */
  14101. _updateNonUniformScalingState(value: boolean): boolean;
  14102. /**
  14103. * Attach the current TransformNode to another TransformNode associated with a bone
  14104. * @param bone Bone affecting the TransformNode
  14105. * @param affectedTransformNode TransformNode associated with the bone
  14106. * @returns this object
  14107. */
  14108. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14109. /**
  14110. * Detach the transform node if its associated with a bone
  14111. * @returns this object
  14112. */
  14113. detachFromBone(): TransformNode;
  14114. private static _rotationAxisCache;
  14115. /**
  14116. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14117. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14118. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14119. * The passed axis is also normalized.
  14120. * @param axis the axis to rotate around
  14121. * @param amount the amount to rotate in radians
  14122. * @param space Space to rotate in (Default: local)
  14123. * @returns the TransformNode.
  14124. */
  14125. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14126. /**
  14127. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14128. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14129. * The passed axis is also normalized. .
  14130. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14131. * @param point the point to rotate around
  14132. * @param axis the axis to rotate around
  14133. * @param amount the amount to rotate in radians
  14134. * @returns the TransformNode
  14135. */
  14136. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14137. /**
  14138. * Translates the mesh along the axis vector for the passed distance in the given space.
  14139. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14140. * @param axis the axis to translate in
  14141. * @param distance the distance to translate
  14142. * @param space Space to rotate in (Default: local)
  14143. * @returns the TransformNode.
  14144. */
  14145. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14146. /**
  14147. * Adds a rotation step to the mesh current rotation.
  14148. * x, y, z are Euler angles expressed in radians.
  14149. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14150. * This means this rotation is made in the mesh local space only.
  14151. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14152. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14153. * ```javascript
  14154. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14155. * ```
  14156. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14157. * Under the hood, only quaternions are used. So it's a little faster is you use .rotationQuaternion because it doesn't need to translate them back to Euler angles.
  14158. * @param x Rotation to add
  14159. * @param y Rotation to add
  14160. * @param z Rotation to add
  14161. * @returns the TransformNode.
  14162. */
  14163. addRotation(x: number, y: number, z: number): TransformNode;
  14164. /**
  14165. * @hidden
  14166. */
  14167. protected _getEffectiveParent(): Nullable<Node>;
  14168. /**
  14169. * Computes the world matrix of the node
  14170. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14171. * @returns the world matrix
  14172. */
  14173. computeWorldMatrix(force?: boolean): Matrix;
  14174. /**
  14175. * Resets this nodeTransform's local matrix to Matrix.Identity().
  14176. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  14177. */
  14178. resetLocalMatrix(independentOfChildren?: boolean): void;
  14179. protected _afterComputeWorldMatrix(): void;
  14180. /**
  14181. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14182. * @param func callback function to add
  14183. *
  14184. * @returns the TransformNode.
  14185. */
  14186. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14187. /**
  14188. * Removes a registered callback function.
  14189. * @param func callback function to remove
  14190. * @returns the TransformNode.
  14191. */
  14192. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14193. /**
  14194. * Gets the position of the current mesh in camera space
  14195. * @param camera defines the camera to use
  14196. * @returns a position
  14197. */
  14198. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14199. /**
  14200. * Returns the distance from the mesh to the active camera
  14201. * @param camera defines the camera to use
  14202. * @returns the distance
  14203. */
  14204. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14205. /**
  14206. * Clone the current transform node
  14207. * @param name Name of the new clone
  14208. * @param newParent New parent for the clone
  14209. * @param doNotCloneChildren Do not clone children hierarchy
  14210. * @returns the new transform node
  14211. */
  14212. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14213. /**
  14214. * Serializes the objects information.
  14215. * @param currentSerializationObject defines the object to serialize in
  14216. * @returns the serialized object
  14217. */
  14218. serialize(currentSerializationObject?: any): any;
  14219. /**
  14220. * Returns a new TransformNode object parsed from the source provided.
  14221. * @param parsedTransformNode is the source.
  14222. * @param scene the scne the object belongs to
  14223. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14224. * @returns a new TransformNode object parsed from the source provided.
  14225. */
  14226. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14227. /**
  14228. * Get all child-transformNodes of this node
  14229. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  14230. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  14231. * @returns an array of TransformNode
  14232. */
  14233. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14234. /**
  14235. * Releases resources associated with this transform node.
  14236. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14237. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14238. */
  14239. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14240. /**
  14241. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14242. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14243. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14244. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14245. * @returns the current mesh
  14246. */
  14247. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14248. private _syncAbsoluteScalingAndRotation;
  14249. }
  14250. }
  14251. declare module "babylonjs/Animations/animationPropertiesOverride" {
  14252. /**
  14253. * Class used to override all child animations of a given target
  14254. */
  14255. export class AnimationPropertiesOverride {
  14256. /**
  14257. * Gets or sets a value indicating if animation blending must be used
  14258. */
  14259. enableBlending: boolean;
  14260. /**
  14261. * Gets or sets the blending speed to use when enableBlending is true
  14262. */
  14263. blendingSpeed: number;
  14264. /**
  14265. * Gets or sets the default loop mode to use
  14266. */
  14267. loopMode: number;
  14268. }
  14269. }
  14270. declare module "babylonjs/Bones/bone" {
  14271. import { Skeleton } from "babylonjs/Bones/skeleton";
  14272. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  14273. import { Nullable } from "babylonjs/types";
  14274. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14275. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14276. import { Node } from "babylonjs/node";
  14277. import { Space } from "babylonjs/Maths/math.axis";
  14278. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  14279. /**
  14280. * Class used to store bone information
  14281. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  14282. */
  14283. export class Bone extends Node {
  14284. /**
  14285. * defines the bone name
  14286. */
  14287. name: string;
  14288. private static _tmpVecs;
  14289. private static _tmpQuat;
  14290. private static _tmpMats;
  14291. /**
  14292. * Gets the list of child bones
  14293. */
  14294. children: Bone[];
  14295. /** Gets the animations associated with this bone */
  14296. animations: import("babylonjs/Animations/animation").Animation[];
  14297. /**
  14298. * Gets or sets bone length
  14299. */
  14300. length: number;
  14301. /**
  14302. * @hidden Internal only
  14303. * Set this value to map this bone to a different index in the transform matrices
  14304. * Set this value to -1 to exclude the bone from the transform matrices
  14305. */
  14306. _index: Nullable<number>;
  14307. private _skeleton;
  14308. private _localMatrix;
  14309. private _restPose;
  14310. private _baseMatrix;
  14311. private _absoluteTransform;
  14312. private _invertedAbsoluteTransform;
  14313. private _parent;
  14314. private _scalingDeterminant;
  14315. private _worldTransform;
  14316. private _localScaling;
  14317. private _localRotation;
  14318. private _localPosition;
  14319. private _needToDecompose;
  14320. private _needToCompose;
  14321. /** @hidden */
  14322. _linkedTransformNode: Nullable<TransformNode>;
  14323. /** @hidden */
  14324. _waitingTransformNodeId: Nullable<string>;
  14325. /** @hidden */
  14326. get _matrix(): Matrix;
  14327. /** @hidden */
  14328. set _matrix(value: Matrix);
  14329. /**
  14330. * Create a new bone
  14331. * @param name defines the bone name
  14332. * @param skeleton defines the parent skeleton
  14333. * @param parentBone defines the parent (can be null if the bone is the root)
  14334. * @param localMatrix defines the local matrix
  14335. * @param restPose defines the rest pose matrix
  14336. * @param baseMatrix defines the base matrix
  14337. * @param index defines index of the bone in the hiearchy
  14338. */
  14339. constructor(
  14340. /**
  14341. * defines the bone name
  14342. */
  14343. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  14344. /**
  14345. * Gets the current object class name.
  14346. * @return the class name
  14347. */
  14348. getClassName(): string;
  14349. /**
  14350. * Gets the parent skeleton
  14351. * @returns a skeleton
  14352. */
  14353. getSkeleton(): Skeleton;
  14354. /**
  14355. * Gets parent bone
  14356. * @returns a bone or null if the bone is the root of the bone hierarchy
  14357. */
  14358. getParent(): Nullable<Bone>;
  14359. /**
  14360. * Returns an array containing the root bones
  14361. * @returns an array containing the root bones
  14362. */
  14363. getChildren(): Array<Bone>;
  14364. /**
  14365. * Gets the node index in matrix array generated for rendering
  14366. * @returns the node index
  14367. */
  14368. getIndex(): number;
  14369. /**
  14370. * Sets the parent bone
  14371. * @param parent defines the parent (can be null if the bone is the root)
  14372. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14373. */
  14374. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  14375. /**
  14376. * Gets the local matrix
  14377. * @returns a matrix
  14378. */
  14379. getLocalMatrix(): Matrix;
  14380. /**
  14381. * Gets the base matrix (initial matrix which remains unchanged)
  14382. * @returns a matrix
  14383. */
  14384. getBaseMatrix(): Matrix;
  14385. /**
  14386. * Gets the rest pose matrix
  14387. * @returns a matrix
  14388. */
  14389. getRestPose(): Matrix;
  14390. /**
  14391. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  14392. */
  14393. getWorldMatrix(): Matrix;
  14394. /**
  14395. * Sets the local matrix to rest pose matrix
  14396. */
  14397. returnToRest(): void;
  14398. /**
  14399. * Gets the inverse of the absolute transform matrix.
  14400. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  14401. * @returns a matrix
  14402. */
  14403. getInvertedAbsoluteTransform(): Matrix;
  14404. /**
  14405. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  14406. * @returns a matrix
  14407. */
  14408. getAbsoluteTransform(): Matrix;
  14409. /**
  14410. * Links with the given transform node.
  14411. * The local matrix of this bone is copied from the transform node every frame.
  14412. * @param transformNode defines the transform node to link to
  14413. */
  14414. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  14415. /**
  14416. * Gets the node used to drive the bone's transformation
  14417. * @returns a transform node or null
  14418. */
  14419. getTransformNode(): Nullable<TransformNode>;
  14420. /** Gets or sets current position (in local space) */
  14421. get position(): Vector3;
  14422. set position(newPosition: Vector3);
  14423. /** Gets or sets current rotation (in local space) */
  14424. get rotation(): Vector3;
  14425. set rotation(newRotation: Vector3);
  14426. /** Gets or sets current rotation quaternion (in local space) */
  14427. get rotationQuaternion(): Quaternion;
  14428. set rotationQuaternion(newRotation: Quaternion);
  14429. /** Gets or sets current scaling (in local space) */
  14430. get scaling(): Vector3;
  14431. set scaling(newScaling: Vector3);
  14432. /**
  14433. * Gets the animation properties override
  14434. */
  14435. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  14436. private _decompose;
  14437. private _compose;
  14438. /**
  14439. * Update the base and local matrices
  14440. * @param matrix defines the new base or local matrix
  14441. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  14442. * @param updateLocalMatrix defines if the local matrix should be updated
  14443. */
  14444. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  14445. /** @hidden */
  14446. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  14447. /**
  14448. * Flag the bone as dirty (Forcing it to update everything)
  14449. */
  14450. markAsDirty(): void;
  14451. /** @hidden */
  14452. _markAsDirtyAndCompose(): void;
  14453. private _markAsDirtyAndDecompose;
  14454. /**
  14455. * Translate the bone in local or world space
  14456. * @param vec The amount to translate the bone
  14457. * @param space The space that the translation is in
  14458. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14459. */
  14460. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14461. /**
  14462. * Set the postion of the bone in local or world space
  14463. * @param position The position to set the bone
  14464. * @param space The space that the position is in
  14465. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14466. */
  14467. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14468. /**
  14469. * Set the absolute position of the bone (world space)
  14470. * @param position The position to set the bone
  14471. * @param mesh The mesh that this bone is attached to
  14472. */
  14473. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  14474. /**
  14475. * Scale the bone on the x, y and z axes (in local space)
  14476. * @param x The amount to scale the bone on the x axis
  14477. * @param y The amount to scale the bone on the y axis
  14478. * @param z The amount to scale the bone on the z axis
  14479. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  14480. */
  14481. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  14482. /**
  14483. * Set the bone scaling in local space
  14484. * @param scale defines the scaling vector
  14485. */
  14486. setScale(scale: Vector3): void;
  14487. /**
  14488. * Gets the current scaling in local space
  14489. * @returns the current scaling vector
  14490. */
  14491. getScale(): Vector3;
  14492. /**
  14493. * Gets the current scaling in local space and stores it in a target vector
  14494. * @param result defines the target vector
  14495. */
  14496. getScaleToRef(result: Vector3): void;
  14497. /**
  14498. * Set the yaw, pitch, and roll of the bone in local or world space
  14499. * @param yaw The rotation of the bone on the y axis
  14500. * @param pitch The rotation of the bone on the x axis
  14501. * @param roll The rotation of the bone on the z axis
  14502. * @param space The space that the axes of rotation are in
  14503. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14504. */
  14505. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14506. /**
  14507. * Add a rotation to the bone on an axis in local or world space
  14508. * @param axis The axis to rotate the bone on
  14509. * @param amount The amount to rotate the bone
  14510. * @param space The space that the axis is in
  14511. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14512. */
  14513. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14514. /**
  14515. * Set the rotation of the bone to a particular axis angle in local or world space
  14516. * @param axis The axis to rotate the bone on
  14517. * @param angle The angle that the bone should be rotated to
  14518. * @param space The space that the axis is in
  14519. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14520. */
  14521. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14522. /**
  14523. * Set the euler rotation of the bone in local of world space
  14524. * @param rotation The euler rotation that the bone should be set to
  14525. * @param space The space that the rotation is in
  14526. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14527. */
  14528. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14529. /**
  14530. * Set the quaternion rotation of the bone in local of world space
  14531. * @param quat The quaternion rotation that the bone should be set to
  14532. * @param space The space that the rotation is in
  14533. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14534. */
  14535. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14536. /**
  14537. * Set the rotation matrix of the bone in local of world space
  14538. * @param rotMat The rotation matrix that the bone should be set to
  14539. * @param space The space that the rotation is in
  14540. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14541. */
  14542. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14543. private _rotateWithMatrix;
  14544. private _getNegativeRotationToRef;
  14545. /**
  14546. * Get the position of the bone in local or world space
  14547. * @param space The space that the returned position is in
  14548. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14549. * @returns The position of the bone
  14550. */
  14551. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14552. /**
  14553. * Copy the position of the bone to a vector3 in local or world space
  14554. * @param space The space that the returned position is in
  14555. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14556. * @param result The vector3 to copy the position to
  14557. */
  14558. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14559. /**
  14560. * Get the absolute position of the bone (world space)
  14561. * @param mesh The mesh that this bone is attached to
  14562. * @returns The absolute position of the bone
  14563. */
  14564. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14565. /**
  14566. * Copy the absolute position of the bone (world space) to the result param
  14567. * @param mesh The mesh that this bone is attached to
  14568. * @param result The vector3 to copy the absolute position to
  14569. */
  14570. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14571. /**
  14572. * Compute the absolute transforms of this bone and its children
  14573. */
  14574. computeAbsoluteTransforms(): void;
  14575. /**
  14576. * Get the world direction from an axis that is in the local space of the bone
  14577. * @param localAxis The local direction that is used to compute the world direction
  14578. * @param mesh The mesh that this bone is attached to
  14579. * @returns The world direction
  14580. */
  14581. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14582. /**
  14583. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14584. * @param localAxis The local direction that is used to compute the world direction
  14585. * @param mesh The mesh that this bone is attached to
  14586. * @param result The vector3 that the world direction will be copied to
  14587. */
  14588. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14589. /**
  14590. * Get the euler rotation of the bone in local or world space
  14591. * @param space The space that the rotation should be in
  14592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14593. * @returns The euler rotation
  14594. */
  14595. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14596. /**
  14597. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14598. * @param space The space that the rotation should be in
  14599. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14600. * @param result The vector3 that the rotation should be copied to
  14601. */
  14602. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14603. /**
  14604. * Get the quaternion rotation of the bone in either local or world space
  14605. * @param space The space that the rotation should be in
  14606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14607. * @returns The quaternion rotation
  14608. */
  14609. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14610. /**
  14611. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14612. * @param space The space that the rotation should be in
  14613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14614. * @param result The quaternion that the rotation should be copied to
  14615. */
  14616. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14617. /**
  14618. * Get the rotation matrix of the bone in local or world space
  14619. * @param space The space that the rotation should be in
  14620. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14621. * @returns The rotation matrix
  14622. */
  14623. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14624. /**
  14625. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14626. * @param space The space that the rotation should be in
  14627. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14628. * @param result The quaternion that the rotation should be copied to
  14629. */
  14630. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14631. /**
  14632. * Get the world position of a point that is in the local space of the bone
  14633. * @param position The local position
  14634. * @param mesh The mesh that this bone is attached to
  14635. * @returns The world position
  14636. */
  14637. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14638. /**
  14639. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14640. * @param position The local position
  14641. * @param mesh The mesh that this bone is attached to
  14642. * @param result The vector3 that the world position should be copied to
  14643. */
  14644. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14645. /**
  14646. * Get the local position of a point that is in world space
  14647. * @param position The world position
  14648. * @param mesh The mesh that this bone is attached to
  14649. * @returns The local position
  14650. */
  14651. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14652. /**
  14653. * Get the local position of a point that is in world space and copy it to the result param
  14654. * @param position The world position
  14655. * @param mesh The mesh that this bone is attached to
  14656. * @param result The vector3 that the local position should be copied to
  14657. */
  14658. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14659. }
  14660. }
  14661. declare module "babylonjs/Animations/runtimeAnimation" {
  14662. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  14663. import { Animatable } from "babylonjs/Animations/animatable";
  14664. import { Scene } from "babylonjs/scene";
  14665. /**
  14666. * Defines a runtime animation
  14667. */
  14668. export class RuntimeAnimation {
  14669. private _events;
  14670. /**
  14671. * The current frame of the runtime animation
  14672. */
  14673. private _currentFrame;
  14674. /**
  14675. * The animation used by the runtime animation
  14676. */
  14677. private _animation;
  14678. /**
  14679. * The target of the runtime animation
  14680. */
  14681. private _target;
  14682. /**
  14683. * The initiating animatable
  14684. */
  14685. private _host;
  14686. /**
  14687. * The original value of the runtime animation
  14688. */
  14689. private _originalValue;
  14690. /**
  14691. * The original blend value of the runtime animation
  14692. */
  14693. private _originalBlendValue;
  14694. /**
  14695. * The offsets cache of the runtime animation
  14696. */
  14697. private _offsetsCache;
  14698. /**
  14699. * The high limits cache of the runtime animation
  14700. */
  14701. private _highLimitsCache;
  14702. /**
  14703. * Specifies if the runtime animation has been stopped
  14704. */
  14705. private _stopped;
  14706. /**
  14707. * The blending factor of the runtime animation
  14708. */
  14709. private _blendingFactor;
  14710. /**
  14711. * The BabylonJS scene
  14712. */
  14713. private _scene;
  14714. /**
  14715. * The current value of the runtime animation
  14716. */
  14717. private _currentValue;
  14718. /** @hidden */
  14719. _animationState: _IAnimationState;
  14720. /**
  14721. * The active target of the runtime animation
  14722. */
  14723. private _activeTargets;
  14724. private _currentActiveTarget;
  14725. private _directTarget;
  14726. /**
  14727. * The target path of the runtime animation
  14728. */
  14729. private _targetPath;
  14730. /**
  14731. * The weight of the runtime animation
  14732. */
  14733. private _weight;
  14734. /**
  14735. * The ratio offset of the runtime animation
  14736. */
  14737. private _ratioOffset;
  14738. /**
  14739. * The previous delay of the runtime animation
  14740. */
  14741. private _previousDelay;
  14742. /**
  14743. * The previous ratio of the runtime animation
  14744. */
  14745. private _previousRatio;
  14746. private _enableBlending;
  14747. private _keys;
  14748. private _minFrame;
  14749. private _maxFrame;
  14750. private _minValue;
  14751. private _maxValue;
  14752. private _targetIsArray;
  14753. /**
  14754. * Gets the current frame of the runtime animation
  14755. */
  14756. get currentFrame(): number;
  14757. /**
  14758. * Gets the weight of the runtime animation
  14759. */
  14760. get weight(): number;
  14761. /**
  14762. * Gets the current value of the runtime animation
  14763. */
  14764. get currentValue(): any;
  14765. /**
  14766. * Gets the target path of the runtime animation
  14767. */
  14768. get targetPath(): string;
  14769. /**
  14770. * Gets the actual target of the runtime animation
  14771. */
  14772. get target(): any;
  14773. /** @hidden */
  14774. _onLoop: () => void;
  14775. /**
  14776. * Create a new RuntimeAnimation object
  14777. * @param target defines the target of the animation
  14778. * @param animation defines the source animation object
  14779. * @param scene defines the hosting scene
  14780. * @param host defines the initiating Animatable
  14781. */
  14782. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  14783. private _preparePath;
  14784. /**
  14785. * Gets the animation from the runtime animation
  14786. */
  14787. get animation(): Animation;
  14788. /**
  14789. * Resets the runtime animation to the beginning
  14790. * @param restoreOriginal defines whether to restore the target property to the original value
  14791. */
  14792. reset(restoreOriginal?: boolean): void;
  14793. /**
  14794. * Specifies if the runtime animation is stopped
  14795. * @returns Boolean specifying if the runtime animation is stopped
  14796. */
  14797. isStopped(): boolean;
  14798. /**
  14799. * Disposes of the runtime animation
  14800. */
  14801. dispose(): void;
  14802. /**
  14803. * Apply the interpolated value to the target
  14804. * @param currentValue defines the value computed by the animation
  14805. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  14806. */
  14807. setValue(currentValue: any, weight: number): void;
  14808. private _getOriginalValues;
  14809. private _setValue;
  14810. /**
  14811. * Gets the loop pmode of the runtime animation
  14812. * @returns Loop Mode
  14813. */
  14814. private _getCorrectLoopMode;
  14815. /**
  14816. * Move the current animation to a given frame
  14817. * @param frame defines the frame to move to
  14818. */
  14819. goToFrame(frame: number): void;
  14820. /**
  14821. * @hidden Internal use only
  14822. */
  14823. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  14824. /**
  14825. * Execute the current animation
  14826. * @param delay defines the delay to add to the current frame
  14827. * @param from defines the lower bound of the animation range
  14828. * @param to defines the upper bound of the animation range
  14829. * @param loop defines if the current animation must loop
  14830. * @param speedRatio defines the current speed ratio
  14831. * @param weight defines the weight of the animation (default is -1 so no weight)
  14832. * @param onLoop optional callback called when animation loops
  14833. * @returns a boolean indicating if the animation is running
  14834. */
  14835. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  14836. }
  14837. }
  14838. declare module "babylonjs/Animations/animatable" {
  14839. import { Animation } from "babylonjs/Animations/animation";
  14840. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  14841. import { Nullable } from "babylonjs/types";
  14842. import { Observable } from "babylonjs/Misc/observable";
  14843. import { Scene } from "babylonjs/scene";
  14844. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  14845. import { Node } from "babylonjs/node";
  14846. /**
  14847. * Class used to store an actual running animation
  14848. */
  14849. export class Animatable {
  14850. /** defines the target object */
  14851. target: any;
  14852. /** defines the starting frame number (default is 0) */
  14853. fromFrame: number;
  14854. /** defines the ending frame number (default is 100) */
  14855. toFrame: number;
  14856. /** defines if the animation must loop (default is false) */
  14857. loopAnimation: boolean;
  14858. /** defines a callback to call when animation ends if it is not looping */
  14859. onAnimationEnd?: (() => void) | null | undefined;
  14860. /** defines a callback to call when animation loops */
  14861. onAnimationLoop?: (() => void) | null | undefined;
  14862. private _localDelayOffset;
  14863. private _pausedDelay;
  14864. private _runtimeAnimations;
  14865. private _paused;
  14866. private _scene;
  14867. private _speedRatio;
  14868. private _weight;
  14869. private _syncRoot;
  14870. /**
  14871. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  14872. * This will only apply for non looping animation (default is true)
  14873. */
  14874. disposeOnEnd: boolean;
  14875. /**
  14876. * Gets a boolean indicating if the animation has started
  14877. */
  14878. animationStarted: boolean;
  14879. /**
  14880. * Observer raised when the animation ends
  14881. */
  14882. onAnimationEndObservable: Observable<Animatable>;
  14883. /**
  14884. * Observer raised when the animation loops
  14885. */
  14886. onAnimationLoopObservable: Observable<Animatable>;
  14887. /**
  14888. * Gets the root Animatable used to synchronize and normalize animations
  14889. */
  14890. get syncRoot(): Nullable<Animatable>;
  14891. /**
  14892. * Gets the current frame of the first RuntimeAnimation
  14893. * Used to synchronize Animatables
  14894. */
  14895. get masterFrame(): number;
  14896. /**
  14897. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  14898. */
  14899. get weight(): number;
  14900. set weight(value: number);
  14901. /**
  14902. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  14903. */
  14904. get speedRatio(): number;
  14905. set speedRatio(value: number);
  14906. /**
  14907. * Creates a new Animatable
  14908. * @param scene defines the hosting scene
  14909. * @param target defines the target object
  14910. * @param fromFrame defines the starting frame number (default is 0)
  14911. * @param toFrame defines the ending frame number (default is 100)
  14912. * @param loopAnimation defines if the animation must loop (default is false)
  14913. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  14914. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  14915. * @param animations defines a group of animation to add to the new Animatable
  14916. * @param onAnimationLoop defines a callback to call when animation loops
  14917. */
  14918. constructor(scene: Scene,
  14919. /** defines the target object */
  14920. target: any,
  14921. /** defines the starting frame number (default is 0) */
  14922. fromFrame?: number,
  14923. /** defines the ending frame number (default is 100) */
  14924. toFrame?: number,
  14925. /** defines if the animation must loop (default is false) */
  14926. loopAnimation?: boolean, speedRatio?: number,
  14927. /** defines a callback to call when animation ends if it is not looping */
  14928. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  14929. /** defines a callback to call when animation loops */
  14930. onAnimationLoop?: (() => void) | null | undefined);
  14931. /**
  14932. * Synchronize and normalize current Animatable with a source Animatable
  14933. * This is useful when using animation weights and when animations are not of the same length
  14934. * @param root defines the root Animatable to synchronize with
  14935. * @returns the current Animatable
  14936. */
  14937. syncWith(root: Animatable): Animatable;
  14938. /**
  14939. * Gets the list of runtime animations
  14940. * @returns an array of RuntimeAnimation
  14941. */
  14942. getAnimations(): RuntimeAnimation[];
  14943. /**
  14944. * Adds more animations to the current animatable
  14945. * @param target defines the target of the animations
  14946. * @param animations defines the new animations to add
  14947. */
  14948. appendAnimations(target: any, animations: Animation[]): void;
  14949. /**
  14950. * Gets the source animation for a specific property
  14951. * @param property defines the propertyu to look for
  14952. * @returns null or the source animation for the given property
  14953. */
  14954. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  14955. /**
  14956. * Gets the runtime animation for a specific property
  14957. * @param property defines the propertyu to look for
  14958. * @returns null or the runtime animation for the given property
  14959. */
  14960. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  14961. /**
  14962. * Resets the animatable to its original state
  14963. */
  14964. reset(): void;
  14965. /**
  14966. * Allows the animatable to blend with current running animations
  14967. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14968. * @param blendingSpeed defines the blending speed to use
  14969. */
  14970. enableBlending(blendingSpeed: number): void;
  14971. /**
  14972. * Disable animation blending
  14973. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  14974. */
  14975. disableBlending(): void;
  14976. /**
  14977. * Jump directly to a given frame
  14978. * @param frame defines the frame to jump to
  14979. */
  14980. goToFrame(frame: number): void;
  14981. /**
  14982. * Pause the animation
  14983. */
  14984. pause(): void;
  14985. /**
  14986. * Restart the animation
  14987. */
  14988. restart(): void;
  14989. private _raiseOnAnimationEnd;
  14990. /**
  14991. * Stop and delete the current animation
  14992. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  14993. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  14994. */
  14995. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  14996. /**
  14997. * Wait asynchronously for the animation to end
  14998. * @returns a promise which will be fullfilled when the animation ends
  14999. */
  15000. waitAsync(): Promise<Animatable>;
  15001. /** @hidden */
  15002. _animate(delay: number): boolean;
  15003. }
  15004. module "babylonjs/scene" {
  15005. interface Scene {
  15006. /** @hidden */
  15007. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15008. /** @hidden */
  15009. _processLateAnimationBindingsForMatrices(holder: {
  15010. totalWeight: number;
  15011. animations: RuntimeAnimation[];
  15012. originalValue: Matrix;
  15013. }): any;
  15014. /** @hidden */
  15015. _processLateAnimationBindingsForQuaternions(holder: {
  15016. totalWeight: number;
  15017. animations: RuntimeAnimation[];
  15018. originalValue: Quaternion;
  15019. }, refQuaternion: Quaternion): Quaternion;
  15020. /** @hidden */
  15021. _processLateAnimationBindings(): void;
  15022. /**
  15023. * Will start the animation sequence of a given target
  15024. * @param target defines the target
  15025. * @param from defines from which frame should animation start
  15026. * @param to defines until which frame should animation run.
  15027. * @param weight defines the weight to apply to the animation (1.0 by default)
  15028. * @param loop defines if the animation loops
  15029. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15030. * @param onAnimationEnd defines the function to be executed when the animation ends
  15031. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15032. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15033. * @param onAnimationLoop defines the callback to call when an animation loops
  15034. * @returns the animatable object created for this animation
  15035. */
  15036. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15037. /**
  15038. * Will start the animation sequence of a given target
  15039. * @param target defines the target
  15040. * @param from defines from which frame should animation start
  15041. * @param to defines until which frame should animation run.
  15042. * @param loop defines if the animation loops
  15043. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15044. * @param onAnimationEnd defines the function to be executed when the animation ends
  15045. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15046. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15047. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15048. * @param onAnimationLoop defines the callback to call when an animation loops
  15049. * @returns the animatable object created for this animation
  15050. */
  15051. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  15052. /**
  15053. * Will start the animation sequence of a given target and its hierarchy
  15054. * @param target defines the target
  15055. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  15056. * @param from defines from which frame should animation start
  15057. * @param to defines until which frame should animation run.
  15058. * @param loop defines if the animation loops
  15059. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15060. * @param onAnimationEnd defines the function to be executed when the animation ends
  15061. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15062. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15063. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15064. * @param onAnimationLoop defines the callback to call when an animation loops
  15065. * @returns the list of created animatables
  15066. */
  15067. beginHierarchyAnimation(target: any, directDescendantsOnly: boolean, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable[];
  15068. /**
  15069. * Begin a new animation on a given node
  15070. * @param target defines the target where the animation will take place
  15071. * @param animations defines the list of animations to start
  15072. * @param from defines the initial value
  15073. * @param to defines the final value
  15074. * @param loop defines if you want animation to loop (off by default)
  15075. * @param speedRatio defines the speed ratio to apply to all animations
  15076. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15077. * @param onAnimationLoop defines the callback to call when an animation loops
  15078. * @returns the list of created animatables
  15079. */
  15080. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  15081. /**
  15082. * Begin a new animation on a given node and its hierarchy
  15083. * @param target defines the root node where the animation will take place
  15084. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used.
  15085. * @param animations defines the list of animations to start
  15086. * @param from defines the initial value
  15087. * @param to defines the final value
  15088. * @param loop defines if you want animation to loop (off by default)
  15089. * @param speedRatio defines the speed ratio to apply to all animations
  15090. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  15091. * @param onAnimationLoop defines the callback to call when an animation loops
  15092. * @returns the list of animatables created for all nodes
  15093. */
  15094. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  15095. /**
  15096. * Gets the animatable associated with a specific target
  15097. * @param target defines the target of the animatable
  15098. * @returns the required animatable if found
  15099. */
  15100. getAnimatableByTarget(target: any): Nullable<Animatable>;
  15101. /**
  15102. * Gets all animatables associated with a given target
  15103. * @param target defines the target to look animatables for
  15104. * @returns an array of Animatables
  15105. */
  15106. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  15107. /**
  15108. * Stops and removes all animations that have been applied to the scene
  15109. */
  15110. stopAllAnimations(): void;
  15111. /**
  15112. * Gets the current delta time used by animation engine
  15113. */
  15114. deltaTime: number;
  15115. }
  15116. }
  15117. module "babylonjs/Bones/bone" {
  15118. interface Bone {
  15119. /**
  15120. * Copy an animation range from another bone
  15121. * @param source defines the source bone
  15122. * @param rangeName defines the range name to copy
  15123. * @param frameOffset defines the frame offset
  15124. * @param rescaleAsRequired defines if rescaling must be applied if required
  15125. * @param skelDimensionsRatio defines the scaling ratio
  15126. * @returns true if operation was successful
  15127. */
  15128. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  15129. }
  15130. }
  15131. }
  15132. declare module "babylonjs/Bones/skeleton" {
  15133. import { Bone } from "babylonjs/Bones/bone";
  15134. import { Observable } from "babylonjs/Misc/observable";
  15135. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15136. import { Scene } from "babylonjs/scene";
  15137. import { Nullable } from "babylonjs/types";
  15138. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15139. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  15140. import { Animatable } from "babylonjs/Animations/animatable";
  15141. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15142. import { Animation } from "babylonjs/Animations/animation";
  15143. import { AnimationRange } from "babylonjs/Animations/animationRange";
  15144. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15145. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  15146. /**
  15147. * Class used to handle skinning animations
  15148. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15149. */
  15150. export class Skeleton implements IAnimatable {
  15151. /** defines the skeleton name */
  15152. name: string;
  15153. /** defines the skeleton Id */
  15154. id: string;
  15155. /**
  15156. * Defines the list of child bones
  15157. */
  15158. bones: Bone[];
  15159. /**
  15160. * Defines an estimate of the dimension of the skeleton at rest
  15161. */
  15162. dimensionsAtRest: Vector3;
  15163. /**
  15164. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  15165. */
  15166. needInitialSkinMatrix: boolean;
  15167. /**
  15168. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  15169. */
  15170. overrideMesh: Nullable<AbstractMesh>;
  15171. /**
  15172. * Gets the list of animations attached to this skeleton
  15173. */
  15174. animations: Array<Animation>;
  15175. private _scene;
  15176. private _isDirty;
  15177. private _transformMatrices;
  15178. private _transformMatrixTexture;
  15179. private _meshesWithPoseMatrix;
  15180. private _animatables;
  15181. private _identity;
  15182. private _synchronizedWithMesh;
  15183. private _ranges;
  15184. private _lastAbsoluteTransformsUpdateId;
  15185. private _canUseTextureForBones;
  15186. private _uniqueId;
  15187. /** @hidden */
  15188. _numBonesWithLinkedTransformNode: number;
  15189. /** @hidden */
  15190. _hasWaitingData: Nullable<boolean>;
  15191. /**
  15192. * Specifies if the skeleton should be serialized
  15193. */
  15194. doNotSerialize: boolean;
  15195. private _useTextureToStoreBoneMatrices;
  15196. /**
  15197. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  15198. * Please note that this option is not available if the hardware does not support it
  15199. */
  15200. get useTextureToStoreBoneMatrices(): boolean;
  15201. set useTextureToStoreBoneMatrices(value: boolean);
  15202. private _animationPropertiesOverride;
  15203. /**
  15204. * Gets or sets the animation properties override
  15205. */
  15206. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15207. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  15208. /**
  15209. * List of inspectable custom properties (used by the Inspector)
  15210. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15211. */
  15212. inspectableCustomProperties: IInspectable[];
  15213. /**
  15214. * An observable triggered before computing the skeleton's matrices
  15215. */
  15216. onBeforeComputeObservable: Observable<Skeleton>;
  15217. /**
  15218. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  15219. */
  15220. get isUsingTextureForMatrices(): boolean;
  15221. /**
  15222. * Gets the unique ID of this skeleton
  15223. */
  15224. get uniqueId(): number;
  15225. /**
  15226. * Creates a new skeleton
  15227. * @param name defines the skeleton name
  15228. * @param id defines the skeleton Id
  15229. * @param scene defines the hosting scene
  15230. */
  15231. constructor(
  15232. /** defines the skeleton name */
  15233. name: string,
  15234. /** defines the skeleton Id */
  15235. id: string, scene: Scene);
  15236. /**
  15237. * Gets the current object class name.
  15238. * @return the class name
  15239. */
  15240. getClassName(): string;
  15241. /**
  15242. * Returns an array containing the root bones
  15243. * @returns an array containing the root bones
  15244. */
  15245. getChildren(): Array<Bone>;
  15246. /**
  15247. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  15248. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15249. * @returns a Float32Array containing matrices data
  15250. */
  15251. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  15252. /**
  15253. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  15254. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  15255. * @returns a raw texture containing the data
  15256. */
  15257. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  15258. /**
  15259. * Gets the current hosting scene
  15260. * @returns a scene object
  15261. */
  15262. getScene(): Scene;
  15263. /**
  15264. * Gets a string representing the current skeleton data
  15265. * @param fullDetails defines a boolean indicating if we want a verbose version
  15266. * @returns a string representing the current skeleton data
  15267. */
  15268. toString(fullDetails?: boolean): string;
  15269. /**
  15270. * Get bone's index searching by name
  15271. * @param name defines bone's name to search for
  15272. * @return the indice of the bone. Returns -1 if not found
  15273. */
  15274. getBoneIndexByName(name: string): number;
  15275. /**
  15276. * Creater a new animation range
  15277. * @param name defines the name of the range
  15278. * @param from defines the start key
  15279. * @param to defines the end key
  15280. */
  15281. createAnimationRange(name: string, from: number, to: number): void;
  15282. /**
  15283. * Delete a specific animation range
  15284. * @param name defines the name of the range
  15285. * @param deleteFrames defines if frames must be removed as well
  15286. */
  15287. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  15288. /**
  15289. * Gets a specific animation range
  15290. * @param name defines the name of the range to look for
  15291. * @returns the requested animation range or null if not found
  15292. */
  15293. getAnimationRange(name: string): Nullable<AnimationRange>;
  15294. /**
  15295. * Gets the list of all animation ranges defined on this skeleton
  15296. * @returns an array
  15297. */
  15298. getAnimationRanges(): Nullable<AnimationRange>[];
  15299. /**
  15300. * Copy animation range from a source skeleton.
  15301. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  15302. * @param source defines the source skeleton
  15303. * @param name defines the name of the range to copy
  15304. * @param rescaleAsRequired defines if rescaling must be applied if required
  15305. * @returns true if operation was successful
  15306. */
  15307. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  15308. /**
  15309. * Forces the skeleton to go to rest pose
  15310. */
  15311. returnToRest(): void;
  15312. private _getHighestAnimationFrame;
  15313. /**
  15314. * Begin a specific animation range
  15315. * @param name defines the name of the range to start
  15316. * @param loop defines if looping must be turned on (false by default)
  15317. * @param speedRatio defines the speed ratio to apply (1 by default)
  15318. * @param onAnimationEnd defines a callback which will be called when animation will end
  15319. * @returns a new animatable
  15320. */
  15321. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  15322. /** @hidden */
  15323. _markAsDirty(): void;
  15324. /** @hidden */
  15325. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15326. /** @hidden */
  15327. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  15328. private _computeTransformMatrices;
  15329. /**
  15330. * Build all resources required to render a skeleton
  15331. */
  15332. prepare(): void;
  15333. /**
  15334. * Gets the list of animatables currently running for this skeleton
  15335. * @returns an array of animatables
  15336. */
  15337. getAnimatables(): IAnimatable[];
  15338. /**
  15339. * Clone the current skeleton
  15340. * @param name defines the name of the new skeleton
  15341. * @param id defines the id of the new skeleton
  15342. * @returns the new skeleton
  15343. */
  15344. clone(name: string, id?: string): Skeleton;
  15345. /**
  15346. * Enable animation blending for this skeleton
  15347. * @param blendingSpeed defines the blending speed to apply
  15348. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  15349. */
  15350. enableBlending(blendingSpeed?: number): void;
  15351. /**
  15352. * Releases all resources associated with the current skeleton
  15353. */
  15354. dispose(): void;
  15355. /**
  15356. * Serialize the skeleton in a JSON object
  15357. * @returns a JSON object
  15358. */
  15359. serialize(): any;
  15360. /**
  15361. * Creates a new skeleton from serialized data
  15362. * @param parsedSkeleton defines the serialized data
  15363. * @param scene defines the hosting scene
  15364. * @returns a new skeleton
  15365. */
  15366. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  15367. /**
  15368. * Compute all node absolute transforms
  15369. * @param forceUpdate defines if computation must be done even if cache is up to date
  15370. */
  15371. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  15372. /**
  15373. * Gets the root pose matrix
  15374. * @returns a matrix
  15375. */
  15376. getPoseMatrix(): Nullable<Matrix>;
  15377. /**
  15378. * Sorts bones per internal index
  15379. */
  15380. sortBones(): void;
  15381. private _sortBones;
  15382. }
  15383. }
  15384. declare module "babylonjs/Meshes/instancedMesh" {
  15385. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  15386. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  15387. import { Camera } from "babylonjs/Cameras/camera";
  15388. import { Node } from "babylonjs/node";
  15389. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15390. import { Mesh } from "babylonjs/Meshes/mesh";
  15391. import { Material } from "babylonjs/Materials/material";
  15392. import { Skeleton } from "babylonjs/Bones/skeleton";
  15393. import { Light } from "babylonjs/Lights/light";
  15394. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  15395. /**
  15396. * Creates an instance based on a source mesh.
  15397. */
  15398. export class InstancedMesh extends AbstractMesh {
  15399. private _sourceMesh;
  15400. private _currentLOD;
  15401. /** @hidden */
  15402. _indexInSourceMeshInstanceArray: number;
  15403. constructor(name: string, source: Mesh);
  15404. /**
  15405. * Returns the string "InstancedMesh".
  15406. */
  15407. getClassName(): string;
  15408. /** Gets the list of lights affecting that mesh */
  15409. get lightSources(): Light[];
  15410. _resyncLightSources(): void;
  15411. _resyncLightSource(light: Light): void;
  15412. _removeLightSource(light: Light, dispose: boolean): void;
  15413. /**
  15414. * If the source mesh receives shadows
  15415. */
  15416. get receiveShadows(): boolean;
  15417. /**
  15418. * The material of the source mesh
  15419. */
  15420. get material(): Nullable<Material>;
  15421. /**
  15422. * Visibility of the source mesh
  15423. */
  15424. get visibility(): number;
  15425. /**
  15426. * Skeleton of the source mesh
  15427. */
  15428. get skeleton(): Nullable<Skeleton>;
  15429. /**
  15430. * Rendering ground id of the source mesh
  15431. */
  15432. get renderingGroupId(): number;
  15433. set renderingGroupId(value: number);
  15434. /**
  15435. * Returns the total number of vertices (integer).
  15436. */
  15437. getTotalVertices(): number;
  15438. /**
  15439. * Returns a positive integer : the total number of indices in this mesh geometry.
  15440. * @returns the numner of indices or zero if the mesh has no geometry.
  15441. */
  15442. getTotalIndices(): number;
  15443. /**
  15444. * The source mesh of the instance
  15445. */
  15446. get sourceMesh(): Mesh;
  15447. /**
  15448. * Is this node ready to be used/rendered
  15449. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  15450. * @return {boolean} is it ready
  15451. */
  15452. isReady(completeCheck?: boolean): boolean;
  15453. /**
  15454. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  15455. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  15456. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  15457. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  15458. */
  15459. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  15460. /**
  15461. * Sets the vertex data of the mesh geometry for the requested `kind`.
  15462. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  15463. * The `data` are either a numeric array either a Float32Array.
  15464. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  15465. * The parameter `stride` is an optional positive integer, it is usually automatically deducted from the `kind` (3 for positions or normals, 2 for UV, etc).
  15466. * Note that a new underlying VertexBuffer object is created each call.
  15467. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15468. *
  15469. * Possible `kind` values :
  15470. * - VertexBuffer.PositionKind
  15471. * - VertexBuffer.UVKind
  15472. * - VertexBuffer.UV2Kind
  15473. * - VertexBuffer.UV3Kind
  15474. * - VertexBuffer.UV4Kind
  15475. * - VertexBuffer.UV5Kind
  15476. * - VertexBuffer.UV6Kind
  15477. * - VertexBuffer.ColorKind
  15478. * - VertexBuffer.MatricesIndicesKind
  15479. * - VertexBuffer.MatricesIndicesExtraKind
  15480. * - VertexBuffer.MatricesWeightsKind
  15481. * - VertexBuffer.MatricesWeightsExtraKind
  15482. *
  15483. * Returns the Mesh.
  15484. */
  15485. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  15486. /**
  15487. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  15488. * If the mesh has no geometry, it is simply returned as it is.
  15489. * The `data` are either a numeric array either a Float32Array.
  15490. * No new underlying VertexBuffer object is created.
  15491. * If the `kind` is the `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  15492. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  15493. *
  15494. * Possible `kind` values :
  15495. * - VertexBuffer.PositionKind
  15496. * - VertexBuffer.UVKind
  15497. * - VertexBuffer.UV2Kind
  15498. * - VertexBuffer.UV3Kind
  15499. * - VertexBuffer.UV4Kind
  15500. * - VertexBuffer.UV5Kind
  15501. * - VertexBuffer.UV6Kind
  15502. * - VertexBuffer.ColorKind
  15503. * - VertexBuffer.MatricesIndicesKind
  15504. * - VertexBuffer.MatricesIndicesExtraKind
  15505. * - VertexBuffer.MatricesWeightsKind
  15506. * - VertexBuffer.MatricesWeightsExtraKind
  15507. *
  15508. * Returns the Mesh.
  15509. */
  15510. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  15511. /**
  15512. * Sets the mesh indices.
  15513. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  15514. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  15515. * This method creates a new index buffer each call.
  15516. * Returns the Mesh.
  15517. */
  15518. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  15519. /**
  15520. * Boolean : True if the mesh owns the requested kind of data.
  15521. */
  15522. isVerticesDataPresent(kind: string): boolean;
  15523. /**
  15524. * Returns an array of indices (IndicesArray).
  15525. */
  15526. getIndices(): Nullable<IndicesArray>;
  15527. get _positions(): Nullable<Vector3[]>;
  15528. /**
  15529. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  15530. * This means the mesh underlying bounding box and sphere are recomputed.
  15531. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  15532. * @returns the current mesh
  15533. */
  15534. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  15535. /** @hidden */
  15536. _preActivate(): InstancedMesh;
  15537. /** @hidden */
  15538. _activate(renderId: number, intermediateRendering: boolean): boolean;
  15539. /** @hidden */
  15540. _postActivate(): void;
  15541. getWorldMatrix(): Matrix;
  15542. get isAnInstance(): boolean;
  15543. /**
  15544. * Returns the current associated LOD AbstractMesh.
  15545. */
  15546. getLOD(camera: Camera): AbstractMesh;
  15547. /** @hidden */
  15548. _syncSubMeshes(): InstancedMesh;
  15549. /** @hidden */
  15550. _generatePointsArray(): boolean;
  15551. /**
  15552. * Creates a new InstancedMesh from the current mesh.
  15553. * - name (string) : the cloned mesh name
  15554. * - newParent (optional Node) : the optional Node to parent the clone to.
  15555. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  15556. *
  15557. * Returns the clone.
  15558. */
  15559. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  15560. /**
  15561. * Disposes the InstancedMesh.
  15562. * Returns nothing.
  15563. */
  15564. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15565. }
  15566. module "babylonjs/Meshes/mesh" {
  15567. interface Mesh {
  15568. /**
  15569. * Register a custom buffer that will be instanced
  15570. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15571. * @param kind defines the buffer kind
  15572. * @param stride defines the stride in floats
  15573. */
  15574. registerInstancedBuffer(kind: string, stride: number): void;
  15575. /** @hidden */
  15576. _userInstancedBuffersStorage: {
  15577. data: {
  15578. [key: string]: Float32Array;
  15579. };
  15580. sizes: {
  15581. [key: string]: number;
  15582. };
  15583. vertexBuffers: {
  15584. [key: string]: Nullable<VertexBuffer>;
  15585. };
  15586. strides: {
  15587. [key: string]: number;
  15588. };
  15589. };
  15590. }
  15591. }
  15592. module "babylonjs/Meshes/abstractMesh" {
  15593. interface AbstractMesh {
  15594. /**
  15595. * Object used to store instanced buffers defined by user
  15596. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  15597. */
  15598. instancedBuffers: {
  15599. [key: string]: any;
  15600. };
  15601. }
  15602. }
  15603. }
  15604. declare module "babylonjs/Materials/shaderMaterial" {
  15605. import { Scene } from "babylonjs/scene";
  15606. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  15607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15608. import { Mesh } from "babylonjs/Meshes/mesh";
  15609. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  15610. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  15611. import { Texture } from "babylonjs/Materials/Textures/texture";
  15612. import { Material } from "babylonjs/Materials/material";
  15613. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  15614. /**
  15615. * Defines the options associated with the creation of a shader material.
  15616. */
  15617. export interface IShaderMaterialOptions {
  15618. /**
  15619. * Does the material work in alpha blend mode
  15620. */
  15621. needAlphaBlending: boolean;
  15622. /**
  15623. * Does the material work in alpha test mode
  15624. */
  15625. needAlphaTesting: boolean;
  15626. /**
  15627. * The list of attribute names used in the shader
  15628. */
  15629. attributes: string[];
  15630. /**
  15631. * The list of unifrom names used in the shader
  15632. */
  15633. uniforms: string[];
  15634. /**
  15635. * The list of UBO names used in the shader
  15636. */
  15637. uniformBuffers: string[];
  15638. /**
  15639. * The list of sampler names used in the shader
  15640. */
  15641. samplers: string[];
  15642. /**
  15643. * The list of defines used in the shader
  15644. */
  15645. defines: string[];
  15646. }
  15647. /**
  15648. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  15649. *
  15650. * This returned material effects how the mesh will look based on the code in the shaders.
  15651. *
  15652. * @see http://doc.babylonjs.com/how_to/shader_material
  15653. */
  15654. export class ShaderMaterial extends Material {
  15655. private _shaderPath;
  15656. private _options;
  15657. private _textures;
  15658. private _textureArrays;
  15659. private _floats;
  15660. private _ints;
  15661. private _floatsArrays;
  15662. private _colors3;
  15663. private _colors3Arrays;
  15664. private _colors4;
  15665. private _colors4Arrays;
  15666. private _vectors2;
  15667. private _vectors3;
  15668. private _vectors4;
  15669. private _matrices;
  15670. private _matrixArrays;
  15671. private _matrices3x3;
  15672. private _matrices2x2;
  15673. private _vectors2Arrays;
  15674. private _vectors3Arrays;
  15675. private _vectors4Arrays;
  15676. private _cachedWorldViewMatrix;
  15677. private _cachedWorldViewProjectionMatrix;
  15678. private _renderId;
  15679. private _multiview;
  15680. /**
  15681. * Instantiate a new shader material.
  15682. * The ShaderMaterial object has the necessary methods to pass data from your scene to the Vertex and Fragment Shaders and returns a material that can be applied to any mesh.
  15683. * This returned material effects how the mesh will look based on the code in the shaders.
  15684. * @see http://doc.babylonjs.com/how_to/shader_material
  15685. * @param name Define the name of the material in the scene
  15686. * @param scene Define the scene the material belongs to
  15687. * @param shaderPath Defines the route to the shader code in one of three ways:
  15688. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  15689. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  15690. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  15691. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  15692. * @param options Define the options used to create the shader
  15693. */
  15694. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  15695. /**
  15696. * Gets the shader path used to define the shader code
  15697. * It can be modified to trigger a new compilation
  15698. */
  15699. get shaderPath(): any;
  15700. /**
  15701. * Sets the shader path used to define the shader code
  15702. * It can be modified to trigger a new compilation
  15703. */
  15704. set shaderPath(shaderPath: any);
  15705. /**
  15706. * Gets the options used to compile the shader.
  15707. * They can be modified to trigger a new compilation
  15708. */
  15709. get options(): IShaderMaterialOptions;
  15710. /**
  15711. * Gets the current class name of the material e.g. "ShaderMaterial"
  15712. * Mainly use in serialization.
  15713. * @returns the class name
  15714. */
  15715. getClassName(): string;
  15716. /**
  15717. * Specifies if the material will require alpha blending
  15718. * @returns a boolean specifying if alpha blending is needed
  15719. */
  15720. needAlphaBlending(): boolean;
  15721. /**
  15722. * Specifies if this material should be rendered in alpha test mode
  15723. * @returns a boolean specifying if an alpha test is needed.
  15724. */
  15725. needAlphaTesting(): boolean;
  15726. private _checkUniform;
  15727. /**
  15728. * Set a texture in the shader.
  15729. * @param name Define the name of the uniform samplers as defined in the shader
  15730. * @param texture Define the texture to bind to this sampler
  15731. * @return the material itself allowing "fluent" like uniform updates
  15732. */
  15733. setTexture(name: string, texture: Texture): ShaderMaterial;
  15734. /**
  15735. * Set a texture array in the shader.
  15736. * @param name Define the name of the uniform sampler array as defined in the shader
  15737. * @param textures Define the list of textures to bind to this sampler
  15738. * @return the material itself allowing "fluent" like uniform updates
  15739. */
  15740. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  15741. /**
  15742. * Set a float in the shader.
  15743. * @param name Define the name of the uniform as defined in the shader
  15744. * @param value Define the value to give to the uniform
  15745. * @return the material itself allowing "fluent" like uniform updates
  15746. */
  15747. setFloat(name: string, value: number): ShaderMaterial;
  15748. /**
  15749. * Set a int in the shader.
  15750. * @param name Define the name of the uniform as defined in the shader
  15751. * @param value Define the value to give to the uniform
  15752. * @return the material itself allowing "fluent" like uniform updates
  15753. */
  15754. setInt(name: string, value: number): ShaderMaterial;
  15755. /**
  15756. * Set an array of floats in the shader.
  15757. * @param name Define the name of the uniform as defined in the shader
  15758. * @param value Define the value to give to the uniform
  15759. * @return the material itself allowing "fluent" like uniform updates
  15760. */
  15761. setFloats(name: string, value: number[]): ShaderMaterial;
  15762. /**
  15763. * Set a vec3 in the shader from a Color3.
  15764. * @param name Define the name of the uniform as defined in the shader
  15765. * @param value Define the value to give to the uniform
  15766. * @return the material itself allowing "fluent" like uniform updates
  15767. */
  15768. setColor3(name: string, value: Color3): ShaderMaterial;
  15769. /**
  15770. * Set a vec3 array in the shader from a Color3 array.
  15771. * @param name Define the name of the uniform as defined in the shader
  15772. * @param value Define the value to give to the uniform
  15773. * @return the material itself allowing "fluent" like uniform updates
  15774. */
  15775. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  15776. /**
  15777. * Set a vec4 in the shader from a Color4.
  15778. * @param name Define the name of the uniform as defined in the shader
  15779. * @param value Define the value to give to the uniform
  15780. * @return the material itself allowing "fluent" like uniform updates
  15781. */
  15782. setColor4(name: string, value: Color4): ShaderMaterial;
  15783. /**
  15784. * Set a vec4 array in the shader from a Color4 array.
  15785. * @param name Define the name of the uniform as defined in the shader
  15786. * @param value Define the value to give to the uniform
  15787. * @return the material itself allowing "fluent" like uniform updates
  15788. */
  15789. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  15790. /**
  15791. * Set a vec2 in the shader from a Vector2.
  15792. * @param name Define the name of the uniform as defined in the shader
  15793. * @param value Define the value to give to the uniform
  15794. * @return the material itself allowing "fluent" like uniform updates
  15795. */
  15796. setVector2(name: string, value: Vector2): ShaderMaterial;
  15797. /**
  15798. * Set a vec3 in the shader from a Vector3.
  15799. * @param name Define the name of the uniform as defined in the shader
  15800. * @param value Define the value to give to the uniform
  15801. * @return the material itself allowing "fluent" like uniform updates
  15802. */
  15803. setVector3(name: string, value: Vector3): ShaderMaterial;
  15804. /**
  15805. * Set a vec4 in the shader from a Vector4.
  15806. * @param name Define the name of the uniform as defined in the shader
  15807. * @param value Define the value to give to the uniform
  15808. * @return the material itself allowing "fluent" like uniform updates
  15809. */
  15810. setVector4(name: string, value: Vector4): ShaderMaterial;
  15811. /**
  15812. * Set a mat4 in the shader from a Matrix.
  15813. * @param name Define the name of the uniform as defined in the shader
  15814. * @param value Define the value to give to the uniform
  15815. * @return the material itself allowing "fluent" like uniform updates
  15816. */
  15817. setMatrix(name: string, value: Matrix): ShaderMaterial;
  15818. /**
  15819. * Set a float32Array in the shader from a matrix array.
  15820. * @param name Define the name of the uniform as defined in the shader
  15821. * @param value Define the value to give to the uniform
  15822. * @return the material itself allowing "fluent" like uniform updates
  15823. */
  15824. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  15825. /**
  15826. * Set a mat3 in the shader from a Float32Array.
  15827. * @param name Define the name of the uniform as defined in the shader
  15828. * @param value Define the value to give to the uniform
  15829. * @return the material itself allowing "fluent" like uniform updates
  15830. */
  15831. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  15832. /**
  15833. * Set a mat2 in the shader from a Float32Array.
  15834. * @param name Define the name of the uniform as defined in the shader
  15835. * @param value Define the value to give to the uniform
  15836. * @return the material itself allowing "fluent" like uniform updates
  15837. */
  15838. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  15839. /**
  15840. * Set a vec2 array in the shader from a number array.
  15841. * @param name Define the name of the uniform as defined in the shader
  15842. * @param value Define the value to give to the uniform
  15843. * @return the material itself allowing "fluent" like uniform updates
  15844. */
  15845. setArray2(name: string, value: number[]): ShaderMaterial;
  15846. /**
  15847. * Set a vec3 array in the shader from a number array.
  15848. * @param name Define the name of the uniform as defined in the shader
  15849. * @param value Define the value to give to the uniform
  15850. * @return the material itself allowing "fluent" like uniform updates
  15851. */
  15852. setArray3(name: string, value: number[]): ShaderMaterial;
  15853. /**
  15854. * Set a vec4 array in the shader from a number array.
  15855. * @param name Define the name of the uniform as defined in the shader
  15856. * @param value Define the value to give to the uniform
  15857. * @return the material itself allowing "fluent" like uniform updates
  15858. */
  15859. setArray4(name: string, value: number[]): ShaderMaterial;
  15860. private _checkCache;
  15861. /**
  15862. * Specifies that the submesh is ready to be used
  15863. * @param mesh defines the mesh to check
  15864. * @param subMesh defines which submesh to check
  15865. * @param useInstances specifies that instances should be used
  15866. * @returns a boolean indicating that the submesh is ready or not
  15867. */
  15868. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  15869. /**
  15870. * Checks if the material is ready to render the requested mesh
  15871. * @param mesh Define the mesh to render
  15872. * @param useInstances Define whether or not the material is used with instances
  15873. * @returns true if ready, otherwise false
  15874. */
  15875. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  15876. /**
  15877. * Binds the world matrix to the material
  15878. * @param world defines the world transformation matrix
  15879. */
  15880. bindOnlyWorldMatrix(world: Matrix): void;
  15881. /**
  15882. * Binds the material to the mesh
  15883. * @param world defines the world transformation matrix
  15884. * @param mesh defines the mesh to bind the material to
  15885. */
  15886. bind(world: Matrix, mesh?: Mesh): void;
  15887. /**
  15888. * Gets the active textures from the material
  15889. * @returns an array of textures
  15890. */
  15891. getActiveTextures(): BaseTexture[];
  15892. /**
  15893. * Specifies if the material uses a texture
  15894. * @param texture defines the texture to check against the material
  15895. * @returns a boolean specifying if the material uses the texture
  15896. */
  15897. hasTexture(texture: BaseTexture): boolean;
  15898. /**
  15899. * Makes a duplicate of the material, and gives it a new name
  15900. * @param name defines the new name for the duplicated material
  15901. * @returns the cloned material
  15902. */
  15903. clone(name: string): ShaderMaterial;
  15904. /**
  15905. * Disposes the material
  15906. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  15907. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  15908. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  15909. */
  15910. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  15911. /**
  15912. * Serializes this material in a JSON representation
  15913. * @returns the serialized material object
  15914. */
  15915. serialize(): any;
  15916. /**
  15917. * Creates a shader material from parsed shader material data
  15918. * @param source defines the JSON represnetation of the material
  15919. * @param scene defines the hosting scene
  15920. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  15921. * @returns a new material
  15922. */
  15923. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  15924. }
  15925. }
  15926. declare module "babylonjs/Shaders/color.fragment" {
  15927. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15928. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15929. /** @hidden */
  15930. export var colorPixelShader: {
  15931. name: string;
  15932. shader: string;
  15933. };
  15934. }
  15935. declare module "babylonjs/Shaders/color.vertex" {
  15936. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  15937. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15938. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  15939. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  15940. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  15941. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15942. /** @hidden */
  15943. export var colorVertexShader: {
  15944. name: string;
  15945. shader: string;
  15946. };
  15947. }
  15948. declare module "babylonjs/Meshes/linesMesh" {
  15949. import { Nullable } from "babylonjs/types";
  15950. import { Scene } from "babylonjs/scene";
  15951. import { Color3 } from "babylonjs/Maths/math.color";
  15952. import { Node } from "babylonjs/node";
  15953. import { SubMesh } from "babylonjs/Meshes/subMesh";
  15954. import { Mesh } from "babylonjs/Meshes/mesh";
  15955. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  15956. import { Effect } from "babylonjs/Materials/effect";
  15957. import { Material } from "babylonjs/Materials/material";
  15958. import "babylonjs/Shaders/color.fragment";
  15959. import "babylonjs/Shaders/color.vertex";
  15960. /**
  15961. * Line mesh
  15962. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  15963. */
  15964. export class LinesMesh extends Mesh {
  15965. /**
  15966. * If vertex color should be applied to the mesh
  15967. */
  15968. readonly useVertexColor?: boolean | undefined;
  15969. /**
  15970. * If vertex alpha should be applied to the mesh
  15971. */
  15972. readonly useVertexAlpha?: boolean | undefined;
  15973. /**
  15974. * Color of the line (Default: White)
  15975. */
  15976. color: Color3;
  15977. /**
  15978. * Alpha of the line (Default: 1)
  15979. */
  15980. alpha: number;
  15981. /**
  15982. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  15983. * This margin is expressed in world space coordinates, so its value may vary.
  15984. * Default value is 0.1
  15985. */
  15986. intersectionThreshold: number;
  15987. private _colorShader;
  15988. private color4;
  15989. /**
  15990. * Creates a new LinesMesh
  15991. * @param name defines the name
  15992. * @param scene defines the hosting scene
  15993. * @param parent defines the parent mesh if any
  15994. * @param source defines the optional source LinesMesh used to clone data from
  15995. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  15996. * When false, achieved by calling a clone(), also passing False.
  15997. * This will make creation of children, recursive.
  15998. * @param useVertexColor defines if this LinesMesh supports vertex color
  15999. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16000. */
  16001. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16002. /**
  16003. * If vertex color should be applied to the mesh
  16004. */
  16005. useVertexColor?: boolean | undefined,
  16006. /**
  16007. * If vertex alpha should be applied to the mesh
  16008. */
  16009. useVertexAlpha?: boolean | undefined);
  16010. private _addClipPlaneDefine;
  16011. private _removeClipPlaneDefine;
  16012. isReady(): boolean;
  16013. /**
  16014. * Returns the string "LineMesh"
  16015. */
  16016. getClassName(): string;
  16017. /**
  16018. * @hidden
  16019. */
  16020. get material(): Material;
  16021. /**
  16022. * @hidden
  16023. */
  16024. set material(value: Material);
  16025. /**
  16026. * @hidden
  16027. */
  16028. get checkCollisions(): boolean;
  16029. /** @hidden */
  16030. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16031. /** @hidden */
  16032. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16033. /**
  16034. * Disposes of the line mesh
  16035. * @param doNotRecurse If children should be disposed
  16036. */
  16037. dispose(doNotRecurse?: boolean): void;
  16038. /**
  16039. * Returns a new LineMesh object cloned from the current one.
  16040. */
  16041. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16042. /**
  16043. * Creates a new InstancedLinesMesh object from the mesh model.
  16044. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  16045. * @param name defines the name of the new instance
  16046. * @returns a new InstancedLinesMesh
  16047. */
  16048. createInstance(name: string): InstancedLinesMesh;
  16049. }
  16050. /**
  16051. * Creates an instance based on a source LinesMesh
  16052. */
  16053. export class InstancedLinesMesh extends InstancedMesh {
  16054. /**
  16055. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16056. * This margin is expressed in world space coordinates, so its value may vary.
  16057. * Initilized with the intersectionThreshold value of the source LinesMesh
  16058. */
  16059. intersectionThreshold: number;
  16060. constructor(name: string, source: LinesMesh);
  16061. /**
  16062. * Returns the string "InstancedLinesMesh".
  16063. */
  16064. getClassName(): string;
  16065. }
  16066. }
  16067. declare module "babylonjs/Shaders/line.fragment" {
  16068. /** @hidden */
  16069. export var linePixelShader: {
  16070. name: string;
  16071. shader: string;
  16072. };
  16073. }
  16074. declare module "babylonjs/Shaders/line.vertex" {
  16075. /** @hidden */
  16076. export var lineVertexShader: {
  16077. name: string;
  16078. shader: string;
  16079. };
  16080. }
  16081. declare module "babylonjs/Rendering/edgesRenderer" {
  16082. import { Nullable } from "babylonjs/types";
  16083. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16084. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16085. import { Vector3 } from "babylonjs/Maths/math.vector";
  16086. import { IDisposable } from "babylonjs/scene";
  16087. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  16088. import "babylonjs/Shaders/line.fragment";
  16089. import "babylonjs/Shaders/line.vertex";
  16090. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  16091. module "babylonjs/Meshes/abstractMesh" {
  16092. interface AbstractMesh {
  16093. /**
  16094. * Gets the edgesRenderer associated with the mesh
  16095. */
  16096. edgesRenderer: Nullable<EdgesRenderer>;
  16097. }
  16098. }
  16099. module "babylonjs/Meshes/linesMesh" {
  16100. interface LinesMesh {
  16101. /**
  16102. * Enables the edge rendering mode on the mesh.
  16103. * This mode makes the mesh edges visible
  16104. * @param epsilon defines the maximal distance between two angles to detect a face
  16105. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16106. * @returns the currentAbstractMesh
  16107. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16108. */
  16109. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  16110. }
  16111. }
  16112. module "babylonjs/Meshes/linesMesh" {
  16113. interface InstancedLinesMesh {
  16114. /**
  16115. * Enables the edge rendering mode on the mesh.
  16116. * This mode makes the mesh edges visible
  16117. * @param epsilon defines the maximal distance between two angles to detect a face
  16118. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  16119. * @returns the current InstancedLinesMesh
  16120. * @see https://www.babylonjs-playground.com/#19O9TU#0
  16121. */
  16122. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  16123. }
  16124. }
  16125. /**
  16126. * Defines the minimum contract an Edges renderer should follow.
  16127. */
  16128. export interface IEdgesRenderer extends IDisposable {
  16129. /**
  16130. * Gets or sets a boolean indicating if the edgesRenderer is active
  16131. */
  16132. isEnabled: boolean;
  16133. /**
  16134. * Renders the edges of the attached mesh,
  16135. */
  16136. render(): void;
  16137. /**
  16138. * Checks wether or not the edges renderer is ready to render.
  16139. * @return true if ready, otherwise false.
  16140. */
  16141. isReady(): boolean;
  16142. }
  16143. /**
  16144. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  16145. */
  16146. export class EdgesRenderer implements IEdgesRenderer {
  16147. /**
  16148. * Define the size of the edges with an orthographic camera
  16149. */
  16150. edgesWidthScalerForOrthographic: number;
  16151. /**
  16152. * Define the size of the edges with a perspective camera
  16153. */
  16154. edgesWidthScalerForPerspective: number;
  16155. protected _source: AbstractMesh;
  16156. protected _linesPositions: number[];
  16157. protected _linesNormals: number[];
  16158. protected _linesIndices: number[];
  16159. protected _epsilon: number;
  16160. protected _indicesCount: number;
  16161. protected _lineShader: ShaderMaterial;
  16162. protected _ib: DataBuffer;
  16163. protected _buffers: {
  16164. [key: string]: Nullable<VertexBuffer>;
  16165. };
  16166. protected _checkVerticesInsteadOfIndices: boolean;
  16167. private _meshRebuildObserver;
  16168. private _meshDisposeObserver;
  16169. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  16170. isEnabled: boolean;
  16171. /**
  16172. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  16173. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  16174. * @param source Mesh used to create edges
  16175. * @param epsilon sum of angles in adjacency to check for edge
  16176. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  16177. * @param generateEdgesLines - should generate Lines or only prepare resources.
  16178. */
  16179. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  16180. protected _prepareRessources(): void;
  16181. /** @hidden */
  16182. _rebuild(): void;
  16183. /**
  16184. * Releases the required resources for the edges renderer
  16185. */
  16186. dispose(): void;
  16187. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  16188. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  16189. /**
  16190. * Checks if the pair of p0 and p1 is en edge
  16191. * @param faceIndex
  16192. * @param edge
  16193. * @param faceNormals
  16194. * @param p0
  16195. * @param p1
  16196. * @private
  16197. */
  16198. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  16199. /**
  16200. * push line into the position, normal and index buffer
  16201. * @protected
  16202. */
  16203. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  16204. /**
  16205. * Generates lines edges from adjacencjes
  16206. * @private
  16207. */
  16208. _generateEdgesLines(): void;
  16209. /**
  16210. * Checks wether or not the edges renderer is ready to render.
  16211. * @return true if ready, otherwise false.
  16212. */
  16213. isReady(): boolean;
  16214. /**
  16215. * Renders the edges of the attached mesh,
  16216. */
  16217. render(): void;
  16218. }
  16219. /**
  16220. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  16221. */
  16222. export class LineEdgesRenderer extends EdgesRenderer {
  16223. /**
  16224. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  16225. * @param source LineMesh used to generate edges
  16226. * @param epsilon not important (specified angle for edge detection)
  16227. * @param checkVerticesInsteadOfIndices not important for LineMesh
  16228. */
  16229. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16230. /**
  16231. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  16232. */
  16233. _generateEdgesLines(): void;
  16234. }
  16235. }
  16236. declare module "babylonjs/Rendering/renderingGroup" {
  16237. import { SmartArray } from "babylonjs/Misc/smartArray";
  16238. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16240. import { Nullable } from "babylonjs/types";
  16241. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16242. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  16243. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16244. import { Material } from "babylonjs/Materials/material";
  16245. import { Scene } from "babylonjs/scene";
  16246. /**
  16247. * This represents the object necessary to create a rendering group.
  16248. * This is exclusively used and created by the rendering manager.
  16249. * To modify the behavior, you use the available helpers in your scene or meshes.
  16250. * @hidden
  16251. */
  16252. export class RenderingGroup {
  16253. index: number;
  16254. private static _zeroVector;
  16255. private _scene;
  16256. private _opaqueSubMeshes;
  16257. private _transparentSubMeshes;
  16258. private _alphaTestSubMeshes;
  16259. private _depthOnlySubMeshes;
  16260. private _particleSystems;
  16261. private _spriteManagers;
  16262. private _opaqueSortCompareFn;
  16263. private _alphaTestSortCompareFn;
  16264. private _transparentSortCompareFn;
  16265. private _renderOpaque;
  16266. private _renderAlphaTest;
  16267. private _renderTransparent;
  16268. /** @hidden */
  16269. _edgesRenderers: SmartArray<IEdgesRenderer>;
  16270. onBeforeTransparentRendering: () => void;
  16271. /**
  16272. * Set the opaque sort comparison function.
  16273. * If null the sub meshes will be render in the order they were created
  16274. */
  16275. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16276. /**
  16277. * Set the alpha test sort comparison function.
  16278. * If null the sub meshes will be render in the order they were created
  16279. */
  16280. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16281. /**
  16282. * Set the transparent sort comparison function.
  16283. * If null the sub meshes will be render in the order they were created
  16284. */
  16285. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16286. /**
  16287. * Creates a new rendering group.
  16288. * @param index The rendering group index
  16289. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16290. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16291. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16292. */
  16293. constructor(index: number, scene: Scene, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>);
  16294. /**
  16295. * Render all the sub meshes contained in the group.
  16296. * @param customRenderFunction Used to override the default render behaviour of the group.
  16297. * @returns true if rendered some submeshes.
  16298. */
  16299. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16300. /**
  16301. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16302. * @param subMeshes The submeshes to render
  16303. */
  16304. private renderOpaqueSorted;
  16305. /**
  16306. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16307. * @param subMeshes The submeshes to render
  16308. */
  16309. private renderAlphaTestSorted;
  16310. /**
  16311. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16312. * @param subMeshes The submeshes to render
  16313. */
  16314. private renderTransparentSorted;
  16315. /**
  16316. * Renders the submeshes in a specified order.
  16317. * @param subMeshes The submeshes to sort before render
  16318. * @param sortCompareFn The comparison function use to sort
  16319. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16320. * @param transparent Specifies to activate blending if true
  16321. */
  16322. private static renderSorted;
  16323. /**
  16324. * Renders the submeshes in the order they were dispatched (no sort applied).
  16325. * @param subMeshes The submeshes to render
  16326. */
  16327. private static renderUnsorted;
  16328. /**
  16329. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16330. * are rendered back to front if in the same alpha index.
  16331. *
  16332. * @param a The first submesh
  16333. * @param b The second submesh
  16334. * @returns The result of the comparison
  16335. */
  16336. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16337. /**
  16338. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16339. * are rendered back to front.
  16340. *
  16341. * @param a The first submesh
  16342. * @param b The second submesh
  16343. * @returns The result of the comparison
  16344. */
  16345. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16346. /**
  16347. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16348. * are rendered front to back (prevent overdraw).
  16349. *
  16350. * @param a The first submesh
  16351. * @param b The second submesh
  16352. * @returns The result of the comparison
  16353. */
  16354. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16355. /**
  16356. * Resets the different lists of submeshes to prepare a new frame.
  16357. */
  16358. prepare(): void;
  16359. dispose(): void;
  16360. /**
  16361. * Inserts the submesh in its correct queue depending on its material.
  16362. * @param subMesh The submesh to dispatch
  16363. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16364. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16365. */
  16366. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16367. dispatchSprites(spriteManager: ISpriteManager): void;
  16368. dispatchParticles(particleSystem: IParticleSystem): void;
  16369. private _renderParticles;
  16370. private _renderSprites;
  16371. }
  16372. }
  16373. declare module "babylonjs/Rendering/renderingManager" {
  16374. import { Nullable } from "babylonjs/types";
  16375. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16376. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16377. import { SmartArray } from "babylonjs/Misc/smartArray";
  16378. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  16379. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  16380. import { Material } from "babylonjs/Materials/material";
  16381. import { Scene } from "babylonjs/scene";
  16382. import { Camera } from "babylonjs/Cameras/camera";
  16383. /**
  16384. * Interface describing the different options available in the rendering manager
  16385. * regarding Auto Clear between groups.
  16386. */
  16387. export interface IRenderingManagerAutoClearSetup {
  16388. /**
  16389. * Defines whether or not autoclear is enable.
  16390. */
  16391. autoClear: boolean;
  16392. /**
  16393. * Defines whether or not to autoclear the depth buffer.
  16394. */
  16395. depth: boolean;
  16396. /**
  16397. * Defines whether or not to autoclear the stencil buffer.
  16398. */
  16399. stencil: boolean;
  16400. }
  16401. /**
  16402. * This class is used by the onRenderingGroupObservable
  16403. */
  16404. export class RenderingGroupInfo {
  16405. /**
  16406. * The Scene that being rendered
  16407. */
  16408. scene: Scene;
  16409. /**
  16410. * The camera currently used for the rendering pass
  16411. */
  16412. camera: Nullable<Camera>;
  16413. /**
  16414. * The ID of the renderingGroup being processed
  16415. */
  16416. renderingGroupId: number;
  16417. }
  16418. /**
  16419. * This is the manager responsible of all the rendering for meshes sprites and particles.
  16420. * It is enable to manage the different groups as well as the different necessary sort functions.
  16421. * This should not be used directly aside of the few static configurations
  16422. */
  16423. export class RenderingManager {
  16424. /**
  16425. * The max id used for rendering groups (not included)
  16426. */
  16427. static MAX_RENDERINGGROUPS: number;
  16428. /**
  16429. * The min id used for rendering groups (included)
  16430. */
  16431. static MIN_RENDERINGGROUPS: number;
  16432. /**
  16433. * Used to globally prevent autoclearing scenes.
  16434. */
  16435. static AUTOCLEAR: boolean;
  16436. /**
  16437. * @hidden
  16438. */
  16439. _useSceneAutoClearSetup: boolean;
  16440. private _scene;
  16441. private _renderingGroups;
  16442. private _depthStencilBufferAlreadyCleaned;
  16443. private _autoClearDepthStencil;
  16444. private _customOpaqueSortCompareFn;
  16445. private _customAlphaTestSortCompareFn;
  16446. private _customTransparentSortCompareFn;
  16447. private _renderingGroupInfo;
  16448. /**
  16449. * Instantiates a new rendering group for a particular scene
  16450. * @param scene Defines the scene the groups belongs to
  16451. */
  16452. constructor(scene: Scene);
  16453. private _clearDepthStencilBuffer;
  16454. /**
  16455. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  16456. * @hidden
  16457. */
  16458. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16459. /**
  16460. * Resets the different information of the group to prepare a new frame
  16461. * @hidden
  16462. */
  16463. reset(): void;
  16464. /**
  16465. * Dispose and release the group and its associated resources.
  16466. * @hidden
  16467. */
  16468. dispose(): void;
  16469. /**
  16470. * Clear the info related to rendering groups preventing retention points during dispose.
  16471. */
  16472. freeRenderingGroups(): void;
  16473. private _prepareRenderingGroup;
  16474. /**
  16475. * Add a sprite manager to the rendering manager in order to render it this frame.
  16476. * @param spriteManager Define the sprite manager to render
  16477. */
  16478. dispatchSprites(spriteManager: ISpriteManager): void;
  16479. /**
  16480. * Add a particle system to the rendering manager in order to render it this frame.
  16481. * @param particleSystem Define the particle system to render
  16482. */
  16483. dispatchParticles(particleSystem: IParticleSystem): void;
  16484. /**
  16485. * Add a submesh to the manager in order to render it this frame
  16486. * @param subMesh The submesh to dispatch
  16487. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16488. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16489. */
  16490. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16491. /**
  16492. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16493. * This allowed control for front to back rendering or reversly depending of the special needs.
  16494. *
  16495. * @param renderingGroupId The rendering group id corresponding to its index
  16496. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16497. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16498. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16499. */
  16500. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  16501. /**
  16502. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16503. *
  16504. * @param renderingGroupId The rendering group id corresponding to its index
  16505. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16506. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16507. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16508. */
  16509. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16510. /**
  16511. * Gets the current auto clear configuration for one rendering group of the rendering
  16512. * manager.
  16513. * @param index the rendering group index to get the information for
  16514. * @returns The auto clear setup for the requested rendering group
  16515. */
  16516. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  16517. }
  16518. }
  16519. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  16520. import { SmartArray } from "babylonjs/Misc/smartArray";
  16521. import { Nullable } from "babylonjs/types";
  16522. import { Scene } from "babylonjs/scene";
  16523. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  16524. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16525. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16526. import { Mesh } from "babylonjs/Meshes/mesh";
  16527. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  16528. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  16529. import { Effect } from "babylonjs/Materials/effect";
  16530. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16531. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16532. import "babylonjs/Shaders/shadowMap.fragment";
  16533. import "babylonjs/Shaders/shadowMap.vertex";
  16534. import "babylonjs/Shaders/depthBoxBlur.fragment";
  16535. import { Observable } from "babylonjs/Misc/observable";
  16536. /**
  16537. * Defines the options associated with the creation of a custom shader for a shadow generator.
  16538. */
  16539. export interface ICustomShaderOptions {
  16540. /**
  16541. * Gets or sets the custom shader name to use
  16542. */
  16543. shaderName: string;
  16544. /**
  16545. * The list of attribute names used in the shader
  16546. */
  16547. attributes?: string[];
  16548. /**
  16549. * The list of unifrom names used in the shader
  16550. */
  16551. uniforms?: string[];
  16552. /**
  16553. * The list of sampler names used in the shader
  16554. */
  16555. samplers?: string[];
  16556. /**
  16557. * The list of defines used in the shader
  16558. */
  16559. defines?: string[];
  16560. }
  16561. /**
  16562. * Interface to implement to create a shadow generator compatible with BJS.
  16563. */
  16564. export interface IShadowGenerator {
  16565. /**
  16566. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16567. * @returns The render target texture if present otherwise, null
  16568. */
  16569. getShadowMap(): Nullable<RenderTargetTexture>;
  16570. /**
  16571. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  16572. * @param subMesh The submesh we want to render in the shadow map
  16573. * @param useInstances Defines wether will draw in the map using instances
  16574. * @returns true if ready otherwise, false
  16575. */
  16576. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16577. /**
  16578. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  16579. * @param defines Defines of the material we want to update
  16580. * @param lightIndex Index of the light in the enabled light list of the material
  16581. */
  16582. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  16583. /**
  16584. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  16585. * defined in the generator but impacting the effect).
  16586. * It implies the unifroms available on the materials are the standard BJS ones.
  16587. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  16588. * @param effect The effect we are binfing the information for
  16589. */
  16590. bindShadowLight(lightIndex: string, effect: Effect): void;
  16591. /**
  16592. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  16593. * (eq to shadow prjection matrix * light transform matrix)
  16594. * @returns The transform matrix used to create the shadow map
  16595. */
  16596. getTransformMatrix(): Matrix;
  16597. /**
  16598. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  16599. * Cube and 2D textures for instance.
  16600. */
  16601. recreateShadowMap(): void;
  16602. /**
  16603. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16604. * @param onCompiled Callback triggered at the and of the effects compilation
  16605. * @param options Sets of optional options forcing the compilation with different modes
  16606. */
  16607. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  16608. useInstances: boolean;
  16609. }>): void;
  16610. /**
  16611. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  16612. * @param options Sets of optional options forcing the compilation with different modes
  16613. * @returns A promise that resolves when the compilation completes
  16614. */
  16615. forceCompilationAsync(options?: Partial<{
  16616. useInstances: boolean;
  16617. }>): Promise<void>;
  16618. /**
  16619. * Serializes the shadow generator setup to a json object.
  16620. * @returns The serialized JSON object
  16621. */
  16622. serialize(): any;
  16623. /**
  16624. * Disposes the Shadow map and related Textures and effects.
  16625. */
  16626. dispose(): void;
  16627. }
  16628. /**
  16629. * Default implementation IShadowGenerator.
  16630. * This is the main object responsible of generating shadows in the framework.
  16631. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  16632. */
  16633. export class ShadowGenerator implements IShadowGenerator {
  16634. /**
  16635. * Name of the shadow generator class
  16636. */
  16637. static CLASSNAME: string;
  16638. /**
  16639. * Shadow generator mode None: no filtering applied.
  16640. */
  16641. static readonly FILTER_NONE: number;
  16642. /**
  16643. * Shadow generator mode ESM: Exponential Shadow Mapping.
  16644. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16645. */
  16646. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  16647. /**
  16648. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  16649. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  16650. */
  16651. static readonly FILTER_POISSONSAMPLING: number;
  16652. /**
  16653. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  16654. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16655. */
  16656. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  16657. /**
  16658. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  16659. * edge artifacts on steep falloff.
  16660. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16661. */
  16662. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  16663. /**
  16664. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  16665. * edge artifacts on steep falloff.
  16666. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  16667. */
  16668. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  16669. /**
  16670. * Shadow generator mode PCF: Percentage Closer Filtering
  16671. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16672. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  16673. */
  16674. static readonly FILTER_PCF: number;
  16675. /**
  16676. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  16677. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  16678. * Contact Hardening
  16679. */
  16680. static readonly FILTER_PCSS: number;
  16681. /**
  16682. * Reserved for PCF and PCSS
  16683. * Highest Quality.
  16684. *
  16685. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  16686. *
  16687. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  16688. */
  16689. static readonly QUALITY_HIGH: number;
  16690. /**
  16691. * Reserved for PCF and PCSS
  16692. * Good tradeoff for quality/perf cross devices
  16693. *
  16694. * Execute PCF on a 3*3 kernel.
  16695. *
  16696. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  16697. */
  16698. static readonly QUALITY_MEDIUM: number;
  16699. /**
  16700. * Reserved for PCF and PCSS
  16701. * The lowest quality but the fastest.
  16702. *
  16703. * Execute PCF on a 1*1 kernel.
  16704. *
  16705. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  16706. */
  16707. static readonly QUALITY_LOW: number;
  16708. /** Gets or sets the custom shader name to use */
  16709. customShaderOptions: ICustomShaderOptions;
  16710. /**
  16711. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  16712. */
  16713. onBeforeShadowMapRenderObservable: Observable<Effect>;
  16714. /**
  16715. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  16716. */
  16717. onAfterShadowMapRenderObservable: Observable<Effect>;
  16718. /**
  16719. * Observable triggered before a mesh is rendered in the shadow map.
  16720. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  16721. */
  16722. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  16723. /**
  16724. * Observable triggered after a mesh is rendered in the shadow map.
  16725. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  16726. */
  16727. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  16728. protected _bias: number;
  16729. /**
  16730. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  16731. */
  16732. get bias(): number;
  16733. /**
  16734. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  16735. */
  16736. set bias(bias: number);
  16737. protected _normalBias: number;
  16738. /**
  16739. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16740. */
  16741. get normalBias(): number;
  16742. /**
  16743. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  16744. */
  16745. set normalBias(normalBias: number);
  16746. protected _blurBoxOffset: number;
  16747. /**
  16748. * Gets the blur box offset: offset applied during the blur pass.
  16749. * Only useful if useKernelBlur = false
  16750. */
  16751. get blurBoxOffset(): number;
  16752. /**
  16753. * Sets the blur box offset: offset applied during the blur pass.
  16754. * Only useful if useKernelBlur = false
  16755. */
  16756. set blurBoxOffset(value: number);
  16757. protected _blurScale: number;
  16758. /**
  16759. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  16760. * 2 means half of the size.
  16761. */
  16762. get blurScale(): number;
  16763. /**
  16764. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  16765. * 2 means half of the size.
  16766. */
  16767. set blurScale(value: number);
  16768. protected _blurKernel: number;
  16769. /**
  16770. * Gets the blur kernel: kernel size of the blur pass.
  16771. * Only useful if useKernelBlur = true
  16772. */
  16773. get blurKernel(): number;
  16774. /**
  16775. * Sets the blur kernel: kernel size of the blur pass.
  16776. * Only useful if useKernelBlur = true
  16777. */
  16778. set blurKernel(value: number);
  16779. protected _useKernelBlur: boolean;
  16780. /**
  16781. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  16782. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16783. */
  16784. get useKernelBlur(): boolean;
  16785. /**
  16786. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  16787. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  16788. */
  16789. set useKernelBlur(value: boolean);
  16790. protected _depthScale: number;
  16791. /**
  16792. * Gets the depth scale used in ESM mode.
  16793. */
  16794. get depthScale(): number;
  16795. /**
  16796. * Sets the depth scale used in ESM mode.
  16797. * This can override the scale stored on the light.
  16798. */
  16799. set depthScale(value: number);
  16800. protected _validateFilter(filter: number): number;
  16801. protected _filter: number;
  16802. /**
  16803. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  16804. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16805. */
  16806. get filter(): number;
  16807. /**
  16808. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  16809. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  16810. */
  16811. set filter(value: number);
  16812. /**
  16813. * Gets if the current filter is set to Poisson Sampling.
  16814. */
  16815. get usePoissonSampling(): boolean;
  16816. /**
  16817. * Sets the current filter to Poisson Sampling.
  16818. */
  16819. set usePoissonSampling(value: boolean);
  16820. /**
  16821. * Gets if the current filter is set to ESM.
  16822. */
  16823. get useExponentialShadowMap(): boolean;
  16824. /**
  16825. * Sets the current filter is to ESM.
  16826. */
  16827. set useExponentialShadowMap(value: boolean);
  16828. /**
  16829. * Gets if the current filter is set to filtered ESM.
  16830. */
  16831. get useBlurExponentialShadowMap(): boolean;
  16832. /**
  16833. * Gets if the current filter is set to filtered ESM.
  16834. */
  16835. set useBlurExponentialShadowMap(value: boolean);
  16836. /**
  16837. * Gets if the current filter is set to "close ESM" (using the inverse of the
  16838. * exponential to prevent steep falloff artifacts).
  16839. */
  16840. get useCloseExponentialShadowMap(): boolean;
  16841. /**
  16842. * Sets the current filter to "close ESM" (using the inverse of the
  16843. * exponential to prevent steep falloff artifacts).
  16844. */
  16845. set useCloseExponentialShadowMap(value: boolean);
  16846. /**
  16847. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  16848. * exponential to prevent steep falloff artifacts).
  16849. */
  16850. get useBlurCloseExponentialShadowMap(): boolean;
  16851. /**
  16852. * Sets the current filter to filtered "close ESM" (using the inverse of the
  16853. * exponential to prevent steep falloff artifacts).
  16854. */
  16855. set useBlurCloseExponentialShadowMap(value: boolean);
  16856. /**
  16857. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  16858. */
  16859. get usePercentageCloserFiltering(): boolean;
  16860. /**
  16861. * Sets the current filter to "PCF" (percentage closer filtering).
  16862. */
  16863. set usePercentageCloserFiltering(value: boolean);
  16864. protected _filteringQuality: number;
  16865. /**
  16866. * Gets the PCF or PCSS Quality.
  16867. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16868. */
  16869. get filteringQuality(): number;
  16870. /**
  16871. * Sets the PCF or PCSS Quality.
  16872. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  16873. */
  16874. set filteringQuality(filteringQuality: number);
  16875. /**
  16876. * Gets if the current filter is set to "PCSS" (contact hardening).
  16877. */
  16878. get useContactHardeningShadow(): boolean;
  16879. /**
  16880. * Sets the current filter to "PCSS" (contact hardening).
  16881. */
  16882. set useContactHardeningShadow(value: boolean);
  16883. protected _contactHardeningLightSizeUVRatio: number;
  16884. /**
  16885. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16886. * Using a ratio helps keeping shape stability independently of the map size.
  16887. *
  16888. * It does not account for the light projection as it was having too much
  16889. * instability during the light setup or during light position changes.
  16890. *
  16891. * Only valid if useContactHardeningShadow is true.
  16892. */
  16893. get contactHardeningLightSizeUVRatio(): number;
  16894. /**
  16895. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  16896. * Using a ratio helps keeping shape stability independently of the map size.
  16897. *
  16898. * It does not account for the light projection as it was having too much
  16899. * instability during the light setup or during light position changes.
  16900. *
  16901. * Only valid if useContactHardeningShadow is true.
  16902. */
  16903. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  16904. protected _darkness: number;
  16905. /** Gets or sets the actual darkness of a shadow */
  16906. get darkness(): number;
  16907. set darkness(value: number);
  16908. /**
  16909. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  16910. * 0 means strongest and 1 would means no shadow.
  16911. * @returns the darkness.
  16912. */
  16913. getDarkness(): number;
  16914. /**
  16915. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  16916. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  16917. * @returns the shadow generator allowing fluent coding.
  16918. */
  16919. setDarkness(darkness: number): ShadowGenerator;
  16920. protected _transparencyShadow: boolean;
  16921. /** Gets or sets the ability to have transparent shadow */
  16922. get transparencyShadow(): boolean;
  16923. set transparencyShadow(value: boolean);
  16924. /**
  16925. * Sets the ability to have transparent shadow (boolean).
  16926. * @param transparent True if transparent else False
  16927. * @returns the shadow generator allowing fluent coding
  16928. */
  16929. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  16930. protected _shadowMap: Nullable<RenderTargetTexture>;
  16931. protected _shadowMap2: Nullable<RenderTargetTexture>;
  16932. /**
  16933. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  16934. * @returns The render target texture if present otherwise, null
  16935. */
  16936. getShadowMap(): Nullable<RenderTargetTexture>;
  16937. /**
  16938. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  16939. * @returns The render target texture if the shadow map is present otherwise, null
  16940. */
  16941. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  16942. /**
  16943. * Gets the class name of that object
  16944. * @returns "ShadowGenerator"
  16945. */
  16946. getClassName(): string;
  16947. /**
  16948. * Helper function to add a mesh and its descendants to the list of shadow casters.
  16949. * @param mesh Mesh to add
  16950. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  16951. * @returns the Shadow Generator itself
  16952. */
  16953. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16954. /**
  16955. * Helper function to remove a mesh and its descendants from the list of shadow casters
  16956. * @param mesh Mesh to remove
  16957. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  16958. * @returns the Shadow Generator itself
  16959. */
  16960. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  16961. /**
  16962. * Controls the extent to which the shadows fade out at the edge of the frustum
  16963. */
  16964. frustumEdgeFalloff: number;
  16965. protected _light: IShadowLight;
  16966. /**
  16967. * Returns the associated light object.
  16968. * @returns the light generating the shadow
  16969. */
  16970. getLight(): IShadowLight;
  16971. /**
  16972. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  16973. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  16974. * It might on the other hand introduce peter panning.
  16975. */
  16976. forceBackFacesOnly: boolean;
  16977. protected _scene: Scene;
  16978. protected _lightDirection: Vector3;
  16979. protected _effect: Effect;
  16980. protected _viewMatrix: Matrix;
  16981. protected _projectionMatrix: Matrix;
  16982. protected _transformMatrix: Matrix;
  16983. protected _cachedPosition: Vector3;
  16984. protected _cachedDirection: Vector3;
  16985. protected _cachedDefines: string;
  16986. protected _currentRenderID: number;
  16987. protected _boxBlurPostprocess: Nullable<PostProcess>;
  16988. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  16989. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  16990. protected _blurPostProcesses: PostProcess[];
  16991. protected _mapSize: number;
  16992. protected _currentFaceIndex: number;
  16993. protected _currentFaceIndexCache: number;
  16994. protected _textureType: number;
  16995. protected _defaultTextureMatrix: Matrix;
  16996. protected _storedUniqueId: Nullable<number>;
  16997. /** @hidden */
  16998. static _SceneComponentInitialization: (scene: Scene) => void;
  16999. /**
  17000. * Creates a ShadowGenerator object.
  17001. * A ShadowGenerator is the required tool to use the shadows.
  17002. * Each light casting shadows needs to use its own ShadowGenerator.
  17003. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17004. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17005. * @param light The light object generating the shadows.
  17006. * @param usefulFloatFirst By default the generator will try to use half float textures but if you need precision (for self shadowing for instance), you can use this option to enforce full float texture.
  17007. */
  17008. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17009. protected _initializeGenerator(): void;
  17010. protected _createTargetRenderTexture(): void;
  17011. protected _initializeShadowMap(): void;
  17012. protected _initializeBlurRTTAndPostProcesses(): void;
  17013. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17014. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  17015. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  17016. protected _applyFilterValues(): void;
  17017. /**
  17018. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17019. * @param onCompiled Callback triggered at the and of the effects compilation
  17020. * @param options Sets of optional options forcing the compilation with different modes
  17021. */
  17022. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17023. useInstances: boolean;
  17024. }>): void;
  17025. /**
  17026. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17027. * @param options Sets of optional options forcing the compilation with different modes
  17028. * @returns A promise that resolves when the compilation completes
  17029. */
  17030. forceCompilationAsync(options?: Partial<{
  17031. useInstances: boolean;
  17032. }>): Promise<void>;
  17033. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  17034. /**
  17035. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17036. * @param subMesh The submesh we want to render in the shadow map
  17037. * @param useInstances Defines wether will draw in the map using instances
  17038. * @returns true if ready otherwise, false
  17039. */
  17040. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  17041. /**
  17042. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17043. * @param defines Defines of the material we want to update
  17044. * @param lightIndex Index of the light in the enabled light list of the material
  17045. */
  17046. prepareDefines(defines: any, lightIndex: number): void;
  17047. /**
  17048. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17049. * defined in the generator but impacting the effect).
  17050. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17051. * @param effect The effect we are binfing the information for
  17052. */
  17053. bindShadowLight(lightIndex: string, effect: Effect): void;
  17054. /**
  17055. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17056. * (eq to shadow prjection matrix * light transform matrix)
  17057. * @returns The transform matrix used to create the shadow map
  17058. */
  17059. getTransformMatrix(): Matrix;
  17060. /**
  17061. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17062. * Cube and 2D textures for instance.
  17063. */
  17064. recreateShadowMap(): void;
  17065. protected _disposeBlurPostProcesses(): void;
  17066. protected _disposeRTTandPostProcesses(): void;
  17067. /**
  17068. * Disposes the ShadowGenerator.
  17069. * Returns nothing.
  17070. */
  17071. dispose(): void;
  17072. /**
  17073. * Serializes the shadow generator setup to a json object.
  17074. * @returns The serialized JSON object
  17075. */
  17076. serialize(): any;
  17077. /**
  17078. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  17079. * @param parsedShadowGenerator The JSON object to parse
  17080. * @param scene The scene to create the shadow map for
  17081. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  17082. * @returns The parsed shadow generator
  17083. */
  17084. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  17085. }
  17086. }
  17087. declare module "babylonjs/Lights/light" {
  17088. import { Nullable } from "babylonjs/types";
  17089. import { Scene } from "babylonjs/scene";
  17090. import { Vector3 } from "babylonjs/Maths/math.vector";
  17091. import { Color3 } from "babylonjs/Maths/math.color";
  17092. import { Node } from "babylonjs/node";
  17093. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17094. import { Effect } from "babylonjs/Materials/effect";
  17095. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  17096. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  17097. /**
  17098. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  17099. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  17100. * All meshes allow light to pass through them unless shadow generation is activated. The default number of lights allowed is four but this can be increased.
  17101. */
  17102. export abstract class Light extends Node {
  17103. /**
  17104. * Falloff Default: light is falling off following the material specification:
  17105. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  17106. */
  17107. static readonly FALLOFF_DEFAULT: number;
  17108. /**
  17109. * Falloff Physical: light is falling off following the inverse squared distance law.
  17110. */
  17111. static readonly FALLOFF_PHYSICAL: number;
  17112. /**
  17113. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  17114. * to enhance interoperability with other engines.
  17115. */
  17116. static readonly FALLOFF_GLTF: number;
  17117. /**
  17118. * Falloff Standard: light is falling off like in the standard material
  17119. * to enhance interoperability with other materials.
  17120. */
  17121. static readonly FALLOFF_STANDARD: number;
  17122. /**
  17123. * If every light affecting the material is in this lightmapMode,
  17124. * material.lightmapTexture adds or multiplies
  17125. * (depends on material.useLightmapAsShadowmap)
  17126. * after every other light calculations.
  17127. */
  17128. static readonly LIGHTMAP_DEFAULT: number;
  17129. /**
  17130. * material.lightmapTexture as only diffuse lighting from this light
  17131. * adds only specular lighting from this light
  17132. * adds dynamic shadows
  17133. */
  17134. static readonly LIGHTMAP_SPECULAR: number;
  17135. /**
  17136. * material.lightmapTexture as only lighting
  17137. * no light calculation from this light
  17138. * only adds dynamic shadows from this light
  17139. */
  17140. static readonly LIGHTMAP_SHADOWSONLY: number;
  17141. /**
  17142. * Each light type uses the default quantity according to its type:
  17143. * point/spot lights use luminous intensity
  17144. * directional lights use illuminance
  17145. */
  17146. static readonly INTENSITYMODE_AUTOMATIC: number;
  17147. /**
  17148. * lumen (lm)
  17149. */
  17150. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  17151. /**
  17152. * candela (lm/sr)
  17153. */
  17154. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  17155. /**
  17156. * lux (lm/m^2)
  17157. */
  17158. static readonly INTENSITYMODE_ILLUMINANCE: number;
  17159. /**
  17160. * nit (cd/m^2)
  17161. */
  17162. static readonly INTENSITYMODE_LUMINANCE: number;
  17163. /**
  17164. * Light type const id of the point light.
  17165. */
  17166. static readonly LIGHTTYPEID_POINTLIGHT: number;
  17167. /**
  17168. * Light type const id of the directional light.
  17169. */
  17170. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  17171. /**
  17172. * Light type const id of the spot light.
  17173. */
  17174. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  17175. /**
  17176. * Light type const id of the hemispheric light.
  17177. */
  17178. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  17179. /**
  17180. * Diffuse gives the basic color to an object.
  17181. */
  17182. diffuse: Color3;
  17183. /**
  17184. * Specular produces a highlight color on an object.
  17185. * Note: This is note affecting PBR materials.
  17186. */
  17187. specular: Color3;
  17188. /**
  17189. * Defines the falloff type for this light. This lets overrriding how punctual light are
  17190. * falling off base on range or angle.
  17191. * This can be set to any values in Light.FALLOFF_x.
  17192. *
  17193. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  17194. * other types of materials.
  17195. */
  17196. falloffType: number;
  17197. /**
  17198. * Strength of the light.
  17199. * Note: By default it is define in the framework own unit.
  17200. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  17201. */
  17202. intensity: number;
  17203. private _range;
  17204. protected _inverseSquaredRange: number;
  17205. /**
  17206. * Defines how far from the source the light is impacting in scene units.
  17207. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17208. */
  17209. get range(): number;
  17210. /**
  17211. * Defines how far from the source the light is impacting in scene units.
  17212. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  17213. */
  17214. set range(value: number);
  17215. /**
  17216. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  17217. * of light.
  17218. */
  17219. private _photometricScale;
  17220. private _intensityMode;
  17221. /**
  17222. * Gets the photometric scale used to interpret the intensity.
  17223. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17224. */
  17225. get intensityMode(): number;
  17226. /**
  17227. * Sets the photometric scale used to interpret the intensity.
  17228. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  17229. */
  17230. set intensityMode(value: number);
  17231. private _radius;
  17232. /**
  17233. * Gets the light radius used by PBR Materials to simulate soft area lights.
  17234. */
  17235. get radius(): number;
  17236. /**
  17237. * sets the light radius used by PBR Materials to simulate soft area lights.
  17238. */
  17239. set radius(value: number);
  17240. private _renderPriority;
  17241. /**
  17242. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  17243. * exceeding the number allowed of the materials.
  17244. */
  17245. renderPriority: number;
  17246. private _shadowEnabled;
  17247. /**
  17248. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17249. * the current shadow generator.
  17250. */
  17251. get shadowEnabled(): boolean;
  17252. /**
  17253. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  17254. * the current shadow generator.
  17255. */
  17256. set shadowEnabled(value: boolean);
  17257. private _includedOnlyMeshes;
  17258. /**
  17259. * Gets the only meshes impacted by this light.
  17260. */
  17261. get includedOnlyMeshes(): AbstractMesh[];
  17262. /**
  17263. * Sets the only meshes impacted by this light.
  17264. */
  17265. set includedOnlyMeshes(value: AbstractMesh[]);
  17266. private _excludedMeshes;
  17267. /**
  17268. * Gets the meshes not impacted by this light.
  17269. */
  17270. get excludedMeshes(): AbstractMesh[];
  17271. /**
  17272. * Sets the meshes not impacted by this light.
  17273. */
  17274. set excludedMeshes(value: AbstractMesh[]);
  17275. private _excludeWithLayerMask;
  17276. /**
  17277. * Gets the layer id use to find what meshes are not impacted by the light.
  17278. * Inactive if 0
  17279. */
  17280. get excludeWithLayerMask(): number;
  17281. /**
  17282. * Sets the layer id use to find what meshes are not impacted by the light.
  17283. * Inactive if 0
  17284. */
  17285. set excludeWithLayerMask(value: number);
  17286. private _includeOnlyWithLayerMask;
  17287. /**
  17288. * Gets the layer id use to find what meshes are impacted by the light.
  17289. * Inactive if 0
  17290. */
  17291. get includeOnlyWithLayerMask(): number;
  17292. /**
  17293. * Sets the layer id use to find what meshes are impacted by the light.
  17294. * Inactive if 0
  17295. */
  17296. set includeOnlyWithLayerMask(value: number);
  17297. private _lightmapMode;
  17298. /**
  17299. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17300. */
  17301. get lightmapMode(): number;
  17302. /**
  17303. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  17304. */
  17305. set lightmapMode(value: number);
  17306. /**
  17307. * Shadow generator associted to the light.
  17308. * @hidden Internal use only.
  17309. */
  17310. _shadowGenerator: Nullable<IShadowGenerator>;
  17311. /**
  17312. * @hidden Internal use only.
  17313. */
  17314. _excludedMeshesIds: string[];
  17315. /**
  17316. * @hidden Internal use only.
  17317. */
  17318. _includedOnlyMeshesIds: string[];
  17319. /**
  17320. * The current light unifom buffer.
  17321. * @hidden Internal use only.
  17322. */
  17323. _uniformBuffer: UniformBuffer;
  17324. /** @hidden */
  17325. _renderId: number;
  17326. /**
  17327. * Creates a Light object in the scene.
  17328. * Documentation : https://doc.babylonjs.com/babylon101/lights
  17329. * @param name The firendly name of the light
  17330. * @param scene The scene the light belongs too
  17331. */
  17332. constructor(name: string, scene: Scene);
  17333. protected abstract _buildUniformLayout(): void;
  17334. /**
  17335. * Sets the passed Effect "effect" with the Light information.
  17336. * @param effect The effect to update
  17337. * @param lightIndex The index of the light in the effect to update
  17338. * @returns The light
  17339. */
  17340. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  17341. /**
  17342. * Sets the passed Effect "effect" with the Light textures.
  17343. * @param effect The effect to update
  17344. * @param lightIndex The index of the light in the effect to update
  17345. * @returns The light
  17346. */
  17347. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  17348. /**
  17349. * Binds the lights information from the scene to the effect for the given mesh.
  17350. * @param lightIndex Light index
  17351. * @param scene The scene where the light belongs to
  17352. * @param effect The effect we are binding the data to
  17353. * @param useSpecular Defines if specular is supported
  17354. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  17355. */
  17356. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  17357. /**
  17358. * Sets the passed Effect "effect" with the Light information.
  17359. * @param effect The effect to update
  17360. * @param lightDataUniformName The uniform used to store light data (position or direction)
  17361. * @returns The light
  17362. */
  17363. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  17364. /**
  17365. * Returns the string "Light".
  17366. * @returns the class name
  17367. */
  17368. getClassName(): string;
  17369. /** @hidden */
  17370. readonly _isLight: boolean;
  17371. /**
  17372. * Converts the light information to a readable string for debug purpose.
  17373. * @param fullDetails Supports for multiple levels of logging within scene loading
  17374. * @returns the human readable light info
  17375. */
  17376. toString(fullDetails?: boolean): string;
  17377. /** @hidden */
  17378. protected _syncParentEnabledState(): void;
  17379. /**
  17380. * Set the enabled state of this node.
  17381. * @param value - the new enabled state
  17382. */
  17383. setEnabled(value: boolean): void;
  17384. /**
  17385. * Returns the Light associated shadow generator if any.
  17386. * @return the associated shadow generator.
  17387. */
  17388. getShadowGenerator(): Nullable<IShadowGenerator>;
  17389. /**
  17390. * Returns a Vector3, the absolute light position in the World.
  17391. * @returns the world space position of the light
  17392. */
  17393. getAbsolutePosition(): Vector3;
  17394. /**
  17395. * Specifies if the light will affect the passed mesh.
  17396. * @param mesh The mesh to test against the light
  17397. * @return true the mesh is affected otherwise, false.
  17398. */
  17399. canAffectMesh(mesh: AbstractMesh): boolean;
  17400. /**
  17401. * Sort function to order lights for rendering.
  17402. * @param a First Light object to compare to second.
  17403. * @param b Second Light object to compare first.
  17404. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  17405. */
  17406. static CompareLightsPriority(a: Light, b: Light): number;
  17407. /**
  17408. * Releases resources associated with this node.
  17409. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  17410. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  17411. */
  17412. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17413. /**
  17414. * Returns the light type ID (integer).
  17415. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  17416. */
  17417. getTypeID(): number;
  17418. /**
  17419. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  17420. * @returns the scaled intensity in intensity mode unit
  17421. */
  17422. getScaledIntensity(): number;
  17423. /**
  17424. * Returns a new Light object, named "name", from the current one.
  17425. * @param name The name of the cloned light
  17426. * @returns the new created light
  17427. */
  17428. clone(name: string): Nullable<Light>;
  17429. /**
  17430. * Serializes the current light into a Serialization object.
  17431. * @returns the serialized object.
  17432. */
  17433. serialize(): any;
  17434. /**
  17435. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  17436. * This new light is named "name" and added to the passed scene.
  17437. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  17438. * @param name The friendly name of the light
  17439. * @param scene The scene the new light will belong to
  17440. * @returns the constructor function
  17441. */
  17442. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  17443. /**
  17444. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  17445. * @param parsedLight The JSON representation of the light
  17446. * @param scene The scene to create the parsed light in
  17447. * @returns the created light after parsing
  17448. */
  17449. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  17450. private _hookArrayForExcluded;
  17451. private _hookArrayForIncludedOnly;
  17452. private _resyncMeshes;
  17453. /**
  17454. * Forces the meshes to update their light related information in their rendering used effects
  17455. * @hidden Internal Use Only
  17456. */
  17457. _markMeshesAsLightDirty(): void;
  17458. /**
  17459. * Recomputes the cached photometric scale if needed.
  17460. */
  17461. private _computePhotometricScale;
  17462. /**
  17463. * Returns the Photometric Scale according to the light type and intensity mode.
  17464. */
  17465. private _getPhotometricScale;
  17466. /**
  17467. * Reorder the light in the scene according to their defined priority.
  17468. * @hidden Internal Use Only
  17469. */
  17470. _reorderLightsInScene(): void;
  17471. /**
  17472. * Prepares the list of defines specific to the light type.
  17473. * @param defines the list of defines
  17474. * @param lightIndex defines the index of the light for the effect
  17475. */
  17476. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  17477. }
  17478. }
  17479. declare module "babylonjs/Actions/action" {
  17480. import { Observable } from "babylonjs/Misc/observable";
  17481. import { Condition } from "babylonjs/Actions/condition";
  17482. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  17483. import { ActionManager } from "babylonjs/Actions/actionManager";
  17484. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17485. /**
  17486. * Interface used to define Action
  17487. */
  17488. export interface IAction {
  17489. /**
  17490. * Trigger for the action
  17491. */
  17492. trigger: number;
  17493. /** Options of the trigger */
  17494. triggerOptions: any;
  17495. /**
  17496. * Gets the trigger parameters
  17497. * @returns the trigger parameters
  17498. */
  17499. getTriggerParameter(): any;
  17500. /**
  17501. * Internal only - executes current action event
  17502. * @hidden
  17503. */
  17504. _executeCurrent(evt?: ActionEvent): void;
  17505. /**
  17506. * Serialize placeholder for child classes
  17507. * @param parent of child
  17508. * @returns the serialized object
  17509. */
  17510. serialize(parent: any): any;
  17511. /**
  17512. * Internal only
  17513. * @hidden
  17514. */
  17515. _prepare(): void;
  17516. /**
  17517. * Internal only - manager for action
  17518. * @hidden
  17519. */
  17520. _actionManager: AbstractActionManager;
  17521. /**
  17522. * Adds action to chain of actions, may be a DoNothingAction
  17523. * @param action defines the next action to execute
  17524. * @returns The action passed in
  17525. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17526. */
  17527. then(action: IAction): IAction;
  17528. }
  17529. /**
  17530. * The action to be carried out following a trigger
  17531. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  17532. */
  17533. export class Action implements IAction {
  17534. /** the trigger, with or without parameters, for the action */
  17535. triggerOptions: any;
  17536. /**
  17537. * Trigger for the action
  17538. */
  17539. trigger: number;
  17540. /**
  17541. * Internal only - manager for action
  17542. * @hidden
  17543. */
  17544. _actionManager: ActionManager;
  17545. private _nextActiveAction;
  17546. private _child;
  17547. private _condition?;
  17548. private _triggerParameter;
  17549. /**
  17550. * An event triggered prior to action being executed.
  17551. */
  17552. onBeforeExecuteObservable: Observable<Action>;
  17553. /**
  17554. * Creates a new Action
  17555. * @param triggerOptions the trigger, with or without parameters, for the action
  17556. * @param condition an optional determinant of action
  17557. */
  17558. constructor(
  17559. /** the trigger, with or without parameters, for the action */
  17560. triggerOptions: any, condition?: Condition);
  17561. /**
  17562. * Internal only
  17563. * @hidden
  17564. */
  17565. _prepare(): void;
  17566. /**
  17567. * Gets the trigger parameters
  17568. * @returns the trigger parameters
  17569. */
  17570. getTriggerParameter(): any;
  17571. /**
  17572. * Internal only - executes current action event
  17573. * @hidden
  17574. */
  17575. _executeCurrent(evt?: ActionEvent): void;
  17576. /**
  17577. * Execute placeholder for child classes
  17578. * @param evt optional action event
  17579. */
  17580. execute(evt?: ActionEvent): void;
  17581. /**
  17582. * Skips to next active action
  17583. */
  17584. skipToNextActiveAction(): void;
  17585. /**
  17586. * Adds action to chain of actions, may be a DoNothingAction
  17587. * @param action defines the next action to execute
  17588. * @returns The action passed in
  17589. * @see https://www.babylonjs-playground.com/#1T30HR#0
  17590. */
  17591. then(action: Action): Action;
  17592. /**
  17593. * Internal only
  17594. * @hidden
  17595. */
  17596. _getProperty(propertyPath: string): string;
  17597. /**
  17598. * Internal only
  17599. * @hidden
  17600. */
  17601. _getEffectiveTarget(target: any, propertyPath: string): any;
  17602. /**
  17603. * Serialize placeholder for child classes
  17604. * @param parent of child
  17605. * @returns the serialized object
  17606. */
  17607. serialize(parent: any): any;
  17608. /**
  17609. * Internal only called by serialize
  17610. * @hidden
  17611. */
  17612. protected _serialize(serializedAction: any, parent?: any): any;
  17613. /**
  17614. * Internal only
  17615. * @hidden
  17616. */
  17617. static _SerializeValueAsString: (value: any) => string;
  17618. /**
  17619. * Internal only
  17620. * @hidden
  17621. */
  17622. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  17623. name: string;
  17624. targetType: string;
  17625. value: string;
  17626. };
  17627. }
  17628. }
  17629. declare module "babylonjs/Actions/condition" {
  17630. import { ActionManager } from "babylonjs/Actions/actionManager";
  17631. /**
  17632. * A Condition applied to an Action
  17633. */
  17634. export class Condition {
  17635. /**
  17636. * Internal only - manager for action
  17637. * @hidden
  17638. */
  17639. _actionManager: ActionManager;
  17640. /**
  17641. * Internal only
  17642. * @hidden
  17643. */
  17644. _evaluationId: number;
  17645. /**
  17646. * Internal only
  17647. * @hidden
  17648. */
  17649. _currentResult: boolean;
  17650. /**
  17651. * Creates a new Condition
  17652. * @param actionManager the manager of the action the condition is applied to
  17653. */
  17654. constructor(actionManager: ActionManager);
  17655. /**
  17656. * Check if the current condition is valid
  17657. * @returns a boolean
  17658. */
  17659. isValid(): boolean;
  17660. /**
  17661. * Internal only
  17662. * @hidden
  17663. */
  17664. _getProperty(propertyPath: string): string;
  17665. /**
  17666. * Internal only
  17667. * @hidden
  17668. */
  17669. _getEffectiveTarget(target: any, propertyPath: string): any;
  17670. /**
  17671. * Serialize placeholder for child classes
  17672. * @returns the serialized object
  17673. */
  17674. serialize(): any;
  17675. /**
  17676. * Internal only
  17677. * @hidden
  17678. */
  17679. protected _serialize(serializedCondition: any): any;
  17680. }
  17681. /**
  17682. * Defines specific conditional operators as extensions of Condition
  17683. */
  17684. export class ValueCondition extends Condition {
  17685. /** path to specify the property of the target the conditional operator uses */
  17686. propertyPath: string;
  17687. /** the value compared by the conditional operator against the current value of the property */
  17688. value: any;
  17689. /** the conditional operator, default ValueCondition.IsEqual */
  17690. operator: number;
  17691. /**
  17692. * Internal only
  17693. * @hidden
  17694. */
  17695. private static _IsEqual;
  17696. /**
  17697. * Internal only
  17698. * @hidden
  17699. */
  17700. private static _IsDifferent;
  17701. /**
  17702. * Internal only
  17703. * @hidden
  17704. */
  17705. private static _IsGreater;
  17706. /**
  17707. * Internal only
  17708. * @hidden
  17709. */
  17710. private static _IsLesser;
  17711. /**
  17712. * returns the number for IsEqual
  17713. */
  17714. static get IsEqual(): number;
  17715. /**
  17716. * Returns the number for IsDifferent
  17717. */
  17718. static get IsDifferent(): number;
  17719. /**
  17720. * Returns the number for IsGreater
  17721. */
  17722. static get IsGreater(): number;
  17723. /**
  17724. * Returns the number for IsLesser
  17725. */
  17726. static get IsLesser(): number;
  17727. /**
  17728. * Internal only The action manager for the condition
  17729. * @hidden
  17730. */
  17731. _actionManager: ActionManager;
  17732. /**
  17733. * Internal only
  17734. * @hidden
  17735. */
  17736. private _target;
  17737. /**
  17738. * Internal only
  17739. * @hidden
  17740. */
  17741. private _effectiveTarget;
  17742. /**
  17743. * Internal only
  17744. * @hidden
  17745. */
  17746. private _property;
  17747. /**
  17748. * Creates a new ValueCondition
  17749. * @param actionManager manager for the action the condition applies to
  17750. * @param target for the action
  17751. * @param propertyPath path to specify the property of the target the conditional operator uses
  17752. * @param value the value compared by the conditional operator against the current value of the property
  17753. * @param operator the conditional operator, default ValueCondition.IsEqual
  17754. */
  17755. constructor(actionManager: ActionManager, target: any,
  17756. /** path to specify the property of the target the conditional operator uses */
  17757. propertyPath: string,
  17758. /** the value compared by the conditional operator against the current value of the property */
  17759. value: any,
  17760. /** the conditional operator, default ValueCondition.IsEqual */
  17761. operator?: number);
  17762. /**
  17763. * Compares the given value with the property value for the specified conditional operator
  17764. * @returns the result of the comparison
  17765. */
  17766. isValid(): boolean;
  17767. /**
  17768. * Serialize the ValueCondition into a JSON compatible object
  17769. * @returns serialization object
  17770. */
  17771. serialize(): any;
  17772. /**
  17773. * Gets the name of the conditional operator for the ValueCondition
  17774. * @param operator the conditional operator
  17775. * @returns the name
  17776. */
  17777. static GetOperatorName(operator: number): string;
  17778. }
  17779. /**
  17780. * Defines a predicate condition as an extension of Condition
  17781. */
  17782. export class PredicateCondition extends Condition {
  17783. /** defines the predicate function used to validate the condition */
  17784. predicate: () => boolean;
  17785. /**
  17786. * Internal only - manager for action
  17787. * @hidden
  17788. */
  17789. _actionManager: ActionManager;
  17790. /**
  17791. * Creates a new PredicateCondition
  17792. * @param actionManager manager for the action the condition applies to
  17793. * @param predicate defines the predicate function used to validate the condition
  17794. */
  17795. constructor(actionManager: ActionManager,
  17796. /** defines the predicate function used to validate the condition */
  17797. predicate: () => boolean);
  17798. /**
  17799. * @returns the validity of the predicate condition
  17800. */
  17801. isValid(): boolean;
  17802. }
  17803. /**
  17804. * Defines a state condition as an extension of Condition
  17805. */
  17806. export class StateCondition extends Condition {
  17807. /** Value to compare with target state */
  17808. value: string;
  17809. /**
  17810. * Internal only - manager for action
  17811. * @hidden
  17812. */
  17813. _actionManager: ActionManager;
  17814. /**
  17815. * Internal only
  17816. * @hidden
  17817. */
  17818. private _target;
  17819. /**
  17820. * Creates a new StateCondition
  17821. * @param actionManager manager for the action the condition applies to
  17822. * @param target of the condition
  17823. * @param value to compare with target state
  17824. */
  17825. constructor(actionManager: ActionManager, target: any,
  17826. /** Value to compare with target state */
  17827. value: string);
  17828. /**
  17829. * Gets a boolean indicating if the current condition is met
  17830. * @returns the validity of the state
  17831. */
  17832. isValid(): boolean;
  17833. /**
  17834. * Serialize the StateCondition into a JSON compatible object
  17835. * @returns serialization object
  17836. */
  17837. serialize(): any;
  17838. }
  17839. }
  17840. declare module "babylonjs/Actions/directActions" {
  17841. import { Action } from "babylonjs/Actions/action";
  17842. import { Condition } from "babylonjs/Actions/condition";
  17843. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  17844. /**
  17845. * This defines an action responsible to toggle a boolean once triggered.
  17846. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17847. */
  17848. export class SwitchBooleanAction extends Action {
  17849. /**
  17850. * The path to the boolean property in the target object
  17851. */
  17852. propertyPath: string;
  17853. private _target;
  17854. private _effectiveTarget;
  17855. private _property;
  17856. /**
  17857. * Instantiate the action
  17858. * @param triggerOptions defines the trigger options
  17859. * @param target defines the object containing the boolean
  17860. * @param propertyPath defines the path to the boolean property in the target object
  17861. * @param condition defines the trigger related conditions
  17862. */
  17863. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  17864. /** @hidden */
  17865. _prepare(): void;
  17866. /**
  17867. * Execute the action toggle the boolean value.
  17868. */
  17869. execute(): void;
  17870. /**
  17871. * Serializes the actions and its related information.
  17872. * @param parent defines the object to serialize in
  17873. * @returns the serialized object
  17874. */
  17875. serialize(parent: any): any;
  17876. }
  17877. /**
  17878. * This defines an action responsible to set a the state field of the target
  17879. * to a desired value once triggered.
  17880. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17881. */
  17882. export class SetStateAction extends Action {
  17883. /**
  17884. * The value to store in the state field.
  17885. */
  17886. value: string;
  17887. private _target;
  17888. /**
  17889. * Instantiate the action
  17890. * @param triggerOptions defines the trigger options
  17891. * @param target defines the object containing the state property
  17892. * @param value defines the value to store in the state field
  17893. * @param condition defines the trigger related conditions
  17894. */
  17895. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  17896. /**
  17897. * Execute the action and store the value on the target state property.
  17898. */
  17899. execute(): void;
  17900. /**
  17901. * Serializes the actions and its related information.
  17902. * @param parent defines the object to serialize in
  17903. * @returns the serialized object
  17904. */
  17905. serialize(parent: any): any;
  17906. }
  17907. /**
  17908. * This defines an action responsible to set a property of the target
  17909. * to a desired value once triggered.
  17910. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17911. */
  17912. export class SetValueAction extends Action {
  17913. /**
  17914. * The path of the property to set in the target.
  17915. */
  17916. propertyPath: string;
  17917. /**
  17918. * The value to set in the property
  17919. */
  17920. value: any;
  17921. private _target;
  17922. private _effectiveTarget;
  17923. private _property;
  17924. /**
  17925. * Instantiate the action
  17926. * @param triggerOptions defines the trigger options
  17927. * @param target defines the object containing the property
  17928. * @param propertyPath defines the path of the property to set in the target
  17929. * @param value defines the value to set in the property
  17930. * @param condition defines the trigger related conditions
  17931. */
  17932. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17933. /** @hidden */
  17934. _prepare(): void;
  17935. /**
  17936. * Execute the action and set the targetted property to the desired value.
  17937. */
  17938. execute(): void;
  17939. /**
  17940. * Serializes the actions and its related information.
  17941. * @param parent defines the object to serialize in
  17942. * @returns the serialized object
  17943. */
  17944. serialize(parent: any): any;
  17945. }
  17946. /**
  17947. * This defines an action responsible to increment the target value
  17948. * to a desired value once triggered.
  17949. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17950. */
  17951. export class IncrementValueAction extends Action {
  17952. /**
  17953. * The path of the property to increment in the target.
  17954. */
  17955. propertyPath: string;
  17956. /**
  17957. * The value we should increment the property by.
  17958. */
  17959. value: any;
  17960. private _target;
  17961. private _effectiveTarget;
  17962. private _property;
  17963. /**
  17964. * Instantiate the action
  17965. * @param triggerOptions defines the trigger options
  17966. * @param target defines the object containing the property
  17967. * @param propertyPath defines the path of the property to increment in the target
  17968. * @param value defines the value value we should increment the property by
  17969. * @param condition defines the trigger related conditions
  17970. */
  17971. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  17972. /** @hidden */
  17973. _prepare(): void;
  17974. /**
  17975. * Execute the action and increment the target of the value amount.
  17976. */
  17977. execute(): void;
  17978. /**
  17979. * Serializes the actions and its related information.
  17980. * @param parent defines the object to serialize in
  17981. * @returns the serialized object
  17982. */
  17983. serialize(parent: any): any;
  17984. }
  17985. /**
  17986. * This defines an action responsible to start an animation once triggered.
  17987. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  17988. */
  17989. export class PlayAnimationAction extends Action {
  17990. /**
  17991. * Where the animation should start (animation frame)
  17992. */
  17993. from: number;
  17994. /**
  17995. * Where the animation should stop (animation frame)
  17996. */
  17997. to: number;
  17998. /**
  17999. * Define if the animation should loop or stop after the first play.
  18000. */
  18001. loop?: boolean;
  18002. private _target;
  18003. /**
  18004. * Instantiate the action
  18005. * @param triggerOptions defines the trigger options
  18006. * @param target defines the target animation or animation name
  18007. * @param from defines from where the animation should start (animation frame)
  18008. * @param end defines where the animation should stop (animation frame)
  18009. * @param loop defines if the animation should loop or stop after the first play
  18010. * @param condition defines the trigger related conditions
  18011. */
  18012. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  18013. /** @hidden */
  18014. _prepare(): void;
  18015. /**
  18016. * Execute the action and play the animation.
  18017. */
  18018. execute(): void;
  18019. /**
  18020. * Serializes the actions and its related information.
  18021. * @param parent defines the object to serialize in
  18022. * @returns the serialized object
  18023. */
  18024. serialize(parent: any): any;
  18025. }
  18026. /**
  18027. * This defines an action responsible to stop an animation once triggered.
  18028. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18029. */
  18030. export class StopAnimationAction extends Action {
  18031. private _target;
  18032. /**
  18033. * Instantiate the action
  18034. * @param triggerOptions defines the trigger options
  18035. * @param target defines the target animation or animation name
  18036. * @param condition defines the trigger related conditions
  18037. */
  18038. constructor(triggerOptions: any, target: any, condition?: Condition);
  18039. /** @hidden */
  18040. _prepare(): void;
  18041. /**
  18042. * Execute the action and stop the animation.
  18043. */
  18044. execute(): void;
  18045. /**
  18046. * Serializes the actions and its related information.
  18047. * @param parent defines the object to serialize in
  18048. * @returns the serialized object
  18049. */
  18050. serialize(parent: any): any;
  18051. }
  18052. /**
  18053. * This defines an action responsible that does nothing once triggered.
  18054. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18055. */
  18056. export class DoNothingAction extends Action {
  18057. /**
  18058. * Instantiate the action
  18059. * @param triggerOptions defines the trigger options
  18060. * @param condition defines the trigger related conditions
  18061. */
  18062. constructor(triggerOptions?: any, condition?: Condition);
  18063. /**
  18064. * Execute the action and do nothing.
  18065. */
  18066. execute(): void;
  18067. /**
  18068. * Serializes the actions and its related information.
  18069. * @param parent defines the object to serialize in
  18070. * @returns the serialized object
  18071. */
  18072. serialize(parent: any): any;
  18073. }
  18074. /**
  18075. * This defines an action responsible to trigger several actions once triggered.
  18076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18077. */
  18078. export class CombineAction extends Action {
  18079. /**
  18080. * The list of aggregated animations to run.
  18081. */
  18082. children: Action[];
  18083. /**
  18084. * Instantiate the action
  18085. * @param triggerOptions defines the trigger options
  18086. * @param children defines the list of aggregated animations to run
  18087. * @param condition defines the trigger related conditions
  18088. */
  18089. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  18090. /** @hidden */
  18091. _prepare(): void;
  18092. /**
  18093. * Execute the action and executes all the aggregated actions.
  18094. */
  18095. execute(evt: ActionEvent): void;
  18096. /**
  18097. * Serializes the actions and its related information.
  18098. * @param parent defines the object to serialize in
  18099. * @returns the serialized object
  18100. */
  18101. serialize(parent: any): any;
  18102. }
  18103. /**
  18104. * This defines an action responsible to run code (external event) once triggered.
  18105. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18106. */
  18107. export class ExecuteCodeAction extends Action {
  18108. /**
  18109. * The callback function to run.
  18110. */
  18111. func: (evt: ActionEvent) => void;
  18112. /**
  18113. * Instantiate the action
  18114. * @param triggerOptions defines the trigger options
  18115. * @param func defines the callback function to run
  18116. * @param condition defines the trigger related conditions
  18117. */
  18118. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  18119. /**
  18120. * Execute the action and run the attached code.
  18121. */
  18122. execute(evt: ActionEvent): void;
  18123. }
  18124. /**
  18125. * This defines an action responsible to set the parent property of the target once triggered.
  18126. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18127. */
  18128. export class SetParentAction extends Action {
  18129. private _parent;
  18130. private _target;
  18131. /**
  18132. * Instantiate the action
  18133. * @param triggerOptions defines the trigger options
  18134. * @param target defines the target containing the parent property
  18135. * @param parent defines from where the animation should start (animation frame)
  18136. * @param condition defines the trigger related conditions
  18137. */
  18138. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  18139. /** @hidden */
  18140. _prepare(): void;
  18141. /**
  18142. * Execute the action and set the parent property.
  18143. */
  18144. execute(): void;
  18145. /**
  18146. * Serializes the actions and its related information.
  18147. * @param parent defines the object to serialize in
  18148. * @returns the serialized object
  18149. */
  18150. serialize(parent: any): any;
  18151. }
  18152. }
  18153. declare module "babylonjs/Actions/actionManager" {
  18154. import { Nullable } from "babylonjs/types";
  18155. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18156. import { Scene } from "babylonjs/scene";
  18157. import { IAction } from "babylonjs/Actions/action";
  18158. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  18159. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  18160. /**
  18161. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  18162. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  18163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  18164. */
  18165. export class ActionManager extends AbstractActionManager {
  18166. /**
  18167. * Nothing
  18168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18169. */
  18170. static readonly NothingTrigger: number;
  18171. /**
  18172. * On pick
  18173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18174. */
  18175. static readonly OnPickTrigger: number;
  18176. /**
  18177. * On left pick
  18178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18179. */
  18180. static readonly OnLeftPickTrigger: number;
  18181. /**
  18182. * On right pick
  18183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18184. */
  18185. static readonly OnRightPickTrigger: number;
  18186. /**
  18187. * On center pick
  18188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18189. */
  18190. static readonly OnCenterPickTrigger: number;
  18191. /**
  18192. * On pick down
  18193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18194. */
  18195. static readonly OnPickDownTrigger: number;
  18196. /**
  18197. * On double pick
  18198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18199. */
  18200. static readonly OnDoublePickTrigger: number;
  18201. /**
  18202. * On pick up
  18203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18204. */
  18205. static readonly OnPickUpTrigger: number;
  18206. /**
  18207. * On pick out.
  18208. * This trigger will only be raised if you also declared a OnPickDown
  18209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18210. */
  18211. static readonly OnPickOutTrigger: number;
  18212. /**
  18213. * On long press
  18214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18215. */
  18216. static readonly OnLongPressTrigger: number;
  18217. /**
  18218. * On pointer over
  18219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18220. */
  18221. static readonly OnPointerOverTrigger: number;
  18222. /**
  18223. * On pointer out
  18224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18225. */
  18226. static readonly OnPointerOutTrigger: number;
  18227. /**
  18228. * On every frame
  18229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18230. */
  18231. static readonly OnEveryFrameTrigger: number;
  18232. /**
  18233. * On intersection enter
  18234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18235. */
  18236. static readonly OnIntersectionEnterTrigger: number;
  18237. /**
  18238. * On intersection exit
  18239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18240. */
  18241. static readonly OnIntersectionExitTrigger: number;
  18242. /**
  18243. * On key down
  18244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18245. */
  18246. static readonly OnKeyDownTrigger: number;
  18247. /**
  18248. * On key up
  18249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  18250. */
  18251. static readonly OnKeyUpTrigger: number;
  18252. private _scene;
  18253. /**
  18254. * Creates a new action manager
  18255. * @param scene defines the hosting scene
  18256. */
  18257. constructor(scene: Scene);
  18258. /**
  18259. * Releases all associated resources
  18260. */
  18261. dispose(): void;
  18262. /**
  18263. * Gets hosting scene
  18264. * @returns the hosting scene
  18265. */
  18266. getScene(): Scene;
  18267. /**
  18268. * Does this action manager handles actions of any of the given triggers
  18269. * @param triggers defines the triggers to be tested
  18270. * @return a boolean indicating whether one (or more) of the triggers is handled
  18271. */
  18272. hasSpecificTriggers(triggers: number[]): boolean;
  18273. /**
  18274. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  18275. * speed.
  18276. * @param triggerA defines the trigger to be tested
  18277. * @param triggerB defines the trigger to be tested
  18278. * @return a boolean indicating whether one (or more) of the triggers is handled
  18279. */
  18280. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  18281. /**
  18282. * Does this action manager handles actions of a given trigger
  18283. * @param trigger defines the trigger to be tested
  18284. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  18285. * @return whether the trigger is handled
  18286. */
  18287. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  18288. /**
  18289. * Does this action manager has pointer triggers
  18290. */
  18291. get hasPointerTriggers(): boolean;
  18292. /**
  18293. * Does this action manager has pick triggers
  18294. */
  18295. get hasPickTriggers(): boolean;
  18296. /**
  18297. * Registers an action to this action manager
  18298. * @param action defines the action to be registered
  18299. * @return the action amended (prepared) after registration
  18300. */
  18301. registerAction(action: IAction): Nullable<IAction>;
  18302. /**
  18303. * Unregisters an action to this action manager
  18304. * @param action defines the action to be unregistered
  18305. * @return a boolean indicating whether the action has been unregistered
  18306. */
  18307. unregisterAction(action: IAction): Boolean;
  18308. /**
  18309. * Process a specific trigger
  18310. * @param trigger defines the trigger to process
  18311. * @param evt defines the event details to be processed
  18312. */
  18313. processTrigger(trigger: number, evt?: IActionEvent): void;
  18314. /** @hidden */
  18315. _getEffectiveTarget(target: any, propertyPath: string): any;
  18316. /** @hidden */
  18317. _getProperty(propertyPath: string): string;
  18318. /**
  18319. * Serialize this manager to a JSON object
  18320. * @param name defines the property name to store this manager
  18321. * @returns a JSON representation of this manager
  18322. */
  18323. serialize(name: string): any;
  18324. /**
  18325. * Creates a new ActionManager from a JSON data
  18326. * @param parsedActions defines the JSON data to read from
  18327. * @param object defines the hosting mesh
  18328. * @param scene defines the hosting scene
  18329. */
  18330. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  18331. /**
  18332. * Get a trigger name by index
  18333. * @param trigger defines the trigger index
  18334. * @returns a trigger name
  18335. */
  18336. static GetTriggerName(trigger: number): string;
  18337. }
  18338. }
  18339. declare module "babylonjs/Sprites/sprite" {
  18340. import { Vector3 } from "babylonjs/Maths/math.vector";
  18341. import { Nullable } from "babylonjs/types";
  18342. import { ActionManager } from "babylonjs/Actions/actionManager";
  18343. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  18344. import { Color4 } from "babylonjs/Maths/math.color";
  18345. /**
  18346. * Class used to represent a sprite
  18347. * @see http://doc.babylonjs.com/babylon101/sprites
  18348. */
  18349. export class Sprite {
  18350. /** defines the name */
  18351. name: string;
  18352. /** Gets or sets the current world position */
  18353. position: Vector3;
  18354. /** Gets or sets the main color */
  18355. color: Color4;
  18356. /** Gets or sets the width */
  18357. width: number;
  18358. /** Gets or sets the height */
  18359. height: number;
  18360. /** Gets or sets rotation angle */
  18361. angle: number;
  18362. /** Gets or sets the cell index in the sprite sheet */
  18363. cellIndex: number;
  18364. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  18365. cellRef: string;
  18366. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  18367. invertU: number;
  18368. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  18369. invertV: number;
  18370. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  18371. disposeWhenFinishedAnimating: boolean;
  18372. /** Gets the list of attached animations */
  18373. animations: Animation[];
  18374. /** Gets or sets a boolean indicating if the sprite can be picked */
  18375. isPickable: boolean;
  18376. /**
  18377. * Gets or sets the associated action manager
  18378. */
  18379. actionManager: Nullable<ActionManager>;
  18380. private _animationStarted;
  18381. private _loopAnimation;
  18382. private _fromIndex;
  18383. private _toIndex;
  18384. private _delay;
  18385. private _direction;
  18386. private _manager;
  18387. private _time;
  18388. private _onAnimationEnd;
  18389. /**
  18390. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  18391. */
  18392. isVisible: boolean;
  18393. /**
  18394. * Gets or sets the sprite size
  18395. */
  18396. get size(): number;
  18397. set size(value: number);
  18398. /**
  18399. * Creates a new Sprite
  18400. * @param name defines the name
  18401. * @param manager defines the manager
  18402. */
  18403. constructor(
  18404. /** defines the name */
  18405. name: string, manager: ISpriteManager);
  18406. /**
  18407. * Starts an animation
  18408. * @param from defines the initial key
  18409. * @param to defines the end key
  18410. * @param loop defines if the animation must loop
  18411. * @param delay defines the start delay (in ms)
  18412. * @param onAnimationEnd defines a callback to call when animation ends
  18413. */
  18414. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  18415. /** Stops current animation (if any) */
  18416. stopAnimation(): void;
  18417. /** @hidden */
  18418. _animate(deltaTime: number): void;
  18419. /** Release associated resources */
  18420. dispose(): void;
  18421. }
  18422. }
  18423. declare module "babylonjs/Collisions/pickingInfo" {
  18424. import { Nullable } from "babylonjs/types";
  18425. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  18426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18427. import { Sprite } from "babylonjs/Sprites/sprite";
  18428. import { Ray } from "babylonjs/Culling/ray";
  18429. /**
  18430. * Information about the result of picking within a scene
  18431. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  18432. */
  18433. export class PickingInfo {
  18434. /** @hidden */
  18435. _pickingUnavailable: boolean;
  18436. /**
  18437. * If the pick collided with an object
  18438. */
  18439. hit: boolean;
  18440. /**
  18441. * Distance away where the pick collided
  18442. */
  18443. distance: number;
  18444. /**
  18445. * The location of pick collision
  18446. */
  18447. pickedPoint: Nullable<Vector3>;
  18448. /**
  18449. * The mesh corresponding the the pick collision
  18450. */
  18451. pickedMesh: Nullable<AbstractMesh>;
  18452. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  18453. bu: number;
  18454. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  18455. bv: number;
  18456. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  18457. faceId: number;
  18458. /** Id of the the submesh that was picked */
  18459. subMeshId: number;
  18460. /** If a sprite was picked, this will be the sprite the pick collided with */
  18461. pickedSprite: Nullable<Sprite>;
  18462. /**
  18463. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  18464. */
  18465. originMesh: Nullable<AbstractMesh>;
  18466. /**
  18467. * The ray that was used to perform the picking.
  18468. */
  18469. ray: Nullable<Ray>;
  18470. /**
  18471. * Gets the normal correspodning to the face the pick collided with
  18472. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  18473. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  18474. * @returns The normal correspodning to the face the pick collided with
  18475. */
  18476. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  18477. /**
  18478. * Gets the texture coordinates of where the pick occured
  18479. * @returns the vector containing the coordnates of the texture
  18480. */
  18481. getTextureCoordinates(): Nullable<Vector2>;
  18482. }
  18483. }
  18484. declare module "babylonjs/Events/pointerEvents" {
  18485. import { Nullable } from "babylonjs/types";
  18486. import { Vector2 } from "babylonjs/Maths/math.vector";
  18487. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  18488. import { Ray } from "babylonjs/Culling/ray";
  18489. /**
  18490. * Gather the list of pointer event types as constants.
  18491. */
  18492. export class PointerEventTypes {
  18493. /**
  18494. * The pointerdown event is fired when a pointer becomes active. For mouse, it is fired when the device transitions from no buttons depressed to at least one button depressed. For touch, it is fired when physical contact is made with the digitizer. For pen, it is fired when the stylus makes physical contact with the digitizer.
  18495. */
  18496. static readonly POINTERDOWN: number;
  18497. /**
  18498. * The pointerup event is fired when a pointer is no longer active.
  18499. */
  18500. static readonly POINTERUP: number;
  18501. /**
  18502. * The pointermove event is fired when a pointer changes coordinates.
  18503. */
  18504. static readonly POINTERMOVE: number;
  18505. /**
  18506. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18507. */
  18508. static readonly POINTERWHEEL: number;
  18509. /**
  18510. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18511. */
  18512. static readonly POINTERPICK: number;
  18513. /**
  18514. * The pointertap event is fired when a the object has been touched and released without drag.
  18515. */
  18516. static readonly POINTERTAP: number;
  18517. /**
  18518. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18519. */
  18520. static readonly POINTERDOUBLETAP: number;
  18521. }
  18522. /**
  18523. * Base class of pointer info types.
  18524. */
  18525. export class PointerInfoBase {
  18526. /**
  18527. * Defines the type of event (PointerEventTypes)
  18528. */
  18529. type: number;
  18530. /**
  18531. * Defines the related dom event
  18532. */
  18533. event: PointerEvent | MouseWheelEvent;
  18534. /**
  18535. * Instantiates the base class of pointers info.
  18536. * @param type Defines the type of event (PointerEventTypes)
  18537. * @param event Defines the related dom event
  18538. */
  18539. constructor(
  18540. /**
  18541. * Defines the type of event (PointerEventTypes)
  18542. */
  18543. type: number,
  18544. /**
  18545. * Defines the related dom event
  18546. */
  18547. event: PointerEvent | MouseWheelEvent);
  18548. }
  18549. /**
  18550. * This class is used to store pointer related info for the onPrePointerObservable event.
  18551. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18552. */
  18553. export class PointerInfoPre extends PointerInfoBase {
  18554. /**
  18555. * Ray from a pointer if availible (eg. 6dof controller)
  18556. */
  18557. ray: Nullable<Ray>;
  18558. /**
  18559. * Defines the local position of the pointer on the canvas.
  18560. */
  18561. localPosition: Vector2;
  18562. /**
  18563. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18564. */
  18565. skipOnPointerObservable: boolean;
  18566. /**
  18567. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18568. * @param type Defines the type of event (PointerEventTypes)
  18569. * @param event Defines the related dom event
  18570. * @param localX Defines the local x coordinates of the pointer when the event occured
  18571. * @param localY Defines the local y coordinates of the pointer when the event occured
  18572. */
  18573. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18574. }
  18575. /**
  18576. * This type contains all the data related to a pointer event in Babylon.js.
  18577. * The event member is an instance of PointerEvent for all types except PointerWheel and is of type MouseWheelEvent when type equals PointerWheel. The different event types can be found in the PointerEventTypes class.
  18578. */
  18579. export class PointerInfo extends PointerInfoBase {
  18580. /**
  18581. * Defines the picking info associated to the info (if any)\
  18582. */
  18583. pickInfo: Nullable<PickingInfo>;
  18584. /**
  18585. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18586. * @param type Defines the type of event (PointerEventTypes)
  18587. * @param event Defines the related dom event
  18588. * @param pickInfo Defines the picking info associated to the info (if any)\
  18589. */
  18590. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18591. /**
  18592. * Defines the picking info associated to the info (if any)\
  18593. */
  18594. pickInfo: Nullable<PickingInfo>);
  18595. }
  18596. /**
  18597. * Data relating to a touch event on the screen.
  18598. */
  18599. export interface PointerTouch {
  18600. /**
  18601. * X coordinate of touch.
  18602. */
  18603. x: number;
  18604. /**
  18605. * Y coordinate of touch.
  18606. */
  18607. y: number;
  18608. /**
  18609. * Id of touch. Unique for each finger.
  18610. */
  18611. pointerId: number;
  18612. /**
  18613. * Event type passed from DOM.
  18614. */
  18615. type: any;
  18616. }
  18617. }
  18618. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  18619. import { Observable } from "babylonjs/Misc/observable";
  18620. import { Nullable } from "babylonjs/types";
  18621. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18622. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18623. /**
  18624. * Manage the mouse inputs to control the movement of a free camera.
  18625. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18626. */
  18627. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18628. /**
  18629. * Define if touch is enabled in the mouse input
  18630. */
  18631. touchEnabled: boolean;
  18632. /**
  18633. * Defines the camera the input is attached to.
  18634. */
  18635. camera: FreeCamera;
  18636. /**
  18637. * Defines the buttons associated with the input to handle camera move.
  18638. */
  18639. buttons: number[];
  18640. /**
  18641. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18642. */
  18643. angularSensibility: number;
  18644. private _pointerInput;
  18645. private _onMouseMove;
  18646. private _observer;
  18647. private previousPosition;
  18648. /**
  18649. * Observable for when a pointer move event occurs containing the move offset
  18650. */
  18651. onPointerMovedObservable: Observable<{
  18652. offsetX: number;
  18653. offsetY: number;
  18654. }>;
  18655. /**
  18656. * @hidden
  18657. * If the camera should be rotated automatically based on pointer movement
  18658. */
  18659. _allowCameraRotation: boolean;
  18660. /**
  18661. * Manage the mouse inputs to control the movement of a free camera.
  18662. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18663. * @param touchEnabled Defines if touch is enabled or not
  18664. */
  18665. constructor(
  18666. /**
  18667. * Define if touch is enabled in the mouse input
  18668. */
  18669. touchEnabled?: boolean);
  18670. /**
  18671. * Attach the input controls to a specific dom element to get the input from.
  18672. * @param element Defines the element the controls should be listened from
  18673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18674. */
  18675. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18676. /**
  18677. * Called on JS contextmenu event.
  18678. * Override this method to provide functionality.
  18679. */
  18680. protected onContextMenu(evt: PointerEvent): void;
  18681. /**
  18682. * Detach the current controls from the specified dom element.
  18683. * @param element Defines the element to stop listening the inputs from
  18684. */
  18685. detachControl(element: Nullable<HTMLElement>): void;
  18686. /**
  18687. * Gets the class name of the current intput.
  18688. * @returns the class name
  18689. */
  18690. getClassName(): string;
  18691. /**
  18692. * Get the friendly name associated with the input class.
  18693. * @returns the input friendly name
  18694. */
  18695. getSimpleName(): string;
  18696. }
  18697. }
  18698. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  18699. import { Nullable } from "babylonjs/types";
  18700. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  18701. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18702. /**
  18703. * Manage the touch inputs to control the movement of a free camera.
  18704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18705. */
  18706. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  18707. /**
  18708. * Defines the camera the input is attached to.
  18709. */
  18710. camera: FreeCamera;
  18711. /**
  18712. * Defines the touch sensibility for rotation.
  18713. * The higher the faster.
  18714. */
  18715. touchAngularSensibility: number;
  18716. /**
  18717. * Defines the touch sensibility for move.
  18718. * The higher the faster.
  18719. */
  18720. touchMoveSensibility: number;
  18721. private _offsetX;
  18722. private _offsetY;
  18723. private _pointerPressed;
  18724. private _pointerInput;
  18725. private _observer;
  18726. private _onLostFocus;
  18727. /**
  18728. * Attach the input controls to a specific dom element to get the input from.
  18729. * @param element Defines the element the controls should be listened from
  18730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18731. */
  18732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18733. /**
  18734. * Detach the current controls from the specified dom element.
  18735. * @param element Defines the element to stop listening the inputs from
  18736. */
  18737. detachControl(element: Nullable<HTMLElement>): void;
  18738. /**
  18739. * Update the current camera state depending on the inputs that have been used this frame.
  18740. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18741. */
  18742. checkInputs(): void;
  18743. /**
  18744. * Gets the class name of the current intput.
  18745. * @returns the class name
  18746. */
  18747. getClassName(): string;
  18748. /**
  18749. * Get the friendly name associated with the input class.
  18750. * @returns the input friendly name
  18751. */
  18752. getSimpleName(): string;
  18753. }
  18754. }
  18755. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  18756. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  18757. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  18758. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  18759. import { Nullable } from "babylonjs/types";
  18760. /**
  18761. * Default Inputs manager for the FreeCamera.
  18762. * It groups all the default supported inputs for ease of use.
  18763. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  18764. */
  18765. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  18766. /**
  18767. * @hidden
  18768. */
  18769. _mouseInput: Nullable<FreeCameraMouseInput>;
  18770. /**
  18771. * Instantiates a new FreeCameraInputsManager.
  18772. * @param camera Defines the camera the inputs belong to
  18773. */
  18774. constructor(camera: FreeCamera);
  18775. /**
  18776. * Add keyboard input support to the input manager.
  18777. * @returns the current input manager
  18778. */
  18779. addKeyboard(): FreeCameraInputsManager;
  18780. /**
  18781. * Add mouse input support to the input manager.
  18782. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  18783. * @returns the current input manager
  18784. */
  18785. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  18786. /**
  18787. * Removes the mouse input support from the manager
  18788. * @returns the current input manager
  18789. */
  18790. removeMouse(): FreeCameraInputsManager;
  18791. /**
  18792. * Add touch input support to the input manager.
  18793. * @returns the current input manager
  18794. */
  18795. addTouch(): FreeCameraInputsManager;
  18796. /**
  18797. * Remove all attached input methods from a camera
  18798. */
  18799. clear(): void;
  18800. }
  18801. }
  18802. declare module "babylonjs/Cameras/freeCamera" {
  18803. import { Vector3 } from "babylonjs/Maths/math.vector";
  18804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18805. import { Scene } from "babylonjs/scene";
  18806. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  18807. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  18808. /**
  18809. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18810. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  18811. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18812. */
  18813. export class FreeCamera extends TargetCamera {
  18814. /**
  18815. * Define the collision ellipsoid of the camera.
  18816. * This is helpful to simulate a camera body like the player body around the camera
  18817. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18818. */
  18819. ellipsoid: Vector3;
  18820. /**
  18821. * Define an offset for the position of the ellipsoid around the camera.
  18822. * This can be helpful to determine the center of the body near the gravity center of the body
  18823. * instead of its head.
  18824. */
  18825. ellipsoidOffset: Vector3;
  18826. /**
  18827. * Enable or disable collisions of the camera with the rest of the scene objects.
  18828. */
  18829. checkCollisions: boolean;
  18830. /**
  18831. * Enable or disable gravity on the camera.
  18832. */
  18833. applyGravity: boolean;
  18834. /**
  18835. * Define the input manager associated to the camera.
  18836. */
  18837. inputs: FreeCameraInputsManager;
  18838. /**
  18839. * Gets the input sensibility for a mouse input. (default is 2000.0)
  18840. * Higher values reduce sensitivity.
  18841. */
  18842. get angularSensibility(): number;
  18843. /**
  18844. * Sets the input sensibility for a mouse input. (default is 2000.0)
  18845. * Higher values reduce sensitivity.
  18846. */
  18847. set angularSensibility(value: number);
  18848. /**
  18849. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18850. */
  18851. get keysUp(): number[];
  18852. set keysUp(value: number[]);
  18853. /**
  18854. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18855. */
  18856. get keysDown(): number[];
  18857. set keysDown(value: number[]);
  18858. /**
  18859. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18860. */
  18861. get keysLeft(): number[];
  18862. set keysLeft(value: number[]);
  18863. /**
  18864. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18865. */
  18866. get keysRight(): number[];
  18867. set keysRight(value: number[]);
  18868. /**
  18869. * Event raised when the camera collide with a mesh in the scene.
  18870. */
  18871. onCollide: (collidedMesh: AbstractMesh) => void;
  18872. private _collider;
  18873. private _needMoveForGravity;
  18874. private _oldPosition;
  18875. private _diffPosition;
  18876. private _newPosition;
  18877. /** @hidden */
  18878. _localDirection: Vector3;
  18879. /** @hidden */
  18880. _transformedDirection: Vector3;
  18881. /**
  18882. * Instantiates a Free Camera.
  18883. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  18884. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  18885. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  18886. * @param name Define the name of the camera in the scene
  18887. * @param position Define the start position of the camera in the scene
  18888. * @param scene Define the scene the camera belongs to
  18889. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18890. */
  18891. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18892. /**
  18893. * Attached controls to the current camera.
  18894. * @param element Defines the element the controls should be listened from
  18895. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18896. */
  18897. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18898. /**
  18899. * Detach the current controls from the camera.
  18900. * The camera will stop reacting to inputs.
  18901. * @param element Defines the element to stop listening the inputs from
  18902. */
  18903. detachControl(element: HTMLElement): void;
  18904. private _collisionMask;
  18905. /**
  18906. * Define a collision mask to limit the list of object the camera can collide with
  18907. */
  18908. get collisionMask(): number;
  18909. set collisionMask(mask: number);
  18910. /** @hidden */
  18911. _collideWithWorld(displacement: Vector3): void;
  18912. private _onCollisionPositionChange;
  18913. /** @hidden */
  18914. _checkInputs(): void;
  18915. /** @hidden */
  18916. _decideIfNeedsToMove(): boolean;
  18917. /** @hidden */
  18918. _updatePosition(): void;
  18919. /**
  18920. * Destroy the camera and release the current resources hold by it.
  18921. */
  18922. dispose(): void;
  18923. /**
  18924. * Gets the current object class name.
  18925. * @return the class name
  18926. */
  18927. getClassName(): string;
  18928. }
  18929. }
  18930. declare module "babylonjs/Gamepads/gamepad" {
  18931. import { Observable } from "babylonjs/Misc/observable";
  18932. /**
  18933. * Represents a gamepad control stick position
  18934. */
  18935. export class StickValues {
  18936. /**
  18937. * The x component of the control stick
  18938. */
  18939. x: number;
  18940. /**
  18941. * The y component of the control stick
  18942. */
  18943. y: number;
  18944. /**
  18945. * Initializes the gamepad x and y control stick values
  18946. * @param x The x component of the gamepad control stick value
  18947. * @param y The y component of the gamepad control stick value
  18948. */
  18949. constructor(
  18950. /**
  18951. * The x component of the control stick
  18952. */
  18953. x: number,
  18954. /**
  18955. * The y component of the control stick
  18956. */
  18957. y: number);
  18958. }
  18959. /**
  18960. * An interface which manages callbacks for gamepad button changes
  18961. */
  18962. export interface GamepadButtonChanges {
  18963. /**
  18964. * Called when a gamepad has been changed
  18965. */
  18966. changed: boolean;
  18967. /**
  18968. * Called when a gamepad press event has been triggered
  18969. */
  18970. pressChanged: boolean;
  18971. /**
  18972. * Called when a touch event has been triggered
  18973. */
  18974. touchChanged: boolean;
  18975. /**
  18976. * Called when a value has changed
  18977. */
  18978. valueChanged: boolean;
  18979. }
  18980. /**
  18981. * Represents a gamepad
  18982. */
  18983. export class Gamepad {
  18984. /**
  18985. * The id of the gamepad
  18986. */
  18987. id: string;
  18988. /**
  18989. * The index of the gamepad
  18990. */
  18991. index: number;
  18992. /**
  18993. * The browser gamepad
  18994. */
  18995. browserGamepad: any;
  18996. /**
  18997. * Specifies what type of gamepad this represents
  18998. */
  18999. type: number;
  19000. private _leftStick;
  19001. private _rightStick;
  19002. /** @hidden */
  19003. _isConnected: boolean;
  19004. private _leftStickAxisX;
  19005. private _leftStickAxisY;
  19006. private _rightStickAxisX;
  19007. private _rightStickAxisY;
  19008. /**
  19009. * Triggered when the left control stick has been changed
  19010. */
  19011. private _onleftstickchanged;
  19012. /**
  19013. * Triggered when the right control stick has been changed
  19014. */
  19015. private _onrightstickchanged;
  19016. /**
  19017. * Represents a gamepad controller
  19018. */
  19019. static GAMEPAD: number;
  19020. /**
  19021. * Represents a generic controller
  19022. */
  19023. static GENERIC: number;
  19024. /**
  19025. * Represents an XBox controller
  19026. */
  19027. static XBOX: number;
  19028. /**
  19029. * Represents a pose-enabled controller
  19030. */
  19031. static POSE_ENABLED: number;
  19032. /**
  19033. * Represents an Dual Shock controller
  19034. */
  19035. static DUALSHOCK: number;
  19036. /**
  19037. * Specifies whether the left control stick should be Y-inverted
  19038. */
  19039. protected _invertLeftStickY: boolean;
  19040. /**
  19041. * Specifies if the gamepad has been connected
  19042. */
  19043. get isConnected(): boolean;
  19044. /**
  19045. * Initializes the gamepad
  19046. * @param id The id of the gamepad
  19047. * @param index The index of the gamepad
  19048. * @param browserGamepad The browser gamepad
  19049. * @param leftStickX The x component of the left joystick
  19050. * @param leftStickY The y component of the left joystick
  19051. * @param rightStickX The x component of the right joystick
  19052. * @param rightStickY The y component of the right joystick
  19053. */
  19054. constructor(
  19055. /**
  19056. * The id of the gamepad
  19057. */
  19058. id: string,
  19059. /**
  19060. * The index of the gamepad
  19061. */
  19062. index: number,
  19063. /**
  19064. * The browser gamepad
  19065. */
  19066. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19067. /**
  19068. * Callback triggered when the left joystick has changed
  19069. * @param callback
  19070. */
  19071. onleftstickchanged(callback: (values: StickValues) => void): void;
  19072. /**
  19073. * Callback triggered when the right joystick has changed
  19074. * @param callback
  19075. */
  19076. onrightstickchanged(callback: (values: StickValues) => void): void;
  19077. /**
  19078. * Gets the left joystick
  19079. */
  19080. get leftStick(): StickValues;
  19081. /**
  19082. * Sets the left joystick values
  19083. */
  19084. set leftStick(newValues: StickValues);
  19085. /**
  19086. * Gets the right joystick
  19087. */
  19088. get rightStick(): StickValues;
  19089. /**
  19090. * Sets the right joystick value
  19091. */
  19092. set rightStick(newValues: StickValues);
  19093. /**
  19094. * Updates the gamepad joystick positions
  19095. */
  19096. update(): void;
  19097. /**
  19098. * Disposes the gamepad
  19099. */
  19100. dispose(): void;
  19101. }
  19102. /**
  19103. * Represents a generic gamepad
  19104. */
  19105. export class GenericPad extends Gamepad {
  19106. private _buttons;
  19107. private _onbuttondown;
  19108. private _onbuttonup;
  19109. /**
  19110. * Observable triggered when a button has been pressed
  19111. */
  19112. onButtonDownObservable: Observable<number>;
  19113. /**
  19114. * Observable triggered when a button has been released
  19115. */
  19116. onButtonUpObservable: Observable<number>;
  19117. /**
  19118. * Callback triggered when a button has been pressed
  19119. * @param callback Called when a button has been pressed
  19120. */
  19121. onbuttondown(callback: (buttonPressed: number) => void): void;
  19122. /**
  19123. * Callback triggered when a button has been released
  19124. * @param callback Called when a button has been released
  19125. */
  19126. onbuttonup(callback: (buttonReleased: number) => void): void;
  19127. /**
  19128. * Initializes the generic gamepad
  19129. * @param id The id of the generic gamepad
  19130. * @param index The index of the generic gamepad
  19131. * @param browserGamepad The browser gamepad
  19132. */
  19133. constructor(id: string, index: number, browserGamepad: any);
  19134. private _setButtonValue;
  19135. /**
  19136. * Updates the generic gamepad
  19137. */
  19138. update(): void;
  19139. /**
  19140. * Disposes the generic gamepad
  19141. */
  19142. dispose(): void;
  19143. }
  19144. }
  19145. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  19146. import { Observable } from "babylonjs/Misc/observable";
  19147. import { Nullable } from "babylonjs/types";
  19148. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19149. import { TransformNode } from "babylonjs/Meshes/transformNode";
  19150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19151. import { Ray } from "babylonjs/Culling/ray";
  19152. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  19153. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  19154. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19155. /**
  19156. * Defines the types of pose enabled controllers that are supported
  19157. */
  19158. export enum PoseEnabledControllerType {
  19159. /**
  19160. * HTC Vive
  19161. */
  19162. VIVE = 0,
  19163. /**
  19164. * Oculus Rift
  19165. */
  19166. OCULUS = 1,
  19167. /**
  19168. * Windows mixed reality
  19169. */
  19170. WINDOWS = 2,
  19171. /**
  19172. * Samsung gear VR
  19173. */
  19174. GEAR_VR = 3,
  19175. /**
  19176. * Google Daydream
  19177. */
  19178. DAYDREAM = 4,
  19179. /**
  19180. * Generic
  19181. */
  19182. GENERIC = 5
  19183. }
  19184. /**
  19185. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19186. */
  19187. export interface MutableGamepadButton {
  19188. /**
  19189. * Value of the button/trigger
  19190. */
  19191. value: number;
  19192. /**
  19193. * If the button/trigger is currently touched
  19194. */
  19195. touched: boolean;
  19196. /**
  19197. * If the button/trigger is currently pressed
  19198. */
  19199. pressed: boolean;
  19200. }
  19201. /**
  19202. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19203. * @hidden
  19204. */
  19205. export interface ExtendedGamepadButton extends GamepadButton {
  19206. /**
  19207. * If the button/trigger is currently pressed
  19208. */
  19209. readonly pressed: boolean;
  19210. /**
  19211. * If the button/trigger is currently touched
  19212. */
  19213. readonly touched: boolean;
  19214. /**
  19215. * Value of the button/trigger
  19216. */
  19217. readonly value: number;
  19218. }
  19219. /** @hidden */
  19220. export interface _GamePadFactory {
  19221. /**
  19222. * Returns whether or not the current gamepad can be created for this type of controller.
  19223. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19224. * @returns true if it can be created, otherwise false
  19225. */
  19226. canCreate(gamepadInfo: any): boolean;
  19227. /**
  19228. * Creates a new instance of the Gamepad.
  19229. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19230. * @returns the new gamepad instance
  19231. */
  19232. create(gamepadInfo: any): Gamepad;
  19233. }
  19234. /**
  19235. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19236. */
  19237. export class PoseEnabledControllerHelper {
  19238. /** @hidden */
  19239. static _ControllerFactories: _GamePadFactory[];
  19240. /** @hidden */
  19241. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19242. /**
  19243. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19244. * @param vrGamepad the gamepad to initialized
  19245. * @returns a vr controller of the type the gamepad identified as
  19246. */
  19247. static InitiateController(vrGamepad: any): Gamepad;
  19248. }
  19249. /**
  19250. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19251. */
  19252. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19253. /**
  19254. * If the controller is used in a webXR session
  19255. */
  19256. isXR: boolean;
  19257. private _deviceRoomPosition;
  19258. private _deviceRoomRotationQuaternion;
  19259. /**
  19260. * The device position in babylon space
  19261. */
  19262. devicePosition: Vector3;
  19263. /**
  19264. * The device rotation in babylon space
  19265. */
  19266. deviceRotationQuaternion: Quaternion;
  19267. /**
  19268. * The scale factor of the device in babylon space
  19269. */
  19270. deviceScaleFactor: number;
  19271. /**
  19272. * (Likely devicePosition should be used instead) The device position in its room space
  19273. */
  19274. position: Vector3;
  19275. /**
  19276. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19277. */
  19278. rotationQuaternion: Quaternion;
  19279. /**
  19280. * The type of controller (Eg. Windows mixed reality)
  19281. */
  19282. controllerType: PoseEnabledControllerType;
  19283. protected _calculatedPosition: Vector3;
  19284. private _calculatedRotation;
  19285. /**
  19286. * The raw pose from the device
  19287. */
  19288. rawPose: DevicePose;
  19289. private _trackPosition;
  19290. private _maxRotationDistFromHeadset;
  19291. private _draggedRoomRotation;
  19292. /**
  19293. * @hidden
  19294. */
  19295. _disableTrackPosition(fixedPosition: Vector3): void;
  19296. /**
  19297. * Internal, the mesh attached to the controller
  19298. * @hidden
  19299. */
  19300. _mesh: Nullable<AbstractMesh>;
  19301. private _poseControlledCamera;
  19302. private _leftHandSystemQuaternion;
  19303. /**
  19304. * Internal, matrix used to convert room space to babylon space
  19305. * @hidden
  19306. */
  19307. _deviceToWorld: Matrix;
  19308. /**
  19309. * Node to be used when casting a ray from the controller
  19310. * @hidden
  19311. */
  19312. _pointingPoseNode: Nullable<TransformNode>;
  19313. /**
  19314. * Name of the child mesh that can be used to cast a ray from the controller
  19315. */
  19316. static readonly POINTING_POSE: string;
  19317. /**
  19318. * Creates a new PoseEnabledController from a gamepad
  19319. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19320. */
  19321. constructor(browserGamepad: any);
  19322. private _workingMatrix;
  19323. /**
  19324. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19325. */
  19326. update(): void;
  19327. /**
  19328. * Updates only the pose device and mesh without doing any button event checking
  19329. */
  19330. protected _updatePoseAndMesh(): void;
  19331. /**
  19332. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19333. * @param poseData raw pose fromthe device
  19334. */
  19335. updateFromDevice(poseData: DevicePose): void;
  19336. /**
  19337. * @hidden
  19338. */
  19339. _meshAttachedObservable: Observable<AbstractMesh>;
  19340. /**
  19341. * Attaches a mesh to the controller
  19342. * @param mesh the mesh to be attached
  19343. */
  19344. attachToMesh(mesh: AbstractMesh): void;
  19345. /**
  19346. * Attaches the controllers mesh to a camera
  19347. * @param camera the camera the mesh should be attached to
  19348. */
  19349. attachToPoseControlledCamera(camera: TargetCamera): void;
  19350. /**
  19351. * Disposes of the controller
  19352. */
  19353. dispose(): void;
  19354. /**
  19355. * The mesh that is attached to the controller
  19356. */
  19357. get mesh(): Nullable<AbstractMesh>;
  19358. /**
  19359. * Gets the ray of the controller in the direction the controller is pointing
  19360. * @param length the length the resulting ray should be
  19361. * @returns a ray in the direction the controller is pointing
  19362. */
  19363. getForwardRay(length?: number): Ray;
  19364. }
  19365. }
  19366. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  19367. import { Observable } from "babylonjs/Misc/observable";
  19368. import { Scene } from "babylonjs/scene";
  19369. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19370. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  19371. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  19372. import { Nullable } from "babylonjs/types";
  19373. /**
  19374. * Defines the WebVRController object that represents controllers tracked in 3D space
  19375. */
  19376. export abstract class WebVRController extends PoseEnabledController {
  19377. /**
  19378. * Internal, the default controller model for the controller
  19379. */
  19380. protected _defaultModel: Nullable<AbstractMesh>;
  19381. /**
  19382. * Fired when the trigger state has changed
  19383. */
  19384. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19385. /**
  19386. * Fired when the main button state has changed
  19387. */
  19388. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19389. /**
  19390. * Fired when the secondary button state has changed
  19391. */
  19392. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19393. /**
  19394. * Fired when the pad state has changed
  19395. */
  19396. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19397. /**
  19398. * Fired when controllers stick values have changed
  19399. */
  19400. onPadValuesChangedObservable: Observable<StickValues>;
  19401. /**
  19402. * Array of button availible on the controller
  19403. */
  19404. protected _buttons: Array<MutableGamepadButton>;
  19405. private _onButtonStateChange;
  19406. /**
  19407. * Fired when a controller button's state has changed
  19408. * @param callback the callback containing the button that was modified
  19409. */
  19410. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19411. /**
  19412. * X and Y axis corresponding to the controllers joystick
  19413. */
  19414. pad: StickValues;
  19415. /**
  19416. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19417. */
  19418. hand: string;
  19419. /**
  19420. * The default controller model for the controller
  19421. */
  19422. get defaultModel(): Nullable<AbstractMesh>;
  19423. /**
  19424. * Creates a new WebVRController from a gamepad
  19425. * @param vrGamepad the gamepad that the WebVRController should be created from
  19426. */
  19427. constructor(vrGamepad: any);
  19428. /**
  19429. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19430. */
  19431. update(): void;
  19432. /**
  19433. * Function to be called when a button is modified
  19434. */
  19435. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19436. /**
  19437. * Loads a mesh and attaches it to the controller
  19438. * @param scene the scene the mesh should be added to
  19439. * @param meshLoaded callback for when the mesh has been loaded
  19440. */
  19441. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19442. private _setButtonValue;
  19443. private _changes;
  19444. private _checkChanges;
  19445. /**
  19446. * Disposes of th webVRCOntroller
  19447. */
  19448. dispose(): void;
  19449. }
  19450. }
  19451. declare module "babylonjs/Lights/hemisphericLight" {
  19452. import { Nullable } from "babylonjs/types";
  19453. import { Scene } from "babylonjs/scene";
  19454. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19455. import { Color3 } from "babylonjs/Maths/math.color";
  19456. import { Effect } from "babylonjs/Materials/effect";
  19457. import { Light } from "babylonjs/Lights/light";
  19458. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  19459. /**
  19460. * The HemisphericLight simulates the ambient environment light,
  19461. * so the passed direction is the light reflection direction, not the incoming direction.
  19462. */
  19463. export class HemisphericLight extends Light {
  19464. /**
  19465. * The groundColor is the light in the opposite direction to the one specified during creation.
  19466. * You can think of the diffuse and specular light as coming from the centre of the object in the given direction and the groundColor light in the opposite direction.
  19467. */
  19468. groundColor: Color3;
  19469. /**
  19470. * The light reflection direction, not the incoming direction.
  19471. */
  19472. direction: Vector3;
  19473. /**
  19474. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19475. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19476. * The HemisphericLight can't cast shadows.
  19477. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19478. * @param name The friendly name of the light
  19479. * @param direction The direction of the light reflection
  19480. * @param scene The scene the light belongs to
  19481. */
  19482. constructor(name: string, direction: Vector3, scene: Scene);
  19483. protected _buildUniformLayout(): void;
  19484. /**
  19485. * Returns the string "HemisphericLight".
  19486. * @return The class name
  19487. */
  19488. getClassName(): string;
  19489. /**
  19490. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19491. * Returns the updated direction.
  19492. * @param target The target the direction should point to
  19493. * @return The computed direction
  19494. */
  19495. setDirectionToTarget(target: Vector3): Vector3;
  19496. /**
  19497. * Returns the shadow generator associated to the light.
  19498. * @returns Always null for hemispheric lights because it does not support shadows.
  19499. */
  19500. getShadowGenerator(): Nullable<IShadowGenerator>;
  19501. /**
  19502. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19503. * @param effect The effect to update
  19504. * @param lightIndex The index of the light in the effect to update
  19505. * @returns The hemispheric light
  19506. */
  19507. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19508. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19509. /**
  19510. * Computes the world matrix of the node
  19511. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19512. * @param useWasUpdatedFlag defines a reserved property
  19513. * @returns the world matrix
  19514. */
  19515. computeWorldMatrix(): Matrix;
  19516. /**
  19517. * Returns the integer 3.
  19518. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19519. */
  19520. getTypeID(): number;
  19521. /**
  19522. * Prepares the list of defines specific to the light type.
  19523. * @param defines the list of defines
  19524. * @param lightIndex defines the index of the light for the effect
  19525. */
  19526. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19527. }
  19528. }
  19529. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  19530. /** @hidden */
  19531. export var vrMultiviewToSingleviewPixelShader: {
  19532. name: string;
  19533. shader: string;
  19534. };
  19535. }
  19536. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  19537. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19538. import { Scene } from "babylonjs/scene";
  19539. /**
  19540. * Renders to multiple views with a single draw call
  19541. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19542. */
  19543. export class MultiviewRenderTarget extends RenderTargetTexture {
  19544. /**
  19545. * Creates a multiview render target
  19546. * @param scene scene used with the render target
  19547. * @param size the size of the render target (used for each view)
  19548. */
  19549. constructor(scene: Scene, size?: number | {
  19550. width: number;
  19551. height: number;
  19552. } | {
  19553. ratio: number;
  19554. });
  19555. /**
  19556. * @hidden
  19557. * @param faceIndex the face index, if its a cube texture
  19558. */
  19559. _bindFrameBuffer(faceIndex?: number): void;
  19560. /**
  19561. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19562. * @returns the view count
  19563. */
  19564. getViewCount(): number;
  19565. }
  19566. }
  19567. declare module "babylonjs/Maths/math.frustum" {
  19568. import { Matrix } from "babylonjs/Maths/math.vector";
  19569. import { DeepImmutable } from "babylonjs/types";
  19570. import { Plane } from "babylonjs/Maths/math.plane";
  19571. /**
  19572. * Represents a camera frustum
  19573. */
  19574. export class Frustum {
  19575. /**
  19576. * Gets the planes representing the frustum
  19577. * @param transform matrix to be applied to the returned planes
  19578. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  19579. */
  19580. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  19581. /**
  19582. * Gets the near frustum plane transformed by the transform matrix
  19583. * @param transform transformation matrix to be applied to the resulting frustum plane
  19584. * @param frustumPlane the resuling frustum plane
  19585. */
  19586. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19587. /**
  19588. * Gets the far frustum plane transformed by the transform matrix
  19589. * @param transform transformation matrix to be applied to the resulting frustum plane
  19590. * @param frustumPlane the resuling frustum plane
  19591. */
  19592. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19593. /**
  19594. * Gets the left frustum plane transformed by the transform matrix
  19595. * @param transform transformation matrix to be applied to the resulting frustum plane
  19596. * @param frustumPlane the resuling frustum plane
  19597. */
  19598. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19599. /**
  19600. * Gets the right frustum plane transformed by the transform matrix
  19601. * @param transform transformation matrix to be applied to the resulting frustum plane
  19602. * @param frustumPlane the resuling frustum plane
  19603. */
  19604. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19605. /**
  19606. * Gets the top frustum plane transformed by the transform matrix
  19607. * @param transform transformation matrix to be applied to the resulting frustum plane
  19608. * @param frustumPlane the resuling frustum plane
  19609. */
  19610. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19611. /**
  19612. * Gets the bottom frustum plane transformed by the transform matrix
  19613. * @param transform transformation matrix to be applied to the resulting frustum plane
  19614. * @param frustumPlane the resuling frustum plane
  19615. */
  19616. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  19617. /**
  19618. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  19619. * @param transform transformation matrix to be applied to the resulting frustum planes
  19620. * @param frustumPlanes the resuling frustum planes
  19621. */
  19622. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  19623. }
  19624. }
  19625. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  19626. import { Camera } from "babylonjs/Cameras/camera";
  19627. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  19628. import { Nullable } from "babylonjs/types";
  19629. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  19630. import { Matrix } from "babylonjs/Maths/math.vector";
  19631. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  19632. module "babylonjs/Engines/engine" {
  19633. interface Engine {
  19634. /**
  19635. * Creates a new multiview render target
  19636. * @param width defines the width of the texture
  19637. * @param height defines the height of the texture
  19638. * @returns the created multiview texture
  19639. */
  19640. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19641. /**
  19642. * Binds a multiview framebuffer to be drawn to
  19643. * @param multiviewTexture texture to bind
  19644. */
  19645. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19646. }
  19647. }
  19648. module "babylonjs/Cameras/camera" {
  19649. interface Camera {
  19650. /**
  19651. * @hidden
  19652. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  19653. */
  19654. _useMultiviewToSingleView: boolean;
  19655. /**
  19656. * @hidden
  19657. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  19658. */
  19659. _multiviewTexture: Nullable<RenderTargetTexture>;
  19660. /**
  19661. * @hidden
  19662. * ensures the multiview texture of the camera exists and has the specified width/height
  19663. * @param width height to set on the multiview texture
  19664. * @param height width to set on the multiview texture
  19665. */
  19666. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19667. }
  19668. }
  19669. module "babylonjs/scene" {
  19670. interface Scene {
  19671. /** @hidden */
  19672. _transformMatrixR: Matrix;
  19673. /** @hidden */
  19674. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19675. /** @hidden */
  19676. _createMultiviewUbo(): void;
  19677. /** @hidden */
  19678. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19679. /** @hidden */
  19680. _renderMultiviewToSingleView(camera: Camera): void;
  19681. }
  19682. }
  19683. }
  19684. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  19685. import { Camera } from "babylonjs/Cameras/camera";
  19686. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  19687. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  19688. import "babylonjs/Engines/Extensions/engine.multiview";
  19689. /**
  19690. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19691. * This will not be used for webXR as it supports displaying texture arrays directly
  19692. */
  19693. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19694. /**
  19695. * Initializes a VRMultiviewToSingleview
  19696. * @param name name of the post process
  19697. * @param camera camera to be applied to
  19698. * @param scaleFactor scaling factor to the size of the output texture
  19699. */
  19700. constructor(name: string, camera: Camera, scaleFactor: number);
  19701. }
  19702. }
  19703. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  19704. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  19705. import { Nullable } from "babylonjs/types";
  19706. import { Size } from "babylonjs/Maths/math.size";
  19707. import { Observable } from "babylonjs/Misc/observable";
  19708. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  19709. /**
  19710. * Interface used to define additional presentation attributes
  19711. */
  19712. export interface IVRPresentationAttributes {
  19713. /**
  19714. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19715. */
  19716. highRefreshRate: boolean;
  19717. /**
  19718. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19719. */
  19720. foveationLevel: number;
  19721. }
  19722. module "babylonjs/Engines/engine" {
  19723. interface Engine {
  19724. /** @hidden */
  19725. _vrDisplay: any;
  19726. /** @hidden */
  19727. _vrSupported: boolean;
  19728. /** @hidden */
  19729. _oldSize: Size;
  19730. /** @hidden */
  19731. _oldHardwareScaleFactor: number;
  19732. /** @hidden */
  19733. _vrExclusivePointerMode: boolean;
  19734. /** @hidden */
  19735. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19736. /** @hidden */
  19737. _onVRDisplayPointerRestricted: () => void;
  19738. /** @hidden */
  19739. _onVRDisplayPointerUnrestricted: () => void;
  19740. /** @hidden */
  19741. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19742. /** @hidden */
  19743. _onVrDisplayDisconnect: Nullable<() => void>;
  19744. /** @hidden */
  19745. _onVrDisplayPresentChange: Nullable<() => void>;
  19746. /**
  19747. * Observable signaled when VR display mode changes
  19748. */
  19749. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19750. /**
  19751. * Observable signaled when VR request present is complete
  19752. */
  19753. onVRRequestPresentComplete: Observable<boolean>;
  19754. /**
  19755. * Observable signaled when VR request present starts
  19756. */
  19757. onVRRequestPresentStart: Observable<Engine>;
  19758. /**
  19759. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19760. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19761. */
  19762. isInVRExclusivePointerMode: boolean;
  19763. /**
  19764. * Gets a boolean indicating if a webVR device was detected
  19765. * @returns true if a webVR device was detected
  19766. */
  19767. isVRDevicePresent(): boolean;
  19768. /**
  19769. * Gets the current webVR device
  19770. * @returns the current webVR device (or null)
  19771. */
  19772. getVRDevice(): any;
  19773. /**
  19774. * Initializes a webVR display and starts listening to display change events
  19775. * The onVRDisplayChangedObservable will be notified upon these changes
  19776. * @returns A promise containing a VRDisplay and if vr is supported
  19777. */
  19778. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  19779. /** @hidden */
  19780. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  19781. /**
  19782. * Gets or sets the presentation attributes used to configure VR rendering
  19783. */
  19784. vrPresentationAttributes?: IVRPresentationAttributes;
  19785. /**
  19786. * Call this function to switch to webVR mode
  19787. * Will do nothing if webVR is not supported or if there is no webVR device
  19788. * @param options the webvr options provided to the camera. mainly used for multiview
  19789. * @see http://doc.babylonjs.com/how_to/webvr_camera
  19790. */
  19791. enableVR(options: WebVROptions): void;
  19792. /** @hidden */
  19793. _onVRFullScreenTriggered(): void;
  19794. }
  19795. }
  19796. }
  19797. declare module "babylonjs/Cameras/VR/webVRCamera" {
  19798. import { Nullable } from "babylonjs/types";
  19799. import { Observable } from "babylonjs/Misc/observable";
  19800. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19801. import { Scene } from "babylonjs/scene";
  19802. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  19803. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  19804. import { Node } from "babylonjs/node";
  19805. import { Ray } from "babylonjs/Culling/ray";
  19806. import "babylonjs/Cameras/RigModes/webVRRigMode";
  19807. import "babylonjs/Engines/Extensions/engine.webVR";
  19808. /**
  19809. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  19810. * IMPORTANT!! The data is right-hand data.
  19811. * @export
  19812. * @interface DevicePose
  19813. */
  19814. export interface DevicePose {
  19815. /**
  19816. * The position of the device, values in array are [x,y,z].
  19817. */
  19818. readonly position: Nullable<Float32Array>;
  19819. /**
  19820. * The linearVelocity of the device, values in array are [x,y,z].
  19821. */
  19822. readonly linearVelocity: Nullable<Float32Array>;
  19823. /**
  19824. * The linearAcceleration of the device, values in array are [x,y,z].
  19825. */
  19826. readonly linearAcceleration: Nullable<Float32Array>;
  19827. /**
  19828. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  19829. */
  19830. readonly orientation: Nullable<Float32Array>;
  19831. /**
  19832. * The angularVelocity of the device, values in array are [x,y,z].
  19833. */
  19834. readonly angularVelocity: Nullable<Float32Array>;
  19835. /**
  19836. * The angularAcceleration of the device, values in array are [x,y,z].
  19837. */
  19838. readonly angularAcceleration: Nullable<Float32Array>;
  19839. }
  19840. /**
  19841. * Interface representing a pose controlled object in Babylon.
  19842. * A pose controlled object has both regular pose values as well as pose values
  19843. * from an external device such as a VR head mounted display
  19844. */
  19845. export interface PoseControlled {
  19846. /**
  19847. * The position of the object in babylon space.
  19848. */
  19849. position: Vector3;
  19850. /**
  19851. * The rotation quaternion of the object in babylon space.
  19852. */
  19853. rotationQuaternion: Quaternion;
  19854. /**
  19855. * The position of the device in babylon space.
  19856. */
  19857. devicePosition?: Vector3;
  19858. /**
  19859. * The rotation quaternion of the device in babylon space.
  19860. */
  19861. deviceRotationQuaternion: Quaternion;
  19862. /**
  19863. * The raw pose coming from the device.
  19864. */
  19865. rawPose: Nullable<DevicePose>;
  19866. /**
  19867. * The scale of the device to be used when translating from device space to babylon space.
  19868. */
  19869. deviceScaleFactor: number;
  19870. /**
  19871. * Updates the poseControlled values based on the input device pose.
  19872. * @param poseData the pose data to update the object with
  19873. */
  19874. updateFromDevice(poseData: DevicePose): void;
  19875. }
  19876. /**
  19877. * Set of options to customize the webVRCamera
  19878. */
  19879. export interface WebVROptions {
  19880. /**
  19881. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  19882. */
  19883. trackPosition?: boolean;
  19884. /**
  19885. * Sets the scale of the vrDevice in babylon space. (default: 1)
  19886. */
  19887. positionScale?: number;
  19888. /**
  19889. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  19890. */
  19891. displayName?: string;
  19892. /**
  19893. * Should the native controller meshes be initialized. (default: true)
  19894. */
  19895. controllerMeshes?: boolean;
  19896. /**
  19897. * Creating a default HemiLight only on controllers. (default: true)
  19898. */
  19899. defaultLightingOnControllers?: boolean;
  19900. /**
  19901. * If you don't want to use the default VR button of the helper. (default: false)
  19902. */
  19903. useCustomVRButton?: boolean;
  19904. /**
  19905. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  19906. */
  19907. customVRButton?: HTMLButtonElement;
  19908. /**
  19909. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  19910. */
  19911. rayLength?: number;
  19912. /**
  19913. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  19914. */
  19915. defaultHeight?: number;
  19916. /**
  19917. * If multiview should be used if availible (default: false)
  19918. */
  19919. useMultiview?: boolean;
  19920. }
  19921. /**
  19922. * This represents a WebVR camera.
  19923. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  19924. * @example http://doc.babylonjs.com/how_to/webvr_camera
  19925. */
  19926. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19927. private webVROptions;
  19928. /**
  19929. * @hidden
  19930. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  19931. */
  19932. _vrDevice: any;
  19933. /**
  19934. * The rawPose of the vrDevice.
  19935. */
  19936. rawPose: Nullable<DevicePose>;
  19937. private _onVREnabled;
  19938. private _specsVersion;
  19939. private _attached;
  19940. private _frameData;
  19941. protected _descendants: Array<Node>;
  19942. private _deviceRoomPosition;
  19943. /** @hidden */
  19944. _deviceRoomRotationQuaternion: Quaternion;
  19945. private _standingMatrix;
  19946. /**
  19947. * Represents device position in babylon space.
  19948. */
  19949. devicePosition: Vector3;
  19950. /**
  19951. * Represents device rotation in babylon space.
  19952. */
  19953. deviceRotationQuaternion: Quaternion;
  19954. /**
  19955. * The scale of the device to be used when translating from device space to babylon space.
  19956. */
  19957. deviceScaleFactor: number;
  19958. private _deviceToWorld;
  19959. private _worldToDevice;
  19960. /**
  19961. * References to the webVR controllers for the vrDevice.
  19962. */
  19963. controllers: Array<WebVRController>;
  19964. /**
  19965. * Emits an event when a controller is attached.
  19966. */
  19967. onControllersAttachedObservable: Observable<WebVRController[]>;
  19968. /**
  19969. * Emits an event when a controller's mesh has been loaded;
  19970. */
  19971. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19972. /**
  19973. * Emits an event when the HMD's pose has been updated.
  19974. */
  19975. onPoseUpdatedFromDeviceObservable: Observable<any>;
  19976. private _poseSet;
  19977. /**
  19978. * If the rig cameras be used as parent instead of this camera.
  19979. */
  19980. rigParenting: boolean;
  19981. private _lightOnControllers;
  19982. private _defaultHeight?;
  19983. /**
  19984. * Instantiates a WebVRFreeCamera.
  19985. * @param name The name of the WebVRFreeCamera
  19986. * @param position The starting anchor position for the camera
  19987. * @param scene The scene the camera belongs to
  19988. * @param webVROptions a set of customizable options for the webVRCamera
  19989. */
  19990. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19991. /**
  19992. * Gets the device distance from the ground in meters.
  19993. * @returns the distance in meters from the vrDevice to ground in device space. If standing matrix is not supported for the vrDevice 0 is returned.
  19994. */
  19995. deviceDistanceToRoomGround(): number;
  19996. /**
  19997. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  19998. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  19999. */
  20000. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20001. /**
  20002. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20003. * @returns A promise with a boolean set to if the standing matrix is supported.
  20004. */
  20005. useStandingMatrixAsync(): Promise<boolean>;
  20006. /**
  20007. * Disposes the camera
  20008. */
  20009. dispose(): void;
  20010. /**
  20011. * Gets a vrController by name.
  20012. * @param name The name of the controller to retreive
  20013. * @returns the controller matching the name specified or null if not found
  20014. */
  20015. getControllerByName(name: string): Nullable<WebVRController>;
  20016. private _leftController;
  20017. /**
  20018. * The controller corresponding to the users left hand.
  20019. */
  20020. get leftController(): Nullable<WebVRController>;
  20021. private _rightController;
  20022. /**
  20023. * The controller corresponding to the users right hand.
  20024. */
  20025. get rightController(): Nullable<WebVRController>;
  20026. /**
  20027. * Casts a ray forward from the vrCamera's gaze.
  20028. * @param length Length of the ray (default: 100)
  20029. * @returns the ray corresponding to the gaze
  20030. */
  20031. getForwardRay(length?: number): Ray;
  20032. /**
  20033. * @hidden
  20034. * Updates the camera based on device's frame data
  20035. */
  20036. _checkInputs(): void;
  20037. /**
  20038. * Updates the poseControlled values based on the input device pose.
  20039. * @param poseData Pose coming from the device
  20040. */
  20041. updateFromDevice(poseData: DevicePose): void;
  20042. private _htmlElementAttached;
  20043. private _detachIfAttached;
  20044. /**
  20045. * WebVR's attach control will start broadcasting frames to the device.
  20046. * Note that in certain browsers (chrome for example) this function must be called
  20047. * within a user-interaction callback. Example:
  20048. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20049. *
  20050. * @param element html element to attach the vrDevice to
  20051. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20052. */
  20053. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20054. /**
  20055. * Detaches the camera from the html element and disables VR
  20056. *
  20057. * @param element html element to detach from
  20058. */
  20059. detachControl(element: HTMLElement): void;
  20060. /**
  20061. * @returns the name of this class
  20062. */
  20063. getClassName(): string;
  20064. /**
  20065. * Calls resetPose on the vrDisplay
  20066. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20067. */
  20068. resetToCurrentRotation(): void;
  20069. /**
  20070. * @hidden
  20071. * Updates the rig cameras (left and right eye)
  20072. */
  20073. _updateRigCameras(): void;
  20074. private _workingVector;
  20075. private _oneVector;
  20076. private _workingMatrix;
  20077. private updateCacheCalled;
  20078. private _correctPositionIfNotTrackPosition;
  20079. /**
  20080. * @hidden
  20081. * Updates the cached values of the camera
  20082. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20083. */
  20084. _updateCache(ignoreParentClass?: boolean): void;
  20085. /**
  20086. * @hidden
  20087. * Get current device position in babylon world
  20088. */
  20089. _computeDevicePosition(): void;
  20090. /**
  20091. * Updates the current device position and rotation in the babylon world
  20092. */
  20093. update(): void;
  20094. /**
  20095. * @hidden
  20096. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20097. * @returns an identity matrix
  20098. */
  20099. _getViewMatrix(): Matrix;
  20100. private _tmpMatrix;
  20101. /**
  20102. * This function is called by the two RIG cameras.
  20103. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20104. * @hidden
  20105. */
  20106. _getWebVRViewMatrix(): Matrix;
  20107. /** @hidden */
  20108. _getWebVRProjectionMatrix(): Matrix;
  20109. private _onGamepadConnectedObserver;
  20110. private _onGamepadDisconnectedObserver;
  20111. private _updateCacheWhenTrackingDisabledObserver;
  20112. /**
  20113. * Initializes the controllers and their meshes
  20114. */
  20115. initControllers(): void;
  20116. }
  20117. }
  20118. declare module "babylonjs/PostProcesses/postProcess" {
  20119. import { Nullable } from "babylonjs/types";
  20120. import { SmartArray } from "babylonjs/Misc/smartArray";
  20121. import { Observable } from "babylonjs/Misc/observable";
  20122. import { Vector2 } from "babylonjs/Maths/math.vector";
  20123. import { Camera } from "babylonjs/Cameras/camera";
  20124. import { Effect } from "babylonjs/Materials/effect";
  20125. import "babylonjs/Shaders/postprocess.vertex";
  20126. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20127. import { Engine } from "babylonjs/Engines/engine";
  20128. import { Color4 } from "babylonjs/Maths/math.color";
  20129. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20130. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20131. /**
  20132. * Size options for a post process
  20133. */
  20134. export type PostProcessOptions = {
  20135. width: number;
  20136. height: number;
  20137. };
  20138. /**
  20139. * PostProcess can be used to apply a shader to a texture after it has been rendered
  20140. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20141. */
  20142. export class PostProcess {
  20143. /** Name of the PostProcess. */
  20144. name: string;
  20145. /**
  20146. * Gets or sets the unique id of the post process
  20147. */
  20148. uniqueId: number;
  20149. /**
  20150. * Width of the texture to apply the post process on
  20151. */
  20152. width: number;
  20153. /**
  20154. * Height of the texture to apply the post process on
  20155. */
  20156. height: number;
  20157. /**
  20158. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  20159. * @hidden
  20160. */
  20161. _outputTexture: Nullable<InternalTexture>;
  20162. /**
  20163. * Sampling mode used by the shader
  20164. * See https://doc.babylonjs.com/classes/3.1/texture
  20165. */
  20166. renderTargetSamplingMode: number;
  20167. /**
  20168. * Clear color to use when screen clearing
  20169. */
  20170. clearColor: Color4;
  20171. /**
  20172. * If the buffer needs to be cleared before applying the post process. (default: true)
  20173. * Should be set to false if shader will overwrite all previous pixels.
  20174. */
  20175. autoClear: boolean;
  20176. /**
  20177. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  20178. */
  20179. alphaMode: number;
  20180. /**
  20181. * Sets the setAlphaBlendConstants of the babylon engine
  20182. */
  20183. alphaConstants: Color4;
  20184. /**
  20185. * Animations to be used for the post processing
  20186. */
  20187. animations: import("babylonjs/Animations/animation").Animation[];
  20188. /**
  20189. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  20190. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  20191. */
  20192. enablePixelPerfectMode: boolean;
  20193. /**
  20194. * Force the postprocess to be applied without taking in account viewport
  20195. */
  20196. forceFullscreenViewport: boolean;
  20197. /**
  20198. * List of inspectable custom properties (used by the Inspector)
  20199. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20200. */
  20201. inspectableCustomProperties: IInspectable[];
  20202. /**
  20203. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  20204. *
  20205. * | Value | Type | Description |
  20206. * | ----- | ----------------------------------- | ----------- |
  20207. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  20208. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  20209. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  20210. *
  20211. */
  20212. scaleMode: number;
  20213. /**
  20214. * Force textures to be a power of two (default: false)
  20215. */
  20216. alwaysForcePOT: boolean;
  20217. private _samples;
  20218. /**
  20219. * Number of sample textures (default: 1)
  20220. */
  20221. get samples(): number;
  20222. set samples(n: number);
  20223. /**
  20224. * Modify the scale of the post process to be the same as the viewport (default: false)
  20225. */
  20226. adaptScaleToCurrentViewport: boolean;
  20227. private _camera;
  20228. private _scene;
  20229. private _engine;
  20230. private _options;
  20231. private _reusable;
  20232. private _textureType;
  20233. private _textureFormat;
  20234. /**
  20235. * Smart array of input and output textures for the post process.
  20236. * @hidden
  20237. */
  20238. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  20239. /**
  20240. * The index in _textures that corresponds to the output texture.
  20241. * @hidden
  20242. */
  20243. _currentRenderTextureInd: number;
  20244. private _effect;
  20245. private _samplers;
  20246. private _fragmentUrl;
  20247. private _vertexUrl;
  20248. private _parameters;
  20249. private _scaleRatio;
  20250. protected _indexParameters: any;
  20251. private _shareOutputWithPostProcess;
  20252. private _texelSize;
  20253. private _forcedOutputTexture;
  20254. /**
  20255. * Returns the fragment url or shader name used in the post process.
  20256. * @returns the fragment url or name in the shader store.
  20257. */
  20258. getEffectName(): string;
  20259. /**
  20260. * An event triggered when the postprocess is activated.
  20261. */
  20262. onActivateObservable: Observable<Camera>;
  20263. private _onActivateObserver;
  20264. /**
  20265. * A function that is added to the onActivateObservable
  20266. */
  20267. set onActivate(callback: Nullable<(camera: Camera) => void>);
  20268. /**
  20269. * An event triggered when the postprocess changes its size.
  20270. */
  20271. onSizeChangedObservable: Observable<PostProcess>;
  20272. private _onSizeChangedObserver;
  20273. /**
  20274. * A function that is added to the onSizeChangedObservable
  20275. */
  20276. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  20277. /**
  20278. * An event triggered when the postprocess applies its effect.
  20279. */
  20280. onApplyObservable: Observable<Effect>;
  20281. private _onApplyObserver;
  20282. /**
  20283. * A function that is added to the onApplyObservable
  20284. */
  20285. set onApply(callback: (effect: Effect) => void);
  20286. /**
  20287. * An event triggered before rendering the postprocess
  20288. */
  20289. onBeforeRenderObservable: Observable<Effect>;
  20290. private _onBeforeRenderObserver;
  20291. /**
  20292. * A function that is added to the onBeforeRenderObservable
  20293. */
  20294. set onBeforeRender(callback: (effect: Effect) => void);
  20295. /**
  20296. * An event triggered after rendering the postprocess
  20297. */
  20298. onAfterRenderObservable: Observable<Effect>;
  20299. private _onAfterRenderObserver;
  20300. /**
  20301. * A function that is added to the onAfterRenderObservable
  20302. */
  20303. set onAfterRender(callback: (efect: Effect) => void);
  20304. /**
  20305. * The input texture for this post process and the output texture of the previous post process. When added to a pipeline the previous post process will
  20306. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  20307. */
  20308. get inputTexture(): InternalTexture;
  20309. set inputTexture(value: InternalTexture);
  20310. /**
  20311. * Gets the camera which post process is applied to.
  20312. * @returns The camera the post process is applied to.
  20313. */
  20314. getCamera(): Camera;
  20315. /**
  20316. * Gets the texel size of the postprocess.
  20317. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  20318. */
  20319. get texelSize(): Vector2;
  20320. /**
  20321. * Creates a new instance PostProcess
  20322. * @param name The name of the PostProcess.
  20323. * @param fragmentUrl The url of the fragment shader to be used.
  20324. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  20325. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  20326. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20327. * @param camera The camera to apply the render pass to.
  20328. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20329. * @param engine The engine which the post process will be applied. (default: current engine)
  20330. * @param reusable If the post process can be reused on the same frame. (default: false)
  20331. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  20332. * @param textureType Type of textures used when performing the post process. (default: 0)
  20333. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  20334. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  20335. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  20336. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  20337. */
  20338. constructor(
  20339. /** Name of the PostProcess. */
  20340. name: string, fragmentUrl: string, parameters: Nullable<string[]>, samplers: Nullable<string[]>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: Nullable<string>, textureType?: number, vertexUrl?: string, indexParameters?: any, blockCompilation?: boolean, textureFormat?: number);
  20341. /**
  20342. * Gets a string idenfifying the name of the class
  20343. * @returns "PostProcess" string
  20344. */
  20345. getClassName(): string;
  20346. /**
  20347. * Gets the engine which this post process belongs to.
  20348. * @returns The engine the post process was enabled with.
  20349. */
  20350. getEngine(): Engine;
  20351. /**
  20352. * The effect that is created when initializing the post process.
  20353. * @returns The created effect corresponding the the postprocess.
  20354. */
  20355. getEffect(): Effect;
  20356. /**
  20357. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  20358. * @param postProcess The post process to share the output with.
  20359. * @returns This post process.
  20360. */
  20361. shareOutputWith(postProcess: PostProcess): PostProcess;
  20362. /**
  20363. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  20364. * This should be called if the post process that shares output with this post process is disabled/disposed.
  20365. */
  20366. useOwnOutput(): void;
  20367. /**
  20368. * Updates the effect with the current post process compile time values and recompiles the shader.
  20369. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20370. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20371. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20372. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  20373. * @param onCompiled Called when the shader has been compiled.
  20374. * @param onError Called if there is an error when compiling a shader.
  20375. */
  20376. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20377. /**
  20378. * The post process is reusable if it can be used multiple times within one frame.
  20379. * @returns If the post process is reusable
  20380. */
  20381. isReusable(): boolean;
  20382. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  20383. markTextureDirty(): void;
  20384. /**
  20385. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  20386. * When this post process is used in a pipeline, this is call will bind the input texture of this post process to the output of the previous.
  20387. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  20388. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  20389. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  20390. * @returns The target texture that was bound to be written to.
  20391. */
  20392. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  20393. /**
  20394. * If the post process is supported.
  20395. */
  20396. get isSupported(): boolean;
  20397. /**
  20398. * The aspect ratio of the output texture.
  20399. */
  20400. get aspectRatio(): number;
  20401. /**
  20402. * Get a value indicating if the post-process is ready to be used
  20403. * @returns true if the post-process is ready (shader is compiled)
  20404. */
  20405. isReady(): boolean;
  20406. /**
  20407. * Binds all textures and uniforms to the shader, this will be run on every pass.
  20408. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  20409. */
  20410. apply(): Nullable<Effect>;
  20411. private _disposeTextures;
  20412. /**
  20413. * Disposes the post process.
  20414. * @param camera The camera to dispose the post process on.
  20415. */
  20416. dispose(camera?: Camera): void;
  20417. }
  20418. }
  20419. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  20420. /** @hidden */
  20421. export var kernelBlurVaryingDeclaration: {
  20422. name: string;
  20423. shader: string;
  20424. };
  20425. }
  20426. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  20427. /** @hidden */
  20428. export var kernelBlurFragment: {
  20429. name: string;
  20430. shader: string;
  20431. };
  20432. }
  20433. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  20434. /** @hidden */
  20435. export var kernelBlurFragment2: {
  20436. name: string;
  20437. shader: string;
  20438. };
  20439. }
  20440. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  20441. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20442. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  20443. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  20444. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  20445. /** @hidden */
  20446. export var kernelBlurPixelShader: {
  20447. name: string;
  20448. shader: string;
  20449. };
  20450. }
  20451. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  20452. /** @hidden */
  20453. export var kernelBlurVertex: {
  20454. name: string;
  20455. shader: string;
  20456. };
  20457. }
  20458. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  20459. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  20460. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  20461. /** @hidden */
  20462. export var kernelBlurVertexShader: {
  20463. name: string;
  20464. shader: string;
  20465. };
  20466. }
  20467. declare module "babylonjs/PostProcesses/blurPostProcess" {
  20468. import { Vector2 } from "babylonjs/Maths/math.vector";
  20469. import { Nullable } from "babylonjs/types";
  20470. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  20471. import { Camera } from "babylonjs/Cameras/camera";
  20472. import { Effect } from "babylonjs/Materials/effect";
  20473. import { Engine } from "babylonjs/Engines/engine";
  20474. import "babylonjs/Shaders/kernelBlur.fragment";
  20475. import "babylonjs/Shaders/kernelBlur.vertex";
  20476. /**
  20477. * The Blur Post Process which blurs an image based on a kernel and direction.
  20478. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  20479. */
  20480. export class BlurPostProcess extends PostProcess {
  20481. /** The direction in which to blur the image. */
  20482. direction: Vector2;
  20483. private blockCompilation;
  20484. protected _kernel: number;
  20485. protected _idealKernel: number;
  20486. protected _packedFloat: boolean;
  20487. private _staticDefines;
  20488. /**
  20489. * Sets the length in pixels of the blur sample region
  20490. */
  20491. set kernel(v: number);
  20492. /**
  20493. * Gets the length in pixels of the blur sample region
  20494. */
  20495. get kernel(): number;
  20496. /**
  20497. * Sets wether or not the blur needs to unpack/repack floats
  20498. */
  20499. set packedFloat(v: boolean);
  20500. /**
  20501. * Gets wether or not the blur is unpacking/repacking floats
  20502. */
  20503. get packedFloat(): boolean;
  20504. /**
  20505. * Creates a new instance BlurPostProcess
  20506. * @param name The name of the effect.
  20507. * @param direction The direction in which to blur the image.
  20508. * @param kernel The size of the kernel to be used when computing the blur. eg. Size of 3 will blur the center pixel by 2 pixels surrounding it.
  20509. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  20510. * @param camera The camera to apply the render pass to.
  20511. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  20512. * @param engine The engine which the post process will be applied. (default: current engine)
  20513. * @param reusable If the post process can be reused on the same frame. (default: false)
  20514. * @param textureType Type of textures used when performing the post process. (default: 0)
  20515. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  20516. */
  20517. constructor(name: string,
  20518. /** The direction in which to blur the image. */
  20519. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  20520. /**
  20521. * Updates the effect with the current post process compile time values and recompiles the shader.
  20522. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  20523. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  20524. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  20525. * @param indexParameters The index parameters to be used for babylons include syntax "#include<kernelBlurVaryingDeclaration>[0..varyingCount]". (default: undefined) See usage in babylon.blurPostProcess.ts and kernelBlur.vertex.fx
  20526. * @param onCompiled Called when the shader has been compiled.
  20527. * @param onError Called if there is an error when compiling a shader.
  20528. */
  20529. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20530. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  20531. /**
  20532. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  20533. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  20534. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  20535. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  20536. * The gaps between physical kernels are compensated for in the weighting of the samples
  20537. * @param idealKernel Ideal blur kernel.
  20538. * @return Nearest best kernel.
  20539. */
  20540. protected _nearestBestKernel(idealKernel: number): number;
  20541. /**
  20542. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  20543. * @param x The point on the Gaussian distribution to sample.
  20544. * @return the value of the Gaussian function at x.
  20545. */
  20546. protected _gaussianWeight(x: number): number;
  20547. /**
  20548. * Generates a string that can be used as a floating point number in GLSL.
  20549. * @param x Value to print.
  20550. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  20551. * @return GLSL float string.
  20552. */
  20553. protected _glslFloat(x: number, decimalFigures?: number): string;
  20554. }
  20555. }
  20556. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  20557. import { Scene } from "babylonjs/scene";
  20558. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20559. import { Plane } from "babylonjs/Maths/math.plane";
  20560. /**
  20561. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20562. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20563. * You can then easily use it as a reflectionTexture on a flat surface.
  20564. * In case the surface is not a plane, please consider relying on reflection probes.
  20565. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20566. */
  20567. export class MirrorTexture extends RenderTargetTexture {
  20568. private scene;
  20569. /**
  20570. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  20571. * It is possible to directly set the mirrorPlane by directly using a Plane(a, b, c, d) where a, b and c give the plane normal vector (a, b, c) and d is a scalar displacement from the mirrorPlane to the origin. However in all but the very simplest of situations it is more straight forward to set it to the reflector as stated in the doc.
  20572. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20573. */
  20574. mirrorPlane: Plane;
  20575. /**
  20576. * Define the blur ratio used to blur the reflection if needed.
  20577. */
  20578. set blurRatio(value: number);
  20579. get blurRatio(): number;
  20580. /**
  20581. * Define the adaptive blur kernel used to blur the reflection if needed.
  20582. * This will autocompute the closest best match for the `blurKernel`
  20583. */
  20584. set adaptiveBlurKernel(value: number);
  20585. /**
  20586. * Define the blur kernel used to blur the reflection if needed.
  20587. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20588. */
  20589. set blurKernel(value: number);
  20590. /**
  20591. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  20592. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20593. */
  20594. set blurKernelX(value: number);
  20595. get blurKernelX(): number;
  20596. /**
  20597. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  20598. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  20599. */
  20600. set blurKernelY(value: number);
  20601. get blurKernelY(): number;
  20602. private _autoComputeBlurKernel;
  20603. protected _onRatioRescale(): void;
  20604. private _updateGammaSpace;
  20605. private _imageProcessingConfigChangeObserver;
  20606. private _transformMatrix;
  20607. private _mirrorMatrix;
  20608. private _savedViewMatrix;
  20609. private _blurX;
  20610. private _blurY;
  20611. private _adaptiveBlurKernel;
  20612. private _blurKernelX;
  20613. private _blurKernelY;
  20614. private _blurRatio;
  20615. /**
  20616. * Instantiates a Mirror Texture.
  20617. * Mirror texture can be used to simulate the view from a mirror in a scene.
  20618. * It will dynamically be rendered every frame to adapt to the camera point of view.
  20619. * You can then easily use it as a reflectionTexture on a flat surface.
  20620. * In case the surface is not a plane, please consider relying on reflection probes.
  20621. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  20622. * @param name
  20623. * @param size
  20624. * @param scene
  20625. * @param generateMipMaps
  20626. * @param type
  20627. * @param samplingMode
  20628. * @param generateDepthBuffer
  20629. */
  20630. constructor(name: string, size: number | {
  20631. width: number;
  20632. height: number;
  20633. } | {
  20634. ratio: number;
  20635. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  20636. private _preparePostProcesses;
  20637. /**
  20638. * Clone the mirror texture.
  20639. * @returns the cloned texture
  20640. */
  20641. clone(): MirrorTexture;
  20642. /**
  20643. * Serialize the texture to a JSON representation you could use in Parse later on
  20644. * @returns the serialized JSON representation
  20645. */
  20646. serialize(): any;
  20647. /**
  20648. * Dispose the texture and release its associated resources.
  20649. */
  20650. dispose(): void;
  20651. }
  20652. }
  20653. declare module "babylonjs/Materials/Textures/texture" {
  20654. import { Observable } from "babylonjs/Misc/observable";
  20655. import { Nullable } from "babylonjs/types";
  20656. import { Matrix } from "babylonjs/Maths/math.vector";
  20657. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20658. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20659. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  20660. import { Scene } from "babylonjs/scene";
  20661. /**
  20662. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20663. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20664. */
  20665. export class Texture extends BaseTexture {
  20666. /**
  20667. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  20668. */
  20669. static SerializeBuffers: boolean;
  20670. /** @hidden */
  20671. static _CubeTextureParser: (jsonTexture: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  20672. /** @hidden */
  20673. static _CreateMirror: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  20674. /** @hidden */
  20675. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: import("babylonjs/scene").Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  20676. /** nearest is mag = nearest and min = nearest and mip = linear */
  20677. static readonly NEAREST_SAMPLINGMODE: number;
  20678. /** nearest is mag = nearest and min = nearest and mip = linear */
  20679. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  20680. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20681. static readonly BILINEAR_SAMPLINGMODE: number;
  20682. /** Bilinear is mag = linear and min = linear and mip = nearest */
  20683. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  20684. /** Trilinear is mag = linear and min = linear and mip = linear */
  20685. static readonly TRILINEAR_SAMPLINGMODE: number;
  20686. /** Trilinear is mag = linear and min = linear and mip = linear */
  20687. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  20688. /** mag = nearest and min = nearest and mip = nearest */
  20689. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  20690. /** mag = nearest and min = linear and mip = nearest */
  20691. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  20692. /** mag = nearest and min = linear and mip = linear */
  20693. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  20694. /** mag = nearest and min = linear and mip = none */
  20695. static readonly NEAREST_LINEAR: number;
  20696. /** mag = nearest and min = nearest and mip = none */
  20697. static readonly NEAREST_NEAREST: number;
  20698. /** mag = linear and min = nearest and mip = nearest */
  20699. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  20700. /** mag = linear and min = nearest and mip = linear */
  20701. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  20702. /** mag = linear and min = linear and mip = none */
  20703. static readonly LINEAR_LINEAR: number;
  20704. /** mag = linear and min = nearest and mip = none */
  20705. static readonly LINEAR_NEAREST: number;
  20706. /** Explicit coordinates mode */
  20707. static readonly EXPLICIT_MODE: number;
  20708. /** Spherical coordinates mode */
  20709. static readonly SPHERICAL_MODE: number;
  20710. /** Planar coordinates mode */
  20711. static readonly PLANAR_MODE: number;
  20712. /** Cubic coordinates mode */
  20713. static readonly CUBIC_MODE: number;
  20714. /** Projection coordinates mode */
  20715. static readonly PROJECTION_MODE: number;
  20716. /** Inverse Cubic coordinates mode */
  20717. static readonly SKYBOX_MODE: number;
  20718. /** Inverse Cubic coordinates mode */
  20719. static readonly INVCUBIC_MODE: number;
  20720. /** Equirectangular coordinates mode */
  20721. static readonly EQUIRECTANGULAR_MODE: number;
  20722. /** Equirectangular Fixed coordinates mode */
  20723. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  20724. /** Equirectangular Fixed Mirrored coordinates mode */
  20725. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  20726. /** Texture is not repeating outside of 0..1 UVs */
  20727. static readonly CLAMP_ADDRESSMODE: number;
  20728. /** Texture is repeating outside of 0..1 UVs */
  20729. static readonly WRAP_ADDRESSMODE: number;
  20730. /** Texture is repeating and mirrored */
  20731. static readonly MIRROR_ADDRESSMODE: number;
  20732. /**
  20733. * Gets or sets a boolean which defines if the texture url must be build from the serialized URL instead of just using the name and loading them side by side with the scene file
  20734. */
  20735. static UseSerializedUrlIfAny: boolean;
  20736. /**
  20737. * Define the url of the texture.
  20738. */
  20739. url: Nullable<string>;
  20740. /**
  20741. * Define an offset on the texture to offset the u coordinates of the UVs
  20742. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20743. */
  20744. uOffset: number;
  20745. /**
  20746. * Define an offset on the texture to offset the v coordinates of the UVs
  20747. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  20748. */
  20749. vOffset: number;
  20750. /**
  20751. * Define an offset on the texture to scale the u coordinates of the UVs
  20752. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20753. */
  20754. uScale: number;
  20755. /**
  20756. * Define an offset on the texture to scale the v coordinates of the UVs
  20757. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  20758. */
  20759. vScale: number;
  20760. /**
  20761. * Define an offset on the texture to rotate around the u coordinates of the UVs
  20762. * @see http://doc.babylonjs.com/how_to/more_materials
  20763. */
  20764. uAng: number;
  20765. /**
  20766. * Define an offset on the texture to rotate around the v coordinates of the UVs
  20767. * @see http://doc.babylonjs.com/how_to/more_materials
  20768. */
  20769. vAng: number;
  20770. /**
  20771. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  20772. * @see http://doc.babylonjs.com/how_to/more_materials
  20773. */
  20774. wAng: number;
  20775. /**
  20776. * Defines the center of rotation (U)
  20777. */
  20778. uRotationCenter: number;
  20779. /**
  20780. * Defines the center of rotation (V)
  20781. */
  20782. vRotationCenter: number;
  20783. /**
  20784. * Defines the center of rotation (W)
  20785. */
  20786. wRotationCenter: number;
  20787. /**
  20788. * Are mip maps generated for this texture or not.
  20789. */
  20790. get noMipmap(): boolean;
  20791. /**
  20792. * List of inspectable custom properties (used by the Inspector)
  20793. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20794. */
  20795. inspectableCustomProperties: Nullable<IInspectable[]>;
  20796. private _noMipmap;
  20797. /** @hidden */
  20798. _invertY: boolean;
  20799. private _rowGenerationMatrix;
  20800. private _cachedTextureMatrix;
  20801. private _projectionModeMatrix;
  20802. private _t0;
  20803. private _t1;
  20804. private _t2;
  20805. private _cachedUOffset;
  20806. private _cachedVOffset;
  20807. private _cachedUScale;
  20808. private _cachedVScale;
  20809. private _cachedUAng;
  20810. private _cachedVAng;
  20811. private _cachedWAng;
  20812. private _cachedProjectionMatrixId;
  20813. private _cachedCoordinatesMode;
  20814. /** @hidden */
  20815. protected _initialSamplingMode: number;
  20816. /** @hidden */
  20817. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  20818. private _deleteBuffer;
  20819. protected _format: Nullable<number>;
  20820. private _delayedOnLoad;
  20821. private _delayedOnError;
  20822. private _mimeType?;
  20823. /**
  20824. * Observable triggered once the texture has been loaded.
  20825. */
  20826. onLoadObservable: Observable<Texture>;
  20827. protected _isBlocking: boolean;
  20828. /**
  20829. * Is the texture preventing material to render while loading.
  20830. * If false, a default texture will be used instead of the loading one during the preparation step.
  20831. */
  20832. set isBlocking(value: boolean);
  20833. get isBlocking(): boolean;
  20834. /**
  20835. * Get the current sampling mode associated with the texture.
  20836. */
  20837. get samplingMode(): number;
  20838. /**
  20839. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  20840. */
  20841. get invertY(): boolean;
  20842. /**
  20843. * Instantiates a new texture.
  20844. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  20845. * @see http://doc.babylonjs.com/babylon101/materials#texture
  20846. * @param url defines the url of the picture to load as a texture
  20847. * @param scene defines the scene or engine the texture will belong to
  20848. * @param noMipmap defines if the texture will require mip maps or not
  20849. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  20850. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20851. * @param onLoad defines a callback triggered when the texture has been loaded
  20852. * @param onError defines a callback triggered when an error occurred during the loading session
  20853. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  20854. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  20855. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20856. * @param mimeType defines an optional mime type information
  20857. */
  20858. constructor(url: Nullable<string>, sceneOrEngine: Nullable<Scene | ThinEngine>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, deleteBuffer?: boolean, format?: number, mimeType?: string);
  20859. /**
  20860. * Update the url (and optional buffer) of this texture if url was null during construction.
  20861. * @param url the url of the texture
  20862. * @param buffer the buffer of the texture (defaults to null)
  20863. * @param onLoad callback called when the texture is loaded (defaults to null)
  20864. */
  20865. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  20866. /**
  20867. * Finish the loading sequence of a texture flagged as delayed load.
  20868. * @hidden
  20869. */
  20870. delayLoad(): void;
  20871. private _prepareRowForTextureGeneration;
  20872. /**
  20873. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  20874. * @returns the transform matrix of the texture.
  20875. */
  20876. getTextureMatrix(uBase?: number): Matrix;
  20877. /**
  20878. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  20879. * @returns The reflection texture transform
  20880. */
  20881. getReflectionTextureMatrix(): Matrix;
  20882. /**
  20883. * Clones the texture.
  20884. * @returns the cloned texture
  20885. */
  20886. clone(): Texture;
  20887. /**
  20888. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20889. * @returns The JSON representation of the texture
  20890. */
  20891. serialize(): any;
  20892. /**
  20893. * Get the current class name of the texture useful for serialization or dynamic coding.
  20894. * @returns "Texture"
  20895. */
  20896. getClassName(): string;
  20897. /**
  20898. * Dispose the texture and release its associated resources.
  20899. */
  20900. dispose(): void;
  20901. /**
  20902. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  20903. * @param parsedTexture Define the JSON representation of the texture
  20904. * @param scene Define the scene the parsed texture should be instantiated in
  20905. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  20906. * @returns The parsed texture if successful
  20907. */
  20908. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  20909. /**
  20910. * Creates a texture from its base 64 representation.
  20911. * @param data Define the base64 payload without the data: prefix
  20912. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20913. * @param scene Define the scene the texture should belong to
  20914. * @param noMipmap Forces the texture to not create mip map information if true
  20915. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20916. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20917. * @param onLoad define a callback triggered when the texture has been loaded
  20918. * @param onError define a callback triggered when an error occurred during the loading session
  20919. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20920. * @returns the created texture
  20921. */
  20922. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  20923. /**
  20924. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  20925. * @param data Define the base64 payload without the data: prefix
  20926. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  20927. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  20928. * @param scene Define the scene the texture should belong to
  20929. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  20930. * @param noMipmap Forces the texture to not create mip map information if true
  20931. * @param invertY define if the texture needs to be inverted on the y axis during loading
  20932. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  20933. * @param onLoad define a callback triggered when the texture has been loaded
  20934. * @param onError define a callback triggered when an error occurred during the loading session
  20935. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  20936. * @returns the created texture
  20937. */
  20938. static LoadFromDataString(name: string, buffer: any, scene: Scene, deleteBuffer?: boolean, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number): Texture;
  20939. }
  20940. }
  20941. declare module "babylonjs/PostProcesses/postProcessManager" {
  20942. import { Nullable } from "babylonjs/types";
  20943. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20944. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20945. import { Scene } from "babylonjs/scene";
  20946. /**
  20947. * PostProcessManager is used to manage one or more post processes or post process pipelines
  20948. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  20949. */
  20950. export class PostProcessManager {
  20951. private _scene;
  20952. private _indexBuffer;
  20953. private _vertexBuffers;
  20954. /**
  20955. * Creates a new instance PostProcess
  20956. * @param scene The scene that the post process is associated with.
  20957. */
  20958. constructor(scene: Scene);
  20959. private _prepareBuffers;
  20960. private _buildIndexBuffer;
  20961. /**
  20962. * Rebuilds the vertex buffers of the manager.
  20963. * @hidden
  20964. */
  20965. _rebuild(): void;
  20966. /**
  20967. * Prepares a frame to be run through a post process.
  20968. * @param sourceTexture The input texture to the post procesess. (default: null)
  20969. * @param postProcesses An array of post processes to be run. (default: null)
  20970. * @returns True if the post processes were able to be run.
  20971. * @hidden
  20972. */
  20973. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  20974. /**
  20975. * Manually render a set of post processes to a texture.
  20976. * @param postProcesses An array of post processes to be run.
  20977. * @param targetTexture The target texture to render to.
  20978. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  20979. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  20980. * @param lodLevel defines which lod of the texture to render to
  20981. */
  20982. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  20983. /**
  20984. * Finalize the result of the output of the postprocesses.
  20985. * @param doNotPresent If true the result will not be displayed to the screen.
  20986. * @param targetTexture The target texture to render to.
  20987. * @param faceIndex The index of the face to bind the target texture to.
  20988. * @param postProcesses The array of post processes to render.
  20989. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  20990. * @hidden
  20991. */
  20992. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  20993. /**
  20994. * Disposes of the post process manager.
  20995. */
  20996. dispose(): void;
  20997. }
  20998. }
  20999. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  21000. import { Observable } from "babylonjs/Misc/observable";
  21001. import { SmartArray } from "babylonjs/Misc/smartArray";
  21002. import { Nullable, Immutable } from "babylonjs/types";
  21003. import { Camera } from "babylonjs/Cameras/camera";
  21004. import { Scene } from "babylonjs/scene";
  21005. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21006. import { Color4 } from "babylonjs/Maths/math.color";
  21007. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  21008. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21009. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21010. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  21011. import { Texture } from "babylonjs/Materials/Textures/texture";
  21012. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  21013. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  21014. import "babylonjs/Engines/Extensions/engine.renderTarget";
  21015. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  21016. import { Engine } from "babylonjs/Engines/engine";
  21017. /**
  21018. * This Helps creating a texture that will be created from a camera in your scene.
  21019. * It is basically a dynamic texture that could be used to create special effects for instance.
  21020. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  21021. */
  21022. export class RenderTargetTexture extends Texture {
  21023. isCube: boolean;
  21024. /**
  21025. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  21026. */
  21027. static readonly REFRESHRATE_RENDER_ONCE: number;
  21028. /**
  21029. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  21030. */
  21031. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21032. /**
  21033. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  21034. * the central point of your effect and can save a lot of performances.
  21035. */
  21036. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21037. /**
  21038. * Use this predicate to dynamically define the list of mesh you want to render.
  21039. * If set, the renderList property will be overwritten.
  21040. */
  21041. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21042. private _renderList;
  21043. /**
  21044. * Use this list to define the list of mesh you want to render.
  21045. */
  21046. get renderList(): Nullable<Array<AbstractMesh>>;
  21047. set renderList(value: Nullable<Array<AbstractMesh>>);
  21048. /**
  21049. * Use this function to overload the renderList array at rendering time.
  21050. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  21051. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  21052. * the cube (if the RTT is a cube, else layerOrFace=0).
  21053. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  21054. */
  21055. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  21056. private _hookArray;
  21057. /**
  21058. * Define if particles should be rendered in your texture.
  21059. */
  21060. renderParticles: boolean;
  21061. /**
  21062. * Define if sprites should be rendered in your texture.
  21063. */
  21064. renderSprites: boolean;
  21065. /**
  21066. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  21067. */
  21068. coordinatesMode: number;
  21069. /**
  21070. * Define the camera used to render the texture.
  21071. */
  21072. activeCamera: Nullable<Camera>;
  21073. /**
  21074. * Override the render function of the texture with your own one.
  21075. */
  21076. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21077. /**
  21078. * Define if camera post processes should be use while rendering the texture.
  21079. */
  21080. useCameraPostProcesses: boolean;
  21081. /**
  21082. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  21083. */
  21084. ignoreCameraViewport: boolean;
  21085. private _postProcessManager;
  21086. private _postProcesses;
  21087. private _resizeObserver;
  21088. /**
  21089. * An event triggered when the texture is unbind.
  21090. */
  21091. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21092. /**
  21093. * An event triggered when the texture is unbind.
  21094. */
  21095. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21096. private _onAfterUnbindObserver;
  21097. /**
  21098. * Set a after unbind callback in the texture.
  21099. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  21100. */
  21101. set onAfterUnbind(callback: () => void);
  21102. /**
  21103. * An event triggered before rendering the texture
  21104. */
  21105. onBeforeRenderObservable: Observable<number>;
  21106. private _onBeforeRenderObserver;
  21107. /**
  21108. * Set a before render callback in the texture.
  21109. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  21110. */
  21111. set onBeforeRender(callback: (faceIndex: number) => void);
  21112. /**
  21113. * An event triggered after rendering the texture
  21114. */
  21115. onAfterRenderObservable: Observable<number>;
  21116. private _onAfterRenderObserver;
  21117. /**
  21118. * Set a after render callback in the texture.
  21119. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  21120. */
  21121. set onAfterRender(callback: (faceIndex: number) => void);
  21122. /**
  21123. * An event triggered after the texture clear
  21124. */
  21125. onClearObservable: Observable<Engine>;
  21126. private _onClearObserver;
  21127. /**
  21128. * Set a clear callback in the texture.
  21129. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  21130. */
  21131. set onClear(callback: (Engine: Engine) => void);
  21132. /**
  21133. * An event triggered when the texture is resized.
  21134. */
  21135. onResizeObservable: Observable<RenderTargetTexture>;
  21136. /**
  21137. * Define the clear color of the Render Target if it should be different from the scene.
  21138. */
  21139. clearColor: Color4;
  21140. protected _size: number | {
  21141. width: number;
  21142. height: number;
  21143. layers?: number;
  21144. };
  21145. protected _initialSizeParameter: number | {
  21146. width: number;
  21147. height: number;
  21148. } | {
  21149. ratio: number;
  21150. };
  21151. protected _sizeRatio: Nullable<number>;
  21152. /** @hidden */
  21153. _generateMipMaps: boolean;
  21154. protected _renderingManager: RenderingManager;
  21155. /** @hidden */
  21156. _waitingRenderList: string[];
  21157. protected _doNotChangeAspectRatio: boolean;
  21158. protected _currentRefreshId: number;
  21159. protected _refreshRate: number;
  21160. protected _textureMatrix: Matrix;
  21161. protected _samples: number;
  21162. protected _renderTargetOptions: RenderTargetCreationOptions;
  21163. /**
  21164. * Gets render target creation options that were used.
  21165. */
  21166. get renderTargetOptions(): RenderTargetCreationOptions;
  21167. protected _engine: Engine;
  21168. protected _onRatioRescale(): void;
  21169. /**
  21170. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  21171. * It must define where the camera used to render the texture is set
  21172. */
  21173. boundingBoxPosition: Vector3;
  21174. private _boundingBoxSize;
  21175. /**
  21176. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  21177. * When defined, the cubemap will switch to local mode
  21178. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  21179. * @example https://www.babylonjs-playground.com/#RNASML
  21180. */
  21181. set boundingBoxSize(value: Vector3);
  21182. get boundingBoxSize(): Vector3;
  21183. /**
  21184. * In case the RTT has been created with a depth texture, get the associated
  21185. * depth texture.
  21186. * Otherwise, return null.
  21187. */
  21188. get depthStencilTexture(): Nullable<InternalTexture>;
  21189. /**
  21190. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  21191. * or used a shadow, depth texture...
  21192. * @param name The friendly name of the texture
  21193. * @param size The size of the RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  21194. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  21195. * @param generateMipMaps True if mip maps need to be generated after render.
  21196. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  21197. * @param type The type of the buffer in the RTT (int, half float, float...)
  21198. * @param isCube True if a cube texture needs to be created
  21199. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  21200. * @param generateDepthBuffer True to generate a depth buffer
  21201. * @param generateStencilBuffer True to generate a stencil buffer
  21202. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  21203. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  21204. * @param delayAllocation if the texture allocation should be delayed (default: false)
  21205. */
  21206. constructor(name: string, size: number | {
  21207. width: number;
  21208. height: number;
  21209. layers?: number;
  21210. } | {
  21211. ratio: number;
  21212. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  21213. /**
  21214. * Creates a depth stencil texture.
  21215. * This is only available in WebGL 2 or with the depth texture extension available.
  21216. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  21217. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  21218. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  21219. */
  21220. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  21221. private _processSizeParameter;
  21222. /**
  21223. * Define the number of samples to use in case of MSAA.
  21224. * It defaults to one meaning no MSAA has been enabled.
  21225. */
  21226. get samples(): number;
  21227. set samples(value: number);
  21228. /**
  21229. * Resets the refresh counter of the texture and start bak from scratch.
  21230. * Could be useful to regenerate the texture if it is setup to render only once.
  21231. */
  21232. resetRefreshCounter(): void;
  21233. /**
  21234. * Define the refresh rate of the texture or the rendering frequency.
  21235. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  21236. */
  21237. get refreshRate(): number;
  21238. set refreshRate(value: number);
  21239. /**
  21240. * Adds a post process to the render target rendering passes.
  21241. * @param postProcess define the post process to add
  21242. */
  21243. addPostProcess(postProcess: PostProcess): void;
  21244. /**
  21245. * Clear all the post processes attached to the render target
  21246. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  21247. */
  21248. clearPostProcesses(dispose?: boolean): void;
  21249. /**
  21250. * Remove one of the post process from the list of attached post processes to the texture
  21251. * @param postProcess define the post process to remove from the list
  21252. */
  21253. removePostProcess(postProcess: PostProcess): void;
  21254. /** @hidden */
  21255. _shouldRender(): boolean;
  21256. /**
  21257. * Gets the actual render size of the texture.
  21258. * @returns the width of the render size
  21259. */
  21260. getRenderSize(): number;
  21261. /**
  21262. * Gets the actual render width of the texture.
  21263. * @returns the width of the render size
  21264. */
  21265. getRenderWidth(): number;
  21266. /**
  21267. * Gets the actual render height of the texture.
  21268. * @returns the height of the render size
  21269. */
  21270. getRenderHeight(): number;
  21271. /**
  21272. * Gets the actual number of layers of the texture.
  21273. * @returns the number of layers
  21274. */
  21275. getRenderLayers(): number;
  21276. /**
  21277. * Get if the texture can be rescaled or not.
  21278. */
  21279. get canRescale(): boolean;
  21280. /**
  21281. * Resize the texture using a ratio.
  21282. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  21283. */
  21284. scale(ratio: number): void;
  21285. /**
  21286. * Get the texture reflection matrix used to rotate/transform the reflection.
  21287. * @returns the reflection matrix
  21288. */
  21289. getReflectionTextureMatrix(): Matrix;
  21290. /**
  21291. * Resize the texture to a new desired size.
  21292. * Be carrefull as it will recreate all the data in the new texture.
  21293. * @param size Define the new size. It can be:
  21294. * - a number for squared texture,
  21295. * - an object containing { width: number, height: number }
  21296. * - or an object containing a ratio { ratio: number }
  21297. */
  21298. resize(size: number | {
  21299. width: number;
  21300. height: number;
  21301. } | {
  21302. ratio: number;
  21303. }): void;
  21304. private _defaultRenderListPrepared;
  21305. /**
  21306. * Renders all the objects from the render list into the texture.
  21307. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  21308. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  21309. */
  21310. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21311. private _bestReflectionRenderTargetDimension;
  21312. private _prepareRenderingManager;
  21313. /**
  21314. * @hidden
  21315. * @param faceIndex face index to bind to if this is a cubetexture
  21316. * @param layer defines the index of the texture to bind in the array
  21317. */
  21318. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  21319. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21320. private renderToTarget;
  21321. /**
  21322. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21323. * This allowed control for front to back rendering or reversly depending of the special needs.
  21324. *
  21325. * @param renderingGroupId The rendering group id corresponding to its index
  21326. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21327. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21328. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21329. */
  21330. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  21331. /**
  21332. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21333. *
  21334. * @param renderingGroupId The rendering group id corresponding to its index
  21335. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21336. */
  21337. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21338. /**
  21339. * Clones the texture.
  21340. * @returns the cloned texture
  21341. */
  21342. clone(): RenderTargetTexture;
  21343. /**
  21344. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  21345. * @returns The JSON representation of the texture
  21346. */
  21347. serialize(): any;
  21348. /**
  21349. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  21350. */
  21351. disposeFramebufferObjects(): void;
  21352. /**
  21353. * Dispose the texture and release its associated resources.
  21354. */
  21355. dispose(): void;
  21356. /** @hidden */
  21357. _rebuild(): void;
  21358. /**
  21359. * Clear the info related to rendering groups preventing retention point in material dispose.
  21360. */
  21361. freeRenderingGroups(): void;
  21362. /**
  21363. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  21364. * @returns the view count
  21365. */
  21366. getViewCount(): number;
  21367. }
  21368. }
  21369. declare module "babylonjs/Materials/material" {
  21370. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  21371. import { SmartArray } from "babylonjs/Misc/smartArray";
  21372. import { Observable } from "babylonjs/Misc/observable";
  21373. import { Nullable } from "babylonjs/types";
  21374. import { Scene } from "babylonjs/scene";
  21375. import { Matrix } from "babylonjs/Maths/math.vector";
  21376. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  21377. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21378. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  21379. import { Effect } from "babylonjs/Materials/effect";
  21380. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21381. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  21382. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21383. import { IInspectable } from "babylonjs/Misc/iInspectable";
  21384. import { Mesh } from "babylonjs/Meshes/mesh";
  21385. import { Animation } from "babylonjs/Animations/animation";
  21386. /**
  21387. * Options for compiling materials.
  21388. */
  21389. export interface IMaterialCompilationOptions {
  21390. /**
  21391. * Defines whether clip planes are enabled.
  21392. */
  21393. clipPlane: boolean;
  21394. /**
  21395. * Defines whether instances are enabled.
  21396. */
  21397. useInstances: boolean;
  21398. }
  21399. /**
  21400. * Base class for the main features of a material in Babylon.js
  21401. */
  21402. export class Material implements IAnimatable {
  21403. /**
  21404. * Returns the triangle fill mode
  21405. */
  21406. static readonly TriangleFillMode: number;
  21407. /**
  21408. * Returns the wireframe mode
  21409. */
  21410. static readonly WireFrameFillMode: number;
  21411. /**
  21412. * Returns the point fill mode
  21413. */
  21414. static readonly PointFillMode: number;
  21415. /**
  21416. * Returns the point list draw mode
  21417. */
  21418. static readonly PointListDrawMode: number;
  21419. /**
  21420. * Returns the line list draw mode
  21421. */
  21422. static readonly LineListDrawMode: number;
  21423. /**
  21424. * Returns the line loop draw mode
  21425. */
  21426. static readonly LineLoopDrawMode: number;
  21427. /**
  21428. * Returns the line strip draw mode
  21429. */
  21430. static readonly LineStripDrawMode: number;
  21431. /**
  21432. * Returns the triangle strip draw mode
  21433. */
  21434. static readonly TriangleStripDrawMode: number;
  21435. /**
  21436. * Returns the triangle fan draw mode
  21437. */
  21438. static readonly TriangleFanDrawMode: number;
  21439. /**
  21440. * Stores the clock-wise side orientation
  21441. */
  21442. static readonly ClockWiseSideOrientation: number;
  21443. /**
  21444. * Stores the counter clock-wise side orientation
  21445. */
  21446. static readonly CounterClockWiseSideOrientation: number;
  21447. /**
  21448. * The dirty texture flag value
  21449. */
  21450. static readonly TextureDirtyFlag: number;
  21451. /**
  21452. * The dirty light flag value
  21453. */
  21454. static readonly LightDirtyFlag: number;
  21455. /**
  21456. * The dirty fresnel flag value
  21457. */
  21458. static readonly FresnelDirtyFlag: number;
  21459. /**
  21460. * The dirty attribute flag value
  21461. */
  21462. static readonly AttributesDirtyFlag: number;
  21463. /**
  21464. * The dirty misc flag value
  21465. */
  21466. static readonly MiscDirtyFlag: number;
  21467. /**
  21468. * The all dirty flag value
  21469. */
  21470. static readonly AllDirtyFlag: number;
  21471. /**
  21472. * The ID of the material
  21473. */
  21474. id: string;
  21475. /**
  21476. * Gets or sets the unique id of the material
  21477. */
  21478. uniqueId: number;
  21479. /**
  21480. * The name of the material
  21481. */
  21482. name: string;
  21483. /**
  21484. * Gets or sets user defined metadata
  21485. */
  21486. metadata: any;
  21487. /**
  21488. * For internal use only. Please do not use.
  21489. */
  21490. reservedDataStore: any;
  21491. /**
  21492. * Specifies if the ready state should be checked on each call
  21493. */
  21494. checkReadyOnEveryCall: boolean;
  21495. /**
  21496. * Specifies if the ready state should be checked once
  21497. */
  21498. checkReadyOnlyOnce: boolean;
  21499. /**
  21500. * The state of the material
  21501. */
  21502. state: string;
  21503. /**
  21504. * The alpha value of the material
  21505. */
  21506. protected _alpha: number;
  21507. /**
  21508. * List of inspectable custom properties (used by the Inspector)
  21509. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  21510. */
  21511. inspectableCustomProperties: IInspectable[];
  21512. /**
  21513. * Sets the alpha value of the material
  21514. */
  21515. set alpha(value: number);
  21516. /**
  21517. * Gets the alpha value of the material
  21518. */
  21519. get alpha(): number;
  21520. /**
  21521. * Specifies if back face culling is enabled
  21522. */
  21523. protected _backFaceCulling: boolean;
  21524. /**
  21525. * Sets the back-face culling state
  21526. */
  21527. set backFaceCulling(value: boolean);
  21528. /**
  21529. * Gets the back-face culling state
  21530. */
  21531. get backFaceCulling(): boolean;
  21532. /**
  21533. * Stores the value for side orientation
  21534. */
  21535. sideOrientation: number;
  21536. /**
  21537. * Callback triggered when the material is compiled
  21538. */
  21539. onCompiled: Nullable<(effect: Effect) => void>;
  21540. /**
  21541. * Callback triggered when an error occurs
  21542. */
  21543. onError: Nullable<(effect: Effect, errors: string) => void>;
  21544. /**
  21545. * Callback triggered to get the render target textures
  21546. */
  21547. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  21548. /**
  21549. * Gets a boolean indicating that current material needs to register RTT
  21550. */
  21551. get hasRenderTargetTextures(): boolean;
  21552. /**
  21553. * Specifies if the material should be serialized
  21554. */
  21555. doNotSerialize: boolean;
  21556. /**
  21557. * @hidden
  21558. */
  21559. _storeEffectOnSubMeshes: boolean;
  21560. /**
  21561. * Stores the animations for the material
  21562. */
  21563. animations: Nullable<Array<Animation>>;
  21564. /**
  21565. * An event triggered when the material is disposed
  21566. */
  21567. onDisposeObservable: Observable<Material>;
  21568. /**
  21569. * An observer which watches for dispose events
  21570. */
  21571. private _onDisposeObserver;
  21572. private _onUnBindObservable;
  21573. /**
  21574. * Called during a dispose event
  21575. */
  21576. set onDispose(callback: () => void);
  21577. private _onBindObservable;
  21578. /**
  21579. * An event triggered when the material is bound
  21580. */
  21581. get onBindObservable(): Observable<AbstractMesh>;
  21582. /**
  21583. * An observer which watches for bind events
  21584. */
  21585. private _onBindObserver;
  21586. /**
  21587. * Called during a bind event
  21588. */
  21589. set onBind(callback: (Mesh: AbstractMesh) => void);
  21590. /**
  21591. * An event triggered when the material is unbound
  21592. */
  21593. get onUnBindObservable(): Observable<Material>;
  21594. /**
  21595. * Stores the value of the alpha mode
  21596. */
  21597. private _alphaMode;
  21598. /**
  21599. * Sets the value of the alpha mode.
  21600. *
  21601. * | Value | Type | Description |
  21602. * | --- | --- | --- |
  21603. * | 0 | ALPHA_DISABLE | |
  21604. * | 1 | ALPHA_ADD | |
  21605. * | 2 | ALPHA_COMBINE | |
  21606. * | 3 | ALPHA_SUBTRACT | |
  21607. * | 4 | ALPHA_MULTIPLY | |
  21608. * | 5 | ALPHA_MAXIMIZED | |
  21609. * | 6 | ALPHA_ONEONE | |
  21610. * | 7 | ALPHA_PREMULTIPLIED | |
  21611. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21612. * | 9 | ALPHA_INTERPOLATE | |
  21613. * | 10 | ALPHA_SCREENMODE | |
  21614. *
  21615. */
  21616. set alphaMode(value: number);
  21617. /**
  21618. * Gets the value of the alpha mode
  21619. */
  21620. get alphaMode(): number;
  21621. /**
  21622. * Stores the state of the need depth pre-pass value
  21623. */
  21624. private _needDepthPrePass;
  21625. /**
  21626. * Sets the need depth pre-pass value
  21627. */
  21628. set needDepthPrePass(value: boolean);
  21629. /**
  21630. * Gets the depth pre-pass value
  21631. */
  21632. get needDepthPrePass(): boolean;
  21633. /**
  21634. * Specifies if depth writing should be disabled
  21635. */
  21636. disableDepthWrite: boolean;
  21637. /**
  21638. * Specifies if depth writing should be forced
  21639. */
  21640. forceDepthWrite: boolean;
  21641. /**
  21642. * Specifies the depth function that should be used. 0 means the default engine function
  21643. */
  21644. depthFunction: number;
  21645. /**
  21646. * Specifies if there should be a separate pass for culling
  21647. */
  21648. separateCullingPass: boolean;
  21649. /**
  21650. * Stores the state specifing if fog should be enabled
  21651. */
  21652. private _fogEnabled;
  21653. /**
  21654. * Sets the state for enabling fog
  21655. */
  21656. set fogEnabled(value: boolean);
  21657. /**
  21658. * Gets the value of the fog enabled state
  21659. */
  21660. get fogEnabled(): boolean;
  21661. /**
  21662. * Stores the size of points
  21663. */
  21664. pointSize: number;
  21665. /**
  21666. * Stores the z offset value
  21667. */
  21668. zOffset: number;
  21669. /**
  21670. * Gets a value specifying if wireframe mode is enabled
  21671. */
  21672. get wireframe(): boolean;
  21673. /**
  21674. * Sets the state of wireframe mode
  21675. */
  21676. set wireframe(value: boolean);
  21677. /**
  21678. * Gets the value specifying if point clouds are enabled
  21679. */
  21680. get pointsCloud(): boolean;
  21681. /**
  21682. * Sets the state of point cloud mode
  21683. */
  21684. set pointsCloud(value: boolean);
  21685. /**
  21686. * Gets the material fill mode
  21687. */
  21688. get fillMode(): number;
  21689. /**
  21690. * Sets the material fill mode
  21691. */
  21692. set fillMode(value: number);
  21693. /**
  21694. * @hidden
  21695. * Stores the effects for the material
  21696. */
  21697. _effect: Nullable<Effect>;
  21698. /**
  21699. * Specifies if uniform buffers should be used
  21700. */
  21701. private _useUBO;
  21702. /**
  21703. * Stores a reference to the scene
  21704. */
  21705. private _scene;
  21706. /**
  21707. * Stores the fill mode state
  21708. */
  21709. private _fillMode;
  21710. /**
  21711. * Specifies if the depth write state should be cached
  21712. */
  21713. private _cachedDepthWriteState;
  21714. /**
  21715. * Specifies if the depth function state should be cached
  21716. */
  21717. private _cachedDepthFunctionState;
  21718. /**
  21719. * Stores the uniform buffer
  21720. */
  21721. protected _uniformBuffer: UniformBuffer;
  21722. /** @hidden */
  21723. _indexInSceneMaterialArray: number;
  21724. /** @hidden */
  21725. meshMap: Nullable<{
  21726. [id: string]: AbstractMesh | undefined;
  21727. }>;
  21728. /**
  21729. * Creates a material instance
  21730. * @param name defines the name of the material
  21731. * @param scene defines the scene to reference
  21732. * @param doNotAdd specifies if the material should be added to the scene
  21733. */
  21734. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21735. /**
  21736. * Returns a string representation of the current material
  21737. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21738. * @returns a string with material information
  21739. */
  21740. toString(fullDetails?: boolean): string;
  21741. /**
  21742. * Gets the class name of the material
  21743. * @returns a string with the class name of the material
  21744. */
  21745. getClassName(): string;
  21746. /**
  21747. * Specifies if updates for the material been locked
  21748. */
  21749. get isFrozen(): boolean;
  21750. /**
  21751. * Locks updates for the material
  21752. */
  21753. freeze(): void;
  21754. /**
  21755. * Unlocks updates for the material
  21756. */
  21757. unfreeze(): void;
  21758. /**
  21759. * Specifies if the material is ready to be used
  21760. * @param mesh defines the mesh to check
  21761. * @param useInstances specifies if instances should be used
  21762. * @returns a boolean indicating if the material is ready to be used
  21763. */
  21764. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21765. /**
  21766. * Specifies that the submesh is ready to be used
  21767. * @param mesh defines the mesh to check
  21768. * @param subMesh defines which submesh to check
  21769. * @param useInstances specifies that instances should be used
  21770. * @returns a boolean indicating that the submesh is ready or not
  21771. */
  21772. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21773. /**
  21774. * Returns the material effect
  21775. * @returns the effect associated with the material
  21776. */
  21777. getEffect(): Nullable<Effect>;
  21778. /**
  21779. * Returns the current scene
  21780. * @returns a Scene
  21781. */
  21782. getScene(): Scene;
  21783. /**
  21784. * Specifies if the material will require alpha blending
  21785. * @returns a boolean specifying if alpha blending is needed
  21786. */
  21787. needAlphaBlending(): boolean;
  21788. /**
  21789. * Specifies if the mesh will require alpha blending
  21790. * @param mesh defines the mesh to check
  21791. * @returns a boolean specifying if alpha blending is needed for the mesh
  21792. */
  21793. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21794. /**
  21795. * Specifies if this material should be rendered in alpha test mode
  21796. * @returns a boolean specifying if an alpha test is needed.
  21797. */
  21798. needAlphaTesting(): boolean;
  21799. /**
  21800. * Gets the texture used for the alpha test
  21801. * @returns the texture to use for alpha testing
  21802. */
  21803. getAlphaTestTexture(): Nullable<BaseTexture>;
  21804. /**
  21805. * Marks the material to indicate that it needs to be re-calculated
  21806. */
  21807. markDirty(): void;
  21808. /** @hidden */
  21809. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21810. /**
  21811. * Binds the material to the mesh
  21812. * @param world defines the world transformation matrix
  21813. * @param mesh defines the mesh to bind the material to
  21814. */
  21815. bind(world: Matrix, mesh?: Mesh): void;
  21816. /**
  21817. * Binds the submesh to the material
  21818. * @param world defines the world transformation matrix
  21819. * @param mesh defines the mesh containing the submesh
  21820. * @param subMesh defines the submesh to bind the material to
  21821. */
  21822. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21823. /**
  21824. * Binds the world matrix to the material
  21825. * @param world defines the world transformation matrix
  21826. */
  21827. bindOnlyWorldMatrix(world: Matrix): void;
  21828. /**
  21829. * Binds the scene's uniform buffer to the effect.
  21830. * @param effect defines the effect to bind to the scene uniform buffer
  21831. * @param sceneUbo defines the uniform buffer storing scene data
  21832. */
  21833. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21834. /**
  21835. * Binds the view matrix to the effect
  21836. * @param effect defines the effect to bind the view matrix to
  21837. */
  21838. bindView(effect: Effect): void;
  21839. /**
  21840. * Binds the view projection matrix to the effect
  21841. * @param effect defines the effect to bind the view projection matrix to
  21842. */
  21843. bindViewProjection(effect: Effect): void;
  21844. /**
  21845. * Specifies if material alpha testing should be turned on for the mesh
  21846. * @param mesh defines the mesh to check
  21847. */
  21848. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21849. /**
  21850. * Processes to execute after binding the material to a mesh
  21851. * @param mesh defines the rendered mesh
  21852. */
  21853. protected _afterBind(mesh?: Mesh): void;
  21854. /**
  21855. * Unbinds the material from the mesh
  21856. */
  21857. unbind(): void;
  21858. /**
  21859. * Gets the active textures from the material
  21860. * @returns an array of textures
  21861. */
  21862. getActiveTextures(): BaseTexture[];
  21863. /**
  21864. * Specifies if the material uses a texture
  21865. * @param texture defines the texture to check against the material
  21866. * @returns a boolean specifying if the material uses the texture
  21867. */
  21868. hasTexture(texture: BaseTexture): boolean;
  21869. /**
  21870. * Makes a duplicate of the material, and gives it a new name
  21871. * @param name defines the new name for the duplicated material
  21872. * @returns the cloned material
  21873. */
  21874. clone(name: string): Nullable<Material>;
  21875. /**
  21876. * Gets the meshes bound to the material
  21877. * @returns an array of meshes bound to the material
  21878. */
  21879. getBindedMeshes(): AbstractMesh[];
  21880. /**
  21881. * Force shader compilation
  21882. * @param mesh defines the mesh associated with this material
  21883. * @param onCompiled defines a function to execute once the material is compiled
  21884. * @param options defines the options to configure the compilation
  21885. * @param onError defines a function to execute if the material fails compiling
  21886. */
  21887. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  21888. /**
  21889. * Force shader compilation
  21890. * @param mesh defines the mesh that will use this material
  21891. * @param options defines additional options for compiling the shaders
  21892. * @returns a promise that resolves when the compilation completes
  21893. */
  21894. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  21895. private static readonly _AllDirtyCallBack;
  21896. private static readonly _ImageProcessingDirtyCallBack;
  21897. private static readonly _TextureDirtyCallBack;
  21898. private static readonly _FresnelDirtyCallBack;
  21899. private static readonly _MiscDirtyCallBack;
  21900. private static readonly _LightsDirtyCallBack;
  21901. private static readonly _AttributeDirtyCallBack;
  21902. private static _FresnelAndMiscDirtyCallBack;
  21903. private static _TextureAndMiscDirtyCallBack;
  21904. private static readonly _DirtyCallbackArray;
  21905. private static readonly _RunDirtyCallBacks;
  21906. /**
  21907. * Marks a define in the material to indicate that it needs to be re-computed
  21908. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21909. */
  21910. markAsDirty(flag: number): void;
  21911. /**
  21912. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21913. * @param func defines a function which checks material defines against the submeshes
  21914. */
  21915. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21916. /**
  21917. * Indicates that we need to re-calculated for all submeshes
  21918. */
  21919. protected _markAllSubMeshesAsAllDirty(): void;
  21920. /**
  21921. * Indicates that image processing needs to be re-calculated for all submeshes
  21922. */
  21923. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21924. /**
  21925. * Indicates that textures need to be re-calculated for all submeshes
  21926. */
  21927. protected _markAllSubMeshesAsTexturesDirty(): void;
  21928. /**
  21929. * Indicates that fresnel needs to be re-calculated for all submeshes
  21930. */
  21931. protected _markAllSubMeshesAsFresnelDirty(): void;
  21932. /**
  21933. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21934. */
  21935. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21936. /**
  21937. * Indicates that lights need to be re-calculated for all submeshes
  21938. */
  21939. protected _markAllSubMeshesAsLightsDirty(): void;
  21940. /**
  21941. * Indicates that attributes need to be re-calculated for all submeshes
  21942. */
  21943. protected _markAllSubMeshesAsAttributesDirty(): void;
  21944. /**
  21945. * Indicates that misc needs to be re-calculated for all submeshes
  21946. */
  21947. protected _markAllSubMeshesAsMiscDirty(): void;
  21948. /**
  21949. * Indicates that textures and misc need to be re-calculated for all submeshes
  21950. */
  21951. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21952. /**
  21953. * Disposes the material
  21954. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21955. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21956. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21957. */
  21958. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21959. /** @hidden */
  21960. private releaseVertexArrayObject;
  21961. /**
  21962. * Serializes this material
  21963. * @returns the serialized material object
  21964. */
  21965. serialize(): any;
  21966. /**
  21967. * Creates a material from parsed material data
  21968. * @param parsedMaterial defines parsed material data
  21969. * @param scene defines the hosting scene
  21970. * @param rootUrl defines the root URL to use to load textures
  21971. * @returns a new material
  21972. */
  21973. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21974. }
  21975. }
  21976. declare module "babylonjs/Materials/multiMaterial" {
  21977. import { Nullable } from "babylonjs/types";
  21978. import { Scene } from "babylonjs/scene";
  21979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21980. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21981. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21982. import { Material } from "babylonjs/Materials/material";
  21983. /**
  21984. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21985. * separate meshes. This can be use to improve performances.
  21986. * @see http://doc.babylonjs.com/how_to/multi_materials
  21987. */
  21988. export class MultiMaterial extends Material {
  21989. private _subMaterials;
  21990. /**
  21991. * Gets or Sets the list of Materials used within the multi material.
  21992. * They need to be ordered according to the submeshes order in the associated mesh
  21993. */
  21994. get subMaterials(): Nullable<Material>[];
  21995. set subMaterials(value: Nullable<Material>[]);
  21996. /**
  21997. * Function used to align with Node.getChildren()
  21998. * @returns the list of Materials used within the multi material
  21999. */
  22000. getChildren(): Nullable<Material>[];
  22001. /**
  22002. * Instantiates a new Multi Material
  22003. * A multi-material is used to apply different materials to different parts of the same object without the need of
  22004. * separate meshes. This can be use to improve performances.
  22005. * @see http://doc.babylonjs.com/how_to/multi_materials
  22006. * @param name Define the name in the scene
  22007. * @param scene Define the scene the material belongs to
  22008. */
  22009. constructor(name: string, scene: Scene);
  22010. private _hookArray;
  22011. /**
  22012. * Get one of the submaterial by its index in the submaterials array
  22013. * @param index The index to look the sub material at
  22014. * @returns The Material if the index has been defined
  22015. */
  22016. getSubMaterial(index: number): Nullable<Material>;
  22017. /**
  22018. * Get the list of active textures for the whole sub materials list.
  22019. * @returns All the textures that will be used during the rendering
  22020. */
  22021. getActiveTextures(): BaseTexture[];
  22022. /**
  22023. * Gets the current class name of the material e.g. "MultiMaterial"
  22024. * Mainly use in serialization.
  22025. * @returns the class name
  22026. */
  22027. getClassName(): string;
  22028. /**
  22029. * Checks if the material is ready to render the requested sub mesh
  22030. * @param mesh Define the mesh the submesh belongs to
  22031. * @param subMesh Define the sub mesh to look readyness for
  22032. * @param useInstances Define whether or not the material is used with instances
  22033. * @returns true if ready, otherwise false
  22034. */
  22035. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22036. /**
  22037. * Clones the current material and its related sub materials
  22038. * @param name Define the name of the newly cloned material
  22039. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  22040. * @returns the cloned material
  22041. */
  22042. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  22043. /**
  22044. * Serializes the materials into a JSON representation.
  22045. * @returns the JSON representation
  22046. */
  22047. serialize(): any;
  22048. /**
  22049. * Dispose the material and release its associated resources
  22050. * @param forceDisposeEffect Define if we want to force disposing the associated effect (if false the shader is not released and could be reuse later on)
  22051. * @param forceDisposeTextures Define if we want to force disposing the associated textures (if false, they will not be disposed and can still be use elsewhere in the app)
  22052. * @param forceDisposeChildren Define if we want to force disposing the associated submaterials (if false, they will not be disposed and can still be use elsewhere in the app)
  22053. */
  22054. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  22055. /**
  22056. * Creates a MultiMaterial from parsed MultiMaterial data.
  22057. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  22058. * @param scene defines the hosting scene
  22059. * @returns a new MultiMaterial
  22060. */
  22061. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  22062. }
  22063. }
  22064. declare module "babylonjs/Meshes/subMesh" {
  22065. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  22066. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  22067. import { Engine } from "babylonjs/Engines/engine";
  22068. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22069. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22070. import { Effect } from "babylonjs/Materials/effect";
  22071. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22072. import { Plane } from "babylonjs/Maths/math.plane";
  22073. import { Collider } from "babylonjs/Collisions/collider";
  22074. import { Material } from "babylonjs/Materials/material";
  22075. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22076. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22077. import { Mesh } from "babylonjs/Meshes/mesh";
  22078. import { Ray } from "babylonjs/Culling/ray";
  22079. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22080. /**
  22081. * Base class for submeshes
  22082. */
  22083. export class BaseSubMesh {
  22084. /** @hidden */
  22085. _materialDefines: Nullable<MaterialDefines>;
  22086. /** @hidden */
  22087. _materialEffect: Nullable<Effect>;
  22088. /**
  22089. * Gets material defines used by the effect associated to the sub mesh
  22090. */
  22091. get materialDefines(): Nullable<MaterialDefines>;
  22092. /**
  22093. * Sets material defines used by the effect associated to the sub mesh
  22094. */
  22095. set materialDefines(defines: Nullable<MaterialDefines>);
  22096. /**
  22097. * Gets associated effect
  22098. */
  22099. get effect(): Nullable<Effect>;
  22100. /**
  22101. * Sets associated effect (effect used to render this submesh)
  22102. * @param effect defines the effect to associate with
  22103. * @param defines defines the set of defines used to compile this effect
  22104. */
  22105. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22106. }
  22107. /**
  22108. * Defines a subdivision inside a mesh
  22109. */
  22110. export class SubMesh extends BaseSubMesh implements ICullable {
  22111. /** the material index to use */
  22112. materialIndex: number;
  22113. /** vertex index start */
  22114. verticesStart: number;
  22115. /** vertices count */
  22116. verticesCount: number;
  22117. /** index start */
  22118. indexStart: number;
  22119. /** indices count */
  22120. indexCount: number;
  22121. /** @hidden */
  22122. _linesIndexCount: number;
  22123. private _mesh;
  22124. private _renderingMesh;
  22125. private _boundingInfo;
  22126. private _linesIndexBuffer;
  22127. /** @hidden */
  22128. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22129. /** @hidden */
  22130. _trianglePlanes: Plane[];
  22131. /** @hidden */
  22132. _lastColliderTransformMatrix: Nullable<Matrix>;
  22133. /** @hidden */
  22134. _renderId: number;
  22135. /** @hidden */
  22136. _alphaIndex: number;
  22137. /** @hidden */
  22138. _distanceToCamera: number;
  22139. /** @hidden */
  22140. _id: number;
  22141. private _currentMaterial;
  22142. /**
  22143. * Add a new submesh to a mesh
  22144. * @param materialIndex defines the material index to use
  22145. * @param verticesStart defines vertex index start
  22146. * @param verticesCount defines vertices count
  22147. * @param indexStart defines index start
  22148. * @param indexCount defines indices count
  22149. * @param mesh defines the parent mesh
  22150. * @param renderingMesh defines an optional rendering mesh
  22151. * @param createBoundingBox defines if bounding box should be created for this submesh
  22152. * @returns the new submesh
  22153. */
  22154. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22155. /**
  22156. * Creates a new submesh
  22157. * @param materialIndex defines the material index to use
  22158. * @param verticesStart defines vertex index start
  22159. * @param verticesCount defines vertices count
  22160. * @param indexStart defines index start
  22161. * @param indexCount defines indices count
  22162. * @param mesh defines the parent mesh
  22163. * @param renderingMesh defines an optional rendering mesh
  22164. * @param createBoundingBox defines if bounding box should be created for this submesh
  22165. */
  22166. constructor(
  22167. /** the material index to use */
  22168. materialIndex: number,
  22169. /** vertex index start */
  22170. verticesStart: number,
  22171. /** vertices count */
  22172. verticesCount: number,
  22173. /** index start */
  22174. indexStart: number,
  22175. /** indices count */
  22176. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22177. /**
  22178. * Returns true if this submesh covers the entire parent mesh
  22179. * @ignorenaming
  22180. */
  22181. get IsGlobal(): boolean;
  22182. /**
  22183. * Returns the submesh BoudingInfo object
  22184. * @returns current bounding info (or mesh's one if the submesh is global)
  22185. */
  22186. getBoundingInfo(): BoundingInfo;
  22187. /**
  22188. * Sets the submesh BoundingInfo
  22189. * @param boundingInfo defines the new bounding info to use
  22190. * @returns the SubMesh
  22191. */
  22192. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22193. /**
  22194. * Returns the mesh of the current submesh
  22195. * @return the parent mesh
  22196. */
  22197. getMesh(): AbstractMesh;
  22198. /**
  22199. * Returns the rendering mesh of the submesh
  22200. * @returns the rendering mesh (could be different from parent mesh)
  22201. */
  22202. getRenderingMesh(): Mesh;
  22203. /**
  22204. * Returns the submesh material
  22205. * @returns null or the current material
  22206. */
  22207. getMaterial(): Nullable<Material>;
  22208. /**
  22209. * Sets a new updated BoundingInfo object to the submesh
  22210. * @param data defines an optional position array to use to determine the bounding info
  22211. * @returns the SubMesh
  22212. */
  22213. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  22214. /** @hidden */
  22215. _checkCollision(collider: Collider): boolean;
  22216. /**
  22217. * Updates the submesh BoundingInfo
  22218. * @param world defines the world matrix to use to update the bounding info
  22219. * @returns the submesh
  22220. */
  22221. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22222. /**
  22223. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22224. * @param frustumPlanes defines the frustum planes
  22225. * @returns true if the submesh is intersecting with the frustum
  22226. */
  22227. isInFrustum(frustumPlanes: Plane[]): boolean;
  22228. /**
  22229. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22230. * @param frustumPlanes defines the frustum planes
  22231. * @returns true if the submesh is inside the frustum
  22232. */
  22233. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22234. /**
  22235. * Renders the submesh
  22236. * @param enableAlphaMode defines if alpha needs to be used
  22237. * @returns the submesh
  22238. */
  22239. render(enableAlphaMode: boolean): SubMesh;
  22240. /**
  22241. * @hidden
  22242. */
  22243. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  22244. /**
  22245. * Checks if the submesh intersects with a ray
  22246. * @param ray defines the ray to test
  22247. * @returns true is the passed ray intersects the submesh bounding box
  22248. */
  22249. canIntersects(ray: Ray): boolean;
  22250. /**
  22251. * Intersects current submesh with a ray
  22252. * @param ray defines the ray to test
  22253. * @param positions defines mesh's positions array
  22254. * @param indices defines mesh's indices array
  22255. * @param fastCheck defines if only bounding info should be used
  22256. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  22257. * @returns intersection info or null if no intersection
  22258. */
  22259. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  22260. /** @hidden */
  22261. private _intersectLines;
  22262. /** @hidden */
  22263. private _intersectUnIndexedLines;
  22264. /** @hidden */
  22265. private _intersectTriangles;
  22266. /** @hidden */
  22267. private _intersectUnIndexedTriangles;
  22268. /** @hidden */
  22269. _rebuild(): void;
  22270. /**
  22271. * Creates a new submesh from the passed mesh
  22272. * @param newMesh defines the new hosting mesh
  22273. * @param newRenderingMesh defines an optional rendering mesh
  22274. * @returns the new submesh
  22275. */
  22276. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  22277. /**
  22278. * Release associated resources
  22279. */
  22280. dispose(): void;
  22281. /**
  22282. * Gets the class name
  22283. * @returns the string "SubMesh".
  22284. */
  22285. getClassName(): string;
  22286. /**
  22287. * Creates a new submesh from indices data
  22288. * @param materialIndex the index of the main mesh material
  22289. * @param startIndex the index where to start the copy in the mesh indices array
  22290. * @param indexCount the number of indices to copy then from the startIndex
  22291. * @param mesh the main mesh to create the submesh from
  22292. * @param renderingMesh the optional rendering mesh
  22293. * @returns a new submesh
  22294. */
  22295. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  22296. }
  22297. }
  22298. declare module "babylonjs/Loading/sceneLoaderFlags" {
  22299. /**
  22300. * Class used to represent data loading progression
  22301. */
  22302. export class SceneLoaderFlags {
  22303. private static _ForceFullSceneLoadingForIncremental;
  22304. private static _ShowLoadingScreen;
  22305. private static _CleanBoneMatrixWeights;
  22306. private static _loggingLevel;
  22307. /**
  22308. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  22309. */
  22310. static get ForceFullSceneLoadingForIncremental(): boolean;
  22311. static set ForceFullSceneLoadingForIncremental(value: boolean);
  22312. /**
  22313. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  22314. */
  22315. static get ShowLoadingScreen(): boolean;
  22316. static set ShowLoadingScreen(value: boolean);
  22317. /**
  22318. * Defines the current logging level (while loading the scene)
  22319. * @ignorenaming
  22320. */
  22321. static get loggingLevel(): number;
  22322. static set loggingLevel(value: number);
  22323. /**
  22324. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  22325. */
  22326. static get CleanBoneMatrixWeights(): boolean;
  22327. static set CleanBoneMatrixWeights(value: boolean);
  22328. }
  22329. }
  22330. declare module "babylonjs/Meshes/geometry" {
  22331. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  22332. import { Scene } from "babylonjs/scene";
  22333. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  22334. import { Engine } from "babylonjs/Engines/engine";
  22335. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  22336. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  22337. import { Effect } from "babylonjs/Materials/effect";
  22338. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22339. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  22340. import { Mesh } from "babylonjs/Meshes/mesh";
  22341. /**
  22342. * Class used to store geometry data (vertex buffers + index buffer)
  22343. */
  22344. export class Geometry implements IGetSetVerticesData {
  22345. /**
  22346. * Gets or sets the ID of the geometry
  22347. */
  22348. id: string;
  22349. /**
  22350. * Gets or sets the unique ID of the geometry
  22351. */
  22352. uniqueId: number;
  22353. /**
  22354. * Gets the delay loading state of the geometry (none by default which means not delayed)
  22355. */
  22356. delayLoadState: number;
  22357. /**
  22358. * Gets the file containing the data to load when running in delay load state
  22359. */
  22360. delayLoadingFile: Nullable<string>;
  22361. /**
  22362. * Callback called when the geometry is updated
  22363. */
  22364. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  22365. private _scene;
  22366. private _engine;
  22367. private _meshes;
  22368. private _totalVertices;
  22369. /** @hidden */
  22370. _indices: IndicesArray;
  22371. /** @hidden */
  22372. _vertexBuffers: {
  22373. [key: string]: VertexBuffer;
  22374. };
  22375. private _isDisposed;
  22376. private _extend;
  22377. private _boundingBias;
  22378. /** @hidden */
  22379. _delayInfo: Array<string>;
  22380. private _indexBuffer;
  22381. private _indexBufferIsUpdatable;
  22382. /** @hidden */
  22383. _boundingInfo: Nullable<BoundingInfo>;
  22384. /** @hidden */
  22385. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  22386. /** @hidden */
  22387. _softwareSkinningFrameId: number;
  22388. private _vertexArrayObjects;
  22389. private _updatable;
  22390. /** @hidden */
  22391. _positions: Nullable<Vector3[]>;
  22392. /**
  22393. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  22394. */
  22395. get boundingBias(): Vector2;
  22396. /**
  22397. * Gets or sets the Bias Vector to apply on the bounding elements (box/sphere), the max extend is computed as v += v * bias.x + bias.y, the min is computed as v -= v * bias.x + bias.y
  22398. */
  22399. set boundingBias(value: Vector2);
  22400. /**
  22401. * Static function used to attach a new empty geometry to a mesh
  22402. * @param mesh defines the mesh to attach the geometry to
  22403. * @returns the new Geometry
  22404. */
  22405. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  22406. /**
  22407. * Creates a new geometry
  22408. * @param id defines the unique ID
  22409. * @param scene defines the hosting scene
  22410. * @param vertexData defines the VertexData used to get geometry data
  22411. * @param updatable defines if geometry must be updatable (false by default)
  22412. * @param mesh defines the mesh that will be associated with the geometry
  22413. */
  22414. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  22415. /**
  22416. * Gets the current extend of the geometry
  22417. */
  22418. get extend(): {
  22419. minimum: Vector3;
  22420. maximum: Vector3;
  22421. };
  22422. /**
  22423. * Gets the hosting scene
  22424. * @returns the hosting Scene
  22425. */
  22426. getScene(): Scene;
  22427. /**
  22428. * Gets the hosting engine
  22429. * @returns the hosting Engine
  22430. */
  22431. getEngine(): Engine;
  22432. /**
  22433. * Defines if the geometry is ready to use
  22434. * @returns true if the geometry is ready to be used
  22435. */
  22436. isReady(): boolean;
  22437. /**
  22438. * Gets a value indicating that the geometry should not be serialized
  22439. */
  22440. get doNotSerialize(): boolean;
  22441. /** @hidden */
  22442. _rebuild(): void;
  22443. /**
  22444. * Affects all geometry data in one call
  22445. * @param vertexData defines the geometry data
  22446. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  22447. */
  22448. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  22449. /**
  22450. * Set specific vertex data
  22451. * @param kind defines the data kind (Position, normal, etc...)
  22452. * @param data defines the vertex data to use
  22453. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22454. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22455. */
  22456. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  22457. /**
  22458. * Removes a specific vertex data
  22459. * @param kind defines the data kind (Position, normal, etc...)
  22460. */
  22461. removeVerticesData(kind: string): void;
  22462. /**
  22463. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  22464. * @param buffer defines the vertex buffer to use
  22465. * @param totalVertices defines the total number of vertices for position kind (could be null)
  22466. */
  22467. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  22468. /**
  22469. * Update a specific vertex buffer
  22470. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  22471. * It will do nothing if the buffer is not updatable
  22472. * @param kind defines the data kind (Position, normal, etc...)
  22473. * @param data defines the data to use
  22474. * @param offset defines the offset in the target buffer where to store the data
  22475. * @param useBytes set to true if the offset is in bytes
  22476. */
  22477. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  22478. /**
  22479. * Update a specific vertex buffer
  22480. * This function will create a new buffer if the current one is not updatable
  22481. * @param kind defines the data kind (Position, normal, etc...)
  22482. * @param data defines the data to use
  22483. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  22484. */
  22485. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  22486. private _updateBoundingInfo;
  22487. /** @hidden */
  22488. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  22489. /**
  22490. * Gets total number of vertices
  22491. * @returns the total number of vertices
  22492. */
  22493. getTotalVertices(): number;
  22494. /**
  22495. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22496. * @param kind defines the data kind (Position, normal, etc...)
  22497. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22498. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22499. * @returns a float array containing vertex data
  22500. */
  22501. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22502. /**
  22503. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  22504. * @param kind defines the data kind (Position, normal, etc...)
  22505. * @returns true if the vertex buffer with the specified kind is updatable
  22506. */
  22507. isVertexBufferUpdatable(kind: string): boolean;
  22508. /**
  22509. * Gets a specific vertex buffer
  22510. * @param kind defines the data kind (Position, normal, etc...)
  22511. * @returns a VertexBuffer
  22512. */
  22513. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  22514. /**
  22515. * Returns all vertex buffers
  22516. * @return an object holding all vertex buffers indexed by kind
  22517. */
  22518. getVertexBuffers(): Nullable<{
  22519. [key: string]: VertexBuffer;
  22520. }>;
  22521. /**
  22522. * Gets a boolean indicating if specific vertex buffer is present
  22523. * @param kind defines the data kind (Position, normal, etc...)
  22524. * @returns true if data is present
  22525. */
  22526. isVerticesDataPresent(kind: string): boolean;
  22527. /**
  22528. * Gets a list of all attached data kinds (Position, normal, etc...)
  22529. * @returns a list of string containing all kinds
  22530. */
  22531. getVerticesDataKinds(): string[];
  22532. /**
  22533. * Update index buffer
  22534. * @param indices defines the indices to store in the index buffer
  22535. * @param offset defines the offset in the target buffer where to store the data
  22536. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  22537. */
  22538. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  22539. /**
  22540. * Creates a new index buffer
  22541. * @param indices defines the indices to store in the index buffer
  22542. * @param totalVertices defines the total number of vertices (could be null)
  22543. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22544. */
  22545. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  22546. /**
  22547. * Return the total number of indices
  22548. * @returns the total number of indices
  22549. */
  22550. getTotalIndices(): number;
  22551. /**
  22552. * Gets the index buffer array
  22553. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22554. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22555. * @returns the index buffer array
  22556. */
  22557. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22558. /**
  22559. * Gets the index buffer
  22560. * @return the index buffer
  22561. */
  22562. getIndexBuffer(): Nullable<DataBuffer>;
  22563. /** @hidden */
  22564. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  22565. /**
  22566. * Release the associated resources for a specific mesh
  22567. * @param mesh defines the source mesh
  22568. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  22569. */
  22570. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  22571. /**
  22572. * Apply current geometry to a given mesh
  22573. * @param mesh defines the mesh to apply geometry to
  22574. */
  22575. applyToMesh(mesh: Mesh): void;
  22576. private _updateExtend;
  22577. private _applyToMesh;
  22578. private notifyUpdate;
  22579. /**
  22580. * Load the geometry if it was flagged as delay loaded
  22581. * @param scene defines the hosting scene
  22582. * @param onLoaded defines a callback called when the geometry is loaded
  22583. */
  22584. load(scene: Scene, onLoaded?: () => void): void;
  22585. private _queueLoad;
  22586. /**
  22587. * Invert the geometry to move from a right handed system to a left handed one.
  22588. */
  22589. toLeftHanded(): void;
  22590. /** @hidden */
  22591. _resetPointsArrayCache(): void;
  22592. /** @hidden */
  22593. _generatePointsArray(): boolean;
  22594. /**
  22595. * Gets a value indicating if the geometry is disposed
  22596. * @returns true if the geometry was disposed
  22597. */
  22598. isDisposed(): boolean;
  22599. private _disposeVertexArrayObjects;
  22600. /**
  22601. * Free all associated resources
  22602. */
  22603. dispose(): void;
  22604. /**
  22605. * Clone the current geometry into a new geometry
  22606. * @param id defines the unique ID of the new geometry
  22607. * @returns a new geometry object
  22608. */
  22609. copy(id: string): Geometry;
  22610. /**
  22611. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22612. * @return a JSON representation of the current geometry data (without the vertices data)
  22613. */
  22614. serialize(): any;
  22615. private toNumberArray;
  22616. /**
  22617. * Serialize all vertices data into a JSON oject
  22618. * @returns a JSON representation of the current geometry data
  22619. */
  22620. serializeVerticeData(): any;
  22621. /**
  22622. * Extracts a clone of a mesh geometry
  22623. * @param mesh defines the source mesh
  22624. * @param id defines the unique ID of the new geometry object
  22625. * @returns the new geometry object
  22626. */
  22627. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22628. /**
  22629. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22630. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22631. * Be aware Math.random() could cause collisions, but:
  22632. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  22633. * @returns a string containing a new GUID
  22634. */
  22635. static RandomId(): string;
  22636. /** @hidden */
  22637. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22638. private static _CleanMatricesWeights;
  22639. /**
  22640. * Create a new geometry from persisted data (Using .babylon file format)
  22641. * @param parsedVertexData defines the persisted data
  22642. * @param scene defines the hosting scene
  22643. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22644. * @returns the new geometry object
  22645. */
  22646. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22647. }
  22648. }
  22649. declare module "babylonjs/Meshes/mesh.vertexData" {
  22650. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22651. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22652. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22653. import { Geometry } from "babylonjs/Meshes/geometry";
  22654. import { Mesh } from "babylonjs/Meshes/mesh";
  22655. /**
  22656. * Define an interface for all classes that will get and set the data on vertices
  22657. */
  22658. export interface IGetSetVerticesData {
  22659. /**
  22660. * Gets a boolean indicating if specific vertex data is present
  22661. * @param kind defines the vertex data kind to use
  22662. * @returns true is data kind is present
  22663. */
  22664. isVerticesDataPresent(kind: string): boolean;
  22665. /**
  22666. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22667. * @param kind defines the data kind (Position, normal, etc...)
  22668. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22669. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22670. * @returns a float array containing vertex data
  22671. */
  22672. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22673. /**
  22674. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22675. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  22676. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22677. * @returns the indices array or an empty array if the mesh has no geometry
  22678. */
  22679. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22680. /**
  22681. * Set specific vertex data
  22682. * @param kind defines the data kind (Position, normal, etc...)
  22683. * @param data defines the vertex data to use
  22684. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22685. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22686. */
  22687. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22688. /**
  22689. * Update a specific associated vertex buffer
  22690. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22691. * - VertexBuffer.PositionKind
  22692. * - VertexBuffer.UVKind
  22693. * - VertexBuffer.UV2Kind
  22694. * - VertexBuffer.UV3Kind
  22695. * - VertexBuffer.UV4Kind
  22696. * - VertexBuffer.UV5Kind
  22697. * - VertexBuffer.UV6Kind
  22698. * - VertexBuffer.ColorKind
  22699. * - VertexBuffer.MatricesIndicesKind
  22700. * - VertexBuffer.MatricesIndicesExtraKind
  22701. * - VertexBuffer.MatricesWeightsKind
  22702. * - VertexBuffer.MatricesWeightsExtraKind
  22703. * @param data defines the data source
  22704. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22705. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  22706. */
  22707. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22708. /**
  22709. * Creates a new index buffer
  22710. * @param indices defines the indices to store in the index buffer
  22711. * @param totalVertices defines the total number of vertices (could be null)
  22712. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22713. */
  22714. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22715. }
  22716. /**
  22717. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22718. */
  22719. export class VertexData {
  22720. /**
  22721. * Mesh side orientation : usually the external or front surface
  22722. */
  22723. static readonly FRONTSIDE: number;
  22724. /**
  22725. * Mesh side orientation : usually the internal or back surface
  22726. */
  22727. static readonly BACKSIDE: number;
  22728. /**
  22729. * Mesh side orientation : both internal and external or front and back surfaces
  22730. */
  22731. static readonly DOUBLESIDE: number;
  22732. /**
  22733. * Mesh side orientation : by default, `FRONTSIDE`
  22734. */
  22735. static readonly DEFAULTSIDE: number;
  22736. /**
  22737. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22738. */
  22739. positions: Nullable<FloatArray>;
  22740. /**
  22741. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22742. */
  22743. normals: Nullable<FloatArray>;
  22744. /**
  22745. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22746. */
  22747. tangents: Nullable<FloatArray>;
  22748. /**
  22749. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22750. */
  22751. uvs: Nullable<FloatArray>;
  22752. /**
  22753. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22754. */
  22755. uvs2: Nullable<FloatArray>;
  22756. /**
  22757. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22758. */
  22759. uvs3: Nullable<FloatArray>;
  22760. /**
  22761. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22762. */
  22763. uvs4: Nullable<FloatArray>;
  22764. /**
  22765. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22766. */
  22767. uvs5: Nullable<FloatArray>;
  22768. /**
  22769. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22770. */
  22771. uvs6: Nullable<FloatArray>;
  22772. /**
  22773. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22774. */
  22775. colors: Nullable<FloatArray>;
  22776. /**
  22777. * An array containing the list of indices to the array of matrices produced by bones, each vertex have up to 4 indices (8 if the matricesIndicesExtra is set).
  22778. */
  22779. matricesIndices: Nullable<FloatArray>;
  22780. /**
  22781. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22782. */
  22783. matricesWeights: Nullable<FloatArray>;
  22784. /**
  22785. * An array extending the number of possible indices
  22786. */
  22787. matricesIndicesExtra: Nullable<FloatArray>;
  22788. /**
  22789. * An array extending the number of possible weights when the number of indices is extended
  22790. */
  22791. matricesWeightsExtra: Nullable<FloatArray>;
  22792. /**
  22793. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22794. */
  22795. indices: Nullable<IndicesArray>;
  22796. /**
  22797. * Uses the passed data array to set the set the values for the specified kind of data
  22798. * @param data a linear array of floating numbers
  22799. * @param kind the type of data that is being set, eg positions, colors etc
  22800. */
  22801. set(data: FloatArray, kind: string): void;
  22802. /**
  22803. * Associates the vertexData to the passed Mesh.
  22804. * Sets it as updatable or not (default `false`)
  22805. * @param mesh the mesh the vertexData is applied to
  22806. * @param updatable when used and having the value true allows new data to update the vertexData
  22807. * @returns the VertexData
  22808. */
  22809. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22810. /**
  22811. * Associates the vertexData to the passed Geometry.
  22812. * Sets it as updatable or not (default `false`)
  22813. * @param geometry the geometry the vertexData is applied to
  22814. * @param updatable when used and having the value true allows new data to update the vertexData
  22815. * @returns VertexData
  22816. */
  22817. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22818. /**
  22819. * Updates the associated mesh
  22820. * @param mesh the mesh to be updated
  22821. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22822. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22823. * @returns VertexData
  22824. */
  22825. updateMesh(mesh: Mesh): VertexData;
  22826. /**
  22827. * Updates the associated geometry
  22828. * @param geometry the geometry to be updated
  22829. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22830. * @param makeItUnique when true, and when and if position kind is updated, a new global geometry will be created from these positions and set to the mesh, optional with default false
  22831. * @returns VertexData.
  22832. */
  22833. updateGeometry(geometry: Geometry): VertexData;
  22834. private _applyTo;
  22835. private _update;
  22836. /**
  22837. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22838. * @param matrix the transforming matrix
  22839. * @returns the VertexData
  22840. */
  22841. transform(matrix: Matrix): VertexData;
  22842. /**
  22843. * Merges the passed VertexData into the current one
  22844. * @param other the VertexData to be merged into the current one
  22845. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22846. * @returns the modified VertexData
  22847. */
  22848. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22849. private _mergeElement;
  22850. private _validate;
  22851. /**
  22852. * Serializes the VertexData
  22853. * @returns a serialized object
  22854. */
  22855. serialize(): any;
  22856. /**
  22857. * Extracts the vertexData from a mesh
  22858. * @param mesh the mesh from which to extract the VertexData
  22859. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22860. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22861. * @returns the object VertexData associated to the passed mesh
  22862. */
  22863. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22864. /**
  22865. * Extracts the vertexData from the geometry
  22866. * @param geometry the geometry from which to extract the VertexData
  22867. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22868. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22869. * @returns the object VertexData associated to the passed mesh
  22870. */
  22871. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22872. private static _ExtractFrom;
  22873. /**
  22874. * Creates the VertexData for a Ribbon
  22875. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22876. * * pathArray array of paths, each of which an array of successive Vector3
  22877. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22878. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22879. * * offset a positive integer, only used when pathArray contains a single path (offset = 10 means the point 1 is joined to the point 11), default rounded half size of the pathArray length
  22880. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22881. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22882. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22883. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22884. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22885. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22886. * @returns the VertexData of the ribbon
  22887. */
  22888. static CreateRibbon(options: {
  22889. pathArray: Vector3[][];
  22890. closeArray?: boolean;
  22891. closePath?: boolean;
  22892. offset?: number;
  22893. sideOrientation?: number;
  22894. frontUVs?: Vector4;
  22895. backUVs?: Vector4;
  22896. invertUV?: boolean;
  22897. uvs?: Vector2[];
  22898. colors?: Color4[];
  22899. }): VertexData;
  22900. /**
  22901. * Creates the VertexData for a box
  22902. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22903. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22904. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22905. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22906. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22907. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22908. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22909. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22910. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22911. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22912. * @returns the VertexData of the box
  22913. */
  22914. static CreateBox(options: {
  22915. size?: number;
  22916. width?: number;
  22917. height?: number;
  22918. depth?: number;
  22919. faceUV?: Vector4[];
  22920. faceColors?: Color4[];
  22921. sideOrientation?: number;
  22922. frontUVs?: Vector4;
  22923. backUVs?: Vector4;
  22924. }): VertexData;
  22925. /**
  22926. * Creates the VertexData for a tiled box
  22927. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22928. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22929. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22930. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22931. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22932. * @returns the VertexData of the box
  22933. */
  22934. static CreateTiledBox(options: {
  22935. pattern?: number;
  22936. width?: number;
  22937. height?: number;
  22938. depth?: number;
  22939. tileSize?: number;
  22940. tileWidth?: number;
  22941. tileHeight?: number;
  22942. alignHorizontal?: number;
  22943. alignVertical?: number;
  22944. faceUV?: Vector4[];
  22945. faceColors?: Color4[];
  22946. sideOrientation?: number;
  22947. }): VertexData;
  22948. /**
  22949. * Creates the VertexData for a tiled plane
  22950. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22951. * * pattern a limited pattern arrangement depending on the number
  22952. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22953. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22954. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22955. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22956. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22957. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22958. * @returns the VertexData of the tiled plane
  22959. */
  22960. static CreateTiledPlane(options: {
  22961. pattern?: number;
  22962. tileSize?: number;
  22963. tileWidth?: number;
  22964. tileHeight?: number;
  22965. size?: number;
  22966. width?: number;
  22967. height?: number;
  22968. alignHorizontal?: number;
  22969. alignVertical?: number;
  22970. sideOrientation?: number;
  22971. frontUVs?: Vector4;
  22972. backUVs?: Vector4;
  22973. }): VertexData;
  22974. /**
  22975. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22976. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22977. * * segments sets the number of horizontal strips optional, default 32
  22978. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22979. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22980. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22981. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22982. * * arc a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the circumference (latitude) given by the arc value, optional, default 1
  22983. * * slice a number from 0 to 1, to create an unclosed ellipsoid based on the fraction of the height (latitude) given by the arc value, optional, default 1
  22984. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22985. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  22986. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  22987. * @returns the VertexData of the ellipsoid
  22988. */
  22989. static CreateSphere(options: {
  22990. segments?: number;
  22991. diameter?: number;
  22992. diameterX?: number;
  22993. diameterY?: number;
  22994. diameterZ?: number;
  22995. arc?: number;
  22996. slice?: number;
  22997. sideOrientation?: number;
  22998. frontUVs?: Vector4;
  22999. backUVs?: Vector4;
  23000. }): VertexData;
  23001. /**
  23002. * Creates the VertexData for a cylinder, cone or prism
  23003. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23004. * * height sets the height (y direction) of the cylinder, optional, default 2
  23005. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23006. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23007. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23008. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23009. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23010. * * arc a number from 0 to 1, to create an unclosed cylinder based on the fraction of the circumference given by the arc value, optional, default 1
  23011. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23012. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23013. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23014. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23015. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23016. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23017. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23018. * @returns the VertexData of the cylinder, cone or prism
  23019. */
  23020. static CreateCylinder(options: {
  23021. height?: number;
  23022. diameterTop?: number;
  23023. diameterBottom?: number;
  23024. diameter?: number;
  23025. tessellation?: number;
  23026. subdivisions?: number;
  23027. arc?: number;
  23028. faceColors?: Color4[];
  23029. faceUV?: Vector4[];
  23030. hasRings?: boolean;
  23031. enclose?: boolean;
  23032. sideOrientation?: number;
  23033. frontUVs?: Vector4;
  23034. backUVs?: Vector4;
  23035. }): VertexData;
  23036. /**
  23037. * Creates the VertexData for a torus
  23038. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23039. * * diameter the diameter of the torus, optional default 1
  23040. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23041. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23042. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23043. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23044. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23045. * @returns the VertexData of the torus
  23046. */
  23047. static CreateTorus(options: {
  23048. diameter?: number;
  23049. thickness?: number;
  23050. tessellation?: number;
  23051. sideOrientation?: number;
  23052. frontUVs?: Vector4;
  23053. backUVs?: Vector4;
  23054. }): VertexData;
  23055. /**
  23056. * Creates the VertexData of the LineSystem
  23057. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23058. * - lines an array of lines, each line being an array of successive Vector3
  23059. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23060. * @returns the VertexData of the LineSystem
  23061. */
  23062. static CreateLineSystem(options: {
  23063. lines: Vector3[][];
  23064. colors?: Nullable<Color4[][]>;
  23065. }): VertexData;
  23066. /**
  23067. * Create the VertexData for a DashedLines
  23068. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23069. * - points an array successive Vector3
  23070. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23071. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23072. * - dashNb the intended total number of dashes, optional, default 200
  23073. * @returns the VertexData for the DashedLines
  23074. */
  23075. static CreateDashedLines(options: {
  23076. points: Vector3[];
  23077. dashSize?: number;
  23078. gapSize?: number;
  23079. dashNb?: number;
  23080. }): VertexData;
  23081. /**
  23082. * Creates the VertexData for a Ground
  23083. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23084. * - width the width (x direction) of the ground, optional, default 1
  23085. * - height the height (z direction) of the ground, optional, default 1
  23086. * - subdivisions the number of subdivisions per side, optional, default 1
  23087. * @returns the VertexData of the Ground
  23088. */
  23089. static CreateGround(options: {
  23090. width?: number;
  23091. height?: number;
  23092. subdivisions?: number;
  23093. subdivisionsX?: number;
  23094. subdivisionsY?: number;
  23095. }): VertexData;
  23096. /**
  23097. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23098. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23099. * * xmin the ground minimum X coordinate, optional, default -1
  23100. * * zmin the ground minimum Z coordinate, optional, default -1
  23101. * * xmax the ground maximum X coordinate, optional, default 1
  23102. * * zmax the ground maximum Z coordinate, optional, default 1
  23103. * * subdivisions a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the ground width and height creating 'tiles', default {w: 6, h: 6}
  23104. * * precision a javascript object {w: positive integer, h: positive integer}, `w` and `h` are the numbers of subdivisions on the tile width and height, default {w: 2, h: 2}
  23105. * @returns the VertexData of the TiledGround
  23106. */
  23107. static CreateTiledGround(options: {
  23108. xmin: number;
  23109. zmin: number;
  23110. xmax: number;
  23111. zmax: number;
  23112. subdivisions?: {
  23113. w: number;
  23114. h: number;
  23115. };
  23116. precision?: {
  23117. w: number;
  23118. h: number;
  23119. };
  23120. }): VertexData;
  23121. /**
  23122. * Creates the VertexData of the Ground designed from a heightmap
  23123. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23124. * * width the width (x direction) of the ground
  23125. * * height the height (z direction) of the ground
  23126. * * subdivisions the number of subdivisions per side
  23127. * * minHeight the minimum altitude on the ground, optional, default 0
  23128. * * maxHeight the maximum altitude on the ground, optional default 1
  23129. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23130. * * buffer the array holding the image color data
  23131. * * bufferWidth the width of image
  23132. * * bufferHeight the height of image
  23133. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23134. * @returns the VertexData of the Ground designed from a heightmap
  23135. */
  23136. static CreateGroundFromHeightMap(options: {
  23137. width: number;
  23138. height: number;
  23139. subdivisions: number;
  23140. minHeight: number;
  23141. maxHeight: number;
  23142. colorFilter: Color3;
  23143. buffer: Uint8Array;
  23144. bufferWidth: number;
  23145. bufferHeight: number;
  23146. alphaFilter: number;
  23147. }): VertexData;
  23148. /**
  23149. * Creates the VertexData for a Plane
  23150. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23151. * * size sets the width and height of the plane to the value of size, optional default 1
  23152. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23153. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23154. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23155. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23156. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23157. * @returns the VertexData of the box
  23158. */
  23159. static CreatePlane(options: {
  23160. size?: number;
  23161. width?: number;
  23162. height?: number;
  23163. sideOrientation?: number;
  23164. frontUVs?: Vector4;
  23165. backUVs?: Vector4;
  23166. }): VertexData;
  23167. /**
  23168. * Creates the VertexData of the Disc or regular Polygon
  23169. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23170. * * radius the radius of the disc, optional default 0.5
  23171. * * tessellation the number of polygon sides, optional, default 64
  23172. * * arc a number from 0 to 1, to create an unclosed polygon based on the fraction of the circumference given by the arc value, optional, default 1
  23173. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23174. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23175. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23176. * @returns the VertexData of the box
  23177. */
  23178. static CreateDisc(options: {
  23179. radius?: number;
  23180. tessellation?: number;
  23181. arc?: number;
  23182. sideOrientation?: number;
  23183. frontUVs?: Vector4;
  23184. backUVs?: Vector4;
  23185. }): VertexData;
  23186. /**
  23187. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23188. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23189. * @param polygon a mesh built from polygonTriangulation.build()
  23190. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23191. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23192. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23193. * @param frontUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23194. * @param backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23195. * @returns the VertexData of the Polygon
  23196. */
  23197. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23198. /**
  23199. * Creates the VertexData of the IcoSphere
  23200. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23201. * * radius the radius of the IcoSphere, optional default 1
  23202. * * radiusX allows stretching in the x direction, optional, default radius
  23203. * * radiusY allows stretching in the y direction, optional, default radius
  23204. * * radiusZ allows stretching in the z direction, optional, default radius
  23205. * * flat when true creates a flat shaded mesh, optional, default true
  23206. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23207. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23208. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23209. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23210. * @returns the VertexData of the IcoSphere
  23211. */
  23212. static CreateIcoSphere(options: {
  23213. radius?: number;
  23214. radiusX?: number;
  23215. radiusY?: number;
  23216. radiusZ?: number;
  23217. flat?: boolean;
  23218. subdivisions?: number;
  23219. sideOrientation?: number;
  23220. frontUVs?: Vector4;
  23221. backUVs?: Vector4;
  23222. }): VertexData;
  23223. /**
  23224. * Creates the VertexData for a Polyhedron
  23225. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23226. * * type provided types are:
  23227. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23228. * * 9 : Pentagonal Pyramid (J2), 10 : Triangular Dipyramid (J12), 11 : Pentagonal Dipyramid (J13), 12 : Elongated Square Dipyramid (J15), 13 : Elongated Pentagonal Dipyramid (J16), 14 : Elongated Pentagonal Cupola (J20)
  23229. * * size the size of the IcoSphere, optional default 1
  23230. * * sizeX allows stretching in the x direction, optional, default size
  23231. * * sizeY allows stretching in the y direction, optional, default size
  23232. * * sizeZ allows stretching in the z direction, optional, default size
  23233. * * custom a number that overwrites the type to create from an extended set of polyhedron from https://www.babylonjs-playground.com/#21QRSK#15 with minimised editor
  23234. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23235. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23236. * * flat when true creates a flat shaded mesh, optional, default true
  23237. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23238. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23239. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23240. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23241. * @returns the VertexData of the Polyhedron
  23242. */
  23243. static CreatePolyhedron(options: {
  23244. type?: number;
  23245. size?: number;
  23246. sizeX?: number;
  23247. sizeY?: number;
  23248. sizeZ?: number;
  23249. custom?: any;
  23250. faceUV?: Vector4[];
  23251. faceColors?: Color4[];
  23252. flat?: boolean;
  23253. sideOrientation?: number;
  23254. frontUVs?: Vector4;
  23255. backUVs?: Vector4;
  23256. }): VertexData;
  23257. /**
  23258. * Creates the VertexData for a TorusKnot
  23259. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23260. * * radius the radius of the torus knot, optional, default 2
  23261. * * tube the thickness of the tube, optional, default 0.5
  23262. * * radialSegments the number of sides on each tube segments, optional, default 32
  23263. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23264. * * p the number of windings around the z axis, optional, default 2
  23265. * * q the number of windings around the x axis, optional, default 3
  23266. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23267. * * frontUvs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the front side, optional, default vector4 (0, 0, 1, 1)
  23268. * * backUVs only usable when you create a double-sided mesh, used to choose what parts of the texture image to crop and apply on the back side, optional, default vector4 (0, 0, 1, 1)
  23269. * @returns the VertexData of the Torus Knot
  23270. */
  23271. static CreateTorusKnot(options: {
  23272. radius?: number;
  23273. tube?: number;
  23274. radialSegments?: number;
  23275. tubularSegments?: number;
  23276. p?: number;
  23277. q?: number;
  23278. sideOrientation?: number;
  23279. frontUVs?: Vector4;
  23280. backUVs?: Vector4;
  23281. }): VertexData;
  23282. /**
  23283. * Compute normals for given positions and indices
  23284. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23285. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23286. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23287. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23288. * * facetNormals : optional array of facet normals (vector3)
  23289. * * facetPositions : optional array of facet positions (vector3)
  23290. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23291. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23292. * * bInfo : optional bounding info, required for facetPartitioning computation
  23293. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23294. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23295. * * useRightHandedSystem: optional boolean to for right handed system computation
  23296. * * depthSort : optional boolean to enable the facet depth sort computation
  23297. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23298. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23299. */
  23300. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23301. facetNormals?: any;
  23302. facetPositions?: any;
  23303. facetPartitioning?: any;
  23304. ratio?: number;
  23305. bInfo?: any;
  23306. bbSize?: Vector3;
  23307. subDiv?: any;
  23308. useRightHandedSystem?: boolean;
  23309. depthSort?: boolean;
  23310. distanceTo?: Vector3;
  23311. depthSortedFacets?: any;
  23312. }): void;
  23313. /** @hidden */
  23314. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23315. /**
  23316. * Applies VertexData created from the imported parameters to the geometry
  23317. * @param parsedVertexData the parsed data from an imported file
  23318. * @param geometry the geometry to apply the VertexData to
  23319. */
  23320. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23321. }
  23322. }
  23323. declare module "babylonjs/Morph/morphTarget" {
  23324. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  23325. import { Observable } from "babylonjs/Misc/observable";
  23326. import { Nullable, FloatArray } from "babylonjs/types";
  23327. import { Scene } from "babylonjs/scene";
  23328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23329. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  23330. /**
  23331. * Defines a target to use with MorphTargetManager
  23332. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23333. */
  23334. export class MorphTarget implements IAnimatable {
  23335. /** defines the name of the target */
  23336. name: string;
  23337. /**
  23338. * Gets or sets the list of animations
  23339. */
  23340. animations: import("babylonjs/Animations/animation").Animation[];
  23341. private _scene;
  23342. private _positions;
  23343. private _normals;
  23344. private _tangents;
  23345. private _uvs;
  23346. private _influence;
  23347. private _uniqueId;
  23348. /**
  23349. * Observable raised when the influence changes
  23350. */
  23351. onInfluenceChanged: Observable<boolean>;
  23352. /** @hidden */
  23353. _onDataLayoutChanged: Observable<void>;
  23354. /**
  23355. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  23356. */
  23357. get influence(): number;
  23358. set influence(influence: number);
  23359. /**
  23360. * Gets or sets the id of the morph Target
  23361. */
  23362. id: string;
  23363. private _animationPropertiesOverride;
  23364. /**
  23365. * Gets or sets the animation properties override
  23366. */
  23367. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  23368. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  23369. /**
  23370. * Creates a new MorphTarget
  23371. * @param name defines the name of the target
  23372. * @param influence defines the influence to use
  23373. * @param scene defines the scene the morphtarget belongs to
  23374. */
  23375. constructor(
  23376. /** defines the name of the target */
  23377. name: string, influence?: number, scene?: Nullable<Scene>);
  23378. /**
  23379. * Gets the unique ID of this manager
  23380. */
  23381. get uniqueId(): number;
  23382. /**
  23383. * Gets a boolean defining if the target contains position data
  23384. */
  23385. get hasPositions(): boolean;
  23386. /**
  23387. * Gets a boolean defining if the target contains normal data
  23388. */
  23389. get hasNormals(): boolean;
  23390. /**
  23391. * Gets a boolean defining if the target contains tangent data
  23392. */
  23393. get hasTangents(): boolean;
  23394. /**
  23395. * Gets a boolean defining if the target contains texture coordinates data
  23396. */
  23397. get hasUVs(): boolean;
  23398. /**
  23399. * Affects position data to this target
  23400. * @param data defines the position data to use
  23401. */
  23402. setPositions(data: Nullable<FloatArray>): void;
  23403. /**
  23404. * Gets the position data stored in this target
  23405. * @returns a FloatArray containing the position data (or null if not present)
  23406. */
  23407. getPositions(): Nullable<FloatArray>;
  23408. /**
  23409. * Affects normal data to this target
  23410. * @param data defines the normal data to use
  23411. */
  23412. setNormals(data: Nullable<FloatArray>): void;
  23413. /**
  23414. * Gets the normal data stored in this target
  23415. * @returns a FloatArray containing the normal data (or null if not present)
  23416. */
  23417. getNormals(): Nullable<FloatArray>;
  23418. /**
  23419. * Affects tangent data to this target
  23420. * @param data defines the tangent data to use
  23421. */
  23422. setTangents(data: Nullable<FloatArray>): void;
  23423. /**
  23424. * Gets the tangent data stored in this target
  23425. * @returns a FloatArray containing the tangent data (or null if not present)
  23426. */
  23427. getTangents(): Nullable<FloatArray>;
  23428. /**
  23429. * Affects texture coordinates data to this target
  23430. * @param data defines the texture coordinates data to use
  23431. */
  23432. setUVs(data: Nullable<FloatArray>): void;
  23433. /**
  23434. * Gets the texture coordinates data stored in this target
  23435. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  23436. */
  23437. getUVs(): Nullable<FloatArray>;
  23438. /**
  23439. * Clone the current target
  23440. * @returns a new MorphTarget
  23441. */
  23442. clone(): MorphTarget;
  23443. /**
  23444. * Serializes the current target into a Serialization object
  23445. * @returns the serialized object
  23446. */
  23447. serialize(): any;
  23448. /**
  23449. * Returns the string "MorphTarget"
  23450. * @returns "MorphTarget"
  23451. */
  23452. getClassName(): string;
  23453. /**
  23454. * Creates a new target from serialized data
  23455. * @param serializationObject defines the serialized data to use
  23456. * @returns a new MorphTarget
  23457. */
  23458. static Parse(serializationObject: any): MorphTarget;
  23459. /**
  23460. * Creates a MorphTarget from mesh data
  23461. * @param mesh defines the source mesh
  23462. * @param name defines the name to use for the new target
  23463. * @param influence defines the influence to attach to the target
  23464. * @returns a new MorphTarget
  23465. */
  23466. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  23467. }
  23468. }
  23469. declare module "babylonjs/Morph/morphTargetManager" {
  23470. import { Nullable } from "babylonjs/types";
  23471. import { Scene } from "babylonjs/scene";
  23472. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  23473. /**
  23474. * This class is used to deform meshes using morphing between different targets
  23475. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23476. */
  23477. export class MorphTargetManager {
  23478. private _targets;
  23479. private _targetInfluenceChangedObservers;
  23480. private _targetDataLayoutChangedObservers;
  23481. private _activeTargets;
  23482. private _scene;
  23483. private _influences;
  23484. private _supportsNormals;
  23485. private _supportsTangents;
  23486. private _supportsUVs;
  23487. private _vertexCount;
  23488. private _uniqueId;
  23489. private _tempInfluences;
  23490. /**
  23491. * Gets or sets a boolean indicating if normals must be morphed
  23492. */
  23493. enableNormalMorphing: boolean;
  23494. /**
  23495. * Gets or sets a boolean indicating if tangents must be morphed
  23496. */
  23497. enableTangentMorphing: boolean;
  23498. /**
  23499. * Gets or sets a boolean indicating if UV must be morphed
  23500. */
  23501. enableUVMorphing: boolean;
  23502. /**
  23503. * Creates a new MorphTargetManager
  23504. * @param scene defines the current scene
  23505. */
  23506. constructor(scene?: Nullable<Scene>);
  23507. /**
  23508. * Gets the unique ID of this manager
  23509. */
  23510. get uniqueId(): number;
  23511. /**
  23512. * Gets the number of vertices handled by this manager
  23513. */
  23514. get vertexCount(): number;
  23515. /**
  23516. * Gets a boolean indicating if this manager supports morphing of normals
  23517. */
  23518. get supportsNormals(): boolean;
  23519. /**
  23520. * Gets a boolean indicating if this manager supports morphing of tangents
  23521. */
  23522. get supportsTangents(): boolean;
  23523. /**
  23524. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  23525. */
  23526. get supportsUVs(): boolean;
  23527. /**
  23528. * Gets the number of targets stored in this manager
  23529. */
  23530. get numTargets(): number;
  23531. /**
  23532. * Gets the number of influencers (ie. the number of targets with influences > 0)
  23533. */
  23534. get numInfluencers(): number;
  23535. /**
  23536. * Gets the list of influences (one per target)
  23537. */
  23538. get influences(): Float32Array;
  23539. /**
  23540. * Gets the active target at specified index. An active target is a target with an influence > 0
  23541. * @param index defines the index to check
  23542. * @returns the requested target
  23543. */
  23544. getActiveTarget(index: number): MorphTarget;
  23545. /**
  23546. * Gets the target at specified index
  23547. * @param index defines the index to check
  23548. * @returns the requested target
  23549. */
  23550. getTarget(index: number): MorphTarget;
  23551. /**
  23552. * Add a new target to this manager
  23553. * @param target defines the target to add
  23554. */
  23555. addTarget(target: MorphTarget): void;
  23556. /**
  23557. * Removes a target from the manager
  23558. * @param target defines the target to remove
  23559. */
  23560. removeTarget(target: MorphTarget): void;
  23561. /**
  23562. * Clone the current manager
  23563. * @returns a new MorphTargetManager
  23564. */
  23565. clone(): MorphTargetManager;
  23566. /**
  23567. * Serializes the current manager into a Serialization object
  23568. * @returns the serialized object
  23569. */
  23570. serialize(): any;
  23571. private _syncActiveTargets;
  23572. /**
  23573. * Syncrhonize the targets with all the meshes using this morph target manager
  23574. */
  23575. synchronize(): void;
  23576. /**
  23577. * Creates a new MorphTargetManager from serialized data
  23578. * @param serializationObject defines the serialized data
  23579. * @param scene defines the hosting scene
  23580. * @returns the new MorphTargetManager
  23581. */
  23582. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  23583. }
  23584. }
  23585. declare module "babylonjs/Meshes/meshLODLevel" {
  23586. import { Mesh } from "babylonjs/Meshes/mesh";
  23587. import { Nullable } from "babylonjs/types";
  23588. /**
  23589. * Class used to represent a specific level of detail of a mesh
  23590. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23591. */
  23592. export class MeshLODLevel {
  23593. /** Defines the distance where this level should start being displayed */
  23594. distance: number;
  23595. /** Defines the mesh to use to render this level */
  23596. mesh: Nullable<Mesh>;
  23597. /**
  23598. * Creates a new LOD level
  23599. * @param distance defines the distance where this level should star being displayed
  23600. * @param mesh defines the mesh to use to render this level
  23601. */
  23602. constructor(
  23603. /** Defines the distance where this level should start being displayed */
  23604. distance: number,
  23605. /** Defines the mesh to use to render this level */
  23606. mesh: Nullable<Mesh>);
  23607. }
  23608. }
  23609. declare module "babylonjs/Meshes/groundMesh" {
  23610. import { Scene } from "babylonjs/scene";
  23611. import { Vector3 } from "babylonjs/Maths/math.vector";
  23612. import { Mesh } from "babylonjs/Meshes/mesh";
  23613. /**
  23614. * Mesh representing the gorund
  23615. */
  23616. export class GroundMesh extends Mesh {
  23617. /** If octree should be generated */
  23618. generateOctree: boolean;
  23619. private _heightQuads;
  23620. /** @hidden */
  23621. _subdivisionsX: number;
  23622. /** @hidden */
  23623. _subdivisionsY: number;
  23624. /** @hidden */
  23625. _width: number;
  23626. /** @hidden */
  23627. _height: number;
  23628. /** @hidden */
  23629. _minX: number;
  23630. /** @hidden */
  23631. _maxX: number;
  23632. /** @hidden */
  23633. _minZ: number;
  23634. /** @hidden */
  23635. _maxZ: number;
  23636. constructor(name: string, scene: Scene);
  23637. /**
  23638. * "GroundMesh"
  23639. * @returns "GroundMesh"
  23640. */
  23641. getClassName(): string;
  23642. /**
  23643. * The minimum of x and y subdivisions
  23644. */
  23645. get subdivisions(): number;
  23646. /**
  23647. * X subdivisions
  23648. */
  23649. get subdivisionsX(): number;
  23650. /**
  23651. * Y subdivisions
  23652. */
  23653. get subdivisionsY(): number;
  23654. /**
  23655. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23656. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23657. * @param chunksCount the number of subdivisions for x and y
  23658. * @param octreeBlocksSize (Default: 32)
  23659. */
  23660. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23661. /**
  23662. * Returns a height (y) value in the Worl system :
  23663. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23664. * @param x x coordinate
  23665. * @param z z coordinate
  23666. * @returns the ground y position if (x, z) are outside the ground surface.
  23667. */
  23668. getHeightAtCoordinates(x: number, z: number): number;
  23669. /**
  23670. * Returns a normalized vector (Vector3) orthogonal to the ground
  23671. * at the ground coordinates (x, z) expressed in the World system.
  23672. * @param x x coordinate
  23673. * @param z z coordinate
  23674. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23675. */
  23676. getNormalAtCoordinates(x: number, z: number): Vector3;
  23677. /**
  23678. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23679. * at the ground coordinates (x, z) expressed in the World system.
  23680. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23681. * @param x x coordinate
  23682. * @param z z coordinate
  23683. * @param ref vector to store the result
  23684. * @returns the GroundMesh.
  23685. */
  23686. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23687. /**
  23688. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23689. * if the ground has been updated.
  23690. * This can be used in the render loop.
  23691. * @returns the GroundMesh.
  23692. */
  23693. updateCoordinateHeights(): GroundMesh;
  23694. private _getFacetAt;
  23695. private _initHeightQuads;
  23696. private _computeHeightQuads;
  23697. /**
  23698. * Serializes this ground mesh
  23699. * @param serializationObject object to write serialization to
  23700. */
  23701. serialize(serializationObject: any): void;
  23702. /**
  23703. * Parses a serialized ground mesh
  23704. * @param parsedMesh the serialized mesh
  23705. * @param scene the scene to create the ground mesh in
  23706. * @returns the created ground mesh
  23707. */
  23708. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23709. }
  23710. }
  23711. declare module "babylonjs/Physics/physicsJoint" {
  23712. import { Vector3 } from "babylonjs/Maths/math.vector";
  23713. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23714. /**
  23715. * Interface for Physics-Joint data
  23716. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23717. */
  23718. export interface PhysicsJointData {
  23719. /**
  23720. * The main pivot of the joint
  23721. */
  23722. mainPivot?: Vector3;
  23723. /**
  23724. * The connected pivot of the joint
  23725. */
  23726. connectedPivot?: Vector3;
  23727. /**
  23728. * The main axis of the joint
  23729. */
  23730. mainAxis?: Vector3;
  23731. /**
  23732. * The connected axis of the joint
  23733. */
  23734. connectedAxis?: Vector3;
  23735. /**
  23736. * The collision of the joint
  23737. */
  23738. collision?: boolean;
  23739. /**
  23740. * Native Oimo/Cannon/Energy data
  23741. */
  23742. nativeParams?: any;
  23743. }
  23744. /**
  23745. * This is a holder class for the physics joint created by the physics plugin
  23746. * It holds a set of functions to control the underlying joint
  23747. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23748. */
  23749. export class PhysicsJoint {
  23750. /**
  23751. * The type of the physics joint
  23752. */
  23753. type: number;
  23754. /**
  23755. * The data for the physics joint
  23756. */
  23757. jointData: PhysicsJointData;
  23758. private _physicsJoint;
  23759. protected _physicsPlugin: IPhysicsEnginePlugin;
  23760. /**
  23761. * Initializes the physics joint
  23762. * @param type The type of the physics joint
  23763. * @param jointData The data for the physics joint
  23764. */
  23765. constructor(
  23766. /**
  23767. * The type of the physics joint
  23768. */
  23769. type: number,
  23770. /**
  23771. * The data for the physics joint
  23772. */
  23773. jointData: PhysicsJointData);
  23774. /**
  23775. * Gets the physics joint
  23776. */
  23777. get physicsJoint(): any;
  23778. /**
  23779. * Sets the physics joint
  23780. */
  23781. set physicsJoint(newJoint: any);
  23782. /**
  23783. * Sets the physics plugin
  23784. */
  23785. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  23786. /**
  23787. * Execute a function that is physics-plugin specific.
  23788. * @param {Function} func the function that will be executed.
  23789. * It accepts two parameters: the physics world and the physics joint
  23790. */
  23791. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23792. /**
  23793. * Distance-Joint type
  23794. */
  23795. static DistanceJoint: number;
  23796. /**
  23797. * Hinge-Joint type
  23798. */
  23799. static HingeJoint: number;
  23800. /**
  23801. * Ball-and-Socket joint type
  23802. */
  23803. static BallAndSocketJoint: number;
  23804. /**
  23805. * Wheel-Joint type
  23806. */
  23807. static WheelJoint: number;
  23808. /**
  23809. * Slider-Joint type
  23810. */
  23811. static SliderJoint: number;
  23812. /**
  23813. * Prismatic-Joint type
  23814. */
  23815. static PrismaticJoint: number;
  23816. /**
  23817. * Universal-Joint type
  23818. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23819. */
  23820. static UniversalJoint: number;
  23821. /**
  23822. * Hinge-Joint 2 type
  23823. */
  23824. static Hinge2Joint: number;
  23825. /**
  23826. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23827. */
  23828. static PointToPointJoint: number;
  23829. /**
  23830. * Spring-Joint type
  23831. */
  23832. static SpringJoint: number;
  23833. /**
  23834. * Lock-Joint type
  23835. */
  23836. static LockJoint: number;
  23837. }
  23838. /**
  23839. * A class representing a physics distance joint
  23840. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23841. */
  23842. export class DistanceJoint extends PhysicsJoint {
  23843. /**
  23844. *
  23845. * @param jointData The data for the Distance-Joint
  23846. */
  23847. constructor(jointData: DistanceJointData);
  23848. /**
  23849. * Update the predefined distance.
  23850. * @param maxDistance The maximum preferred distance
  23851. * @param minDistance The minimum preferred distance
  23852. */
  23853. updateDistance(maxDistance: number, minDistance?: number): void;
  23854. }
  23855. /**
  23856. * Represents a Motor-Enabled Joint
  23857. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23858. */
  23859. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23860. /**
  23861. * Initializes the Motor-Enabled Joint
  23862. * @param type The type of the joint
  23863. * @param jointData The physica joint data for the joint
  23864. */
  23865. constructor(type: number, jointData: PhysicsJointData);
  23866. /**
  23867. * Set the motor values.
  23868. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23869. * @param force the force to apply
  23870. * @param maxForce max force for this motor.
  23871. */
  23872. setMotor(force?: number, maxForce?: number): void;
  23873. /**
  23874. * Set the motor's limits.
  23875. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23876. * @param upperLimit The upper limit of the motor
  23877. * @param lowerLimit The lower limit of the motor
  23878. */
  23879. setLimit(upperLimit: number, lowerLimit?: number): void;
  23880. }
  23881. /**
  23882. * This class represents a single physics Hinge-Joint
  23883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23884. */
  23885. export class HingeJoint extends MotorEnabledJoint {
  23886. /**
  23887. * Initializes the Hinge-Joint
  23888. * @param jointData The joint data for the Hinge-Joint
  23889. */
  23890. constructor(jointData: PhysicsJointData);
  23891. /**
  23892. * Set the motor values.
  23893. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23894. * @param {number} force the force to apply
  23895. * @param {number} maxForce max force for this motor.
  23896. */
  23897. setMotor(force?: number, maxForce?: number): void;
  23898. /**
  23899. * Set the motor's limits.
  23900. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23901. * @param upperLimit The upper limit of the motor
  23902. * @param lowerLimit The lower limit of the motor
  23903. */
  23904. setLimit(upperLimit: number, lowerLimit?: number): void;
  23905. }
  23906. /**
  23907. * This class represents a dual hinge physics joint (same as wheel joint)
  23908. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23909. */
  23910. export class Hinge2Joint extends MotorEnabledJoint {
  23911. /**
  23912. * Initializes the Hinge2-Joint
  23913. * @param jointData The joint data for the Hinge2-Joint
  23914. */
  23915. constructor(jointData: PhysicsJointData);
  23916. /**
  23917. * Set the motor values.
  23918. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23919. * @param {number} targetSpeed the speed the motor is to reach
  23920. * @param {number} maxForce max force for this motor.
  23921. * @param {motorIndex} the motor's index, 0 or 1.
  23922. */
  23923. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23924. /**
  23925. * Set the motor limits.
  23926. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23927. * @param {number} upperLimit the upper limit
  23928. * @param {number} lowerLimit lower limit
  23929. * @param {motorIndex} the motor's index, 0 or 1.
  23930. */
  23931. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23932. }
  23933. /**
  23934. * Interface for a motor enabled joint
  23935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23936. */
  23937. export interface IMotorEnabledJoint {
  23938. /**
  23939. * Physics joint
  23940. */
  23941. physicsJoint: any;
  23942. /**
  23943. * Sets the motor of the motor-enabled joint
  23944. * @param force The force of the motor
  23945. * @param maxForce The maximum force of the motor
  23946. * @param motorIndex The index of the motor
  23947. */
  23948. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23949. /**
  23950. * Sets the limit of the motor
  23951. * @param upperLimit The upper limit of the motor
  23952. * @param lowerLimit The lower limit of the motor
  23953. * @param motorIndex The index of the motor
  23954. */
  23955. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23956. }
  23957. /**
  23958. * Joint data for a Distance-Joint
  23959. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23960. */
  23961. export interface DistanceJointData extends PhysicsJointData {
  23962. /**
  23963. * Max distance the 2 joint objects can be apart
  23964. */
  23965. maxDistance: number;
  23966. }
  23967. /**
  23968. * Joint data from a spring joint
  23969. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23970. */
  23971. export interface SpringJointData extends PhysicsJointData {
  23972. /**
  23973. * Length of the spring
  23974. */
  23975. length: number;
  23976. /**
  23977. * Stiffness of the spring
  23978. */
  23979. stiffness: number;
  23980. /**
  23981. * Damping of the spring
  23982. */
  23983. damping: number;
  23984. /** this callback will be called when applying the force to the impostors. */
  23985. forceApplicationCallback: () => void;
  23986. }
  23987. }
  23988. declare module "babylonjs/Physics/physicsRaycastResult" {
  23989. import { Vector3 } from "babylonjs/Maths/math.vector";
  23990. /**
  23991. * Holds the data for the raycast result
  23992. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23993. */
  23994. export class PhysicsRaycastResult {
  23995. private _hasHit;
  23996. private _hitDistance;
  23997. private _hitNormalWorld;
  23998. private _hitPointWorld;
  23999. private _rayFromWorld;
  24000. private _rayToWorld;
  24001. /**
  24002. * Gets if there was a hit
  24003. */
  24004. get hasHit(): boolean;
  24005. /**
  24006. * Gets the distance from the hit
  24007. */
  24008. get hitDistance(): number;
  24009. /**
  24010. * Gets the hit normal/direction in the world
  24011. */
  24012. get hitNormalWorld(): Vector3;
  24013. /**
  24014. * Gets the hit point in the world
  24015. */
  24016. get hitPointWorld(): Vector3;
  24017. /**
  24018. * Gets the ray "start point" of the ray in the world
  24019. */
  24020. get rayFromWorld(): Vector3;
  24021. /**
  24022. * Gets the ray "end point" of the ray in the world
  24023. */
  24024. get rayToWorld(): Vector3;
  24025. /**
  24026. * Sets the hit data (normal & point in world space)
  24027. * @param hitNormalWorld defines the normal in world space
  24028. * @param hitPointWorld defines the point in world space
  24029. */
  24030. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  24031. /**
  24032. * Sets the distance from the start point to the hit point
  24033. * @param distance
  24034. */
  24035. setHitDistance(distance: number): void;
  24036. /**
  24037. * Calculates the distance manually
  24038. */
  24039. calculateHitDistance(): void;
  24040. /**
  24041. * Resets all the values to default
  24042. * @param from The from point on world space
  24043. * @param to The to point on world space
  24044. */
  24045. reset(from?: Vector3, to?: Vector3): void;
  24046. }
  24047. /**
  24048. * Interface for the size containing width and height
  24049. */
  24050. interface IXYZ {
  24051. /**
  24052. * X
  24053. */
  24054. x: number;
  24055. /**
  24056. * Y
  24057. */
  24058. y: number;
  24059. /**
  24060. * Z
  24061. */
  24062. z: number;
  24063. }
  24064. }
  24065. declare module "babylonjs/Physics/IPhysicsEngine" {
  24066. import { Nullable } from "babylonjs/types";
  24067. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  24068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24069. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24070. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  24071. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  24072. /**
  24073. * Interface used to describe a physics joint
  24074. */
  24075. export interface PhysicsImpostorJoint {
  24076. /** Defines the main impostor to which the joint is linked */
  24077. mainImpostor: PhysicsImpostor;
  24078. /** Defines the impostor that is connected to the main impostor using this joint */
  24079. connectedImpostor: PhysicsImpostor;
  24080. /** Defines the joint itself */
  24081. joint: PhysicsJoint;
  24082. }
  24083. /** @hidden */
  24084. export interface IPhysicsEnginePlugin {
  24085. world: any;
  24086. name: string;
  24087. setGravity(gravity: Vector3): void;
  24088. setTimeStep(timeStep: number): void;
  24089. getTimeStep(): number;
  24090. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  24091. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24092. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  24093. generatePhysicsBody(impostor: PhysicsImpostor): void;
  24094. removePhysicsBody(impostor: PhysicsImpostor): void;
  24095. generateJoint(joint: PhysicsImpostorJoint): void;
  24096. removeJoint(joint: PhysicsImpostorJoint): void;
  24097. isSupported(): boolean;
  24098. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  24099. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  24100. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24101. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  24102. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24103. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  24104. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  24105. getBodyMass(impostor: PhysicsImpostor): number;
  24106. getBodyFriction(impostor: PhysicsImpostor): number;
  24107. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  24108. getBodyRestitution(impostor: PhysicsImpostor): number;
  24109. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  24110. getBodyPressure?(impostor: PhysicsImpostor): number;
  24111. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  24112. getBodyStiffness?(impostor: PhysicsImpostor): number;
  24113. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  24114. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  24115. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  24116. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  24117. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  24118. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24119. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  24120. sleepBody(impostor: PhysicsImpostor): void;
  24121. wakeUpBody(impostor: PhysicsImpostor): void;
  24122. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24123. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  24124. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  24125. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  24126. getRadius(impostor: PhysicsImpostor): number;
  24127. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  24128. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  24129. dispose(): void;
  24130. }
  24131. /**
  24132. * Interface used to define a physics engine
  24133. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  24134. */
  24135. export interface IPhysicsEngine {
  24136. /**
  24137. * Gets the gravity vector used by the simulation
  24138. */
  24139. gravity: Vector3;
  24140. /**
  24141. * Sets the gravity vector used by the simulation
  24142. * @param gravity defines the gravity vector to use
  24143. */
  24144. setGravity(gravity: Vector3): void;
  24145. /**
  24146. * Set the time step of the physics engine.
  24147. * Default is 1/60.
  24148. * To slow it down, enter 1/600 for example.
  24149. * To speed it up, 1/30
  24150. * @param newTimeStep the new timestep to apply to this world.
  24151. */
  24152. setTimeStep(newTimeStep: number): void;
  24153. /**
  24154. * Get the time step of the physics engine.
  24155. * @returns the current time step
  24156. */
  24157. getTimeStep(): number;
  24158. /**
  24159. * Set the sub time step of the physics engine.
  24160. * Default is 0 meaning there is no sub steps
  24161. * To increase physics resolution precision, set a small value (like 1 ms)
  24162. * @param subTimeStep defines the new sub timestep used for physics resolution.
  24163. */
  24164. setSubTimeStep(subTimeStep: number): void;
  24165. /**
  24166. * Get the sub time step of the physics engine.
  24167. * @returns the current sub time step
  24168. */
  24169. getSubTimeStep(): number;
  24170. /**
  24171. * Release all resources
  24172. */
  24173. dispose(): void;
  24174. /**
  24175. * Gets the name of the current physics plugin
  24176. * @returns the name of the plugin
  24177. */
  24178. getPhysicsPluginName(): string;
  24179. /**
  24180. * Adding a new impostor for the impostor tracking.
  24181. * This will be done by the impostor itself.
  24182. * @param impostor the impostor to add
  24183. */
  24184. addImpostor(impostor: PhysicsImpostor): void;
  24185. /**
  24186. * Remove an impostor from the engine.
  24187. * This impostor and its mesh will not longer be updated by the physics engine.
  24188. * @param impostor the impostor to remove
  24189. */
  24190. removeImpostor(impostor: PhysicsImpostor): void;
  24191. /**
  24192. * Add a joint to the physics engine
  24193. * @param mainImpostor defines the main impostor to which the joint is added.
  24194. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  24195. * @param joint defines the joint that will connect both impostors.
  24196. */
  24197. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24198. /**
  24199. * Removes a joint from the simulation
  24200. * @param mainImpostor defines the impostor used with the joint
  24201. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  24202. * @param joint defines the joint to remove
  24203. */
  24204. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  24205. /**
  24206. * Gets the current plugin used to run the simulation
  24207. * @returns current plugin
  24208. */
  24209. getPhysicsPlugin(): IPhysicsEnginePlugin;
  24210. /**
  24211. * Gets the list of physic impostors
  24212. * @returns an array of PhysicsImpostor
  24213. */
  24214. getImpostors(): Array<PhysicsImpostor>;
  24215. /**
  24216. * Gets the impostor for a physics enabled object
  24217. * @param object defines the object impersonated by the impostor
  24218. * @returns the PhysicsImpostor or null if not found
  24219. */
  24220. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24221. /**
  24222. * Gets the impostor for a physics body object
  24223. * @param body defines physics body used by the impostor
  24224. * @returns the PhysicsImpostor or null if not found
  24225. */
  24226. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  24227. /**
  24228. * Does a raycast in the physics world
  24229. * @param from when should the ray start?
  24230. * @param to when should the ray end?
  24231. * @returns PhysicsRaycastResult
  24232. */
  24233. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  24234. /**
  24235. * Called by the scene. No need to call it.
  24236. * @param delta defines the timespam between frames
  24237. */
  24238. _step(delta: number): void;
  24239. }
  24240. }
  24241. declare module "babylonjs/Physics/physicsImpostor" {
  24242. import { Nullable, IndicesArray } from "babylonjs/types";
  24243. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  24244. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24246. import { Scene } from "babylonjs/scene";
  24247. import { Bone } from "babylonjs/Bones/bone";
  24248. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24249. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  24250. import { Space } from "babylonjs/Maths/math.axis";
  24251. /**
  24252. * The interface for the physics imposter parameters
  24253. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24254. */
  24255. export interface PhysicsImpostorParameters {
  24256. /**
  24257. * The mass of the physics imposter
  24258. */
  24259. mass: number;
  24260. /**
  24261. * The friction of the physics imposter
  24262. */
  24263. friction?: number;
  24264. /**
  24265. * The coefficient of restitution of the physics imposter
  24266. */
  24267. restitution?: number;
  24268. /**
  24269. * The native options of the physics imposter
  24270. */
  24271. nativeOptions?: any;
  24272. /**
  24273. * Specifies if the parent should be ignored
  24274. */
  24275. ignoreParent?: boolean;
  24276. /**
  24277. * Specifies if bi-directional transformations should be disabled
  24278. */
  24279. disableBidirectionalTransformation?: boolean;
  24280. /**
  24281. * The pressure inside the physics imposter, soft object only
  24282. */
  24283. pressure?: number;
  24284. /**
  24285. * The stiffness the physics imposter, soft object only
  24286. */
  24287. stiffness?: number;
  24288. /**
  24289. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  24290. */
  24291. velocityIterations?: number;
  24292. /**
  24293. * The number of iterations used in maintaining consistent vertex positions, soft object only
  24294. */
  24295. positionIterations?: number;
  24296. /**
  24297. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  24298. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  24299. * Add to fix multiple points
  24300. */
  24301. fixedPoints?: number;
  24302. /**
  24303. * The collision margin around a soft object
  24304. */
  24305. margin?: number;
  24306. /**
  24307. * The collision margin around a soft object
  24308. */
  24309. damping?: number;
  24310. /**
  24311. * The path for a rope based on an extrusion
  24312. */
  24313. path?: any;
  24314. /**
  24315. * The shape of an extrusion used for a rope based on an extrusion
  24316. */
  24317. shape?: any;
  24318. }
  24319. /**
  24320. * Interface for a physics-enabled object
  24321. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24322. */
  24323. export interface IPhysicsEnabledObject {
  24324. /**
  24325. * The position of the physics-enabled object
  24326. */
  24327. position: Vector3;
  24328. /**
  24329. * The rotation of the physics-enabled object
  24330. */
  24331. rotationQuaternion: Nullable<Quaternion>;
  24332. /**
  24333. * The scale of the physics-enabled object
  24334. */
  24335. scaling: Vector3;
  24336. /**
  24337. * The rotation of the physics-enabled object
  24338. */
  24339. rotation?: Vector3;
  24340. /**
  24341. * The parent of the physics-enabled object
  24342. */
  24343. parent?: any;
  24344. /**
  24345. * The bounding info of the physics-enabled object
  24346. * @returns The bounding info of the physics-enabled object
  24347. */
  24348. getBoundingInfo(): BoundingInfo;
  24349. /**
  24350. * Computes the world matrix
  24351. * @param force Specifies if the world matrix should be computed by force
  24352. * @returns A world matrix
  24353. */
  24354. computeWorldMatrix(force: boolean): Matrix;
  24355. /**
  24356. * Gets the world matrix
  24357. * @returns A world matrix
  24358. */
  24359. getWorldMatrix?(): Matrix;
  24360. /**
  24361. * Gets the child meshes
  24362. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  24363. * @returns An array of abstract meshes
  24364. */
  24365. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  24366. /**
  24367. * Gets the vertex data
  24368. * @param kind The type of vertex data
  24369. * @returns A nullable array of numbers, or a float32 array
  24370. */
  24371. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  24372. /**
  24373. * Gets the indices from the mesh
  24374. * @returns A nullable array of index arrays
  24375. */
  24376. getIndices?(): Nullable<IndicesArray>;
  24377. /**
  24378. * Gets the scene from the mesh
  24379. * @returns the indices array or null
  24380. */
  24381. getScene?(): Scene;
  24382. /**
  24383. * Gets the absolute position from the mesh
  24384. * @returns the absolute position
  24385. */
  24386. getAbsolutePosition(): Vector3;
  24387. /**
  24388. * Gets the absolute pivot point from the mesh
  24389. * @returns the absolute pivot point
  24390. */
  24391. getAbsolutePivotPoint(): Vector3;
  24392. /**
  24393. * Rotates the mesh
  24394. * @param axis The axis of rotation
  24395. * @param amount The amount of rotation
  24396. * @param space The space of the rotation
  24397. * @returns The rotation transform node
  24398. */
  24399. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  24400. /**
  24401. * Translates the mesh
  24402. * @param axis The axis of translation
  24403. * @param distance The distance of translation
  24404. * @param space The space of the translation
  24405. * @returns The transform node
  24406. */
  24407. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  24408. /**
  24409. * Sets the absolute position of the mesh
  24410. * @param absolutePosition The absolute position of the mesh
  24411. * @returns The transform node
  24412. */
  24413. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  24414. /**
  24415. * Gets the class name of the mesh
  24416. * @returns The class name
  24417. */
  24418. getClassName(): string;
  24419. }
  24420. /**
  24421. * Represents a physics imposter
  24422. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  24423. */
  24424. export class PhysicsImpostor {
  24425. /**
  24426. * The physics-enabled object used as the physics imposter
  24427. */
  24428. object: IPhysicsEnabledObject;
  24429. /**
  24430. * The type of the physics imposter
  24431. */
  24432. type: number;
  24433. private _options;
  24434. private _scene?;
  24435. /**
  24436. * The default object size of the imposter
  24437. */
  24438. static DEFAULT_OBJECT_SIZE: Vector3;
  24439. /**
  24440. * The identity quaternion of the imposter
  24441. */
  24442. static IDENTITY_QUATERNION: Quaternion;
  24443. /** @hidden */
  24444. _pluginData: any;
  24445. private _physicsEngine;
  24446. private _physicsBody;
  24447. private _bodyUpdateRequired;
  24448. private _onBeforePhysicsStepCallbacks;
  24449. private _onAfterPhysicsStepCallbacks;
  24450. /** @hidden */
  24451. _onPhysicsCollideCallbacks: Array<{
  24452. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  24453. otherImpostors: Array<PhysicsImpostor>;
  24454. }>;
  24455. private _deltaPosition;
  24456. private _deltaRotation;
  24457. private _deltaRotationConjugated;
  24458. /** @hidden */
  24459. _isFromLine: boolean;
  24460. private _parent;
  24461. private _isDisposed;
  24462. private static _tmpVecs;
  24463. private static _tmpQuat;
  24464. /**
  24465. * Specifies if the physics imposter is disposed
  24466. */
  24467. get isDisposed(): boolean;
  24468. /**
  24469. * Gets the mass of the physics imposter
  24470. */
  24471. get mass(): number;
  24472. set mass(value: number);
  24473. /**
  24474. * Gets the coefficient of friction
  24475. */
  24476. get friction(): number;
  24477. /**
  24478. * Sets the coefficient of friction
  24479. */
  24480. set friction(value: number);
  24481. /**
  24482. * Gets the coefficient of restitution
  24483. */
  24484. get restitution(): number;
  24485. /**
  24486. * Sets the coefficient of restitution
  24487. */
  24488. set restitution(value: number);
  24489. /**
  24490. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  24491. */
  24492. get pressure(): number;
  24493. /**
  24494. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  24495. */
  24496. set pressure(value: number);
  24497. /**
  24498. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24499. */
  24500. get stiffness(): number;
  24501. /**
  24502. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  24503. */
  24504. set stiffness(value: number);
  24505. /**
  24506. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24507. */
  24508. get velocityIterations(): number;
  24509. /**
  24510. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  24511. */
  24512. set velocityIterations(value: number);
  24513. /**
  24514. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24515. */
  24516. get positionIterations(): number;
  24517. /**
  24518. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  24519. */
  24520. set positionIterations(value: number);
  24521. /**
  24522. * The unique id of the physics imposter
  24523. * set by the physics engine when adding this impostor to the array
  24524. */
  24525. uniqueId: number;
  24526. /**
  24527. * @hidden
  24528. */
  24529. soft: boolean;
  24530. /**
  24531. * @hidden
  24532. */
  24533. segments: number;
  24534. private _joints;
  24535. /**
  24536. * Initializes the physics imposter
  24537. * @param object The physics-enabled object used as the physics imposter
  24538. * @param type The type of the physics imposter
  24539. * @param _options The options for the physics imposter
  24540. * @param _scene The Babylon scene
  24541. */
  24542. constructor(
  24543. /**
  24544. * The physics-enabled object used as the physics imposter
  24545. */
  24546. object: IPhysicsEnabledObject,
  24547. /**
  24548. * The type of the physics imposter
  24549. */
  24550. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  24551. /**
  24552. * This function will completly initialize this impostor.
  24553. * It will create a new body - but only if this mesh has no parent.
  24554. * If it has, this impostor will not be used other than to define the impostor
  24555. * of the child mesh.
  24556. * @hidden
  24557. */
  24558. _init(): void;
  24559. private _getPhysicsParent;
  24560. /**
  24561. * Should a new body be generated.
  24562. * @returns boolean specifying if body initialization is required
  24563. */
  24564. isBodyInitRequired(): boolean;
  24565. /**
  24566. * Sets the updated scaling
  24567. * @param updated Specifies if the scaling is updated
  24568. */
  24569. setScalingUpdated(): void;
  24570. /**
  24571. * Force a regeneration of this or the parent's impostor's body.
  24572. * Use under cautious - This will remove all joints already implemented.
  24573. */
  24574. forceUpdate(): void;
  24575. /**
  24576. * Gets the body that holds this impostor. Either its own, or its parent.
  24577. */
  24578. get physicsBody(): any;
  24579. /**
  24580. * Get the parent of the physics imposter
  24581. * @returns Physics imposter or null
  24582. */
  24583. get parent(): Nullable<PhysicsImpostor>;
  24584. /**
  24585. * Sets the parent of the physics imposter
  24586. */
  24587. set parent(value: Nullable<PhysicsImpostor>);
  24588. /**
  24589. * Set the physics body. Used mainly by the physics engine/plugin
  24590. */
  24591. set physicsBody(physicsBody: any);
  24592. /**
  24593. * Resets the update flags
  24594. */
  24595. resetUpdateFlags(): void;
  24596. /**
  24597. * Gets the object extend size
  24598. * @returns the object extend size
  24599. */
  24600. getObjectExtendSize(): Vector3;
  24601. /**
  24602. * Gets the object center
  24603. * @returns The object center
  24604. */
  24605. getObjectCenter(): Vector3;
  24606. /**
  24607. * Get a specific parameter from the options parameters
  24608. * @param paramName The object parameter name
  24609. * @returns The object parameter
  24610. */
  24611. getParam(paramName: string): any;
  24612. /**
  24613. * Sets a specific parameter in the options given to the physics plugin
  24614. * @param paramName The parameter name
  24615. * @param value The value of the parameter
  24616. */
  24617. setParam(paramName: string, value: number): void;
  24618. /**
  24619. * Specifically change the body's mass option. Won't recreate the physics body object
  24620. * @param mass The mass of the physics imposter
  24621. */
  24622. setMass(mass: number): void;
  24623. /**
  24624. * Gets the linear velocity
  24625. * @returns linear velocity or null
  24626. */
  24627. getLinearVelocity(): Nullable<Vector3>;
  24628. /**
  24629. * Sets the linear velocity
  24630. * @param velocity linear velocity or null
  24631. */
  24632. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24633. /**
  24634. * Gets the angular velocity
  24635. * @returns angular velocity or null
  24636. */
  24637. getAngularVelocity(): Nullable<Vector3>;
  24638. /**
  24639. * Sets the angular velocity
  24640. * @param velocity The velocity or null
  24641. */
  24642. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24643. /**
  24644. * Execute a function with the physics plugin native code
  24645. * Provide a function the will have two variables - the world object and the physics body object
  24646. * @param func The function to execute with the physics plugin native code
  24647. */
  24648. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24649. /**
  24650. * Register a function that will be executed before the physics world is stepping forward
  24651. * @param func The function to execute before the physics world is stepped forward
  24652. */
  24653. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24654. /**
  24655. * Unregister a function that will be executed before the physics world is stepping forward
  24656. * @param func The function to execute before the physics world is stepped forward
  24657. */
  24658. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24659. /**
  24660. * Register a function that will be executed after the physics step
  24661. * @param func The function to execute after physics step
  24662. */
  24663. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24664. /**
  24665. * Unregisters a function that will be executed after the physics step
  24666. * @param func The function to execute after physics step
  24667. */
  24668. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24669. /**
  24670. * register a function that will be executed when this impostor collides against a different body
  24671. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24672. * @param func Callback that is executed on collision
  24673. */
  24674. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24675. /**
  24676. * Unregisters the physics imposter on contact
  24677. * @param collideAgainst The physics object to collide against
  24678. * @param func Callback to execute on collision
  24679. */
  24680. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24681. private _tmpQuat;
  24682. private _tmpQuat2;
  24683. /**
  24684. * Get the parent rotation
  24685. * @returns The parent rotation
  24686. */
  24687. getParentsRotation(): Quaternion;
  24688. /**
  24689. * this function is executed by the physics engine.
  24690. */
  24691. beforeStep: () => void;
  24692. /**
  24693. * this function is executed by the physics engine
  24694. */
  24695. afterStep: () => void;
  24696. /**
  24697. * Legacy collision detection event support
  24698. */
  24699. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24700. /**
  24701. * event and body object due to cannon's event-based architecture.
  24702. */
  24703. onCollide: (e: {
  24704. body: any;
  24705. }) => void;
  24706. /**
  24707. * Apply a force
  24708. * @param force The force to apply
  24709. * @param contactPoint The contact point for the force
  24710. * @returns The physics imposter
  24711. */
  24712. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24713. /**
  24714. * Apply an impulse
  24715. * @param force The impulse force
  24716. * @param contactPoint The contact point for the impulse force
  24717. * @returns The physics imposter
  24718. */
  24719. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24720. /**
  24721. * A help function to create a joint
  24722. * @param otherImpostor A physics imposter used to create a joint
  24723. * @param jointType The type of joint
  24724. * @param jointData The data for the joint
  24725. * @returns The physics imposter
  24726. */
  24727. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24728. /**
  24729. * Add a joint to this impostor with a different impostor
  24730. * @param otherImpostor A physics imposter used to add a joint
  24731. * @param joint The joint to add
  24732. * @returns The physics imposter
  24733. */
  24734. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24735. /**
  24736. * Add an anchor to a cloth impostor
  24737. * @param otherImpostor rigid impostor to anchor to
  24738. * @param width ratio across width from 0 to 1
  24739. * @param height ratio up height from 0 to 1
  24740. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24741. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24742. * @returns impostor the soft imposter
  24743. */
  24744. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24745. /**
  24746. * Add a hook to a rope impostor
  24747. * @param otherImpostor rigid impostor to anchor to
  24748. * @param length ratio across rope from 0 to 1
  24749. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24750. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24751. * @returns impostor the rope imposter
  24752. */
  24753. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24754. /**
  24755. * Will keep this body still, in a sleep mode.
  24756. * @returns the physics imposter
  24757. */
  24758. sleep(): PhysicsImpostor;
  24759. /**
  24760. * Wake the body up.
  24761. * @returns The physics imposter
  24762. */
  24763. wakeUp(): PhysicsImpostor;
  24764. /**
  24765. * Clones the physics imposter
  24766. * @param newObject The physics imposter clones to this physics-enabled object
  24767. * @returns A nullable physics imposter
  24768. */
  24769. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24770. /**
  24771. * Disposes the physics imposter
  24772. */
  24773. dispose(): void;
  24774. /**
  24775. * Sets the delta position
  24776. * @param position The delta position amount
  24777. */
  24778. setDeltaPosition(position: Vector3): void;
  24779. /**
  24780. * Sets the delta rotation
  24781. * @param rotation The delta rotation amount
  24782. */
  24783. setDeltaRotation(rotation: Quaternion): void;
  24784. /**
  24785. * Gets the box size of the physics imposter and stores the result in the input parameter
  24786. * @param result Stores the box size
  24787. * @returns The physics imposter
  24788. */
  24789. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24790. /**
  24791. * Gets the radius of the physics imposter
  24792. * @returns Radius of the physics imposter
  24793. */
  24794. getRadius(): number;
  24795. /**
  24796. * Sync a bone with this impostor
  24797. * @param bone The bone to sync to the impostor.
  24798. * @param boneMesh The mesh that the bone is influencing.
  24799. * @param jointPivot The pivot of the joint / bone in local space.
  24800. * @param distToJoint Optional distance from the impostor to the joint.
  24801. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24802. */
  24803. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24804. /**
  24805. * Sync impostor to a bone
  24806. * @param bone The bone that the impostor will be synced to.
  24807. * @param boneMesh The mesh that the bone is influencing.
  24808. * @param jointPivot The pivot of the joint / bone in local space.
  24809. * @param distToJoint Optional distance from the impostor to the joint.
  24810. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24811. * @param boneAxis Optional vector3 axis the bone is aligned with
  24812. */
  24813. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24814. /**
  24815. * No-Imposter type
  24816. */
  24817. static NoImpostor: number;
  24818. /**
  24819. * Sphere-Imposter type
  24820. */
  24821. static SphereImpostor: number;
  24822. /**
  24823. * Box-Imposter type
  24824. */
  24825. static BoxImpostor: number;
  24826. /**
  24827. * Plane-Imposter type
  24828. */
  24829. static PlaneImpostor: number;
  24830. /**
  24831. * Mesh-imposter type
  24832. */
  24833. static MeshImpostor: number;
  24834. /**
  24835. * Capsule-Impostor type (Ammo.js plugin only)
  24836. */
  24837. static CapsuleImpostor: number;
  24838. /**
  24839. * Cylinder-Imposter type
  24840. */
  24841. static CylinderImpostor: number;
  24842. /**
  24843. * Particle-Imposter type
  24844. */
  24845. static ParticleImpostor: number;
  24846. /**
  24847. * Heightmap-Imposter type
  24848. */
  24849. static HeightmapImpostor: number;
  24850. /**
  24851. * ConvexHull-Impostor type (Ammo.js plugin only)
  24852. */
  24853. static ConvexHullImpostor: number;
  24854. /**
  24855. * Custom-Imposter type (Ammo.js plugin only)
  24856. */
  24857. static CustomImpostor: number;
  24858. /**
  24859. * Rope-Imposter type
  24860. */
  24861. static RopeImpostor: number;
  24862. /**
  24863. * Cloth-Imposter type
  24864. */
  24865. static ClothImpostor: number;
  24866. /**
  24867. * Softbody-Imposter type
  24868. */
  24869. static SoftbodyImpostor: number;
  24870. }
  24871. }
  24872. declare module "babylonjs/Meshes/mesh" {
  24873. import { Observable } from "babylonjs/Misc/observable";
  24874. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24875. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24876. import { Camera } from "babylonjs/Cameras/camera";
  24877. import { Scene } from "babylonjs/scene";
  24878. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24879. import { Color4 } from "babylonjs/Maths/math.color";
  24880. import { Engine } from "babylonjs/Engines/engine";
  24881. import { Node } from "babylonjs/node";
  24882. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24883. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24884. import { Buffer } from "babylonjs/Meshes/buffer";
  24885. import { Geometry } from "babylonjs/Meshes/geometry";
  24886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24887. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24888. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24889. import { Effect } from "babylonjs/Materials/effect";
  24890. import { Material } from "babylonjs/Materials/material";
  24891. import { Skeleton } from "babylonjs/Bones/skeleton";
  24892. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24893. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24894. import { Path3D } from "babylonjs/Maths/math.path";
  24895. import { Plane } from "babylonjs/Maths/math.plane";
  24896. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24897. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24898. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24899. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24900. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24901. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24902. /**
  24903. * @hidden
  24904. **/
  24905. export class _CreationDataStorage {
  24906. closePath?: boolean;
  24907. closeArray?: boolean;
  24908. idx: number[];
  24909. dashSize: number;
  24910. gapSize: number;
  24911. path3D: Path3D;
  24912. pathArray: Vector3[][];
  24913. arc: number;
  24914. radius: number;
  24915. cap: number;
  24916. tessellation: number;
  24917. }
  24918. /**
  24919. * @hidden
  24920. **/
  24921. class _InstanceDataStorage {
  24922. visibleInstances: any;
  24923. batchCache: _InstancesBatch;
  24924. instancesBufferSize: number;
  24925. instancesBuffer: Nullable<Buffer>;
  24926. instancesData: Float32Array;
  24927. overridenInstanceCount: number;
  24928. isFrozen: boolean;
  24929. previousBatch: Nullable<_InstancesBatch>;
  24930. hardwareInstancedRendering: boolean;
  24931. sideOrientation: number;
  24932. manualUpdate: boolean;
  24933. }
  24934. /**
  24935. * @hidden
  24936. **/
  24937. export class _InstancesBatch {
  24938. mustReturn: boolean;
  24939. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24940. renderSelf: boolean[];
  24941. hardwareInstancedRendering: boolean[];
  24942. }
  24943. /**
  24944. * Class used to represent renderable models
  24945. */
  24946. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24947. /**
  24948. * Mesh side orientation : usually the external or front surface
  24949. */
  24950. static readonly FRONTSIDE: number;
  24951. /**
  24952. * Mesh side orientation : usually the internal or back surface
  24953. */
  24954. static readonly BACKSIDE: number;
  24955. /**
  24956. * Mesh side orientation : both internal and external or front and back surfaces
  24957. */
  24958. static readonly DOUBLESIDE: number;
  24959. /**
  24960. * Mesh side orientation : by default, `FRONTSIDE`
  24961. */
  24962. static readonly DEFAULTSIDE: number;
  24963. /**
  24964. * Mesh cap setting : no cap
  24965. */
  24966. static readonly NO_CAP: number;
  24967. /**
  24968. * Mesh cap setting : one cap at the beginning of the mesh
  24969. */
  24970. static readonly CAP_START: number;
  24971. /**
  24972. * Mesh cap setting : one cap at the end of the mesh
  24973. */
  24974. static readonly CAP_END: number;
  24975. /**
  24976. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24977. */
  24978. static readonly CAP_ALL: number;
  24979. /**
  24980. * Mesh pattern setting : no flip or rotate
  24981. */
  24982. static readonly NO_FLIP: number;
  24983. /**
  24984. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24985. */
  24986. static readonly FLIP_TILE: number;
  24987. /**
  24988. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24989. */
  24990. static readonly ROTATE_TILE: number;
  24991. /**
  24992. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24993. */
  24994. static readonly FLIP_ROW: number;
  24995. /**
  24996. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24997. */
  24998. static readonly ROTATE_ROW: number;
  24999. /**
  25000. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  25001. */
  25002. static readonly FLIP_N_ROTATE_TILE: number;
  25003. /**
  25004. * Mesh pattern setting : rotate pattern and rotate
  25005. */
  25006. static readonly FLIP_N_ROTATE_ROW: number;
  25007. /**
  25008. * Mesh tile positioning : part tiles same on left/right or top/bottom
  25009. */
  25010. static readonly CENTER: number;
  25011. /**
  25012. * Mesh tile positioning : part tiles on left
  25013. */
  25014. static readonly LEFT: number;
  25015. /**
  25016. * Mesh tile positioning : part tiles on right
  25017. */
  25018. static readonly RIGHT: number;
  25019. /**
  25020. * Mesh tile positioning : part tiles on top
  25021. */
  25022. static readonly TOP: number;
  25023. /**
  25024. * Mesh tile positioning : part tiles on bottom
  25025. */
  25026. static readonly BOTTOM: number;
  25027. /**
  25028. * Gets the default side orientation.
  25029. * @param orientation the orientation to value to attempt to get
  25030. * @returns the default orientation
  25031. * @hidden
  25032. */
  25033. static _GetDefaultSideOrientation(orientation?: number): number;
  25034. private _internalMeshDataInfo;
  25035. /**
  25036. * An event triggered before rendering the mesh
  25037. */
  25038. get onBeforeRenderObservable(): Observable<Mesh>;
  25039. /**
  25040. * An event triggered before binding the mesh
  25041. */
  25042. get onBeforeBindObservable(): Observable<Mesh>;
  25043. /**
  25044. * An event triggered after rendering the mesh
  25045. */
  25046. get onAfterRenderObservable(): Observable<Mesh>;
  25047. /**
  25048. * An event triggered before drawing the mesh
  25049. */
  25050. get onBeforeDrawObservable(): Observable<Mesh>;
  25051. private _onBeforeDrawObserver;
  25052. /**
  25053. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  25054. */
  25055. set onBeforeDraw(callback: () => void);
  25056. get hasInstances(): boolean;
  25057. /**
  25058. * Gets the delay loading state of the mesh (when delay loading is turned on)
  25059. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  25060. */
  25061. delayLoadState: number;
  25062. /**
  25063. * Gets the list of instances created from this mesh
  25064. * it is not supposed to be modified manually.
  25065. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  25066. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25067. */
  25068. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  25069. /**
  25070. * Gets the file containing delay loading data for this mesh
  25071. */
  25072. delayLoadingFile: string;
  25073. /** @hidden */
  25074. _binaryInfo: any;
  25075. /**
  25076. * User defined function used to change how LOD level selection is done
  25077. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  25078. */
  25079. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  25080. /**
  25081. * Gets or sets the morph target manager
  25082. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  25083. */
  25084. get morphTargetManager(): Nullable<MorphTargetManager>;
  25085. set morphTargetManager(value: Nullable<MorphTargetManager>);
  25086. /** @hidden */
  25087. _creationDataStorage: Nullable<_CreationDataStorage>;
  25088. /** @hidden */
  25089. _geometry: Nullable<Geometry>;
  25090. /** @hidden */
  25091. _delayInfo: Array<string>;
  25092. /** @hidden */
  25093. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  25094. /** @hidden */
  25095. _instanceDataStorage: _InstanceDataStorage;
  25096. private _effectiveMaterial;
  25097. /** @hidden */
  25098. _shouldGenerateFlatShading: boolean;
  25099. /** @hidden */
  25100. _originalBuilderSideOrientation: number;
  25101. /**
  25102. * Use this property to change the original side orientation defined at construction time
  25103. */
  25104. overrideMaterialSideOrientation: Nullable<number>;
  25105. /**
  25106. * Gets the source mesh (the one used to clone this one from)
  25107. */
  25108. get source(): Nullable<Mesh>;
  25109. /**
  25110. * Gets or sets a boolean indicating that this mesh does not use index buffer
  25111. */
  25112. get isUnIndexed(): boolean;
  25113. set isUnIndexed(value: boolean);
  25114. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  25115. get worldMatrixInstancedBuffer(): Float32Array;
  25116. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  25117. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  25118. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  25119. /**
  25120. * @constructor
  25121. * @param name The value used by scene.getMeshByName() to do a lookup.
  25122. * @param scene The scene to add this mesh to.
  25123. * @param parent The parent of this mesh, if it has one
  25124. * @param source An optional Mesh from which geometry is shared, cloned.
  25125. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  25126. * When false, achieved by calling a clone(), also passing False.
  25127. * This will make creation of children, recursive.
  25128. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  25129. */
  25130. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  25131. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  25132. doNotInstantiate: boolean;
  25133. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  25134. /**
  25135. * Gets the class name
  25136. * @returns the string "Mesh".
  25137. */
  25138. getClassName(): string;
  25139. /** @hidden */
  25140. get _isMesh(): boolean;
  25141. /**
  25142. * Returns a description of this mesh
  25143. * @param fullDetails define if full details about this mesh must be used
  25144. * @returns a descriptive string representing this mesh
  25145. */
  25146. toString(fullDetails?: boolean): string;
  25147. /** @hidden */
  25148. _unBindEffect(): void;
  25149. /**
  25150. * Gets a boolean indicating if this mesh has LOD
  25151. */
  25152. get hasLODLevels(): boolean;
  25153. /**
  25154. * Gets the list of MeshLODLevel associated with the current mesh
  25155. * @returns an array of MeshLODLevel
  25156. */
  25157. getLODLevels(): MeshLODLevel[];
  25158. private _sortLODLevels;
  25159. /**
  25160. * Add a mesh as LOD level triggered at the given distance.
  25161. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25162. * @param distance The distance from the center of the object to show this level
  25163. * @param mesh The mesh to be added as LOD level (can be null)
  25164. * @return This mesh (for chaining)
  25165. */
  25166. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  25167. /**
  25168. * Returns the LOD level mesh at the passed distance or null if not found.
  25169. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25170. * @param distance The distance from the center of the object to show this level
  25171. * @returns a Mesh or `null`
  25172. */
  25173. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  25174. /**
  25175. * Remove a mesh from the LOD array
  25176. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25177. * @param mesh defines the mesh to be removed
  25178. * @return This mesh (for chaining)
  25179. */
  25180. removeLODLevel(mesh: Mesh): Mesh;
  25181. /**
  25182. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  25183. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  25184. * @param camera defines the camera to use to compute distance
  25185. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  25186. * @return This mesh (for chaining)
  25187. */
  25188. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  25189. /**
  25190. * Gets the mesh internal Geometry object
  25191. */
  25192. get geometry(): Nullable<Geometry>;
  25193. /**
  25194. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  25195. * @returns the total number of vertices
  25196. */
  25197. getTotalVertices(): number;
  25198. /**
  25199. * Returns the content of an associated vertex buffer
  25200. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25201. * - VertexBuffer.PositionKind
  25202. * - VertexBuffer.UVKind
  25203. * - VertexBuffer.UV2Kind
  25204. * - VertexBuffer.UV3Kind
  25205. * - VertexBuffer.UV4Kind
  25206. * - VertexBuffer.UV5Kind
  25207. * - VertexBuffer.UV6Kind
  25208. * - VertexBuffer.ColorKind
  25209. * - VertexBuffer.MatricesIndicesKind
  25210. * - VertexBuffer.MatricesIndicesExtraKind
  25211. * - VertexBuffer.MatricesWeightsKind
  25212. * - VertexBuffer.MatricesWeightsExtraKind
  25213. * @param copyWhenShared defines a boolean indicating that if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one
  25214. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  25215. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  25216. */
  25217. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  25218. /**
  25219. * Returns the mesh VertexBuffer object from the requested `kind`
  25220. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25221. * - VertexBuffer.PositionKind
  25222. * - VertexBuffer.NormalKind
  25223. * - VertexBuffer.UVKind
  25224. * - VertexBuffer.UV2Kind
  25225. * - VertexBuffer.UV3Kind
  25226. * - VertexBuffer.UV4Kind
  25227. * - VertexBuffer.UV5Kind
  25228. * - VertexBuffer.UV6Kind
  25229. * - VertexBuffer.ColorKind
  25230. * - VertexBuffer.MatricesIndicesKind
  25231. * - VertexBuffer.MatricesIndicesExtraKind
  25232. * - VertexBuffer.MatricesWeightsKind
  25233. * - VertexBuffer.MatricesWeightsExtraKind
  25234. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  25235. */
  25236. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  25237. /**
  25238. * Tests if a specific vertex buffer is associated with this mesh
  25239. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25240. * - VertexBuffer.PositionKind
  25241. * - VertexBuffer.NormalKind
  25242. * - VertexBuffer.UVKind
  25243. * - VertexBuffer.UV2Kind
  25244. * - VertexBuffer.UV3Kind
  25245. * - VertexBuffer.UV4Kind
  25246. * - VertexBuffer.UV5Kind
  25247. * - VertexBuffer.UV6Kind
  25248. * - VertexBuffer.ColorKind
  25249. * - VertexBuffer.MatricesIndicesKind
  25250. * - VertexBuffer.MatricesIndicesExtraKind
  25251. * - VertexBuffer.MatricesWeightsKind
  25252. * - VertexBuffer.MatricesWeightsExtraKind
  25253. * @returns a boolean
  25254. */
  25255. isVerticesDataPresent(kind: string): boolean;
  25256. /**
  25257. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  25258. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  25259. * - VertexBuffer.PositionKind
  25260. * - VertexBuffer.UVKind
  25261. * - VertexBuffer.UV2Kind
  25262. * - VertexBuffer.UV3Kind
  25263. * - VertexBuffer.UV4Kind
  25264. * - VertexBuffer.UV5Kind
  25265. * - VertexBuffer.UV6Kind
  25266. * - VertexBuffer.ColorKind
  25267. * - VertexBuffer.MatricesIndicesKind
  25268. * - VertexBuffer.MatricesIndicesExtraKind
  25269. * - VertexBuffer.MatricesWeightsKind
  25270. * - VertexBuffer.MatricesWeightsExtraKind
  25271. * @returns a boolean
  25272. */
  25273. isVertexBufferUpdatable(kind: string): boolean;
  25274. /**
  25275. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  25276. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  25277. * - VertexBuffer.PositionKind
  25278. * - VertexBuffer.NormalKind
  25279. * - VertexBuffer.UVKind
  25280. * - VertexBuffer.UV2Kind
  25281. * - VertexBuffer.UV3Kind
  25282. * - VertexBuffer.UV4Kind
  25283. * - VertexBuffer.UV5Kind
  25284. * - VertexBuffer.UV6Kind
  25285. * - VertexBuffer.ColorKind
  25286. * - VertexBuffer.MatricesIndicesKind
  25287. * - VertexBuffer.MatricesIndicesExtraKind
  25288. * - VertexBuffer.MatricesWeightsKind
  25289. * - VertexBuffer.MatricesWeightsExtraKind
  25290. * @returns an array of strings
  25291. */
  25292. getVerticesDataKinds(): string[];
  25293. /**
  25294. * Returns a positive integer : the total number of indices in this mesh geometry.
  25295. * @returns the numner of indices or zero if the mesh has no geometry.
  25296. */
  25297. getTotalIndices(): number;
  25298. /**
  25299. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  25300. * @param copyWhenShared If true (default false) and and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  25301. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  25302. * @returns the indices array or an empty array if the mesh has no geometry
  25303. */
  25304. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  25305. get isBlocked(): boolean;
  25306. /**
  25307. * Determine if the current mesh is ready to be rendered
  25308. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25309. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  25310. * @returns true if all associated assets are ready (material, textures, shaders)
  25311. */
  25312. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  25313. /**
  25314. * Gets a boolean indicating if the normals aren't to be recomputed on next mesh `positions` array update. This property is pertinent only for updatable parametric shapes.
  25315. */
  25316. get areNormalsFrozen(): boolean;
  25317. /**
  25318. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It prevents the mesh normals from being recomputed on next `positions` array update.
  25319. * @returns the current mesh
  25320. */
  25321. freezeNormals(): Mesh;
  25322. /**
  25323. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc. It has no effect at all on other shapes. It reactivates the mesh normals computation if it was previously frozen
  25324. * @returns the current mesh
  25325. */
  25326. unfreezeNormals(): Mesh;
  25327. /**
  25328. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  25329. */
  25330. set overridenInstanceCount(count: number);
  25331. /** @hidden */
  25332. _preActivate(): Mesh;
  25333. /** @hidden */
  25334. _preActivateForIntermediateRendering(renderId: number): Mesh;
  25335. /** @hidden */
  25336. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  25337. /**
  25338. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25339. * This means the mesh underlying bounding box and sphere are recomputed.
  25340. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25341. * @returns the current mesh
  25342. */
  25343. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  25344. /** @hidden */
  25345. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  25346. /**
  25347. * This function will subdivide the mesh into multiple submeshes
  25348. * @param count defines the expected number of submeshes
  25349. */
  25350. subdivide(count: number): void;
  25351. /**
  25352. * Copy a FloatArray into a specific associated vertex buffer
  25353. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25354. * - VertexBuffer.PositionKind
  25355. * - VertexBuffer.UVKind
  25356. * - VertexBuffer.UV2Kind
  25357. * - VertexBuffer.UV3Kind
  25358. * - VertexBuffer.UV4Kind
  25359. * - VertexBuffer.UV5Kind
  25360. * - VertexBuffer.UV6Kind
  25361. * - VertexBuffer.ColorKind
  25362. * - VertexBuffer.MatricesIndicesKind
  25363. * - VertexBuffer.MatricesIndicesExtraKind
  25364. * - VertexBuffer.MatricesWeightsKind
  25365. * - VertexBuffer.MatricesWeightsExtraKind
  25366. * @param data defines the data source
  25367. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25368. * @param stride defines the data stride size (can be null)
  25369. * @returns the current mesh
  25370. */
  25371. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25372. /**
  25373. * Delete a vertex buffer associated with this mesh
  25374. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  25375. * - VertexBuffer.PositionKind
  25376. * - VertexBuffer.UVKind
  25377. * - VertexBuffer.UV2Kind
  25378. * - VertexBuffer.UV3Kind
  25379. * - VertexBuffer.UV4Kind
  25380. * - VertexBuffer.UV5Kind
  25381. * - VertexBuffer.UV6Kind
  25382. * - VertexBuffer.ColorKind
  25383. * - VertexBuffer.MatricesIndicesKind
  25384. * - VertexBuffer.MatricesIndicesExtraKind
  25385. * - VertexBuffer.MatricesWeightsKind
  25386. * - VertexBuffer.MatricesWeightsExtraKind
  25387. */
  25388. removeVerticesData(kind: string): void;
  25389. /**
  25390. * Flags an associated vertex buffer as updatable
  25391. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  25392. * - VertexBuffer.PositionKind
  25393. * - VertexBuffer.UVKind
  25394. * - VertexBuffer.UV2Kind
  25395. * - VertexBuffer.UV3Kind
  25396. * - VertexBuffer.UV4Kind
  25397. * - VertexBuffer.UV5Kind
  25398. * - VertexBuffer.UV6Kind
  25399. * - VertexBuffer.ColorKind
  25400. * - VertexBuffer.MatricesIndicesKind
  25401. * - VertexBuffer.MatricesIndicesExtraKind
  25402. * - VertexBuffer.MatricesWeightsKind
  25403. * - VertexBuffer.MatricesWeightsExtraKind
  25404. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  25405. */
  25406. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  25407. /**
  25408. * Sets the mesh global Vertex Buffer
  25409. * @param buffer defines the buffer to use
  25410. * @returns the current mesh
  25411. */
  25412. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  25413. /**
  25414. * Update a specific associated vertex buffer
  25415. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  25416. * - VertexBuffer.PositionKind
  25417. * - VertexBuffer.UVKind
  25418. * - VertexBuffer.UV2Kind
  25419. * - VertexBuffer.UV3Kind
  25420. * - VertexBuffer.UV4Kind
  25421. * - VertexBuffer.UV5Kind
  25422. * - VertexBuffer.UV6Kind
  25423. * - VertexBuffer.ColorKind
  25424. * - VertexBuffer.MatricesIndicesKind
  25425. * - VertexBuffer.MatricesIndicesExtraKind
  25426. * - VertexBuffer.MatricesWeightsKind
  25427. * - VertexBuffer.MatricesWeightsExtraKind
  25428. * @param data defines the data source
  25429. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  25430. * @param makeItUnique defines if the geometry associated with the mesh must be cloned to make the change only for this mesh (and not all meshes associated with the same geometry)
  25431. * @returns the current mesh
  25432. */
  25433. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25434. /**
  25435. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  25436. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  25437. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  25438. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  25439. * @returns the current mesh
  25440. */
  25441. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  25442. /**
  25443. * Creates a un-shared specific occurence of the geometry for the mesh.
  25444. * @returns the current mesh
  25445. */
  25446. makeGeometryUnique(): Mesh;
  25447. /**
  25448. * Set the index buffer of this mesh
  25449. * @param indices defines the source data
  25450. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  25451. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  25452. * @returns the current mesh
  25453. */
  25454. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  25455. /**
  25456. * Update the current index buffer
  25457. * @param indices defines the source data
  25458. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25459. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  25460. * @returns the current mesh
  25461. */
  25462. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25463. /**
  25464. * Invert the geometry to move from a right handed system to a left handed one.
  25465. * @returns the current mesh
  25466. */
  25467. toLeftHanded(): Mesh;
  25468. /** @hidden */
  25469. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  25470. /** @hidden */
  25471. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  25472. /**
  25473. * Registers for this mesh a javascript function called just before the rendering process
  25474. * @param func defines the function to call before rendering this mesh
  25475. * @returns the current mesh
  25476. */
  25477. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25478. /**
  25479. * Disposes a previously registered javascript function called before the rendering
  25480. * @param func defines the function to remove
  25481. * @returns the current mesh
  25482. */
  25483. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  25484. /**
  25485. * Registers for this mesh a javascript function called just after the rendering is complete
  25486. * @param func defines the function to call after rendering this mesh
  25487. * @returns the current mesh
  25488. */
  25489. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25490. /**
  25491. * Disposes a previously registered javascript function called after the rendering.
  25492. * @param func defines the function to remove
  25493. * @returns the current mesh
  25494. */
  25495. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  25496. /** @hidden */
  25497. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  25498. /** @hidden */
  25499. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  25500. /** @hidden */
  25501. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  25502. /** @hidden */
  25503. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  25504. /** @hidden */
  25505. _rebuild(): void;
  25506. /** @hidden */
  25507. _freeze(): void;
  25508. /** @hidden */
  25509. _unFreeze(): void;
  25510. /**
  25511. * Triggers the draw call for the mesh. Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager
  25512. * @param subMesh defines the subMesh to render
  25513. * @param enableAlphaMode defines if alpha mode can be changed
  25514. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  25515. * @returns the current mesh
  25516. */
  25517. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  25518. private _onBeforeDraw;
  25519. /**
  25520. * Renormalize the mesh and patch it up if there are no weights
  25521. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  25522. * However in the case of zero weights then we set just a single influence to 1.
  25523. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  25524. */
  25525. cleanMatrixWeights(): void;
  25526. private normalizeSkinFourWeights;
  25527. private normalizeSkinWeightsAndExtra;
  25528. /**
  25529. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  25530. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  25531. * the user know there was an issue with importing the mesh
  25532. * @returns a validation object with skinned, valid and report string
  25533. */
  25534. validateSkinning(): {
  25535. skinned: boolean;
  25536. valid: boolean;
  25537. report: string;
  25538. };
  25539. /** @hidden */
  25540. _checkDelayState(): Mesh;
  25541. private _queueLoad;
  25542. /**
  25543. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25544. * A mesh is in the frustum if its bounding box intersects the frustum
  25545. * @param frustumPlanes defines the frustum to test
  25546. * @returns true if the mesh is in the frustum planes
  25547. */
  25548. isInFrustum(frustumPlanes: Plane[]): boolean;
  25549. /**
  25550. * Sets the mesh material by the material or multiMaterial `id` property
  25551. * @param id is a string identifying the material or the multiMaterial
  25552. * @returns the current mesh
  25553. */
  25554. setMaterialByID(id: string): Mesh;
  25555. /**
  25556. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  25557. * @returns an array of IAnimatable
  25558. */
  25559. getAnimatables(): IAnimatable[];
  25560. /**
  25561. * Modifies the mesh geometry according to the passed transformation matrix.
  25562. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  25563. * The mesh normals are modified using the same transformation.
  25564. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25565. * @param transform defines the transform matrix to use
  25566. * @see http://doc.babylonjs.com/resources/baking_transformations
  25567. * @returns the current mesh
  25568. */
  25569. bakeTransformIntoVertices(transform: Matrix): Mesh;
  25570. /**
  25571. * Modifies the mesh geometry according to its own current World Matrix.
  25572. * The mesh World Matrix is then reset.
  25573. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  25574. * Note that, under the hood, this method sets a new VertexBuffer each call.
  25575. * @see http://doc.babylonjs.com/resources/baking_transformations
  25576. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  25577. * @returns the current mesh
  25578. */
  25579. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  25580. /** @hidden */
  25581. get _positions(): Nullable<Vector3[]>;
  25582. /** @hidden */
  25583. _resetPointsArrayCache(): Mesh;
  25584. /** @hidden */
  25585. _generatePointsArray(): boolean;
  25586. /**
  25587. * Returns a new Mesh object generated from the current mesh properties.
  25588. * This method must not get confused with createInstance()
  25589. * @param name is a string, the name given to the new mesh
  25590. * @param newParent can be any Node object (default `null`)
  25591. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  25592. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  25593. * @returns a new mesh
  25594. */
  25595. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  25596. /**
  25597. * Releases resources associated with this mesh.
  25598. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25599. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25600. */
  25601. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25602. /** @hidden */
  25603. _disposeInstanceSpecificData(): void;
  25604. /**
  25605. * Modifies the mesh geometry according to a displacement map.
  25606. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  25607. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25608. * @param url is a string, the URL from the image file is to be downloaded.
  25609. * @param minHeight is the lower limit of the displacement.
  25610. * @param maxHeight is the upper limit of the displacement.
  25611. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  25612. * @param uvOffset is an optional vector2 used to offset UV.
  25613. * @param uvScale is an optional vector2 used to scale UV.
  25614. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  25615. * @returns the Mesh.
  25616. */
  25617. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25618. /**
  25619. * Modifies the mesh geometry according to a displacementMap buffer.
  25620. * A displacement map is a colored image. Each pixel color value (actually a gradient computed from red, green, blue values) will give the displacement to apply to each mesh vertex.
  25621. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  25622. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  25623. * @param heightMapWidth is the width of the buffer image.
  25624. * @param heightMapHeight is the height of the buffer image.
  25625. * @param minHeight is the lower limit of the displacement.
  25626. * @param maxHeight is the upper limit of the displacement.
  25627. * @param onSuccess is an optional Javascript function to be called just after the mesh is modified. It is passed the modified mesh and must return nothing.
  25628. * @param uvOffset is an optional vector2 used to offset UV.
  25629. * @param uvScale is an optional vector2 used to scale UV.
  25630. * @param forceUpdate defines whether or not to force an update of the generated buffers. This is useful to apply on a deserialized model for instance.
  25631. * @returns the Mesh.
  25632. */
  25633. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  25634. /**
  25635. * Modify the mesh to get a flat shading rendering.
  25636. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  25637. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  25638. * @returns current mesh
  25639. */
  25640. convertToFlatShadedMesh(): Mesh;
  25641. /**
  25642. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  25643. * In other words, more vertices, no more indices and a single bigger VBO.
  25644. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  25645. * @returns current mesh
  25646. */
  25647. convertToUnIndexedMesh(): Mesh;
  25648. /**
  25649. * Inverses facet orientations.
  25650. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25651. * @param flipNormals will also inverts the normals
  25652. * @returns current mesh
  25653. */
  25654. flipFaces(flipNormals?: boolean): Mesh;
  25655. /**
  25656. * Increase the number of facets and hence vertices in a mesh
  25657. * Vertex normals are interpolated from existing vertex normals
  25658. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25659. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  25660. */
  25661. increaseVertices(numberPerEdge: number): void;
  25662. /**
  25663. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  25664. * This will undo any application of covertToFlatShadedMesh
  25665. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  25666. */
  25667. forceSharedVertices(): void;
  25668. /** @hidden */
  25669. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25670. /** @hidden */
  25671. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25672. /**
  25673. * Creates a new InstancedMesh object from the mesh model.
  25674. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25675. * @param name defines the name of the new instance
  25676. * @returns a new InstancedMesh
  25677. */
  25678. createInstance(name: string): InstancedMesh;
  25679. /**
  25680. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25681. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25682. * @returns the current mesh
  25683. */
  25684. synchronizeInstances(): Mesh;
  25685. /**
  25686. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25687. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25688. * This should be used together with the simplification to avoid disappearing triangles.
  25689. * @param successCallback an optional success callback to be called after the optimization finished.
  25690. * @returns the current mesh
  25691. */
  25692. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25693. /**
  25694. * Serialize current mesh
  25695. * @param serializationObject defines the object which will receive the serialization data
  25696. */
  25697. serialize(serializationObject: any): void;
  25698. /** @hidden */
  25699. _syncGeometryWithMorphTargetManager(): void;
  25700. /** @hidden */
  25701. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25702. /**
  25703. * Returns a new Mesh object parsed from the source provided.
  25704. * @param parsedMesh is the source
  25705. * @param scene defines the hosting scene
  25706. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25707. * @returns a new Mesh
  25708. */
  25709. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25710. /**
  25711. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25712. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25713. * @param name defines the name of the mesh to create
  25714. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25715. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25716. * @param closePath creates a seam between the first and the last points of each path of the path array
  25717. * @param offset is taken in account only if the `pathArray` is containing a single path
  25718. * @param scene defines the hosting scene
  25719. * @param updatable defines if the mesh must be flagged as updatable
  25720. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25721. * @param instance defines an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#ribbon)
  25722. * @returns a new Mesh
  25723. */
  25724. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25725. /**
  25726. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25727. * @param name defines the name of the mesh to create
  25728. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25729. * @param tessellation sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  25730. * @param scene defines the hosting scene
  25731. * @param updatable defines if the mesh must be flagged as updatable
  25732. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25733. * @returns a new Mesh
  25734. */
  25735. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25736. /**
  25737. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25738. * @param name defines the name of the mesh to create
  25739. * @param size sets the size (float) of each box side (default 1)
  25740. * @param scene defines the hosting scene
  25741. * @param updatable defines if the mesh must be flagged as updatable
  25742. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25743. * @returns a new Mesh
  25744. */
  25745. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25746. /**
  25747. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25748. * @param name defines the name of the mesh to create
  25749. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25750. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25751. * @param scene defines the hosting scene
  25752. * @param updatable defines if the mesh must be flagged as updatable
  25753. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25754. * @returns a new Mesh
  25755. */
  25756. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25757. /**
  25758. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25759. * @param name defines the name of the mesh to create
  25760. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25761. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25762. * @param scene defines the hosting scene
  25763. * @returns a new Mesh
  25764. */
  25765. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25766. /**
  25767. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25768. * @param name defines the name of the mesh to create
  25769. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25770. * @param diameterTop set the top cap diameter (floats, default 1)
  25771. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25772. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25773. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25774. * @param scene defines the hosting scene
  25775. * @param updatable defines if the mesh must be flagged as updatable
  25776. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25777. * @returns a new Mesh
  25778. */
  25779. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25780. /**
  25781. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25782. * @param name defines the name of the mesh to create
  25783. * @param diameter sets the diameter size (float) of the torus (default 1)
  25784. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25785. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25786. * @param scene defines the hosting scene
  25787. * @param updatable defines if the mesh must be flagged as updatable
  25788. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25789. * @returns a new Mesh
  25790. */
  25791. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25792. /**
  25793. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25794. * @param name defines the name of the mesh to create
  25795. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25796. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25797. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25798. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25799. * @param p the number of windings on X axis (positive integers, default 2)
  25800. * @param q the number of windings on Y axis (positive integers, default 3)
  25801. * @param scene defines the hosting scene
  25802. * @param updatable defines if the mesh must be flagged as updatable
  25803. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25804. * @returns a new Mesh
  25805. */
  25806. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25807. /**
  25808. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25809. * @param name defines the name of the mesh to create
  25810. * @param points is an array successive Vector3
  25811. * @param scene defines the hosting scene
  25812. * @param updatable defines if the mesh must be flagged as updatable
  25813. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines).
  25814. * @returns a new Mesh
  25815. */
  25816. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25817. /**
  25818. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25819. * @param name defines the name of the mesh to create
  25820. * @param points is an array successive Vector3
  25821. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25822. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25823. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25824. * @param scene defines the hosting scene
  25825. * @param updatable defines if the mesh must be flagged as updatable
  25826. * @param instance is an instance of an existing LineMesh object to be updated with the passed `points` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#lines-and-dashedlines)
  25827. * @returns a new Mesh
  25828. */
  25829. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25830. /**
  25831. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25832. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25833. * The parameter `shape` is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors.
  25834. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25835. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25836. * Remember you can only change the shape positions, not their number when updating a polygon.
  25837. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25838. * @param name defines the name of the mesh to create
  25839. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  25840. * @param scene defines the hosting scene
  25841. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25842. * @param updatable defines if the mesh must be flagged as updatable
  25843. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25844. * @param earcutInjection can be used to inject your own earcut reference
  25845. * @returns a new Mesh
  25846. */
  25847. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25848. /**
  25849. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25850. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25851. * @param name defines the name of the mesh to create
  25852. * @param shape is a required array of successive Vector3 representing the corners of the polygon in th XoZ plane, that is y = 0 for all vectors
  25853. * @param depth defines the height of extrusion
  25854. * @param scene defines the hosting scene
  25855. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25856. * @param updatable defines if the mesh must be flagged as updatable
  25857. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25858. * @param earcutInjection can be used to inject your own earcut reference
  25859. * @returns a new Mesh
  25860. */
  25861. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25862. /**
  25863. * Creates an extruded shape mesh.
  25864. * The extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters. Please consider using the same method from the MeshBuilder class instead
  25865. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25866. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25867. * @param name defines the name of the mesh to create
  25868. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  25869. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25870. * @param scale is the value to scale the shape
  25871. * @param rotation is the angle value to rotate the shape each step (each path point), from the former step (so rotation added each step) along the curve
  25872. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25873. * @param scene defines the hosting scene
  25874. * @param updatable defines if the mesh must be flagged as updatable
  25875. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25876. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#extruded-shape)
  25877. * @returns a new Mesh
  25878. */
  25879. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25880. /**
  25881. * Creates an custom extruded shape mesh.
  25882. * The custom extrusion is a parametric shape.
  25883. * It has no predefined shape. Its final shape will depend on the input parameters.
  25884. * Please consider using the same method from the MeshBuilder class instead
  25885. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25886. * @param name defines the name of the mesh to create
  25887. * @param shape is a required array of successive Vector3. This array depicts the shape to be extruded in its local space : the shape must be designed in the xOy plane and will be extruded along the Z axis
  25888. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25889. * @param scaleFunction is a custom Javascript function called on each path point
  25890. * @param rotationFunction is a custom Javascript function called on each path point
  25891. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25892. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25893. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25894. * @param scene defines the hosting scene
  25895. * @param updatable defines if the mesh must be flagged as updatable
  25896. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25897. * @param instance is an instance of an existing ExtrudedShape object to be updated with the passed `shape`, `path`, `scale` or `rotation` parameters (http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#extruded-shape)
  25898. * @returns a new Mesh
  25899. */
  25900. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: Function, rotationFunction: Function, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25901. /**
  25902. * Creates lathe mesh.
  25903. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25904. * Please consider using the same method from the MeshBuilder class instead
  25905. * @param name defines the name of the mesh to create
  25906. * @param shape is a required array of successive Vector3. This array depicts the shape to be rotated in its local space : the shape must be designed in the xOy plane and will be rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero
  25907. * @param radius is the radius value of the lathe
  25908. * @param tessellation is the side number of the lathe.
  25909. * @param scene defines the hosting scene
  25910. * @param updatable defines if the mesh must be flagged as updatable
  25911. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25912. * @returns a new Mesh
  25913. */
  25914. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25915. /**
  25916. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25917. * @param name defines the name of the mesh to create
  25918. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25919. * @param scene defines the hosting scene
  25920. * @param updatable defines if the mesh must be flagged as updatable
  25921. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25922. * @returns a new Mesh
  25923. */
  25924. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25925. /**
  25926. * Creates a ground mesh.
  25927. * Please consider using the same method from the MeshBuilder class instead
  25928. * @param name defines the name of the mesh to create
  25929. * @param width set the width of the ground
  25930. * @param height set the height of the ground
  25931. * @param subdivisions sets the number of subdivisions per side
  25932. * @param scene defines the hosting scene
  25933. * @param updatable defines if the mesh must be flagged as updatable
  25934. * @returns a new Mesh
  25935. */
  25936. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25937. /**
  25938. * Creates a tiled ground mesh.
  25939. * Please consider using the same method from the MeshBuilder class instead
  25940. * @param name defines the name of the mesh to create
  25941. * @param xmin set the ground minimum X coordinate
  25942. * @param zmin set the ground minimum Y coordinate
  25943. * @param xmax set the ground maximum X coordinate
  25944. * @param zmax set the ground maximum Z coordinate
  25945. * @param subdivisions is an object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the numbers of subdivisions on the ground width and height. Each subdivision is called a tile
  25946. * @param precision is an object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the numbers of subdivisions on the ground width and height of each tile
  25947. * @param scene defines the hosting scene
  25948. * @param updatable defines if the mesh must be flagged as updatable
  25949. * @returns a new Mesh
  25950. */
  25951. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25952. w: number;
  25953. h: number;
  25954. }, precision: {
  25955. w: number;
  25956. h: number;
  25957. }, scene: Scene, updatable?: boolean): Mesh;
  25958. /**
  25959. * Creates a ground mesh from a height map.
  25960. * Please consider using the same method from the MeshBuilder class instead
  25961. * @see http://doc.babylonjs.com/babylon101/height_map
  25962. * @param name defines the name of the mesh to create
  25963. * @param url sets the URL of the height map image resource
  25964. * @param width set the ground width size
  25965. * @param height set the ground height size
  25966. * @param subdivisions sets the number of subdivision per side
  25967. * @param minHeight is the minimum altitude on the ground
  25968. * @param maxHeight is the maximum altitude on the ground
  25969. * @param scene defines the hosting scene
  25970. * @param updatable defines if the mesh must be flagged as updatable
  25971. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25972. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25973. * @returns a new Mesh
  25974. */
  25975. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void, alphaFilter?: number): GroundMesh;
  25976. /**
  25977. * Creates a tube mesh.
  25978. * The tube is a parametric shape.
  25979. * It has no predefined shape. Its final shape will depend on the input parameters.
  25980. * Please consider using the same method from the MeshBuilder class instead
  25981. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25982. * @param name defines the name of the mesh to create
  25983. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25984. * @param radius sets the tube radius size
  25985. * @param tessellation is the number of sides on the tubular surface
  25986. * @param radiusFunction is a custom function. If it is not null, it overwrittes the parameter `radius`. This function is called on each point of the tube path and is passed the index `i` of the i-th point and the distance of this point from the first point of the path
  25987. * @param cap sets the way the extruded shape is capped. Possible values : Mesh.NO_CAP (default), Mesh.CAP_START, Mesh.CAP_END, Mesh.CAP_ALL
  25988. * @param scene defines the hosting scene
  25989. * @param updatable defines if the mesh must be flagged as updatable
  25990. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25991. * @param instance is an instance of an existing Tube object to be updated with the passed `pathArray` parameter (http://doc.babylonjs.com/how_to/How_to_dynamically_morph_a_mesh#tube)
  25992. * @returns a new Mesh
  25993. */
  25994. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25995. (i: number, distance: number): number;
  25996. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25997. /**
  25998. * Creates a polyhedron mesh.
  25999. * Please consider using the same method from the MeshBuilder class instead.
  26000. * * The parameter `type` (positive integer, max 14, default 0) sets the polyhedron type to build among the 15 embbeded types. Please refer to the type sheet in the tutorial to choose the wanted type
  26001. * * The parameter `size` (positive float, default 1) sets the polygon size
  26002. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  26003. * * You can build other polyhedron types than the 15 embbeded ones by setting the parameter `custom` (`polyhedronObject`, default null). If you set the parameter `custom`, this overwrittes the parameter `type`
  26004. * * A `polyhedronObject` is a formatted javascript object. You'll find a full file with pre-set polyhedra here : https://github.com/BabylonJS/Extensions/tree/master/Polyhedron
  26005. * * You can set the color and the UV of each side of the polyhedron with the parameters `faceColors` (Color4, default `(1, 1, 1, 1)`) and faceUV (Vector4, default `(0, 0, 1, 1)`)
  26006. * * To understand how to set `faceUV` or `faceColors`, please read this by considering the right number of faces of your polyhedron, instead of only 6 for the box : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  26007. * * The parameter `flat` (boolean, default true). If set to false, it gives the polyhedron a single global face, so less vertices and shared normals. In this case, `faceColors` and `faceUV` are ignored
  26008. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26009. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26010. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26011. * @param name defines the name of the mesh to create
  26012. * @param options defines the options used to create the mesh
  26013. * @param scene defines the hosting scene
  26014. * @returns a new Mesh
  26015. */
  26016. static CreatePolyhedron(name: string, options: {
  26017. type?: number;
  26018. size?: number;
  26019. sizeX?: number;
  26020. sizeY?: number;
  26021. sizeZ?: number;
  26022. custom?: any;
  26023. faceUV?: Vector4[];
  26024. faceColors?: Color4[];
  26025. updatable?: boolean;
  26026. sideOrientation?: number;
  26027. }, scene: Scene): Mesh;
  26028. /**
  26029. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  26030. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  26031. * * You can set some different icosphere dimensions, for instance to build an ellipsoid, by using the parameters `radiusX`, `radiusY` and `radiusZ` (all by default have the same value than `radius`)
  26032. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  26033. * * The parameter `flat` (boolean, default true) gives each side its own normals. Set it to false to get a smooth continuous light reflection on the surface
  26034. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  26035. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26037. * @param name defines the name of the mesh
  26038. * @param options defines the options used to create the mesh
  26039. * @param scene defines the hosting scene
  26040. * @returns a new Mesh
  26041. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  26042. */
  26043. static CreateIcoSphere(name: string, options: {
  26044. radius?: number;
  26045. flat?: boolean;
  26046. subdivisions?: number;
  26047. sideOrientation?: number;
  26048. updatable?: boolean;
  26049. }, scene: Scene): Mesh;
  26050. /**
  26051. * Creates a decal mesh.
  26052. * Please consider using the same method from the MeshBuilder class instead.
  26053. * A decal is a mesh usually applied as a model onto the surface of another mesh
  26054. * @param name defines the name of the mesh
  26055. * @param sourceMesh defines the mesh receiving the decal
  26056. * @param position sets the position of the decal in world coordinates
  26057. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  26058. * @param size sets the decal scaling
  26059. * @param angle sets the angle to rotate the decal
  26060. * @returns a new Mesh
  26061. */
  26062. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  26063. /**
  26064. * Prepare internal position array for software CPU skinning
  26065. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  26066. */
  26067. setPositionsForCPUSkinning(): Float32Array;
  26068. /**
  26069. * Prepare internal normal array for software CPU skinning
  26070. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  26071. */
  26072. setNormalsForCPUSkinning(): Float32Array;
  26073. /**
  26074. * Updates the vertex buffer by applying transformation from the bones
  26075. * @param skeleton defines the skeleton to apply to current mesh
  26076. * @returns the current mesh
  26077. */
  26078. applySkeleton(skeleton: Skeleton): Mesh;
  26079. /**
  26080. * Returns an object containing a min and max Vector3 which are the minimum and maximum vectors of each mesh bounding box from the passed array, in the world coordinates
  26081. * @param meshes defines the list of meshes to scan
  26082. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  26083. */
  26084. static MinMax(meshes: AbstractMesh[]): {
  26085. min: Vector3;
  26086. max: Vector3;
  26087. };
  26088. /**
  26089. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  26090. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  26091. * @returns a vector3
  26092. */
  26093. static Center(meshesOrMinMaxVector: {
  26094. min: Vector3;
  26095. max: Vector3;
  26096. } | AbstractMesh[]): Vector3;
  26097. /**
  26098. * Merge the array of meshes into a single mesh for performance reasons.
  26099. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  26100. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  26101. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  26102. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  26103. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  26104. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  26105. * @returns a new mesh
  26106. */
  26107. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  26108. /** @hidden */
  26109. addInstance(instance: InstancedMesh): void;
  26110. /** @hidden */
  26111. removeInstance(instance: InstancedMesh): void;
  26112. }
  26113. }
  26114. declare module "babylonjs/Cameras/camera" {
  26115. import { SmartArray } from "babylonjs/Misc/smartArray";
  26116. import { Observable } from "babylonjs/Misc/observable";
  26117. import { Nullable } from "babylonjs/types";
  26118. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  26119. import { Scene } from "babylonjs/scene";
  26120. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  26121. import { Node } from "babylonjs/node";
  26122. import { Mesh } from "babylonjs/Meshes/mesh";
  26123. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26124. import { ICullable } from "babylonjs/Culling/boundingInfo";
  26125. import { Viewport } from "babylonjs/Maths/math.viewport";
  26126. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  26127. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  26128. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  26129. import { Ray } from "babylonjs/Culling/ray";
  26130. /**
  26131. * This is the base class of all the camera used in the application.
  26132. * @see http://doc.babylonjs.com/features/cameras
  26133. */
  26134. export class Camera extends Node {
  26135. /** @hidden */
  26136. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  26137. /**
  26138. * This is the default projection mode used by the cameras.
  26139. * It helps recreating a feeling of perspective and better appreciate depth.
  26140. * This is the best way to simulate real life cameras.
  26141. */
  26142. static readonly PERSPECTIVE_CAMERA: number;
  26143. /**
  26144. * This helps creating camera with an orthographic mode.
  26145. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  26146. */
  26147. static readonly ORTHOGRAPHIC_CAMERA: number;
  26148. /**
  26149. * This is the default FOV mode for perspective cameras.
  26150. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  26151. */
  26152. static readonly FOVMODE_VERTICAL_FIXED: number;
  26153. /**
  26154. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  26155. */
  26156. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  26157. /**
  26158. * This specifies ther is no need for a camera rig.
  26159. * Basically only one eye is rendered corresponding to the camera.
  26160. */
  26161. static readonly RIG_MODE_NONE: number;
  26162. /**
  26163. * Simulates a camera Rig with one blue eye and one red eye.
  26164. * This can be use with 3d blue and red glasses.
  26165. */
  26166. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  26167. /**
  26168. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  26169. */
  26170. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  26171. /**
  26172. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  26173. */
  26174. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  26175. /**
  26176. * Defines that both eyes of the camera will be rendered over under each other.
  26177. */
  26178. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  26179. /**
  26180. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  26181. */
  26182. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  26183. /**
  26184. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  26185. */
  26186. static readonly RIG_MODE_VR: number;
  26187. /**
  26188. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  26189. */
  26190. static readonly RIG_MODE_WEBVR: number;
  26191. /**
  26192. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  26193. */
  26194. static readonly RIG_MODE_CUSTOM: number;
  26195. /**
  26196. * Defines if by default attaching controls should prevent the default javascript event to continue.
  26197. */
  26198. static ForceAttachControlToAlwaysPreventDefault: boolean;
  26199. /**
  26200. * Define the input manager associated with the camera.
  26201. */
  26202. inputs: CameraInputsManager<Camera>;
  26203. /** @hidden */
  26204. _position: Vector3;
  26205. /**
  26206. * Define the current local position of the camera in the scene
  26207. */
  26208. get position(): Vector3;
  26209. set position(newPosition: Vector3);
  26210. /**
  26211. * The vector the camera should consider as up.
  26212. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  26213. */
  26214. upVector: Vector3;
  26215. /**
  26216. * Define the current limit on the left side for an orthographic camera
  26217. * In scene unit
  26218. */
  26219. orthoLeft: Nullable<number>;
  26220. /**
  26221. * Define the current limit on the right side for an orthographic camera
  26222. * In scene unit
  26223. */
  26224. orthoRight: Nullable<number>;
  26225. /**
  26226. * Define the current limit on the bottom side for an orthographic camera
  26227. * In scene unit
  26228. */
  26229. orthoBottom: Nullable<number>;
  26230. /**
  26231. * Define the current limit on the top side for an orthographic camera
  26232. * In scene unit
  26233. */
  26234. orthoTop: Nullable<number>;
  26235. /**
  26236. * Field Of View is set in Radians. (default is 0.8)
  26237. */
  26238. fov: number;
  26239. /**
  26240. * Define the minimum distance the camera can see from.
  26241. * This is important to note that the depth buffer are not infinite and the closer it starts
  26242. * the more your scene might encounter depth fighting issue.
  26243. */
  26244. minZ: number;
  26245. /**
  26246. * Define the maximum distance the camera can see to.
  26247. * This is important to note that the depth buffer are not infinite and the further it end
  26248. * the more your scene might encounter depth fighting issue.
  26249. */
  26250. maxZ: number;
  26251. /**
  26252. * Define the default inertia of the camera.
  26253. * This helps giving a smooth feeling to the camera movement.
  26254. */
  26255. inertia: number;
  26256. /**
  26257. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  26258. */
  26259. mode: number;
  26260. /**
  26261. * Define whether the camera is intermediate.
  26262. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  26263. */
  26264. isIntermediate: boolean;
  26265. /**
  26266. * Define the viewport of the camera.
  26267. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  26268. */
  26269. viewport: Viewport;
  26270. /**
  26271. * Restricts the camera to viewing objects with the same layerMask.
  26272. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  26273. */
  26274. layerMask: number;
  26275. /**
  26276. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  26277. */
  26278. fovMode: number;
  26279. /**
  26280. * Rig mode of the camera.
  26281. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  26282. * This is normally controlled byt the camera themselves as internal use.
  26283. */
  26284. cameraRigMode: number;
  26285. /**
  26286. * Defines the distance between both "eyes" in case of a RIG
  26287. */
  26288. interaxialDistance: number;
  26289. /**
  26290. * Defines if stereoscopic rendering is done side by side or over under.
  26291. */
  26292. isStereoscopicSideBySide: boolean;
  26293. /**
  26294. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  26295. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  26296. * else in the scene. (Eg. security camera)
  26297. *
  26298. * To change the final output target of the camera, camera.outputRenderTarget should be used instead (eg. webXR renders to a render target corrisponding to an HMD)
  26299. */
  26300. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  26301. /**
  26302. * When set, the camera will render to this render target instead of the default canvas
  26303. *
  26304. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  26305. */
  26306. outputRenderTarget: Nullable<RenderTargetTexture>;
  26307. /**
  26308. * Observable triggered when the camera view matrix has changed.
  26309. */
  26310. onViewMatrixChangedObservable: Observable<Camera>;
  26311. /**
  26312. * Observable triggered when the camera Projection matrix has changed.
  26313. */
  26314. onProjectionMatrixChangedObservable: Observable<Camera>;
  26315. /**
  26316. * Observable triggered when the inputs have been processed.
  26317. */
  26318. onAfterCheckInputsObservable: Observable<Camera>;
  26319. /**
  26320. * Observable triggered when reset has been called and applied to the camera.
  26321. */
  26322. onRestoreStateObservable: Observable<Camera>;
  26323. /**
  26324. * Is this camera a part of a rig system?
  26325. */
  26326. isRigCamera: boolean;
  26327. /**
  26328. * If isRigCamera set to true this will be set with the parent camera.
  26329. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  26330. */
  26331. rigParent?: Camera;
  26332. /** @hidden */
  26333. _cameraRigParams: any;
  26334. /** @hidden */
  26335. _rigCameras: Camera[];
  26336. /** @hidden */
  26337. _rigPostProcess: Nullable<PostProcess>;
  26338. protected _webvrViewMatrix: Matrix;
  26339. /** @hidden */
  26340. _skipRendering: boolean;
  26341. /** @hidden */
  26342. _projectionMatrix: Matrix;
  26343. /** @hidden */
  26344. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  26345. /** @hidden */
  26346. _activeMeshes: SmartArray<AbstractMesh>;
  26347. protected _globalPosition: Vector3;
  26348. /** @hidden */
  26349. _computedViewMatrix: Matrix;
  26350. private _doNotComputeProjectionMatrix;
  26351. private _transformMatrix;
  26352. private _frustumPlanes;
  26353. private _refreshFrustumPlanes;
  26354. private _storedFov;
  26355. private _stateStored;
  26356. /**
  26357. * Instantiates a new camera object.
  26358. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  26359. * @see http://doc.babylonjs.com/features/cameras
  26360. * @param name Defines the name of the camera in the scene
  26361. * @param position Defines the position of the camera
  26362. * @param scene Defines the scene the camera belongs too
  26363. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  26364. */
  26365. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  26366. /**
  26367. * Store current camera state (fov, position, etc..)
  26368. * @returns the camera
  26369. */
  26370. storeState(): Camera;
  26371. /**
  26372. * Restores the camera state values if it has been stored. You must call storeState() first
  26373. */
  26374. protected _restoreStateValues(): boolean;
  26375. /**
  26376. * Restored camera state. You must call storeState() first.
  26377. * @returns true if restored and false otherwise
  26378. */
  26379. restoreState(): boolean;
  26380. /**
  26381. * Gets the class name of the camera.
  26382. * @returns the class name
  26383. */
  26384. getClassName(): string;
  26385. /** @hidden */
  26386. readonly _isCamera: boolean;
  26387. /**
  26388. * Gets a string representation of the camera useful for debug purpose.
  26389. * @param fullDetails Defines that a more verboe level of logging is required
  26390. * @returns the string representation
  26391. */
  26392. toString(fullDetails?: boolean): string;
  26393. /**
  26394. * Gets the current world space position of the camera.
  26395. */
  26396. get globalPosition(): Vector3;
  26397. /**
  26398. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  26399. * @returns the active meshe list
  26400. */
  26401. getActiveMeshes(): SmartArray<AbstractMesh>;
  26402. /**
  26403. * Check whether a mesh is part of the current active mesh list of the camera
  26404. * @param mesh Defines the mesh to check
  26405. * @returns true if active, false otherwise
  26406. */
  26407. isActiveMesh(mesh: Mesh): boolean;
  26408. /**
  26409. * Is this camera ready to be used/rendered
  26410. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  26411. * @return true if the camera is ready
  26412. */
  26413. isReady(completeCheck?: boolean): boolean;
  26414. /** @hidden */
  26415. _initCache(): void;
  26416. /** @hidden */
  26417. _updateCache(ignoreParentClass?: boolean): void;
  26418. /** @hidden */
  26419. _isSynchronized(): boolean;
  26420. /** @hidden */
  26421. _isSynchronizedViewMatrix(): boolean;
  26422. /** @hidden */
  26423. _isSynchronizedProjectionMatrix(): boolean;
  26424. /**
  26425. * Attach the input controls to a specific dom element to get the input from.
  26426. * @param element Defines the element the controls should be listened from
  26427. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  26428. */
  26429. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  26430. /**
  26431. * Detach the current controls from the specified dom element.
  26432. * @param element Defines the element to stop listening the inputs from
  26433. */
  26434. detachControl(element: HTMLElement): void;
  26435. /**
  26436. * Update the camera state according to the different inputs gathered during the frame.
  26437. */
  26438. update(): void;
  26439. /** @hidden */
  26440. _checkInputs(): void;
  26441. /** @hidden */
  26442. get rigCameras(): Camera[];
  26443. /**
  26444. * Gets the post process used by the rig cameras
  26445. */
  26446. get rigPostProcess(): Nullable<PostProcess>;
  26447. /**
  26448. * Internal, gets the first post proces.
  26449. * @returns the first post process to be run on this camera.
  26450. */
  26451. _getFirstPostProcess(): Nullable<PostProcess>;
  26452. private _cascadePostProcessesToRigCams;
  26453. /**
  26454. * Attach a post process to the camera.
  26455. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26456. * @param postProcess The post process to attach to the camera
  26457. * @param insertAt The position of the post process in case several of them are in use in the scene
  26458. * @returns the position the post process has been inserted at
  26459. */
  26460. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  26461. /**
  26462. * Detach a post process to the camera.
  26463. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  26464. * @param postProcess The post process to detach from the camera
  26465. */
  26466. detachPostProcess(postProcess: PostProcess): void;
  26467. /**
  26468. * Gets the current world matrix of the camera
  26469. */
  26470. getWorldMatrix(): Matrix;
  26471. /** @hidden */
  26472. _getViewMatrix(): Matrix;
  26473. /**
  26474. * Gets the current view matrix of the camera.
  26475. * @param force forces the camera to recompute the matrix without looking at the cached state
  26476. * @returns the view matrix
  26477. */
  26478. getViewMatrix(force?: boolean): Matrix;
  26479. /**
  26480. * Freeze the projection matrix.
  26481. * It will prevent the cache check of the camera projection compute and can speed up perf
  26482. * if no parameter of the camera are meant to change
  26483. * @param projection Defines manually a projection if necessary
  26484. */
  26485. freezeProjectionMatrix(projection?: Matrix): void;
  26486. /**
  26487. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  26488. */
  26489. unfreezeProjectionMatrix(): void;
  26490. /**
  26491. * Gets the current projection matrix of the camera.
  26492. * @param force forces the camera to recompute the matrix without looking at the cached state
  26493. * @returns the projection matrix
  26494. */
  26495. getProjectionMatrix(force?: boolean): Matrix;
  26496. /**
  26497. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  26498. * @returns a Matrix
  26499. */
  26500. getTransformationMatrix(): Matrix;
  26501. private _updateFrustumPlanes;
  26502. /**
  26503. * Checks if a cullable object (mesh...) is in the camera frustum
  26504. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  26505. * @param target The object to check
  26506. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  26507. * @returns true if the object is in frustum otherwise false
  26508. */
  26509. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  26510. /**
  26511. * Checks if a cullable object (mesh...) is in the camera frustum
  26512. * Unlike isInFrustum this cheks the full bounding box
  26513. * @param target The object to check
  26514. * @returns true if the object is in frustum otherwise false
  26515. */
  26516. isCompletelyInFrustum(target: ICullable): boolean;
  26517. /**
  26518. * Gets a ray in the forward direction from the camera.
  26519. * @param length Defines the length of the ray to create
  26520. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  26521. * @param origin Defines the start point of the ray which defaults to the camera position
  26522. * @returns the forward ray
  26523. */
  26524. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  26525. /**
  26526. * Releases resources associated with this node.
  26527. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26528. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26529. */
  26530. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26531. /** @hidden */
  26532. _isLeftCamera: boolean;
  26533. /**
  26534. * Gets the left camera of a rig setup in case of Rigged Camera
  26535. */
  26536. get isLeftCamera(): boolean;
  26537. /** @hidden */
  26538. _isRightCamera: boolean;
  26539. /**
  26540. * Gets the right camera of a rig setup in case of Rigged Camera
  26541. */
  26542. get isRightCamera(): boolean;
  26543. /**
  26544. * Gets the left camera of a rig setup in case of Rigged Camera
  26545. */
  26546. get leftCamera(): Nullable<FreeCamera>;
  26547. /**
  26548. * Gets the right camera of a rig setup in case of Rigged Camera
  26549. */
  26550. get rightCamera(): Nullable<FreeCamera>;
  26551. /**
  26552. * Gets the left camera target of a rig setup in case of Rigged Camera
  26553. * @returns the target position
  26554. */
  26555. getLeftTarget(): Nullable<Vector3>;
  26556. /**
  26557. * Gets the right camera target of a rig setup in case of Rigged Camera
  26558. * @returns the target position
  26559. */
  26560. getRightTarget(): Nullable<Vector3>;
  26561. /**
  26562. * @hidden
  26563. */
  26564. setCameraRigMode(mode: number, rigParams: any): void;
  26565. /** @hidden */
  26566. static _setStereoscopicRigMode(camera: Camera): void;
  26567. /** @hidden */
  26568. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  26569. /** @hidden */
  26570. static _setVRRigMode(camera: Camera, rigParams: any): void;
  26571. /** @hidden */
  26572. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  26573. /** @hidden */
  26574. _getVRProjectionMatrix(): Matrix;
  26575. protected _updateCameraRotationMatrix(): void;
  26576. protected _updateWebVRCameraRotationMatrix(): void;
  26577. /**
  26578. * This function MUST be overwritten by the different WebVR cameras available.
  26579. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26580. * @hidden
  26581. */
  26582. _getWebVRProjectionMatrix(): Matrix;
  26583. /**
  26584. * This function MUST be overwritten by the different WebVR cameras available.
  26585. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  26586. * @hidden
  26587. */
  26588. _getWebVRViewMatrix(): Matrix;
  26589. /** @hidden */
  26590. setCameraRigParameter(name: string, value: any): void;
  26591. /**
  26592. * needs to be overridden by children so sub has required properties to be copied
  26593. * @hidden
  26594. */
  26595. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  26596. /**
  26597. * May need to be overridden by children
  26598. * @hidden
  26599. */
  26600. _updateRigCameras(): void;
  26601. /** @hidden */
  26602. _setupInputs(): void;
  26603. /**
  26604. * Serialiaze the camera setup to a json represention
  26605. * @returns the JSON representation
  26606. */
  26607. serialize(): any;
  26608. /**
  26609. * Clones the current camera.
  26610. * @param name The cloned camera name
  26611. * @returns the cloned camera
  26612. */
  26613. clone(name: string): Camera;
  26614. /**
  26615. * Gets the direction of the camera relative to a given local axis.
  26616. * @param localAxis Defines the reference axis to provide a relative direction.
  26617. * @return the direction
  26618. */
  26619. getDirection(localAxis: Vector3): Vector3;
  26620. /**
  26621. * Returns the current camera absolute rotation
  26622. */
  26623. get absoluteRotation(): Quaternion;
  26624. /**
  26625. * Gets the direction of the camera relative to a given local axis into a passed vector.
  26626. * @param localAxis Defines the reference axis to provide a relative direction.
  26627. * @param result Defines the vector to store the result in
  26628. */
  26629. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  26630. /**
  26631. * Gets a camera constructor for a given camera type
  26632. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  26633. * @param name The name of the camera the result will be able to instantiate
  26634. * @param scene The scene the result will construct the camera in
  26635. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  26636. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  26637. * @returns a factory method to construc the camera
  26638. */
  26639. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  26640. /**
  26641. * Compute the world matrix of the camera.
  26642. * @returns the camera world matrix
  26643. */
  26644. computeWorldMatrix(): Matrix;
  26645. /**
  26646. * Parse a JSON and creates the camera from the parsed information
  26647. * @param parsedCamera The JSON to parse
  26648. * @param scene The scene to instantiate the camera in
  26649. * @returns the newly constructed camera
  26650. */
  26651. static Parse(parsedCamera: any, scene: Scene): Camera;
  26652. }
  26653. }
  26654. declare module "babylonjs/Meshes/Builders/discBuilder" {
  26655. import { Nullable } from "babylonjs/types";
  26656. import { Scene } from "babylonjs/scene";
  26657. import { Vector4 } from "babylonjs/Maths/math.vector";
  26658. import { Mesh } from "babylonjs/Meshes/mesh";
  26659. /**
  26660. * Class containing static functions to help procedurally build meshes
  26661. */
  26662. export class DiscBuilder {
  26663. /**
  26664. * Creates a plane polygonal mesh. By default, this is a disc
  26665. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  26666. * * The parameter `tessellation` sets the number of polygon sides (positive integer, default 64). So a tessellation valued to 3 will build a triangle, to 4 a square, etc
  26667. * * You can create an unclosed polygon with the parameter `arc` (positive float, default 1), valued between 0 and 1, what is the ratio of the circumference : 2 x PI x ratio
  26668. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  26669. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  26670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  26671. * @param name defines the name of the mesh
  26672. * @param options defines the options used to create the mesh
  26673. * @param scene defines the hosting scene
  26674. * @returns the plane polygonal mesh
  26675. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  26676. */
  26677. static CreateDisc(name: string, options: {
  26678. radius?: number;
  26679. tessellation?: number;
  26680. arc?: number;
  26681. updatable?: boolean;
  26682. sideOrientation?: number;
  26683. frontUVs?: Vector4;
  26684. backUVs?: Vector4;
  26685. }, scene?: Nullable<Scene>): Mesh;
  26686. }
  26687. }
  26688. declare module "babylonjs/Materials/fresnelParameters" {
  26689. import { Color3 } from "babylonjs/Maths/math.color";
  26690. /**
  26691. * This represents all the required information to add a fresnel effect on a material:
  26692. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26693. */
  26694. export class FresnelParameters {
  26695. private _isEnabled;
  26696. /**
  26697. * Define if the fresnel effect is enable or not.
  26698. */
  26699. get isEnabled(): boolean;
  26700. set isEnabled(value: boolean);
  26701. /**
  26702. * Define the color used on edges (grazing angle)
  26703. */
  26704. leftColor: Color3;
  26705. /**
  26706. * Define the color used on center
  26707. */
  26708. rightColor: Color3;
  26709. /**
  26710. * Define bias applied to computed fresnel term
  26711. */
  26712. bias: number;
  26713. /**
  26714. * Defined the power exponent applied to fresnel term
  26715. */
  26716. power: number;
  26717. /**
  26718. * Clones the current fresnel and its valuues
  26719. * @returns a clone fresnel configuration
  26720. */
  26721. clone(): FresnelParameters;
  26722. /**
  26723. * Serializes the current fresnel parameters to a JSON representation.
  26724. * @return the JSON serialization
  26725. */
  26726. serialize(): any;
  26727. /**
  26728. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26729. * @param parsedFresnelParameters Define the JSON representation
  26730. * @returns the parsed parameters
  26731. */
  26732. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26733. }
  26734. }
  26735. declare module "babylonjs/Materials/pushMaterial" {
  26736. import { Nullable } from "babylonjs/types";
  26737. import { Scene } from "babylonjs/scene";
  26738. import { Matrix } from "babylonjs/Maths/math.vector";
  26739. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26740. import { Mesh } from "babylonjs/Meshes/mesh";
  26741. import { Material } from "babylonjs/Materials/material";
  26742. import { Effect } from "babylonjs/Materials/effect";
  26743. /**
  26744. * Base class of materials working in push mode in babylon JS
  26745. * @hidden
  26746. */
  26747. export class PushMaterial extends Material {
  26748. protected _activeEffect: Effect;
  26749. protected _normalMatrix: Matrix;
  26750. /**
  26751. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  26752. * This means that the material can keep using a previous shader while a new one is being compiled.
  26753. * This is mostly used when shader parallel compilation is supported (true by default)
  26754. */
  26755. allowShaderHotSwapping: boolean;
  26756. constructor(name: string, scene: Scene);
  26757. getEffect(): Effect;
  26758. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26759. /**
  26760. * Binds the given world matrix to the active effect
  26761. *
  26762. * @param world the matrix to bind
  26763. */
  26764. bindOnlyWorldMatrix(world: Matrix): void;
  26765. /**
  26766. * Binds the given normal matrix to the active effect
  26767. *
  26768. * @param normalMatrix the matrix to bind
  26769. */
  26770. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  26771. bind(world: Matrix, mesh?: Mesh): void;
  26772. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  26773. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  26774. }
  26775. }
  26776. declare module "babylonjs/Materials/materialFlags" {
  26777. /**
  26778. * This groups all the flags used to control the materials channel.
  26779. */
  26780. export class MaterialFlags {
  26781. private static _DiffuseTextureEnabled;
  26782. /**
  26783. * Are diffuse textures enabled in the application.
  26784. */
  26785. static get DiffuseTextureEnabled(): boolean;
  26786. static set DiffuseTextureEnabled(value: boolean);
  26787. private static _AmbientTextureEnabled;
  26788. /**
  26789. * Are ambient textures enabled in the application.
  26790. */
  26791. static get AmbientTextureEnabled(): boolean;
  26792. static set AmbientTextureEnabled(value: boolean);
  26793. private static _OpacityTextureEnabled;
  26794. /**
  26795. * Are opacity textures enabled in the application.
  26796. */
  26797. static get OpacityTextureEnabled(): boolean;
  26798. static set OpacityTextureEnabled(value: boolean);
  26799. private static _ReflectionTextureEnabled;
  26800. /**
  26801. * Are reflection textures enabled in the application.
  26802. */
  26803. static get ReflectionTextureEnabled(): boolean;
  26804. static set ReflectionTextureEnabled(value: boolean);
  26805. private static _EmissiveTextureEnabled;
  26806. /**
  26807. * Are emissive textures enabled in the application.
  26808. */
  26809. static get EmissiveTextureEnabled(): boolean;
  26810. static set EmissiveTextureEnabled(value: boolean);
  26811. private static _SpecularTextureEnabled;
  26812. /**
  26813. * Are specular textures enabled in the application.
  26814. */
  26815. static get SpecularTextureEnabled(): boolean;
  26816. static set SpecularTextureEnabled(value: boolean);
  26817. private static _BumpTextureEnabled;
  26818. /**
  26819. * Are bump textures enabled in the application.
  26820. */
  26821. static get BumpTextureEnabled(): boolean;
  26822. static set BumpTextureEnabled(value: boolean);
  26823. private static _LightmapTextureEnabled;
  26824. /**
  26825. * Are lightmap textures enabled in the application.
  26826. */
  26827. static get LightmapTextureEnabled(): boolean;
  26828. static set LightmapTextureEnabled(value: boolean);
  26829. private static _RefractionTextureEnabled;
  26830. /**
  26831. * Are refraction textures enabled in the application.
  26832. */
  26833. static get RefractionTextureEnabled(): boolean;
  26834. static set RefractionTextureEnabled(value: boolean);
  26835. private static _ColorGradingTextureEnabled;
  26836. /**
  26837. * Are color grading textures enabled in the application.
  26838. */
  26839. static get ColorGradingTextureEnabled(): boolean;
  26840. static set ColorGradingTextureEnabled(value: boolean);
  26841. private static _FresnelEnabled;
  26842. /**
  26843. * Are fresnels enabled in the application.
  26844. */
  26845. static get FresnelEnabled(): boolean;
  26846. static set FresnelEnabled(value: boolean);
  26847. private static _ClearCoatTextureEnabled;
  26848. /**
  26849. * Are clear coat textures enabled in the application.
  26850. */
  26851. static get ClearCoatTextureEnabled(): boolean;
  26852. static set ClearCoatTextureEnabled(value: boolean);
  26853. private static _ClearCoatBumpTextureEnabled;
  26854. /**
  26855. * Are clear coat bump textures enabled in the application.
  26856. */
  26857. static get ClearCoatBumpTextureEnabled(): boolean;
  26858. static set ClearCoatBumpTextureEnabled(value: boolean);
  26859. private static _ClearCoatTintTextureEnabled;
  26860. /**
  26861. * Are clear coat tint textures enabled in the application.
  26862. */
  26863. static get ClearCoatTintTextureEnabled(): boolean;
  26864. static set ClearCoatTintTextureEnabled(value: boolean);
  26865. private static _SheenTextureEnabled;
  26866. /**
  26867. * Are sheen textures enabled in the application.
  26868. */
  26869. static get SheenTextureEnabled(): boolean;
  26870. static set SheenTextureEnabled(value: boolean);
  26871. private static _AnisotropicTextureEnabled;
  26872. /**
  26873. * Are anisotropic textures enabled in the application.
  26874. */
  26875. static get AnisotropicTextureEnabled(): boolean;
  26876. static set AnisotropicTextureEnabled(value: boolean);
  26877. private static _ThicknessTextureEnabled;
  26878. /**
  26879. * Are thickness textures enabled in the application.
  26880. */
  26881. static get ThicknessTextureEnabled(): boolean;
  26882. static set ThicknessTextureEnabled(value: boolean);
  26883. }
  26884. }
  26885. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  26886. /** @hidden */
  26887. export var defaultFragmentDeclaration: {
  26888. name: string;
  26889. shader: string;
  26890. };
  26891. }
  26892. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  26893. /** @hidden */
  26894. export var defaultUboDeclaration: {
  26895. name: string;
  26896. shader: string;
  26897. };
  26898. }
  26899. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  26900. /** @hidden */
  26901. export var lightFragmentDeclaration: {
  26902. name: string;
  26903. shader: string;
  26904. };
  26905. }
  26906. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  26907. /** @hidden */
  26908. export var lightUboDeclaration: {
  26909. name: string;
  26910. shader: string;
  26911. };
  26912. }
  26913. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  26914. /** @hidden */
  26915. export var lightsFragmentFunctions: {
  26916. name: string;
  26917. shader: string;
  26918. };
  26919. }
  26920. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  26921. /** @hidden */
  26922. export var shadowsFragmentFunctions: {
  26923. name: string;
  26924. shader: string;
  26925. };
  26926. }
  26927. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  26928. /** @hidden */
  26929. export var fresnelFunction: {
  26930. name: string;
  26931. shader: string;
  26932. };
  26933. }
  26934. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  26935. /** @hidden */
  26936. export var reflectionFunction: {
  26937. name: string;
  26938. shader: string;
  26939. };
  26940. }
  26941. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  26942. /** @hidden */
  26943. export var bumpFragmentFunctions: {
  26944. name: string;
  26945. shader: string;
  26946. };
  26947. }
  26948. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  26949. /** @hidden */
  26950. export var logDepthDeclaration: {
  26951. name: string;
  26952. shader: string;
  26953. };
  26954. }
  26955. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  26956. /** @hidden */
  26957. export var bumpFragment: {
  26958. name: string;
  26959. shader: string;
  26960. };
  26961. }
  26962. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  26963. /** @hidden */
  26964. export var depthPrePass: {
  26965. name: string;
  26966. shader: string;
  26967. };
  26968. }
  26969. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  26970. /** @hidden */
  26971. export var lightFragment: {
  26972. name: string;
  26973. shader: string;
  26974. };
  26975. }
  26976. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  26977. /** @hidden */
  26978. export var logDepthFragment: {
  26979. name: string;
  26980. shader: string;
  26981. };
  26982. }
  26983. declare module "babylonjs/Shaders/default.fragment" {
  26984. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  26985. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  26986. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  26987. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  26988. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  26989. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  26990. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  26991. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  26992. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  26993. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  26994. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  26995. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  26996. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  26997. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  26998. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  26999. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27000. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27001. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27002. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27003. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27004. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27005. /** @hidden */
  27006. export var defaultPixelShader: {
  27007. name: string;
  27008. shader: string;
  27009. };
  27010. }
  27011. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27012. /** @hidden */
  27013. export var defaultVertexDeclaration: {
  27014. name: string;
  27015. shader: string;
  27016. };
  27017. }
  27018. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27019. /** @hidden */
  27020. export var bumpVertexDeclaration: {
  27021. name: string;
  27022. shader: string;
  27023. };
  27024. }
  27025. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27026. /** @hidden */
  27027. export var bumpVertex: {
  27028. name: string;
  27029. shader: string;
  27030. };
  27031. }
  27032. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27033. /** @hidden */
  27034. export var fogVertex: {
  27035. name: string;
  27036. shader: string;
  27037. };
  27038. }
  27039. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27040. /** @hidden */
  27041. export var shadowsVertex: {
  27042. name: string;
  27043. shader: string;
  27044. };
  27045. }
  27046. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27047. /** @hidden */
  27048. export var pointCloudVertex: {
  27049. name: string;
  27050. shader: string;
  27051. };
  27052. }
  27053. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27054. /** @hidden */
  27055. export var logDepthVertex: {
  27056. name: string;
  27057. shader: string;
  27058. };
  27059. }
  27060. declare module "babylonjs/Shaders/default.vertex" {
  27061. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27062. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27063. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27064. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27065. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27066. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27067. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27068. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27069. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27070. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27071. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27072. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27073. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27074. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27075. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27076. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27077. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27078. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27079. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27080. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27081. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27082. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27083. /** @hidden */
  27084. export var defaultVertexShader: {
  27085. name: string;
  27086. shader: string;
  27087. };
  27088. }
  27089. declare module "babylonjs/Materials/standardMaterial" {
  27090. import { SmartArray } from "babylonjs/Misc/smartArray";
  27091. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27092. import { Nullable } from "babylonjs/types";
  27093. import { Scene } from "babylonjs/scene";
  27094. import { Matrix } from "babylonjs/Maths/math.vector";
  27095. import { Color3 } from "babylonjs/Maths/math.color";
  27096. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27097. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27098. import { Mesh } from "babylonjs/Meshes/mesh";
  27099. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27100. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27101. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27102. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27103. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27104. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27105. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27106. import "babylonjs/Shaders/default.fragment";
  27107. import "babylonjs/Shaders/default.vertex";
  27108. /** @hidden */
  27109. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27110. MAINUV1: boolean;
  27111. MAINUV2: boolean;
  27112. DIFFUSE: boolean;
  27113. DIFFUSEDIRECTUV: number;
  27114. AMBIENT: boolean;
  27115. AMBIENTDIRECTUV: number;
  27116. OPACITY: boolean;
  27117. OPACITYDIRECTUV: number;
  27118. OPACITYRGB: boolean;
  27119. REFLECTION: boolean;
  27120. EMISSIVE: boolean;
  27121. EMISSIVEDIRECTUV: number;
  27122. SPECULAR: boolean;
  27123. SPECULARDIRECTUV: number;
  27124. BUMP: boolean;
  27125. BUMPDIRECTUV: number;
  27126. PARALLAX: boolean;
  27127. PARALLAXOCCLUSION: boolean;
  27128. SPECULAROVERALPHA: boolean;
  27129. CLIPPLANE: boolean;
  27130. CLIPPLANE2: boolean;
  27131. CLIPPLANE3: boolean;
  27132. CLIPPLANE4: boolean;
  27133. CLIPPLANE5: boolean;
  27134. CLIPPLANE6: boolean;
  27135. ALPHATEST: boolean;
  27136. DEPTHPREPASS: boolean;
  27137. ALPHAFROMDIFFUSE: boolean;
  27138. POINTSIZE: boolean;
  27139. FOG: boolean;
  27140. SPECULARTERM: boolean;
  27141. DIFFUSEFRESNEL: boolean;
  27142. OPACITYFRESNEL: boolean;
  27143. REFLECTIONFRESNEL: boolean;
  27144. REFRACTIONFRESNEL: boolean;
  27145. EMISSIVEFRESNEL: boolean;
  27146. FRESNEL: boolean;
  27147. NORMAL: boolean;
  27148. UV1: boolean;
  27149. UV2: boolean;
  27150. VERTEXCOLOR: boolean;
  27151. VERTEXALPHA: boolean;
  27152. NUM_BONE_INFLUENCERS: number;
  27153. BonesPerMesh: number;
  27154. BONETEXTURE: boolean;
  27155. INSTANCES: boolean;
  27156. GLOSSINESS: boolean;
  27157. ROUGHNESS: boolean;
  27158. EMISSIVEASILLUMINATION: boolean;
  27159. LINKEMISSIVEWITHDIFFUSE: boolean;
  27160. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27161. LIGHTMAP: boolean;
  27162. LIGHTMAPDIRECTUV: number;
  27163. OBJECTSPACE_NORMALMAP: boolean;
  27164. USELIGHTMAPASSHADOWMAP: boolean;
  27165. REFLECTIONMAP_3D: boolean;
  27166. REFLECTIONMAP_SPHERICAL: boolean;
  27167. REFLECTIONMAP_PLANAR: boolean;
  27168. REFLECTIONMAP_CUBIC: boolean;
  27169. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27170. REFLECTIONMAP_PROJECTION: boolean;
  27171. REFLECTIONMAP_SKYBOX: boolean;
  27172. REFLECTIONMAP_EXPLICIT: boolean;
  27173. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27174. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27175. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27176. INVERTCUBICMAP: boolean;
  27177. LOGARITHMICDEPTH: boolean;
  27178. REFRACTION: boolean;
  27179. REFRACTIONMAP_3D: boolean;
  27180. REFLECTIONOVERALPHA: boolean;
  27181. TWOSIDEDLIGHTING: boolean;
  27182. SHADOWFLOAT: boolean;
  27183. MORPHTARGETS: boolean;
  27184. MORPHTARGETS_NORMAL: boolean;
  27185. MORPHTARGETS_TANGENT: boolean;
  27186. MORPHTARGETS_UV: boolean;
  27187. NUM_MORPH_INFLUENCERS: number;
  27188. NONUNIFORMSCALING: boolean;
  27189. PREMULTIPLYALPHA: boolean;
  27190. IMAGEPROCESSING: boolean;
  27191. VIGNETTE: boolean;
  27192. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27193. VIGNETTEBLENDMODEOPAQUE: boolean;
  27194. TONEMAPPING: boolean;
  27195. TONEMAPPING_ACES: boolean;
  27196. CONTRAST: boolean;
  27197. COLORCURVES: boolean;
  27198. COLORGRADING: boolean;
  27199. COLORGRADING3D: boolean;
  27200. SAMPLER3DGREENDEPTH: boolean;
  27201. SAMPLER3DBGRMAP: boolean;
  27202. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27203. MULTIVIEW: boolean;
  27204. /**
  27205. * If the reflection texture on this material is in linear color space
  27206. * @hidden
  27207. */
  27208. IS_REFLECTION_LINEAR: boolean;
  27209. /**
  27210. * If the refraction texture on this material is in linear color space
  27211. * @hidden
  27212. */
  27213. IS_REFRACTION_LINEAR: boolean;
  27214. EXPOSURE: boolean;
  27215. constructor();
  27216. setReflectionMode(modeToEnable: string): void;
  27217. }
  27218. /**
  27219. * This is the default material used in Babylon. It is the best trade off between quality
  27220. * and performances.
  27221. * @see http://doc.babylonjs.com/babylon101/materials
  27222. */
  27223. export class StandardMaterial extends PushMaterial {
  27224. private _diffuseTexture;
  27225. /**
  27226. * The basic texture of the material as viewed under a light.
  27227. */
  27228. diffuseTexture: Nullable<BaseTexture>;
  27229. private _ambientTexture;
  27230. /**
  27231. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27232. */
  27233. ambientTexture: Nullable<BaseTexture>;
  27234. private _opacityTexture;
  27235. /**
  27236. * Define the transparency of the material from a texture.
  27237. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27238. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27239. */
  27240. opacityTexture: Nullable<BaseTexture>;
  27241. private _reflectionTexture;
  27242. /**
  27243. * Define the texture used to display the reflection.
  27244. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27245. */
  27246. reflectionTexture: Nullable<BaseTexture>;
  27247. private _emissiveTexture;
  27248. /**
  27249. * Define texture of the material as if self lit.
  27250. * This will be mixed in the final result even in the absence of light.
  27251. */
  27252. emissiveTexture: Nullable<BaseTexture>;
  27253. private _specularTexture;
  27254. /**
  27255. * Define how the color and intensity of the highlight given by the light in the material.
  27256. */
  27257. specularTexture: Nullable<BaseTexture>;
  27258. private _bumpTexture;
  27259. /**
  27260. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27261. * These are made by creating a normal map from an image. The means to do this can be found on the web, a search for 'normal map generator' will bring up free and paid for methods of doing this.
  27262. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27263. */
  27264. bumpTexture: Nullable<BaseTexture>;
  27265. private _lightmapTexture;
  27266. /**
  27267. * Complex lighting can be computationally expensive to compute at runtime.
  27268. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27269. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27270. */
  27271. lightmapTexture: Nullable<BaseTexture>;
  27272. private _refractionTexture;
  27273. /**
  27274. * Define the texture used to display the refraction.
  27275. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27276. */
  27277. refractionTexture: Nullable<BaseTexture>;
  27278. /**
  27279. * The color of the material lit by the environmental background lighting.
  27280. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27281. */
  27282. ambientColor: Color3;
  27283. /**
  27284. * The basic color of the material as viewed under a light.
  27285. */
  27286. diffuseColor: Color3;
  27287. /**
  27288. * Define how the color and intensity of the highlight given by the light in the material.
  27289. */
  27290. specularColor: Color3;
  27291. /**
  27292. * Define the color of the material as if self lit.
  27293. * This will be mixed in the final result even in the absence of light.
  27294. */
  27295. emissiveColor: Color3;
  27296. /**
  27297. * Defines how sharp are the highlights in the material.
  27298. * The bigger the value the sharper giving a more glossy feeling to the result.
  27299. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27300. */
  27301. specularPower: number;
  27302. private _useAlphaFromDiffuseTexture;
  27303. /**
  27304. * Does the transparency come from the diffuse texture alpha channel.
  27305. */
  27306. useAlphaFromDiffuseTexture: boolean;
  27307. private _useEmissiveAsIllumination;
  27308. /**
  27309. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27310. */
  27311. useEmissiveAsIllumination: boolean;
  27312. private _linkEmissiveWithDiffuse;
  27313. /**
  27314. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27315. * the emissive level when the final color is close to one.
  27316. */
  27317. linkEmissiveWithDiffuse: boolean;
  27318. private _useSpecularOverAlpha;
  27319. /**
  27320. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27321. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27322. */
  27323. useSpecularOverAlpha: boolean;
  27324. private _useReflectionOverAlpha;
  27325. /**
  27326. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27327. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27328. */
  27329. useReflectionOverAlpha: boolean;
  27330. private _disableLighting;
  27331. /**
  27332. * Does lights from the scene impacts this material.
  27333. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27334. */
  27335. disableLighting: boolean;
  27336. private _useObjectSpaceNormalMap;
  27337. /**
  27338. * Allows using an object space normal map (instead of tangent space).
  27339. */
  27340. useObjectSpaceNormalMap: boolean;
  27341. private _useParallax;
  27342. /**
  27343. * Is parallax enabled or not.
  27344. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27345. */
  27346. useParallax: boolean;
  27347. private _useParallaxOcclusion;
  27348. /**
  27349. * Is parallax occlusion enabled or not.
  27350. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27351. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27352. */
  27353. useParallaxOcclusion: boolean;
  27354. /**
  27355. * Apply a scaling factor that determine which "depth" the height map should reprensent. A value between 0.05 and 0.1 is reasonnable in Parallax, you can reach 0.2 using Parallax Occlusion.
  27356. */
  27357. parallaxScaleBias: number;
  27358. private _roughness;
  27359. /**
  27360. * Helps to define how blurry the reflections should appears in the material.
  27361. */
  27362. roughness: number;
  27363. /**
  27364. * In case of refraction, define the value of the index of refraction.
  27365. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27366. */
  27367. indexOfRefraction: number;
  27368. /**
  27369. * Invert the refraction texture alongside the y axis.
  27370. * It can be useful with procedural textures or probe for instance.
  27371. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27372. */
  27373. invertRefractionY: boolean;
  27374. /**
  27375. * Defines the alpha limits in alpha test mode.
  27376. */
  27377. alphaCutOff: number;
  27378. private _useLightmapAsShadowmap;
  27379. /**
  27380. * In case of light mapping, define whether the map contains light or shadow informations.
  27381. */
  27382. useLightmapAsShadowmap: boolean;
  27383. private _diffuseFresnelParameters;
  27384. /**
  27385. * Define the diffuse fresnel parameters of the material.
  27386. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27387. */
  27388. diffuseFresnelParameters: FresnelParameters;
  27389. private _opacityFresnelParameters;
  27390. /**
  27391. * Define the opacity fresnel parameters of the material.
  27392. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27393. */
  27394. opacityFresnelParameters: FresnelParameters;
  27395. private _reflectionFresnelParameters;
  27396. /**
  27397. * Define the reflection fresnel parameters of the material.
  27398. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27399. */
  27400. reflectionFresnelParameters: FresnelParameters;
  27401. private _refractionFresnelParameters;
  27402. /**
  27403. * Define the refraction fresnel parameters of the material.
  27404. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27405. */
  27406. refractionFresnelParameters: FresnelParameters;
  27407. private _emissiveFresnelParameters;
  27408. /**
  27409. * Define the emissive fresnel parameters of the material.
  27410. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27411. */
  27412. emissiveFresnelParameters: FresnelParameters;
  27413. private _useReflectionFresnelFromSpecular;
  27414. /**
  27415. * If true automatically deducts the fresnels values from the material specularity.
  27416. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27417. */
  27418. useReflectionFresnelFromSpecular: boolean;
  27419. private _useGlossinessFromSpecularMapAlpha;
  27420. /**
  27421. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27422. */
  27423. useGlossinessFromSpecularMapAlpha: boolean;
  27424. private _maxSimultaneousLights;
  27425. /**
  27426. * Defines the maximum number of lights that can be used in the material
  27427. */
  27428. maxSimultaneousLights: number;
  27429. private _invertNormalMapX;
  27430. /**
  27431. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27432. */
  27433. invertNormalMapX: boolean;
  27434. private _invertNormalMapY;
  27435. /**
  27436. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27437. */
  27438. invertNormalMapY: boolean;
  27439. private _twoSidedLighting;
  27440. /**
  27441. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27442. */
  27443. twoSidedLighting: boolean;
  27444. /**
  27445. * Default configuration related to image processing available in the standard Material.
  27446. */
  27447. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27448. /**
  27449. * Gets the image processing configuration used either in this material.
  27450. */
  27451. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27452. /**
  27453. * Sets the Default image processing configuration used either in the this material.
  27454. *
  27455. * If sets to null, the scene one is in use.
  27456. */
  27457. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27458. /**
  27459. * Keep track of the image processing observer to allow dispose and replace.
  27460. */
  27461. private _imageProcessingObserver;
  27462. /**
  27463. * Attaches a new image processing configuration to the Standard Material.
  27464. * @param configuration
  27465. */
  27466. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27467. /**
  27468. * Gets wether the color curves effect is enabled.
  27469. */
  27470. get cameraColorCurvesEnabled(): boolean;
  27471. /**
  27472. * Sets wether the color curves effect is enabled.
  27473. */
  27474. set cameraColorCurvesEnabled(value: boolean);
  27475. /**
  27476. * Gets wether the color grading effect is enabled.
  27477. */
  27478. get cameraColorGradingEnabled(): boolean;
  27479. /**
  27480. * Gets wether the color grading effect is enabled.
  27481. */
  27482. set cameraColorGradingEnabled(value: boolean);
  27483. /**
  27484. * Gets wether tonemapping is enabled or not.
  27485. */
  27486. get cameraToneMappingEnabled(): boolean;
  27487. /**
  27488. * Sets wether tonemapping is enabled or not
  27489. */
  27490. set cameraToneMappingEnabled(value: boolean);
  27491. /**
  27492. * The camera exposure used on this material.
  27493. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27494. * This corresponds to a photographic exposure.
  27495. */
  27496. get cameraExposure(): number;
  27497. /**
  27498. * The camera exposure used on this material.
  27499. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27500. * This corresponds to a photographic exposure.
  27501. */
  27502. set cameraExposure(value: number);
  27503. /**
  27504. * Gets The camera contrast used on this material.
  27505. */
  27506. get cameraContrast(): number;
  27507. /**
  27508. * Sets The camera contrast used on this material.
  27509. */
  27510. set cameraContrast(value: number);
  27511. /**
  27512. * Gets the Color Grading 2D Lookup Texture.
  27513. */
  27514. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27515. /**
  27516. * Sets the Color Grading 2D Lookup Texture.
  27517. */
  27518. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27519. /**
  27520. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27521. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27522. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  27523. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27524. */
  27525. get cameraColorCurves(): Nullable<ColorCurves>;
  27526. /**
  27527. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27528. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27529. * These are similar to controls found in many professional imaging or colorist software. The global controls are applied to the entire image. For advanced tuning, extra controls are provided to adjust the shadow, midtone and highlight areas of the image;
  27530. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27531. */
  27532. set cameraColorCurves(value: Nullable<ColorCurves>);
  27533. /**
  27534. * Custom callback helping to override the default shader used in the material.
  27535. */
  27536. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  27537. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27538. protected _worldViewProjectionMatrix: Matrix;
  27539. protected _globalAmbientColor: Color3;
  27540. protected _useLogarithmicDepth: boolean;
  27541. protected _rebuildInParallel: boolean;
  27542. /**
  27543. * Instantiates a new standard material.
  27544. * This is the default material used in Babylon. It is the best trade off between quality
  27545. * and performances.
  27546. * @see http://doc.babylonjs.com/babylon101/materials
  27547. * @param name Define the name of the material in the scene
  27548. * @param scene Define the scene the material belong to
  27549. */
  27550. constructor(name: string, scene: Scene);
  27551. /**
  27552. * Gets a boolean indicating that current material needs to register RTT
  27553. */
  27554. get hasRenderTargetTextures(): boolean;
  27555. /**
  27556. * Gets the current class name of the material e.g. "StandardMaterial"
  27557. * Mainly use in serialization.
  27558. * @returns the class name
  27559. */
  27560. getClassName(): string;
  27561. /**
  27562. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27563. * You can try switching to logarithmic depth.
  27564. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27565. */
  27566. get useLogarithmicDepth(): boolean;
  27567. set useLogarithmicDepth(value: boolean);
  27568. /**
  27569. * Specifies if the material will require alpha blending
  27570. * @returns a boolean specifying if alpha blending is needed
  27571. */
  27572. needAlphaBlending(): boolean;
  27573. /**
  27574. * Specifies if this material should be rendered in alpha test mode
  27575. * @returns a boolean specifying if an alpha test is needed.
  27576. */
  27577. needAlphaTesting(): boolean;
  27578. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27579. /**
  27580. * Get the texture used for alpha test purpose.
  27581. * @returns the diffuse texture in case of the standard material.
  27582. */
  27583. getAlphaTestTexture(): Nullable<BaseTexture>;
  27584. /**
  27585. * Get if the submesh is ready to be used and all its information available.
  27586. * Child classes can use it to update shaders
  27587. * @param mesh defines the mesh to check
  27588. * @param subMesh defines which submesh to check
  27589. * @param useInstances specifies that instances should be used
  27590. * @returns a boolean indicating that the submesh is ready or not
  27591. */
  27592. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27593. /**
  27594. * Builds the material UBO layouts.
  27595. * Used internally during the effect preparation.
  27596. */
  27597. buildUniformLayout(): void;
  27598. /**
  27599. * Unbinds the material from the mesh
  27600. */
  27601. unbind(): void;
  27602. /**
  27603. * Binds the submesh to this material by preparing the effect and shader to draw
  27604. * @param world defines the world transformation matrix
  27605. * @param mesh defines the mesh containing the submesh
  27606. * @param subMesh defines the submesh to bind the material to
  27607. */
  27608. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27609. /**
  27610. * Get the list of animatables in the material.
  27611. * @returns the list of animatables object used in the material
  27612. */
  27613. getAnimatables(): IAnimatable[];
  27614. /**
  27615. * Gets the active textures from the material
  27616. * @returns an array of textures
  27617. */
  27618. getActiveTextures(): BaseTexture[];
  27619. /**
  27620. * Specifies if the material uses a texture
  27621. * @param texture defines the texture to check against the material
  27622. * @returns a boolean specifying if the material uses the texture
  27623. */
  27624. hasTexture(texture: BaseTexture): boolean;
  27625. /**
  27626. * Disposes the material
  27627. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27628. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27629. */
  27630. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27631. /**
  27632. * Makes a duplicate of the material, and gives it a new name
  27633. * @param name defines the new name for the duplicated material
  27634. * @returns the cloned material
  27635. */
  27636. clone(name: string): StandardMaterial;
  27637. /**
  27638. * Serializes this material in a JSON representation
  27639. * @returns the serialized material object
  27640. */
  27641. serialize(): any;
  27642. /**
  27643. * Creates a standard material from parsed material data
  27644. * @param source defines the JSON representation of the material
  27645. * @param scene defines the hosting scene
  27646. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27647. * @returns a new standard material
  27648. */
  27649. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27650. /**
  27651. * Are diffuse textures enabled in the application.
  27652. */
  27653. static get DiffuseTextureEnabled(): boolean;
  27654. static set DiffuseTextureEnabled(value: boolean);
  27655. /**
  27656. * Are ambient textures enabled in the application.
  27657. */
  27658. static get AmbientTextureEnabled(): boolean;
  27659. static set AmbientTextureEnabled(value: boolean);
  27660. /**
  27661. * Are opacity textures enabled in the application.
  27662. */
  27663. static get OpacityTextureEnabled(): boolean;
  27664. static set OpacityTextureEnabled(value: boolean);
  27665. /**
  27666. * Are reflection textures enabled in the application.
  27667. */
  27668. static get ReflectionTextureEnabled(): boolean;
  27669. static set ReflectionTextureEnabled(value: boolean);
  27670. /**
  27671. * Are emissive textures enabled in the application.
  27672. */
  27673. static get EmissiveTextureEnabled(): boolean;
  27674. static set EmissiveTextureEnabled(value: boolean);
  27675. /**
  27676. * Are specular textures enabled in the application.
  27677. */
  27678. static get SpecularTextureEnabled(): boolean;
  27679. static set SpecularTextureEnabled(value: boolean);
  27680. /**
  27681. * Are bump textures enabled in the application.
  27682. */
  27683. static get BumpTextureEnabled(): boolean;
  27684. static set BumpTextureEnabled(value: boolean);
  27685. /**
  27686. * Are lightmap textures enabled in the application.
  27687. */
  27688. static get LightmapTextureEnabled(): boolean;
  27689. static set LightmapTextureEnabled(value: boolean);
  27690. /**
  27691. * Are refraction textures enabled in the application.
  27692. */
  27693. static get RefractionTextureEnabled(): boolean;
  27694. static set RefractionTextureEnabled(value: boolean);
  27695. /**
  27696. * Are color grading textures enabled in the application.
  27697. */
  27698. static get ColorGradingTextureEnabled(): boolean;
  27699. static set ColorGradingTextureEnabled(value: boolean);
  27700. /**
  27701. * Are fresnels enabled in the application.
  27702. */
  27703. static get FresnelEnabled(): boolean;
  27704. static set FresnelEnabled(value: boolean);
  27705. }
  27706. }
  27707. declare module "babylonjs/Particles/solidParticleSystem" {
  27708. import { Nullable } from "babylonjs/types";
  27709. import { Vector3 } from "babylonjs/Maths/math.vector";
  27710. import { Mesh } from "babylonjs/Meshes/mesh";
  27711. import { Scene, IDisposable } from "babylonjs/scene";
  27712. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  27713. import { Material } from "babylonjs/Materials/material";
  27714. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  27715. /**
  27716. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  27717. *As it is just a mesh, the SPS has all the same properties than any other BJS mesh : not more, not less. It can be scaled, rotated, translated, enlighted, textured, moved, etc.
  27718. * The SPS is also a particle system. It provides some methods to manage the particles.
  27719. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  27720. *
  27721. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  27722. */
  27723. export class SolidParticleSystem implements IDisposable {
  27724. /**
  27725. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  27726. * Example : var p = SPS.particles[i];
  27727. */
  27728. particles: SolidParticle[];
  27729. /**
  27730. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  27731. */
  27732. nbParticles: number;
  27733. /**
  27734. * If the particles must ever face the camera (default false). Useful for planar particles.
  27735. */
  27736. billboard: boolean;
  27737. /**
  27738. * Recompute normals when adding a shape
  27739. */
  27740. recomputeNormals: boolean;
  27741. /**
  27742. * This a counter ofr your own usage. It's not set by any SPS functions.
  27743. */
  27744. counter: number;
  27745. /**
  27746. * The SPS name. This name is also given to the underlying mesh.
  27747. */
  27748. name: string;
  27749. /**
  27750. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  27751. */
  27752. mesh: Mesh;
  27753. /**
  27754. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  27755. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  27756. */
  27757. vars: any;
  27758. /**
  27759. * This array is populated when the SPS is set as 'pickable'.
  27760. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  27761. * Each element of this array is an object `{idx: int, faceId: int}`.
  27762. * `idx` is the picked particle index in the `SPS.particles` array
  27763. * `faceId` is the picked face index counted within this particle.
  27764. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  27765. */
  27766. pickedParticles: {
  27767. idx: number;
  27768. faceId: number;
  27769. }[];
  27770. /**
  27771. * This array is populated when `enableDepthSort` is set to true.
  27772. * Each element of this array is an instance of the class DepthSortedParticle.
  27773. */
  27774. depthSortedParticles: DepthSortedParticle[];
  27775. /**
  27776. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  27777. * @hidden
  27778. */
  27779. _bSphereOnly: boolean;
  27780. /**
  27781. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  27782. * @hidden
  27783. */
  27784. _bSphereRadiusFactor: number;
  27785. private _scene;
  27786. private _positions;
  27787. private _indices;
  27788. private _normals;
  27789. private _colors;
  27790. private _uvs;
  27791. private _indices32;
  27792. private _positions32;
  27793. private _normals32;
  27794. private _fixedNormal32;
  27795. private _colors32;
  27796. private _uvs32;
  27797. private _index;
  27798. private _updatable;
  27799. private _pickable;
  27800. private _isVisibilityBoxLocked;
  27801. private _alwaysVisible;
  27802. private _depthSort;
  27803. private _expandable;
  27804. private _shapeCounter;
  27805. private _copy;
  27806. private _color;
  27807. private _computeParticleColor;
  27808. private _computeParticleTexture;
  27809. private _computeParticleRotation;
  27810. private _computeParticleVertex;
  27811. private _computeBoundingBox;
  27812. private _depthSortParticles;
  27813. private _camera;
  27814. private _mustUnrotateFixedNormals;
  27815. private _particlesIntersect;
  27816. private _needs32Bits;
  27817. private _isNotBuilt;
  27818. private _lastParticleId;
  27819. private _idxOfId;
  27820. private _multimaterialEnabled;
  27821. private _useModelMaterial;
  27822. private _indicesByMaterial;
  27823. private _materialIndexes;
  27824. private _depthSortFunction;
  27825. private _materialSortFunction;
  27826. private _materials;
  27827. private _multimaterial;
  27828. private _materialIndexesById;
  27829. private _defaultMaterial;
  27830. private _autoUpdateSubMeshes;
  27831. /**
  27832. * Creates a SPS (Solid Particle System) object.
  27833. * @param name (String) is the SPS name, this will be the underlying mesh name.
  27834. * @param scene (Scene) is the scene in which the SPS is added.
  27835. * @param options defines the options of the sps e.g.
  27836. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  27837. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  27838. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  27839. * * useModelMaterial (optional boolean, defaut false) : if the model materials must be used to create the SPS multimaterial. This enables the multimaterial supports of the SPS.
  27840. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  27841. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  27842. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  27843. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  27844. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  27845. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  27846. */
  27847. constructor(name: string, scene: Scene, options?: {
  27848. updatable?: boolean;
  27849. isPickable?: boolean;
  27850. enableDepthSort?: boolean;
  27851. particleIntersection?: boolean;
  27852. boundingSphereOnly?: boolean;
  27853. bSphereRadiusFactor?: number;
  27854. expandable?: boolean;
  27855. useModelMaterial?: boolean;
  27856. enableMultiMaterial?: boolean;
  27857. });
  27858. /**
  27859. * Builds the SPS underlying mesh. Returns a standard Mesh.
  27860. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  27861. * @returns the created mesh
  27862. */
  27863. buildMesh(): Mesh;
  27864. /**
  27865. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  27866. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  27867. * Thus the particles generated from `digest()` have their property `position` set yet.
  27868. * @param mesh ( Mesh ) is the mesh to be digested
  27869. * @param options {facetNb} (optional integer, default 1) is the number of mesh facets per particle, this parameter is overriden by the parameter `number` if any
  27870. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  27871. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  27872. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27873. * @returns the current SPS
  27874. */
  27875. digest(mesh: Mesh, options?: {
  27876. facetNb?: number;
  27877. number?: number;
  27878. delta?: number;
  27879. storage?: [];
  27880. }): SolidParticleSystem;
  27881. /**
  27882. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  27883. * @hidden
  27884. */
  27885. private _unrotateFixedNormals;
  27886. /**
  27887. * Resets the temporary working copy particle
  27888. * @hidden
  27889. */
  27890. private _resetCopy;
  27891. /**
  27892. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  27893. * @param p the current index in the positions array to be updated
  27894. * @param ind the current index in the indices array
  27895. * @param shape a Vector3 array, the shape geometry
  27896. * @param positions the positions array to be updated
  27897. * @param meshInd the shape indices array
  27898. * @param indices the indices array to be updated
  27899. * @param meshUV the shape uv array
  27900. * @param uvs the uv array to be updated
  27901. * @param meshCol the shape color array
  27902. * @param colors the color array to be updated
  27903. * @param meshNor the shape normals array
  27904. * @param normals the normals array to be updated
  27905. * @param idx the particle index
  27906. * @param idxInShape the particle index in its shape
  27907. * @param options the addShape() method passed options
  27908. * @model the particle model
  27909. * @hidden
  27910. */
  27911. private _meshBuilder;
  27912. /**
  27913. * Returns a shape Vector3 array from positions float array
  27914. * @param positions float array
  27915. * @returns a vector3 array
  27916. * @hidden
  27917. */
  27918. private _posToShape;
  27919. /**
  27920. * Returns a shapeUV array from a float uvs (array deep copy)
  27921. * @param uvs as a float array
  27922. * @returns a shapeUV array
  27923. * @hidden
  27924. */
  27925. private _uvsToShapeUV;
  27926. /**
  27927. * Adds a new particle object in the particles array
  27928. * @param idx particle index in particles array
  27929. * @param id particle id
  27930. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  27931. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  27932. * @param model particle ModelShape object
  27933. * @param shapeId model shape identifier
  27934. * @param idxInShape index of the particle in the current model
  27935. * @param bInfo model bounding info object
  27936. * @param storage target storage array, if any
  27937. * @hidden
  27938. */
  27939. private _addParticle;
  27940. /**
  27941. * Adds some particles to the SPS from the model shape. Returns the shape id.
  27942. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  27943. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  27944. * @param nb (positive integer) the number of particles to be created from this model
  27945. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  27946. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  27947. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  27948. * @returns the number of shapes in the system
  27949. */
  27950. addShape(mesh: Mesh, nb: number, options?: {
  27951. positionFunction?: any;
  27952. vertexFunction?: any;
  27953. storage?: [];
  27954. }): number;
  27955. /**
  27956. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  27957. * @hidden
  27958. */
  27959. private _rebuildParticle;
  27960. /**
  27961. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  27962. * @param reset boolean, default false : if the particles must be reset at position and rotation zero, scaling 1, color white, initial UVs and not parented.
  27963. * @returns the SPS.
  27964. */
  27965. rebuildMesh(reset?: boolean): SolidParticleSystem;
  27966. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  27967. * Returns an array with the removed particles.
  27968. * If the number of particles to remove is lower than zero or greater than the global remaining particle number, then an empty array is returned.
  27969. * The SPS can't be empty so at least one particle needs to remain in place.
  27970. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  27971. * @param start index of the first particle to remove
  27972. * @param end index of the last particle to remove (included)
  27973. * @returns an array populated with the removed particles
  27974. */
  27975. removeParticles(start: number, end: number): SolidParticle[];
  27976. /**
  27977. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  27978. * @param solidParticleArray an array populated with Solid Particles objects
  27979. * @returns the SPS
  27980. */
  27981. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  27982. /**
  27983. * Creates a new particle and modifies the SPS mesh geometry :
  27984. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  27985. * - calls _addParticle() to populate the particle array
  27986. * factorized code from addShape() and insertParticlesFromArray()
  27987. * @param idx particle index in the particles array
  27988. * @param i particle index in its shape
  27989. * @param modelShape particle ModelShape object
  27990. * @param shape shape vertex array
  27991. * @param meshInd shape indices array
  27992. * @param meshUV shape uv array
  27993. * @param meshCol shape color array
  27994. * @param meshNor shape normals array
  27995. * @param bbInfo shape bounding info
  27996. * @param storage target particle storage
  27997. * @options addShape() passed options
  27998. * @hidden
  27999. */
  28000. private _insertNewParticle;
  28001. /**
  28002. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28003. * This method calls `updateParticle()` for each particle of the SPS.
  28004. * For an animated SPS, it is usually called within the render loop.
  28005. * This methods does nothing if called on a non updatable or not yet built SPS. Example : buildMesh() not called after having added or removed particles from an expandable SPS.
  28006. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28007. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28008. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28009. * @returns the SPS.
  28010. */
  28011. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28012. /**
  28013. * Disposes the SPS.
  28014. */
  28015. dispose(): void;
  28016. /**
  28017. * Returns a SolidParticle object from its identifier : particle.id
  28018. * @param id (integer) the particle Id
  28019. * @returns the searched particle or null if not found in the SPS.
  28020. */
  28021. getParticleById(id: number): Nullable<SolidParticle>;
  28022. /**
  28023. * Returns a new array populated with the particles having the passed shapeId.
  28024. * @param shapeId (integer) the shape identifier
  28025. * @returns a new solid particle array
  28026. */
  28027. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28028. /**
  28029. * Populates the passed array "ref" with the particles having the passed shapeId.
  28030. * @param shapeId the shape identifier
  28031. * @returns the SPS
  28032. * @param ref
  28033. */
  28034. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28035. /**
  28036. * Computes the required SubMeshes according the materials assigned to the particles.
  28037. * @returns the solid particle system.
  28038. * Does nothing if called before the SPS mesh is built.
  28039. */
  28040. computeSubMeshes(): SolidParticleSystem;
  28041. /**
  28042. * Sorts the solid particles by material when MultiMaterial is enabled.
  28043. * Updates the indices32 array.
  28044. * Updates the indicesByMaterial array.
  28045. * Updates the mesh indices array.
  28046. * @returns the SPS
  28047. * @hidden
  28048. */
  28049. private _sortParticlesByMaterial;
  28050. /**
  28051. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28052. * @hidden
  28053. */
  28054. private _setMaterialIndexesById;
  28055. /**
  28056. * Returns an array with unique values of Materials from the passed array
  28057. * @param array the material array to be checked and filtered
  28058. * @hidden
  28059. */
  28060. private _filterUniqueMaterialId;
  28061. /**
  28062. * Sets a new Standard Material as _defaultMaterial if not already set.
  28063. * @hidden
  28064. */
  28065. private _setDefaultMaterial;
  28066. /**
  28067. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28068. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28069. * @returns the SPS.
  28070. */
  28071. refreshVisibleSize(): SolidParticleSystem;
  28072. /**
  28073. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28074. * @param size the size (float) of the visibility box
  28075. * note : this doesn't lock the SPS mesh bounding box.
  28076. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28077. */
  28078. setVisibilityBox(size: number): void;
  28079. /**
  28080. * Gets whether the SPS as always visible or not
  28081. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28082. */
  28083. get isAlwaysVisible(): boolean;
  28084. /**
  28085. * Sets the SPS as always visible or not
  28086. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28087. */
  28088. set isAlwaysVisible(val: boolean);
  28089. /**
  28090. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28091. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28092. */
  28093. set isVisibilityBoxLocked(val: boolean);
  28094. /**
  28095. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28096. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28097. */
  28098. get isVisibilityBoxLocked(): boolean;
  28099. /**
  28100. * Tells to `setParticles()` to compute the particle rotations or not.
  28101. * Default value : true. The SPS is faster when it's set to false.
  28102. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28103. */
  28104. set computeParticleRotation(val: boolean);
  28105. /**
  28106. * Tells to `setParticles()` to compute the particle colors or not.
  28107. * Default value : true. The SPS is faster when it's set to false.
  28108. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28109. */
  28110. set computeParticleColor(val: boolean);
  28111. set computeParticleTexture(val: boolean);
  28112. /**
  28113. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28114. * Default value : false. The SPS is faster when it's set to false.
  28115. * Note : the particle custom vertex positions aren't stored values.
  28116. */
  28117. set computeParticleVertex(val: boolean);
  28118. /**
  28119. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28120. */
  28121. set computeBoundingBox(val: boolean);
  28122. /**
  28123. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28124. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28125. * Default : `true`
  28126. */
  28127. set depthSortParticles(val: boolean);
  28128. /**
  28129. * Gets if `setParticles()` computes the particle rotations or not.
  28130. * Default value : true. The SPS is faster when it's set to false.
  28131. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28132. */
  28133. get computeParticleRotation(): boolean;
  28134. /**
  28135. * Gets if `setParticles()` computes the particle colors or not.
  28136. * Default value : true. The SPS is faster when it's set to false.
  28137. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28138. */
  28139. get computeParticleColor(): boolean;
  28140. /**
  28141. * Gets if `setParticles()` computes the particle textures or not.
  28142. * Default value : true. The SPS is faster when it's set to false.
  28143. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28144. */
  28145. get computeParticleTexture(): boolean;
  28146. /**
  28147. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28148. * Default value : false. The SPS is faster when it's set to false.
  28149. * Note : the particle custom vertex positions aren't stored values.
  28150. */
  28151. get computeParticleVertex(): boolean;
  28152. /**
  28153. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28154. */
  28155. get computeBoundingBox(): boolean;
  28156. /**
  28157. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28158. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28159. * Default : `true`
  28160. */
  28161. get depthSortParticles(): boolean;
  28162. /**
  28163. * Gets if the SPS is created as expandable at construction time.
  28164. * Default : `false`
  28165. */
  28166. get expandable(): boolean;
  28167. /**
  28168. * Gets if the SPS supports the Multi Materials
  28169. */
  28170. get multimaterialEnabled(): boolean;
  28171. /**
  28172. * Gets if the SPS uses the model materials for its own multimaterial.
  28173. */
  28174. get useModelMaterial(): boolean;
  28175. /**
  28176. * The SPS used material array.
  28177. */
  28178. get materials(): Material[];
  28179. /**
  28180. * Sets the SPS MultiMaterial from the passed materials.
  28181. * Note : the passed array is internally copied and not used then by reference.
  28182. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28183. */
  28184. setMultiMaterial(materials: Material[]): void;
  28185. /**
  28186. * The SPS computed multimaterial object
  28187. */
  28188. get multimaterial(): MultiMaterial;
  28189. set multimaterial(mm: MultiMaterial);
  28190. /**
  28191. * If the subMeshes must be updated on the next call to setParticles()
  28192. */
  28193. get autoUpdateSubMeshes(): boolean;
  28194. set autoUpdateSubMeshes(val: boolean);
  28195. /**
  28196. * This function does nothing. It may be overwritten to set all the particle first values.
  28197. * The SPS doesn't call this function, you may have to call it by your own.
  28198. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28199. */
  28200. initParticles(): void;
  28201. /**
  28202. * This function does nothing. It may be overwritten to recycle a particle.
  28203. * The SPS doesn't call this function, you may have to call it by your own.
  28204. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28205. * @param particle The particle to recycle
  28206. * @returns the recycled particle
  28207. */
  28208. recycleParticle(particle: SolidParticle): SolidParticle;
  28209. /**
  28210. * Updates a particle : this function should be overwritten by the user.
  28211. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28212. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28213. * @example : just set a particle position or velocity and recycle conditions
  28214. * @param particle The particle to update
  28215. * @returns the updated particle
  28216. */
  28217. updateParticle(particle: SolidParticle): SolidParticle;
  28218. /**
  28219. * Updates a vertex of a particle : it can be overwritten by the user.
  28220. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28221. * @param particle the current particle
  28222. * @param vertex the current index of the current particle
  28223. * @param pt the index of the current vertex in the particle shape
  28224. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28225. * @example : just set a vertex particle position
  28226. * @returns the updated vertex
  28227. */
  28228. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28229. /**
  28230. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28231. * This does nothing and may be overwritten by the user.
  28232. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28233. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28234. * @param update the boolean update value actually passed to setParticles()
  28235. */
  28236. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28237. /**
  28238. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28239. * This will be passed three parameters.
  28240. * This does nothing and may be overwritten by the user.
  28241. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28242. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28243. * @param update the boolean update value actually passed to setParticles()
  28244. */
  28245. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28246. }
  28247. }
  28248. declare module "babylonjs/Particles/solidParticle" {
  28249. import { Nullable } from "babylonjs/types";
  28250. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28251. import { Color4 } from "babylonjs/Maths/math.color";
  28252. import { Mesh } from "babylonjs/Meshes/mesh";
  28253. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28254. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28255. import { Plane } from "babylonjs/Maths/math.plane";
  28256. import { Material } from "babylonjs/Materials/material";
  28257. /**
  28258. * Represents one particle of a solid particle system.
  28259. */
  28260. export class SolidParticle {
  28261. /**
  28262. * particle global index
  28263. */
  28264. idx: number;
  28265. /**
  28266. * particle identifier
  28267. */
  28268. id: number;
  28269. /**
  28270. * The color of the particle
  28271. */
  28272. color: Nullable<Color4>;
  28273. /**
  28274. * The world space position of the particle.
  28275. */
  28276. position: Vector3;
  28277. /**
  28278. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28279. */
  28280. rotation: Vector3;
  28281. /**
  28282. * The world space rotation quaternion of the particle.
  28283. */
  28284. rotationQuaternion: Nullable<Quaternion>;
  28285. /**
  28286. * The scaling of the particle.
  28287. */
  28288. scaling: Vector3;
  28289. /**
  28290. * The uvs of the particle.
  28291. */
  28292. uvs: Vector4;
  28293. /**
  28294. * The current speed of the particle.
  28295. */
  28296. velocity: Vector3;
  28297. /**
  28298. * The pivot point in the particle local space.
  28299. */
  28300. pivot: Vector3;
  28301. /**
  28302. * Must the particle be translated from its pivot point in its local space ?
  28303. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28304. * Default : false
  28305. */
  28306. translateFromPivot: boolean;
  28307. /**
  28308. * Is the particle active or not ?
  28309. */
  28310. alive: boolean;
  28311. /**
  28312. * Is the particle visible or not ?
  28313. */
  28314. isVisible: boolean;
  28315. /**
  28316. * Index of this particle in the global "positions" array (Internal use)
  28317. * @hidden
  28318. */
  28319. _pos: number;
  28320. /**
  28321. * @hidden Index of this particle in the global "indices" array (Internal use)
  28322. */
  28323. _ind: number;
  28324. /**
  28325. * @hidden ModelShape of this particle (Internal use)
  28326. */
  28327. _model: ModelShape;
  28328. /**
  28329. * ModelShape id of this particle
  28330. */
  28331. shapeId: number;
  28332. /**
  28333. * Index of the particle in its shape id
  28334. */
  28335. idxInShape: number;
  28336. /**
  28337. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28338. */
  28339. _modelBoundingInfo: BoundingInfo;
  28340. /**
  28341. * @hidden Particle BoundingInfo object (Internal use)
  28342. */
  28343. _boundingInfo: BoundingInfo;
  28344. /**
  28345. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28346. */
  28347. _sps: SolidParticleSystem;
  28348. /**
  28349. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28350. */
  28351. _stillInvisible: boolean;
  28352. /**
  28353. * @hidden Last computed particle rotation matrix
  28354. */
  28355. _rotationMatrix: number[];
  28356. /**
  28357. * Parent particle Id, if any.
  28358. * Default null.
  28359. */
  28360. parentId: Nullable<number>;
  28361. /**
  28362. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28363. */
  28364. materialIndex: Nullable<number>;
  28365. /**
  28366. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28367. * The possible values are :
  28368. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28369. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28370. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28371. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28372. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28373. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28374. * */
  28375. cullingStrategy: number;
  28376. /**
  28377. * @hidden Internal global position in the SPS.
  28378. */
  28379. _globalPosition: Vector3;
  28380. /**
  28381. * Creates a Solid Particle object.
  28382. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28383. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28384. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28385. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28386. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28387. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28388. * @param shapeId (integer) is the model shape identifier in the SPS.
  28389. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28390. * @param sps defines the sps it is associated to
  28391. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28392. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28393. */
  28394. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28395. /**
  28396. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28397. * @param target the particle target
  28398. * @returns the current particle
  28399. */
  28400. copyToRef(target: SolidParticle): SolidParticle;
  28401. /**
  28402. * Legacy support, changed scale to scaling
  28403. */
  28404. get scale(): Vector3;
  28405. /**
  28406. * Legacy support, changed scale to scaling
  28407. */
  28408. set scale(scale: Vector3);
  28409. /**
  28410. * Legacy support, changed quaternion to rotationQuaternion
  28411. */
  28412. get quaternion(): Nullable<Quaternion>;
  28413. /**
  28414. * Legacy support, changed quaternion to rotationQuaternion
  28415. */
  28416. set quaternion(q: Nullable<Quaternion>);
  28417. /**
  28418. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28419. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28420. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28421. * @returns true if it intersects
  28422. */
  28423. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28424. /**
  28425. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28426. * A particle is in the frustum if its bounding box intersects the frustum
  28427. * @param frustumPlanes defines the frustum to test
  28428. * @returns true if the particle is in the frustum planes
  28429. */
  28430. isInFrustum(frustumPlanes: Plane[]): boolean;
  28431. /**
  28432. * get the rotation matrix of the particle
  28433. * @hidden
  28434. */
  28435. getRotationMatrix(m: Matrix): void;
  28436. }
  28437. /**
  28438. * Represents the shape of the model used by one particle of a solid particle system.
  28439. * SPS internal tool, don't use it manually.
  28440. */
  28441. export class ModelShape {
  28442. /**
  28443. * The shape id
  28444. * @hidden
  28445. */
  28446. shapeID: number;
  28447. /**
  28448. * flat array of model positions (internal use)
  28449. * @hidden
  28450. */
  28451. _shape: Vector3[];
  28452. /**
  28453. * flat array of model UVs (internal use)
  28454. * @hidden
  28455. */
  28456. _shapeUV: number[];
  28457. /**
  28458. * color array of the model
  28459. * @hidden
  28460. */
  28461. _shapeColors: number[];
  28462. /**
  28463. * indices array of the model
  28464. * @hidden
  28465. */
  28466. _indices: number[];
  28467. /**
  28468. * normals array of the model
  28469. * @hidden
  28470. */
  28471. _normals: number[];
  28472. /**
  28473. * length of the shape in the model indices array (internal use)
  28474. * @hidden
  28475. */
  28476. _indicesLength: number;
  28477. /**
  28478. * Custom position function (internal use)
  28479. * @hidden
  28480. */
  28481. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28482. /**
  28483. * Custom vertex function (internal use)
  28484. * @hidden
  28485. */
  28486. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28487. /**
  28488. * Model material (internal use)
  28489. * @hidden
  28490. */
  28491. _material: Nullable<Material>;
  28492. /**
  28493. * Creates a ModelShape object. This is an internal simplified reference to a mesh used as for a model to replicate particles from by the SPS.
  28494. * SPS internal tool, don't use it manually.
  28495. * @hidden
  28496. */
  28497. constructor(id: number, shape: Vector3[], indices: number[], normals: number[], colors: number[], shapeUV: number[], posFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>, vtxFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>, material: Nullable<Material>);
  28498. }
  28499. /**
  28500. * Represents a Depth Sorted Particle in the solid particle system.
  28501. * @hidden
  28502. */
  28503. export class DepthSortedParticle {
  28504. /**
  28505. * Index of the particle in the "indices" array
  28506. */
  28507. ind: number;
  28508. /**
  28509. * Length of the particle shape in the "indices" array
  28510. */
  28511. indicesLength: number;
  28512. /**
  28513. * Squared distance from the particle to the camera
  28514. */
  28515. sqDistance: number;
  28516. /**
  28517. * Material index when used with MultiMaterials
  28518. */
  28519. materialIndex: number;
  28520. /**
  28521. * Creates a new sorted particle
  28522. * @param materialIndex
  28523. */
  28524. constructor(ind: number, indLength: number, materialIndex: number);
  28525. }
  28526. }
  28527. declare module "babylonjs/Collisions/meshCollisionData" {
  28528. import { Collider } from "babylonjs/Collisions/collider";
  28529. import { Vector3 } from "babylonjs/Maths/math.vector";
  28530. import { Nullable } from "babylonjs/types";
  28531. import { Observer } from "babylonjs/Misc/observable";
  28532. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28533. /**
  28534. * @hidden
  28535. */
  28536. export class _MeshCollisionData {
  28537. _checkCollisions: boolean;
  28538. _collisionMask: number;
  28539. _collisionGroup: number;
  28540. _collider: Nullable<Collider>;
  28541. _oldPositionForCollisions: Vector3;
  28542. _diffPositionForCollisions: Vector3;
  28543. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28544. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28545. }
  28546. }
  28547. declare module "babylonjs/Meshes/abstractMesh" {
  28548. import { Observable } from "babylonjs/Misc/observable";
  28549. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28550. import { Camera } from "babylonjs/Cameras/camera";
  28551. import { Scene, IDisposable } from "babylonjs/scene";
  28552. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28553. import { Node } from "babylonjs/node";
  28554. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28555. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28556. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28557. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28558. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28559. import { Material } from "babylonjs/Materials/material";
  28560. import { Light } from "babylonjs/Lights/light";
  28561. import { Skeleton } from "babylonjs/Bones/skeleton";
  28562. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28563. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28564. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28565. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28566. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28567. import { Plane } from "babylonjs/Maths/math.plane";
  28568. import { Ray } from "babylonjs/Culling/ray";
  28569. import { Collider } from "babylonjs/Collisions/collider";
  28570. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28571. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28572. /** @hidden */
  28573. class _FacetDataStorage {
  28574. facetPositions: Vector3[];
  28575. facetNormals: Vector3[];
  28576. facetPartitioning: number[][];
  28577. facetNb: number;
  28578. partitioningSubdivisions: number;
  28579. partitioningBBoxRatio: number;
  28580. facetDataEnabled: boolean;
  28581. facetParameters: any;
  28582. bbSize: Vector3;
  28583. subDiv: {
  28584. max: number;
  28585. X: number;
  28586. Y: number;
  28587. Z: number;
  28588. };
  28589. facetDepthSort: boolean;
  28590. facetDepthSortEnabled: boolean;
  28591. depthSortedIndices: IndicesArray;
  28592. depthSortedFacets: {
  28593. ind: number;
  28594. sqDistance: number;
  28595. }[];
  28596. facetDepthSortFunction: (f1: {
  28597. ind: number;
  28598. sqDistance: number;
  28599. }, f2: {
  28600. ind: number;
  28601. sqDistance: number;
  28602. }) => number;
  28603. facetDepthSortFrom: Vector3;
  28604. facetDepthSortOrigin: Vector3;
  28605. invertedMatrix: Matrix;
  28606. }
  28607. /**
  28608. * @hidden
  28609. **/
  28610. class _InternalAbstractMeshDataInfo {
  28611. _hasVertexAlpha: boolean;
  28612. _useVertexColors: boolean;
  28613. _numBoneInfluencers: number;
  28614. _applyFog: boolean;
  28615. _receiveShadows: boolean;
  28616. _facetData: _FacetDataStorage;
  28617. _visibility: number;
  28618. _skeleton: Nullable<Skeleton>;
  28619. _layerMask: number;
  28620. _computeBonesUsingShaders: boolean;
  28621. _isActive: boolean;
  28622. _onlyForInstances: boolean;
  28623. _isActiveIntermediate: boolean;
  28624. _onlyForInstancesIntermediate: boolean;
  28625. _actAsRegularMesh: boolean;
  28626. }
  28627. /**
  28628. * Class used to store all common mesh properties
  28629. */
  28630. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28631. /** No occlusion */
  28632. static OCCLUSION_TYPE_NONE: number;
  28633. /** Occlusion set to optimisitic */
  28634. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28635. /** Occlusion set to strict */
  28636. static OCCLUSION_TYPE_STRICT: number;
  28637. /** Use an accurante occlusion algorithm */
  28638. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28639. /** Use a conservative occlusion algorithm */
  28640. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  28641. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  28642. * Test order :
  28643. * Is the bounding sphere outside the frustum ?
  28644. * If not, are the bounding box vertices outside the frustum ?
  28645. * It not, then the cullable object is in the frustum.
  28646. */
  28647. static readonly CULLINGSTRATEGY_STANDARD: number;
  28648. /** Culling strategy : Bounding Sphere Only.
  28649. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  28650. * It's also less accurate than the standard because some not visible objects can still be selected.
  28651. * Test : is the bounding sphere outside the frustum ?
  28652. * If not, then the cullable object is in the frustum.
  28653. */
  28654. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  28655. /** Culling strategy : Optimistic Inclusion.
  28656. * This in an inclusion test first, then the standard exclusion test.
  28657. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  28658. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  28659. * Anyway, it's as accurate as the standard strategy.
  28660. * Test :
  28661. * Is the cullable object bounding sphere center in the frustum ?
  28662. * If not, apply the default culling strategy.
  28663. */
  28664. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  28665. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  28666. * This in an inclusion test first, then the bounding sphere only exclusion test.
  28667. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  28668. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  28669. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  28670. * Test :
  28671. * Is the cullable object bounding sphere center in the frustum ?
  28672. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  28673. */
  28674. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  28675. /**
  28676. * No billboard
  28677. */
  28678. static get BILLBOARDMODE_NONE(): number;
  28679. /** Billboard on X axis */
  28680. static get BILLBOARDMODE_X(): number;
  28681. /** Billboard on Y axis */
  28682. static get BILLBOARDMODE_Y(): number;
  28683. /** Billboard on Z axis */
  28684. static get BILLBOARDMODE_Z(): number;
  28685. /** Billboard on all axes */
  28686. static get BILLBOARDMODE_ALL(): number;
  28687. /** Billboard on using position instead of orientation */
  28688. static get BILLBOARDMODE_USE_POSITION(): number;
  28689. /** @hidden */
  28690. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  28691. /**
  28692. * The culling strategy to use to check whether the mesh must be rendered or not.
  28693. * This value can be changed at any time and will be used on the next render mesh selection.
  28694. * The possible values are :
  28695. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28696. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28697. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28698. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28699. * Please read each static variable documentation to get details about the culling process.
  28700. * */
  28701. cullingStrategy: number;
  28702. /**
  28703. * Gets the number of facets in the mesh
  28704. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28705. */
  28706. get facetNb(): number;
  28707. /**
  28708. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  28709. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28710. */
  28711. get partitioningSubdivisions(): number;
  28712. set partitioningSubdivisions(nb: number);
  28713. /**
  28714. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  28715. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  28716. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  28717. */
  28718. get partitioningBBoxRatio(): number;
  28719. set partitioningBBoxRatio(ratio: number);
  28720. /**
  28721. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  28722. * Works only for updatable meshes.
  28723. * Doesn't work with multi-materials
  28724. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28725. */
  28726. get mustDepthSortFacets(): boolean;
  28727. set mustDepthSortFacets(sort: boolean);
  28728. /**
  28729. * The location (Vector3) where the facet depth sort must be computed from.
  28730. * By default, the active camera position.
  28731. * Used only when facet depth sort is enabled
  28732. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  28733. */
  28734. get facetDepthSortFrom(): Vector3;
  28735. set facetDepthSortFrom(location: Vector3);
  28736. /**
  28737. * gets a boolean indicating if facetData is enabled
  28738. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  28739. */
  28740. get isFacetDataEnabled(): boolean;
  28741. /** @hidden */
  28742. _updateNonUniformScalingState(value: boolean): boolean;
  28743. /**
  28744. * An event triggered when this mesh collides with another one
  28745. */
  28746. onCollideObservable: Observable<AbstractMesh>;
  28747. /** Set a function to call when this mesh collides with another one */
  28748. set onCollide(callback: () => void);
  28749. /**
  28750. * An event triggered when the collision's position changes
  28751. */
  28752. onCollisionPositionChangeObservable: Observable<Vector3>;
  28753. /** Set a function to call when the collision's position changes */
  28754. set onCollisionPositionChange(callback: () => void);
  28755. /**
  28756. * An event triggered when material is changed
  28757. */
  28758. onMaterialChangedObservable: Observable<AbstractMesh>;
  28759. /**
  28760. * Gets or sets the orientation for POV movement & rotation
  28761. */
  28762. definedFacingForward: boolean;
  28763. /** @hidden */
  28764. _occlusionQuery: Nullable<WebGLQuery>;
  28765. /** @hidden */
  28766. _renderingGroup: Nullable<RenderingGroup>;
  28767. /**
  28768. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28769. */
  28770. get visibility(): number;
  28771. /**
  28772. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  28773. */
  28774. set visibility(value: number);
  28775. /** Gets or sets the alpha index used to sort transparent meshes
  28776. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  28777. */
  28778. alphaIndex: number;
  28779. /**
  28780. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  28781. */
  28782. isVisible: boolean;
  28783. /**
  28784. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  28785. */
  28786. isPickable: boolean;
  28787. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  28788. showSubMeshesBoundingBox: boolean;
  28789. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  28790. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  28791. */
  28792. isBlocker: boolean;
  28793. /**
  28794. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  28795. */
  28796. enablePointerMoveEvents: boolean;
  28797. /**
  28798. * Specifies the rendering group id for this mesh (0 by default)
  28799. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  28800. */
  28801. renderingGroupId: number;
  28802. private _material;
  28803. /** Gets or sets current material */
  28804. get material(): Nullable<Material>;
  28805. set material(value: Nullable<Material>);
  28806. /**
  28807. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  28808. * @see http://doc.babylonjs.com/babylon101/shadows
  28809. */
  28810. get receiveShadows(): boolean;
  28811. set receiveShadows(value: boolean);
  28812. /** Defines color to use when rendering outline */
  28813. outlineColor: Color3;
  28814. /** Define width to use when rendering outline */
  28815. outlineWidth: number;
  28816. /** Defines color to use when rendering overlay */
  28817. overlayColor: Color3;
  28818. /** Defines alpha to use when rendering overlay */
  28819. overlayAlpha: number;
  28820. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  28821. get hasVertexAlpha(): boolean;
  28822. set hasVertexAlpha(value: boolean);
  28823. /** Gets or sets a boolean indicating that this mesh needs to use vertex color data to render (if this kind of vertex data is available in the geometry) */
  28824. get useVertexColors(): boolean;
  28825. set useVertexColors(value: boolean);
  28826. /**
  28827. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  28828. */
  28829. get computeBonesUsingShaders(): boolean;
  28830. set computeBonesUsingShaders(value: boolean);
  28831. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  28832. get numBoneInfluencers(): number;
  28833. set numBoneInfluencers(value: number);
  28834. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  28835. get applyFog(): boolean;
  28836. set applyFog(value: boolean);
  28837. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  28838. useOctreeForRenderingSelection: boolean;
  28839. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  28840. useOctreeForPicking: boolean;
  28841. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  28842. useOctreeForCollisions: boolean;
  28843. /**
  28844. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  28845. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  28846. */
  28847. get layerMask(): number;
  28848. set layerMask(value: number);
  28849. /**
  28850. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  28851. */
  28852. alwaysSelectAsActiveMesh: boolean;
  28853. /**
  28854. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  28855. */
  28856. doNotSyncBoundingInfo: boolean;
  28857. /**
  28858. * Gets or sets the current action manager
  28859. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  28860. */
  28861. actionManager: Nullable<AbstractActionManager>;
  28862. private _meshCollisionData;
  28863. /**
  28864. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  28865. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28866. */
  28867. ellipsoid: Vector3;
  28868. /**
  28869. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  28870. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  28871. */
  28872. ellipsoidOffset: Vector3;
  28873. /**
  28874. * Gets or sets a collision mask used to mask collisions (default is -1).
  28875. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28876. */
  28877. get collisionMask(): number;
  28878. set collisionMask(mask: number);
  28879. /**
  28880. * Gets or sets the current collision group mask (-1 by default).
  28881. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  28882. */
  28883. get collisionGroup(): number;
  28884. set collisionGroup(mask: number);
  28885. /**
  28886. * Defines edge width used when edgesRenderer is enabled
  28887. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28888. */
  28889. edgesWidth: number;
  28890. /**
  28891. * Defines edge color used when edgesRenderer is enabled
  28892. * @see https://www.babylonjs-playground.com/#10OJSG#13
  28893. */
  28894. edgesColor: Color4;
  28895. /** @hidden */
  28896. _edgesRenderer: Nullable<IEdgesRenderer>;
  28897. /** @hidden */
  28898. _masterMesh: Nullable<AbstractMesh>;
  28899. /** @hidden */
  28900. _boundingInfo: Nullable<BoundingInfo>;
  28901. /** @hidden */
  28902. _renderId: number;
  28903. /**
  28904. * Gets or sets the list of subMeshes
  28905. * @see http://doc.babylonjs.com/how_to/multi_materials
  28906. */
  28907. subMeshes: SubMesh[];
  28908. /** @hidden */
  28909. _intersectionsInProgress: AbstractMesh[];
  28910. /** @hidden */
  28911. _unIndexed: boolean;
  28912. /** @hidden */
  28913. _lightSources: Light[];
  28914. /** Gets the list of lights affecting that mesh */
  28915. get lightSources(): Light[];
  28916. /** @hidden */
  28917. get _positions(): Nullable<Vector3[]>;
  28918. /** @hidden */
  28919. _waitingData: {
  28920. lods: Nullable<any>;
  28921. actions: Nullable<any>;
  28922. freezeWorldMatrix: Nullable<boolean>;
  28923. };
  28924. /** @hidden */
  28925. _bonesTransformMatrices: Nullable<Float32Array>;
  28926. /** @hidden */
  28927. _transformMatrixTexture: Nullable<RawTexture>;
  28928. /**
  28929. * Gets or sets a skeleton to apply skining transformations
  28930. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  28931. */
  28932. set skeleton(value: Nullable<Skeleton>);
  28933. get skeleton(): Nullable<Skeleton>;
  28934. /**
  28935. * An event triggered when the mesh is rebuilt.
  28936. */
  28937. onRebuildObservable: Observable<AbstractMesh>;
  28938. /**
  28939. * Creates a new AbstractMesh
  28940. * @param name defines the name of the mesh
  28941. * @param scene defines the hosting scene
  28942. */
  28943. constructor(name: string, scene?: Nullable<Scene>);
  28944. /**
  28945. * Returns the string "AbstractMesh"
  28946. * @returns "AbstractMesh"
  28947. */
  28948. getClassName(): string;
  28949. /**
  28950. * Gets a string representation of the current mesh
  28951. * @param fullDetails defines a boolean indicating if full details must be included
  28952. * @returns a string representation of the current mesh
  28953. */
  28954. toString(fullDetails?: boolean): string;
  28955. /**
  28956. * @hidden
  28957. */
  28958. protected _getEffectiveParent(): Nullable<Node>;
  28959. /** @hidden */
  28960. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  28961. /** @hidden */
  28962. _rebuild(): void;
  28963. /** @hidden */
  28964. _resyncLightSources(): void;
  28965. /** @hidden */
  28966. _resyncLightSource(light: Light): void;
  28967. /** @hidden */
  28968. _unBindEffect(): void;
  28969. /** @hidden */
  28970. _removeLightSource(light: Light, dispose: boolean): void;
  28971. private _markSubMeshesAsDirty;
  28972. /** @hidden */
  28973. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  28974. /** @hidden */
  28975. _markSubMeshesAsAttributesDirty(): void;
  28976. /** @hidden */
  28977. _markSubMeshesAsMiscDirty(): void;
  28978. /**
  28979. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  28980. */
  28981. get scaling(): Vector3;
  28982. set scaling(newScaling: Vector3);
  28983. /**
  28984. * Returns true if the mesh is blocked. Implemented by child classes
  28985. */
  28986. get isBlocked(): boolean;
  28987. /**
  28988. * Returns the mesh itself by default. Implemented by child classes
  28989. * @param camera defines the camera to use to pick the right LOD level
  28990. * @returns the currentAbstractMesh
  28991. */
  28992. getLOD(camera: Camera): Nullable<AbstractMesh>;
  28993. /**
  28994. * Returns 0 by default. Implemented by child classes
  28995. * @returns an integer
  28996. */
  28997. getTotalVertices(): number;
  28998. /**
  28999. * Returns a positive integer : the total number of indices in this mesh geometry.
  29000. * @returns the numner of indices or zero if the mesh has no geometry.
  29001. */
  29002. getTotalIndices(): number;
  29003. /**
  29004. * Returns null by default. Implemented by child classes
  29005. * @returns null
  29006. */
  29007. getIndices(): Nullable<IndicesArray>;
  29008. /**
  29009. * Returns the array of the requested vertex data kind. Implemented by child classes
  29010. * @param kind defines the vertex data kind to use
  29011. * @returns null
  29012. */
  29013. getVerticesData(kind: string): Nullable<FloatArray>;
  29014. /**
  29015. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29016. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29017. * Note that a new underlying VertexBuffer object is created each call.
  29018. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29019. * @param kind defines vertex data kind:
  29020. * * VertexBuffer.PositionKind
  29021. * * VertexBuffer.UVKind
  29022. * * VertexBuffer.UV2Kind
  29023. * * VertexBuffer.UV3Kind
  29024. * * VertexBuffer.UV4Kind
  29025. * * VertexBuffer.UV5Kind
  29026. * * VertexBuffer.UV6Kind
  29027. * * VertexBuffer.ColorKind
  29028. * * VertexBuffer.MatricesIndicesKind
  29029. * * VertexBuffer.MatricesIndicesExtraKind
  29030. * * VertexBuffer.MatricesWeightsKind
  29031. * * VertexBuffer.MatricesWeightsExtraKind
  29032. * @param data defines the data source
  29033. * @param updatable defines if the data must be flagged as updatable (or static)
  29034. * @param stride defines the vertex stride (size of an entire vertex). Can be null and in this case will be deduced from vertex data kind
  29035. * @returns the current mesh
  29036. */
  29037. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29038. /**
  29039. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29040. * If the mesh has no geometry, it is simply returned as it is.
  29041. * @param kind defines vertex data kind:
  29042. * * VertexBuffer.PositionKind
  29043. * * VertexBuffer.UVKind
  29044. * * VertexBuffer.UV2Kind
  29045. * * VertexBuffer.UV3Kind
  29046. * * VertexBuffer.UV4Kind
  29047. * * VertexBuffer.UV5Kind
  29048. * * VertexBuffer.UV6Kind
  29049. * * VertexBuffer.ColorKind
  29050. * * VertexBuffer.MatricesIndicesKind
  29051. * * VertexBuffer.MatricesIndicesExtraKind
  29052. * * VertexBuffer.MatricesWeightsKind
  29053. * * VertexBuffer.MatricesWeightsExtraKind
  29054. * @param data defines the data source
  29055. * @param updateExtends If `kind` is `PositionKind` and if `updateExtends` is true, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed
  29056. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29057. * @returns the current mesh
  29058. */
  29059. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29060. /**
  29061. * Sets the mesh indices,
  29062. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29063. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29064. * @param totalVertices Defines the total number of vertices
  29065. * @returns the current mesh
  29066. */
  29067. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29068. /**
  29069. * Gets a boolean indicating if specific vertex data is present
  29070. * @param kind defines the vertex data kind to use
  29071. * @returns true is data kind is present
  29072. */
  29073. isVerticesDataPresent(kind: string): boolean;
  29074. /**
  29075. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29076. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29077. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29078. * @returns a BoundingInfo
  29079. */
  29080. getBoundingInfo(): BoundingInfo;
  29081. /**
  29082. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29083. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29084. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29085. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29086. * @returns the current mesh
  29087. */
  29088. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29089. /**
  29090. * Overwrite the current bounding info
  29091. * @param boundingInfo defines the new bounding info
  29092. * @returns the current mesh
  29093. */
  29094. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29095. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29096. get useBones(): boolean;
  29097. /** @hidden */
  29098. _preActivate(): void;
  29099. /** @hidden */
  29100. _preActivateForIntermediateRendering(renderId: number): void;
  29101. /** @hidden */
  29102. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29103. /** @hidden */
  29104. _postActivate(): void;
  29105. /** @hidden */
  29106. _freeze(): void;
  29107. /** @hidden */
  29108. _unFreeze(): void;
  29109. /**
  29110. * Gets the current world matrix
  29111. * @returns a Matrix
  29112. */
  29113. getWorldMatrix(): Matrix;
  29114. /** @hidden */
  29115. _getWorldMatrixDeterminant(): number;
  29116. /**
  29117. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29118. */
  29119. get isAnInstance(): boolean;
  29120. /**
  29121. * Gets a boolean indicating if this mesh has instances
  29122. */
  29123. get hasInstances(): boolean;
  29124. /**
  29125. * Perform relative position change from the point of view of behind the front of the mesh.
  29126. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29127. * Supports definition of mesh facing forward or backward
  29128. * @param amountRight defines the distance on the right axis
  29129. * @param amountUp defines the distance on the up axis
  29130. * @param amountForward defines the distance on the forward axis
  29131. * @returns the current mesh
  29132. */
  29133. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29134. /**
  29135. * Calculate relative position change from the point of view of behind the front of the mesh.
  29136. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29137. * Supports definition of mesh facing forward or backward
  29138. * @param amountRight defines the distance on the right axis
  29139. * @param amountUp defines the distance on the up axis
  29140. * @param amountForward defines the distance on the forward axis
  29141. * @returns the new displacement vector
  29142. */
  29143. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29144. /**
  29145. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29146. * Supports definition of mesh facing forward or backward
  29147. * @param flipBack defines the flip
  29148. * @param twirlClockwise defines the twirl
  29149. * @param tiltRight defines the tilt
  29150. * @returns the current mesh
  29151. */
  29152. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29153. /**
  29154. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29155. * Supports definition of mesh facing forward or backward.
  29156. * @param flipBack defines the flip
  29157. * @param twirlClockwise defines the twirl
  29158. * @param tiltRight defines the tilt
  29159. * @returns the new rotation vector
  29160. */
  29161. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29162. /**
  29163. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29164. * This means the mesh underlying bounding box and sphere are recomputed.
  29165. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29166. * @returns the current mesh
  29167. */
  29168. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29169. /** @hidden */
  29170. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29171. /** @hidden */
  29172. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29173. /** @hidden */
  29174. _updateBoundingInfo(): AbstractMesh;
  29175. /** @hidden */
  29176. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29177. /** @hidden */
  29178. protected _afterComputeWorldMatrix(): void;
  29179. /** @hidden */
  29180. get _effectiveMesh(): AbstractMesh;
  29181. /**
  29182. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29183. * A mesh is in the frustum if its bounding box intersects the frustum
  29184. * @param frustumPlanes defines the frustum to test
  29185. * @returns true if the mesh is in the frustum planes
  29186. */
  29187. isInFrustum(frustumPlanes: Plane[]): boolean;
  29188. /**
  29189. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29190. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29191. * @param frustumPlanes defines the frustum to test
  29192. * @returns true if the mesh is completely in the frustum planes
  29193. */
  29194. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29195. /**
  29196. * True if the mesh intersects another mesh or a SolidParticle object
  29197. * @param mesh defines a target mesh or SolidParticle to test
  29198. * @param precise Unless the parameter `precise` is set to `true` the intersection is computed according to Axis Aligned Bounding Boxes (AABB), else according to OBB (Oriented BBoxes)
  29199. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29200. * @returns true if there is an intersection
  29201. */
  29202. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29203. /**
  29204. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29205. * @param point defines the point to test
  29206. * @returns true if there is an intersection
  29207. */
  29208. intersectsPoint(point: Vector3): boolean;
  29209. /**
  29210. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29211. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29212. */
  29213. get checkCollisions(): boolean;
  29214. set checkCollisions(collisionEnabled: boolean);
  29215. /**
  29216. * Gets Collider object used to compute collisions (not physics)
  29217. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29218. */
  29219. get collider(): Nullable<Collider>;
  29220. /**
  29221. * Move the mesh using collision engine
  29222. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29223. * @param displacement defines the requested displacement vector
  29224. * @returns the current mesh
  29225. */
  29226. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29227. private _onCollisionPositionChange;
  29228. /** @hidden */
  29229. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29230. /** @hidden */
  29231. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29232. /** @hidden */
  29233. _checkCollision(collider: Collider): AbstractMesh;
  29234. /** @hidden */
  29235. _generatePointsArray(): boolean;
  29236. /**
  29237. * Checks if the passed Ray intersects with the mesh
  29238. * @param ray defines the ray to use
  29239. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29240. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29241. * @returns the picking info
  29242. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29243. */
  29244. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29245. /**
  29246. * Clones the current mesh
  29247. * @param name defines the mesh name
  29248. * @param newParent defines the new mesh parent
  29249. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29250. * @returns the new mesh
  29251. */
  29252. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29253. /**
  29254. * Disposes all the submeshes of the current meshnp
  29255. * @returns the current mesh
  29256. */
  29257. releaseSubMeshes(): AbstractMesh;
  29258. /**
  29259. * Releases resources associated with this abstract mesh.
  29260. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29261. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29262. */
  29263. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29264. /**
  29265. * Adds the passed mesh as a child to the current mesh
  29266. * @param mesh defines the child mesh
  29267. * @returns the current mesh
  29268. */
  29269. addChild(mesh: AbstractMesh): AbstractMesh;
  29270. /**
  29271. * Removes the passed mesh from the current mesh children list
  29272. * @param mesh defines the child mesh
  29273. * @returns the current mesh
  29274. */
  29275. removeChild(mesh: AbstractMesh): AbstractMesh;
  29276. /** @hidden */
  29277. private _initFacetData;
  29278. /**
  29279. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29280. * This method can be called within the render loop.
  29281. * You don't need to call this method by yourself in the render loop when you update/morph a mesh with the methods CreateXXX() as they automatically manage this computation
  29282. * @returns the current mesh
  29283. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29284. */
  29285. updateFacetData(): AbstractMesh;
  29286. /**
  29287. * Returns the facetLocalNormals array.
  29288. * The normals are expressed in the mesh local spac
  29289. * @returns an array of Vector3
  29290. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29291. */
  29292. getFacetLocalNormals(): Vector3[];
  29293. /**
  29294. * Returns the facetLocalPositions array.
  29295. * The facet positions are expressed in the mesh local space
  29296. * @returns an array of Vector3
  29297. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29298. */
  29299. getFacetLocalPositions(): Vector3[];
  29300. /**
  29301. * Returns the facetLocalPartioning array
  29302. * @returns an array of array of numbers
  29303. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29304. */
  29305. getFacetLocalPartitioning(): number[][];
  29306. /**
  29307. * Returns the i-th facet position in the world system.
  29308. * This method allocates a new Vector3 per call
  29309. * @param i defines the facet index
  29310. * @returns a new Vector3
  29311. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29312. */
  29313. getFacetPosition(i: number): Vector3;
  29314. /**
  29315. * Sets the reference Vector3 with the i-th facet position in the world system
  29316. * @param i defines the facet index
  29317. * @param ref defines the target vector
  29318. * @returns the current mesh
  29319. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29320. */
  29321. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29322. /**
  29323. * Returns the i-th facet normal in the world system.
  29324. * This method allocates a new Vector3 per call
  29325. * @param i defines the facet index
  29326. * @returns a new Vector3
  29327. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29328. */
  29329. getFacetNormal(i: number): Vector3;
  29330. /**
  29331. * Sets the reference Vector3 with the i-th facet normal in the world system
  29332. * @param i defines the facet index
  29333. * @param ref defines the target vector
  29334. * @returns the current mesh
  29335. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29336. */
  29337. getFacetNormalToRef(i: number, ref: Vector3): this;
  29338. /**
  29339. * Returns the facets (in an array) in the same partitioning block than the one the passed coordinates are located (expressed in the mesh local system)
  29340. * @param x defines x coordinate
  29341. * @param y defines y coordinate
  29342. * @param z defines z coordinate
  29343. * @returns the array of facet indexes
  29344. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29345. */
  29346. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29347. /**
  29348. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29349. * @param projected sets as the (x,y,z) world projection on the facet
  29350. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  29351. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  29352. * @param x defines x coordinate
  29353. * @param y defines y coordinate
  29354. * @param z defines z coordinate
  29355. * @returns the face index if found (or null instead)
  29356. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29357. */
  29358. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29359. /**
  29360. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29361. * @param projected sets as the (x,y,z) local projection on the facet
  29362. * @param checkFace if true (default false), only the facet "facing" to (x,y,z) or only the ones "turning their backs", according to the parameter "facing" are returned
  29363. * @param facing if facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position. If facing si false and checkFace is true, only the facet "turning their backs" to (x, y, z) are returned : negative dot (x, y, z) * facet position
  29364. * @param x defines x coordinate
  29365. * @param y defines y coordinate
  29366. * @param z defines z coordinate
  29367. * @returns the face index if found (or null instead)
  29368. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29369. */
  29370. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29371. /**
  29372. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29373. * @returns the parameters
  29374. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29375. */
  29376. getFacetDataParameters(): any;
  29377. /**
  29378. * Disables the feature FacetData and frees the related memory
  29379. * @returns the current mesh
  29380. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29381. */
  29382. disableFacetData(): AbstractMesh;
  29383. /**
  29384. * Updates the AbstractMesh indices array
  29385. * @param indices defines the data source
  29386. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29387. * @param gpuMemoryOnly defines a boolean indicating that only the GPU memory must be updated leaving the CPU version of the indices unchanged (false by default)
  29388. * @returns the current mesh
  29389. */
  29390. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29391. /**
  29392. * Creates new normals data for the mesh
  29393. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29394. * @returns the current mesh
  29395. */
  29396. createNormals(updatable: boolean): AbstractMesh;
  29397. /**
  29398. * Align the mesh with a normal
  29399. * @param normal defines the normal to use
  29400. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29401. * @returns the current mesh
  29402. */
  29403. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29404. /** @hidden */
  29405. _checkOcclusionQuery(): boolean;
  29406. /**
  29407. * Disables the mesh edge rendering mode
  29408. * @returns the currentAbstractMesh
  29409. */
  29410. disableEdgesRendering(): AbstractMesh;
  29411. /**
  29412. * Enables the edge rendering mode on the mesh.
  29413. * This mode makes the mesh edges visible
  29414. * @param epsilon defines the maximal distance between two angles to detect a face
  29415. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29416. * @returns the currentAbstractMesh
  29417. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29418. */
  29419. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29420. }
  29421. }
  29422. declare module "babylonjs/Actions/actionEvent" {
  29423. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29424. import { Nullable } from "babylonjs/types";
  29425. import { Sprite } from "babylonjs/Sprites/sprite";
  29426. import { Scene } from "babylonjs/scene";
  29427. import { Vector2 } from "babylonjs/Maths/math.vector";
  29428. /**
  29429. * Interface used to define ActionEvent
  29430. */
  29431. export interface IActionEvent {
  29432. /** The mesh or sprite that triggered the action */
  29433. source: any;
  29434. /** The X mouse cursor position at the time of the event */
  29435. pointerX: number;
  29436. /** The Y mouse cursor position at the time of the event */
  29437. pointerY: number;
  29438. /** The mesh that is currently pointed at (can be null) */
  29439. meshUnderPointer: Nullable<AbstractMesh>;
  29440. /** the original (browser) event that triggered the ActionEvent */
  29441. sourceEvent?: any;
  29442. /** additional data for the event */
  29443. additionalData?: any;
  29444. }
  29445. /**
  29446. * ActionEvent is the event being sent when an action is triggered.
  29447. */
  29448. export class ActionEvent implements IActionEvent {
  29449. /** The mesh or sprite that triggered the action */
  29450. source: any;
  29451. /** The X mouse cursor position at the time of the event */
  29452. pointerX: number;
  29453. /** The Y mouse cursor position at the time of the event */
  29454. pointerY: number;
  29455. /** The mesh that is currently pointed at (can be null) */
  29456. meshUnderPointer: Nullable<AbstractMesh>;
  29457. /** the original (browser) event that triggered the ActionEvent */
  29458. sourceEvent?: any;
  29459. /** additional data for the event */
  29460. additionalData?: any;
  29461. /**
  29462. * Creates a new ActionEvent
  29463. * @param source The mesh or sprite that triggered the action
  29464. * @param pointerX The X mouse cursor position at the time of the event
  29465. * @param pointerY The Y mouse cursor position at the time of the event
  29466. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29467. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29468. * @param additionalData additional data for the event
  29469. */
  29470. constructor(
  29471. /** The mesh or sprite that triggered the action */
  29472. source: any,
  29473. /** The X mouse cursor position at the time of the event */
  29474. pointerX: number,
  29475. /** The Y mouse cursor position at the time of the event */
  29476. pointerY: number,
  29477. /** The mesh that is currently pointed at (can be null) */
  29478. meshUnderPointer: Nullable<AbstractMesh>,
  29479. /** the original (browser) event that triggered the ActionEvent */
  29480. sourceEvent?: any,
  29481. /** additional data for the event */
  29482. additionalData?: any);
  29483. /**
  29484. * Helper function to auto-create an ActionEvent from a source mesh.
  29485. * @param source The source mesh that triggered the event
  29486. * @param evt The original (browser) event
  29487. * @param additionalData additional data for the event
  29488. * @returns the new ActionEvent
  29489. */
  29490. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29491. /**
  29492. * Helper function to auto-create an ActionEvent from a source sprite
  29493. * @param source The source sprite that triggered the event
  29494. * @param scene Scene associated with the sprite
  29495. * @param evt The original (browser) event
  29496. * @param additionalData additional data for the event
  29497. * @returns the new ActionEvent
  29498. */
  29499. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29500. /**
  29501. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29502. * @param scene the scene where the event occurred
  29503. * @param evt The original (browser) event
  29504. * @returns the new ActionEvent
  29505. */
  29506. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29507. /**
  29508. * Helper function to auto-create an ActionEvent from a primitive
  29509. * @param prim defines the target primitive
  29510. * @param pointerPos defines the pointer position
  29511. * @param evt The original (browser) event
  29512. * @param additionalData additional data for the event
  29513. * @returns the new ActionEvent
  29514. */
  29515. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29516. }
  29517. }
  29518. declare module "babylonjs/Actions/abstractActionManager" {
  29519. import { IDisposable } from "babylonjs/scene";
  29520. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29521. import { IAction } from "babylonjs/Actions/action";
  29522. import { Nullable } from "babylonjs/types";
  29523. /**
  29524. * Abstract class used to decouple action Manager from scene and meshes.
  29525. * Do not instantiate.
  29526. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29527. */
  29528. export abstract class AbstractActionManager implements IDisposable {
  29529. /** Gets the list of active triggers */
  29530. static Triggers: {
  29531. [key: string]: number;
  29532. };
  29533. /** Gets the cursor to use when hovering items */
  29534. hoverCursor: string;
  29535. /** Gets the list of actions */
  29536. actions: IAction[];
  29537. /**
  29538. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29539. */
  29540. isRecursive: boolean;
  29541. /**
  29542. * Releases all associated resources
  29543. */
  29544. abstract dispose(): void;
  29545. /**
  29546. * Does this action manager has pointer triggers
  29547. */
  29548. abstract get hasPointerTriggers(): boolean;
  29549. /**
  29550. * Does this action manager has pick triggers
  29551. */
  29552. abstract get hasPickTriggers(): boolean;
  29553. /**
  29554. * Process a specific trigger
  29555. * @param trigger defines the trigger to process
  29556. * @param evt defines the event details to be processed
  29557. */
  29558. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29559. /**
  29560. * Does this action manager handles actions of any of the given triggers
  29561. * @param triggers defines the triggers to be tested
  29562. * @return a boolean indicating whether one (or more) of the triggers is handled
  29563. */
  29564. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29565. /**
  29566. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29567. * speed.
  29568. * @param triggerA defines the trigger to be tested
  29569. * @param triggerB defines the trigger to be tested
  29570. * @return a boolean indicating whether one (or more) of the triggers is handled
  29571. */
  29572. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29573. /**
  29574. * Does this action manager handles actions of a given trigger
  29575. * @param trigger defines the trigger to be tested
  29576. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29577. * @return whether the trigger is handled
  29578. */
  29579. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29580. /**
  29581. * Serialize this manager to a JSON object
  29582. * @param name defines the property name to store this manager
  29583. * @returns a JSON representation of this manager
  29584. */
  29585. abstract serialize(name: string): any;
  29586. /**
  29587. * Registers an action to this action manager
  29588. * @param action defines the action to be registered
  29589. * @return the action amended (prepared) after registration
  29590. */
  29591. abstract registerAction(action: IAction): Nullable<IAction>;
  29592. /**
  29593. * Unregisters an action to this action manager
  29594. * @param action defines the action to be unregistered
  29595. * @return a boolean indicating whether the action has been unregistered
  29596. */
  29597. abstract unregisterAction(action: IAction): Boolean;
  29598. /**
  29599. * Does exist one action manager with at least one trigger
  29600. **/
  29601. static get HasTriggers(): boolean;
  29602. /**
  29603. * Does exist one action manager with at least one pick trigger
  29604. **/
  29605. static get HasPickTriggers(): boolean;
  29606. /**
  29607. * Does exist one action manager that handles actions of a given trigger
  29608. * @param trigger defines the trigger to be tested
  29609. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29610. **/
  29611. static HasSpecificTrigger(trigger: number): boolean;
  29612. }
  29613. }
  29614. declare module "babylonjs/node" {
  29615. import { Scene } from "babylonjs/scene";
  29616. import { Nullable } from "babylonjs/types";
  29617. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29618. import { Engine } from "babylonjs/Engines/engine";
  29619. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29620. import { Observable } from "babylonjs/Misc/observable";
  29621. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29622. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29623. import { Animatable } from "babylonjs/Animations/animatable";
  29624. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29625. import { Animation } from "babylonjs/Animations/animation";
  29626. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29628. /**
  29629. * Defines how a node can be built from a string name.
  29630. */
  29631. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  29632. /**
  29633. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  29634. */
  29635. export class Node implements IBehaviorAware<Node> {
  29636. /** @hidden */
  29637. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  29638. private static _NodeConstructors;
  29639. /**
  29640. * Add a new node constructor
  29641. * @param type defines the type name of the node to construct
  29642. * @param constructorFunc defines the constructor function
  29643. */
  29644. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  29645. /**
  29646. * Returns a node constructor based on type name
  29647. * @param type defines the type name
  29648. * @param name defines the new node name
  29649. * @param scene defines the hosting scene
  29650. * @param options defines optional options to transmit to constructors
  29651. * @returns the new constructor or null
  29652. */
  29653. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  29654. /**
  29655. * Gets or sets the name of the node
  29656. */
  29657. name: string;
  29658. /**
  29659. * Gets or sets the id of the node
  29660. */
  29661. id: string;
  29662. /**
  29663. * Gets or sets the unique id of the node
  29664. */
  29665. uniqueId: number;
  29666. /**
  29667. * Gets or sets a string used to store user defined state for the node
  29668. */
  29669. state: string;
  29670. /**
  29671. * Gets or sets an object used to store user defined information for the node
  29672. */
  29673. metadata: any;
  29674. /**
  29675. * For internal use only. Please do not use.
  29676. */
  29677. reservedDataStore: any;
  29678. /**
  29679. * List of inspectable custom properties (used by the Inspector)
  29680. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  29681. */
  29682. inspectableCustomProperties: IInspectable[];
  29683. private _doNotSerialize;
  29684. /**
  29685. * Gets or sets a boolean used to define if the node must be serialized
  29686. */
  29687. get doNotSerialize(): boolean;
  29688. set doNotSerialize(value: boolean);
  29689. /** @hidden */
  29690. _isDisposed: boolean;
  29691. /**
  29692. * Gets a list of Animations associated with the node
  29693. */
  29694. animations: import("babylonjs/Animations/animation").Animation[];
  29695. protected _ranges: {
  29696. [name: string]: Nullable<AnimationRange>;
  29697. };
  29698. /**
  29699. * Callback raised when the node is ready to be used
  29700. */
  29701. onReady: Nullable<(node: Node) => void>;
  29702. private _isEnabled;
  29703. private _isParentEnabled;
  29704. private _isReady;
  29705. /** @hidden */
  29706. _currentRenderId: number;
  29707. private _parentUpdateId;
  29708. /** @hidden */
  29709. _childUpdateId: number;
  29710. /** @hidden */
  29711. _waitingParentId: Nullable<string>;
  29712. /** @hidden */
  29713. _scene: Scene;
  29714. /** @hidden */
  29715. _cache: any;
  29716. private _parentNode;
  29717. private _children;
  29718. /** @hidden */
  29719. _worldMatrix: Matrix;
  29720. /** @hidden */
  29721. _worldMatrixDeterminant: number;
  29722. /** @hidden */
  29723. _worldMatrixDeterminantIsDirty: boolean;
  29724. /** @hidden */
  29725. private _sceneRootNodesIndex;
  29726. /**
  29727. * Gets a boolean indicating if the node has been disposed
  29728. * @returns true if the node was disposed
  29729. */
  29730. isDisposed(): boolean;
  29731. /**
  29732. * Gets or sets the parent of the node (without keeping the current position in the scene)
  29733. * @see https://doc.babylonjs.com/how_to/parenting
  29734. */
  29735. set parent(parent: Nullable<Node>);
  29736. get parent(): Nullable<Node>;
  29737. /** @hidden */
  29738. _addToSceneRootNodes(): void;
  29739. /** @hidden */
  29740. _removeFromSceneRootNodes(): void;
  29741. private _animationPropertiesOverride;
  29742. /**
  29743. * Gets or sets the animation properties override
  29744. */
  29745. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  29746. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  29747. /**
  29748. * Gets a string idenfifying the name of the class
  29749. * @returns "Node" string
  29750. */
  29751. getClassName(): string;
  29752. /** @hidden */
  29753. readonly _isNode: boolean;
  29754. /**
  29755. * An event triggered when the mesh is disposed
  29756. */
  29757. onDisposeObservable: Observable<Node>;
  29758. private _onDisposeObserver;
  29759. /**
  29760. * Sets a callback that will be raised when the node will be disposed
  29761. */
  29762. set onDispose(callback: () => void);
  29763. /**
  29764. * Creates a new Node
  29765. * @param name the name and id to be given to this node
  29766. * @param scene the scene this node will be added to
  29767. */
  29768. constructor(name: string, scene?: Nullable<Scene>);
  29769. /**
  29770. * Gets the scene of the node
  29771. * @returns a scene
  29772. */
  29773. getScene(): Scene;
  29774. /**
  29775. * Gets the engine of the node
  29776. * @returns a Engine
  29777. */
  29778. getEngine(): Engine;
  29779. private _behaviors;
  29780. /**
  29781. * Attach a behavior to the node
  29782. * @see http://doc.babylonjs.com/features/behaviour
  29783. * @param behavior defines the behavior to attach
  29784. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  29785. * @returns the current Node
  29786. */
  29787. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  29788. /**
  29789. * Remove an attached behavior
  29790. * @see http://doc.babylonjs.com/features/behaviour
  29791. * @param behavior defines the behavior to attach
  29792. * @returns the current Node
  29793. */
  29794. removeBehavior(behavior: Behavior<Node>): Node;
  29795. /**
  29796. * Gets the list of attached behaviors
  29797. * @see http://doc.babylonjs.com/features/behaviour
  29798. */
  29799. get behaviors(): Behavior<Node>[];
  29800. /**
  29801. * Gets an attached behavior by name
  29802. * @param name defines the name of the behavior to look for
  29803. * @see http://doc.babylonjs.com/features/behaviour
  29804. * @returns null if behavior was not found else the requested behavior
  29805. */
  29806. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  29807. /**
  29808. * Returns the latest update of the World matrix
  29809. * @returns a Matrix
  29810. */
  29811. getWorldMatrix(): Matrix;
  29812. /** @hidden */
  29813. _getWorldMatrixDeterminant(): number;
  29814. /**
  29815. * Returns directly the latest state of the mesh World matrix.
  29816. * A Matrix is returned.
  29817. */
  29818. get worldMatrixFromCache(): Matrix;
  29819. /** @hidden */
  29820. _initCache(): void;
  29821. /** @hidden */
  29822. updateCache(force?: boolean): void;
  29823. /** @hidden */
  29824. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29825. /** @hidden */
  29826. _updateCache(ignoreParentClass?: boolean): void;
  29827. /** @hidden */
  29828. _isSynchronized(): boolean;
  29829. /** @hidden */
  29830. _markSyncedWithParent(): void;
  29831. /** @hidden */
  29832. isSynchronizedWithParent(): boolean;
  29833. /** @hidden */
  29834. isSynchronized(): boolean;
  29835. /**
  29836. * Is this node ready to be used/rendered
  29837. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29838. * @return true if the node is ready
  29839. */
  29840. isReady(completeCheck?: boolean): boolean;
  29841. /**
  29842. * Is this node enabled?
  29843. * If the node has a parent, all ancestors will be checked and false will be returned if any are false (not enabled), otherwise will return true
  29844. * @param checkAncestors indicates if this method should check the ancestors. The default is to check the ancestors. If set to false, the method will return the value of this node without checking ancestors
  29845. * @return whether this node (and its parent) is enabled
  29846. */
  29847. isEnabled(checkAncestors?: boolean): boolean;
  29848. /** @hidden */
  29849. protected _syncParentEnabledState(): void;
  29850. /**
  29851. * Set the enabled state of this node
  29852. * @param value defines the new enabled state
  29853. */
  29854. setEnabled(value: boolean): void;
  29855. /**
  29856. * Is this node a descendant of the given node?
  29857. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  29858. * @param ancestor defines the parent node to inspect
  29859. * @returns a boolean indicating if this node is a descendant of the given node
  29860. */
  29861. isDescendantOf(ancestor: Node): boolean;
  29862. /** @hidden */
  29863. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  29864. /**
  29865. * Will return all nodes that have this node as ascendant
  29866. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered
  29867. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  29868. * @return all children nodes of all types
  29869. */
  29870. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  29871. /**
  29872. * Get all child-meshes of this node
  29873. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: false)
  29874. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  29875. * @returns an array of AbstractMesh
  29876. */
  29877. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  29878. /**
  29879. * Get all direct children of this node
  29880. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  29881. * @param directDescendantsOnly defines if true only direct descendants of 'this' will be considered, if false direct and also indirect (children of children, an so on in a recursive manner) descendants of 'this' will be considered (Default: true)
  29882. * @returns an array of Node
  29883. */
  29884. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  29885. /** @hidden */
  29886. _setReady(state: boolean): void;
  29887. /**
  29888. * Get an animation by name
  29889. * @param name defines the name of the animation to look for
  29890. * @returns null if not found else the requested animation
  29891. */
  29892. getAnimationByName(name: string): Nullable<Animation>;
  29893. /**
  29894. * Creates an animation range for this node
  29895. * @param name defines the name of the range
  29896. * @param from defines the starting key
  29897. * @param to defines the end key
  29898. */
  29899. createAnimationRange(name: string, from: number, to: number): void;
  29900. /**
  29901. * Delete a specific animation range
  29902. * @param name defines the name of the range to delete
  29903. * @param deleteFrames defines if animation frames from the range must be deleted as well
  29904. */
  29905. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  29906. /**
  29907. * Get an animation range by name
  29908. * @param name defines the name of the animation range to look for
  29909. * @returns null if not found else the requested animation range
  29910. */
  29911. getAnimationRange(name: string): Nullable<AnimationRange>;
  29912. /**
  29913. * Gets the list of all animation ranges defined on this node
  29914. * @returns an array
  29915. */
  29916. getAnimationRanges(): Nullable<AnimationRange>[];
  29917. /**
  29918. * Will start the animation sequence
  29919. * @param name defines the range frames for animation sequence
  29920. * @param loop defines if the animation should loop (false by default)
  29921. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  29922. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  29923. * @returns the object created for this animation. If range does not exist, it will return null
  29924. */
  29925. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  29926. /**
  29927. * Serialize animation ranges into a JSON compatible object
  29928. * @returns serialization object
  29929. */
  29930. serializeAnimationRanges(): any;
  29931. /**
  29932. * Computes the world matrix of the node
  29933. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  29934. * @returns the world matrix
  29935. */
  29936. computeWorldMatrix(force?: boolean): Matrix;
  29937. /**
  29938. * Releases resources associated with this node.
  29939. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29940. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29941. */
  29942. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29943. /**
  29944. * Parse animation range data from a serialization object and store them into a given node
  29945. * @param node defines where to store the animation ranges
  29946. * @param parsedNode defines the serialization object to read data from
  29947. * @param scene defines the hosting scene
  29948. */
  29949. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  29950. /**
  29951. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  29952. * @param includeDescendants Include bounding info from descendants as well (true by default)
  29953. * @param predicate defines a callback function that can be customize to filter what meshes should be included in the list used to compute the bounding vectors
  29954. * @returns the new bounding vectors
  29955. */
  29956. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  29957. min: Vector3;
  29958. max: Vector3;
  29959. };
  29960. }
  29961. }
  29962. declare module "babylonjs/Animations/animation" {
  29963. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  29964. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  29965. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  29966. import { Nullable } from "babylonjs/types";
  29967. import { Scene } from "babylonjs/scene";
  29968. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  29969. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29970. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  29971. import { Node } from "babylonjs/node";
  29972. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29973. import { Size } from "babylonjs/Maths/math.size";
  29974. import { Animatable } from "babylonjs/Animations/animatable";
  29975. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  29976. /**
  29977. * @hidden
  29978. */
  29979. export class _IAnimationState {
  29980. key: number;
  29981. repeatCount: number;
  29982. workValue?: any;
  29983. loopMode?: number;
  29984. offsetValue?: any;
  29985. highLimitValue?: any;
  29986. }
  29987. /**
  29988. * Class used to store any kind of animation
  29989. */
  29990. export class Animation {
  29991. /**Name of the animation */
  29992. name: string;
  29993. /**Property to animate */
  29994. targetProperty: string;
  29995. /**The frames per second of the animation */
  29996. framePerSecond: number;
  29997. /**The data type of the animation */
  29998. dataType: number;
  29999. /**The loop mode of the animation */
  30000. loopMode?: number | undefined;
  30001. /**Specifies if blending should be enabled */
  30002. enableBlending?: boolean | undefined;
  30003. /**
  30004. * Use matrix interpolation instead of using direct key value when animating matrices
  30005. */
  30006. static AllowMatricesInterpolation: boolean;
  30007. /**
  30008. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30009. */
  30010. static AllowMatrixDecomposeForInterpolation: boolean;
  30011. /**
  30012. * Stores the key frames of the animation
  30013. */
  30014. private _keys;
  30015. /**
  30016. * Stores the easing function of the animation
  30017. */
  30018. private _easingFunction;
  30019. /**
  30020. * @hidden Internal use only
  30021. */
  30022. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30023. /**
  30024. * The set of event that will be linked to this animation
  30025. */
  30026. private _events;
  30027. /**
  30028. * Stores an array of target property paths
  30029. */
  30030. targetPropertyPath: string[];
  30031. /**
  30032. * Stores the blending speed of the animation
  30033. */
  30034. blendingSpeed: number;
  30035. /**
  30036. * Stores the animation ranges for the animation
  30037. */
  30038. private _ranges;
  30039. /**
  30040. * @hidden Internal use
  30041. */
  30042. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30043. /**
  30044. * Sets up an animation
  30045. * @param property The property to animate
  30046. * @param animationType The animation type to apply
  30047. * @param framePerSecond The frames per second of the animation
  30048. * @param easingFunction The easing function used in the animation
  30049. * @returns The created animation
  30050. */
  30051. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30052. /**
  30053. * Create and start an animation on a node
  30054. * @param name defines the name of the global animation that will be run on all nodes
  30055. * @param node defines the root node where the animation will take place
  30056. * @param targetProperty defines property to animate
  30057. * @param framePerSecond defines the number of frame per second yo use
  30058. * @param totalFrame defines the number of frames in total
  30059. * @param from defines the initial value
  30060. * @param to defines the final value
  30061. * @param loopMode defines which loop mode you want to use (off by default)
  30062. * @param easingFunction defines the easing function to use (linear by default)
  30063. * @param onAnimationEnd defines the callback to call when animation end
  30064. * @returns the animatable created for this animation
  30065. */
  30066. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30067. /**
  30068. * Create and start an animation on a node and its descendants
  30069. * @param name defines the name of the global animation that will be run on all nodes
  30070. * @param node defines the root node where the animation will take place
  30071. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  30072. * @param targetProperty defines property to animate
  30073. * @param framePerSecond defines the number of frame per second to use
  30074. * @param totalFrame defines the number of frames in total
  30075. * @param from defines the initial value
  30076. * @param to defines the final value
  30077. * @param loopMode defines which loop mode you want to use (off by default)
  30078. * @param easingFunction defines the easing function to use (linear by default)
  30079. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30080. * @returns the list of animatables created for all nodes
  30081. * @example https://www.babylonjs-playground.com/#MH0VLI
  30082. */
  30083. static CreateAndStartHierarchyAnimation(name: string, node: Node, directDescendantsOnly: boolean, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable[]>;
  30084. /**
  30085. * Creates a new animation, merges it with the existing animations and starts it
  30086. * @param name Name of the animation
  30087. * @param node Node which contains the scene that begins the animations
  30088. * @param targetProperty Specifies which property to animate
  30089. * @param framePerSecond The frames per second of the animation
  30090. * @param totalFrame The total number of frames
  30091. * @param from The frame at the beginning of the animation
  30092. * @param to The frame at the end of the animation
  30093. * @param loopMode Specifies the loop mode of the animation
  30094. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30095. * @param onAnimationEnd Callback to run once the animation is complete
  30096. * @returns Nullable animation
  30097. */
  30098. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30099. /**
  30100. * Transition property of an host to the target Value
  30101. * @param property The property to transition
  30102. * @param targetValue The target Value of the property
  30103. * @param host The object where the property to animate belongs
  30104. * @param scene Scene used to run the animation
  30105. * @param frameRate Framerate (in frame/s) to use
  30106. * @param transition The transition type we want to use
  30107. * @param duration The duration of the animation, in milliseconds
  30108. * @param onAnimationEnd Callback trigger at the end of the animation
  30109. * @returns Nullable animation
  30110. */
  30111. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30112. /**
  30113. * Return the array of runtime animations currently using this animation
  30114. */
  30115. get runtimeAnimations(): RuntimeAnimation[];
  30116. /**
  30117. * Specifies if any of the runtime animations are currently running
  30118. */
  30119. get hasRunningRuntimeAnimations(): boolean;
  30120. /**
  30121. * Initializes the animation
  30122. * @param name Name of the animation
  30123. * @param targetProperty Property to animate
  30124. * @param framePerSecond The frames per second of the animation
  30125. * @param dataType The data type of the animation
  30126. * @param loopMode The loop mode of the animation
  30127. * @param enableBlending Specifies if blending should be enabled
  30128. */
  30129. constructor(
  30130. /**Name of the animation */
  30131. name: string,
  30132. /**Property to animate */
  30133. targetProperty: string,
  30134. /**The frames per second of the animation */
  30135. framePerSecond: number,
  30136. /**The data type of the animation */
  30137. dataType: number,
  30138. /**The loop mode of the animation */
  30139. loopMode?: number | undefined,
  30140. /**Specifies if blending should be enabled */
  30141. enableBlending?: boolean | undefined);
  30142. /**
  30143. * Converts the animation to a string
  30144. * @param fullDetails support for multiple levels of logging within scene loading
  30145. * @returns String form of the animation
  30146. */
  30147. toString(fullDetails?: boolean): string;
  30148. /**
  30149. * Add an event to this animation
  30150. * @param event Event to add
  30151. */
  30152. addEvent(event: AnimationEvent): void;
  30153. /**
  30154. * Remove all events found at the given frame
  30155. * @param frame The frame to remove events from
  30156. */
  30157. removeEvents(frame: number): void;
  30158. /**
  30159. * Retrieves all the events from the animation
  30160. * @returns Events from the animation
  30161. */
  30162. getEvents(): AnimationEvent[];
  30163. /**
  30164. * Creates an animation range
  30165. * @param name Name of the animation range
  30166. * @param from Starting frame of the animation range
  30167. * @param to Ending frame of the animation
  30168. */
  30169. createRange(name: string, from: number, to: number): void;
  30170. /**
  30171. * Deletes an animation range by name
  30172. * @param name Name of the animation range to delete
  30173. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30174. */
  30175. deleteRange(name: string, deleteFrames?: boolean): void;
  30176. /**
  30177. * Gets the animation range by name, or null if not defined
  30178. * @param name Name of the animation range
  30179. * @returns Nullable animation range
  30180. */
  30181. getRange(name: string): Nullable<AnimationRange>;
  30182. /**
  30183. * Gets the key frames from the animation
  30184. * @returns The key frames of the animation
  30185. */
  30186. getKeys(): Array<IAnimationKey>;
  30187. /**
  30188. * Gets the highest frame rate of the animation
  30189. * @returns Highest frame rate of the animation
  30190. */
  30191. getHighestFrame(): number;
  30192. /**
  30193. * Gets the easing function of the animation
  30194. * @returns Easing function of the animation
  30195. */
  30196. getEasingFunction(): IEasingFunction;
  30197. /**
  30198. * Sets the easing function of the animation
  30199. * @param easingFunction A custom mathematical formula for animation
  30200. */
  30201. setEasingFunction(easingFunction: EasingFunction): void;
  30202. /**
  30203. * Interpolates a scalar linearly
  30204. * @param startValue Start value of the animation curve
  30205. * @param endValue End value of the animation curve
  30206. * @param gradient Scalar amount to interpolate
  30207. * @returns Interpolated scalar value
  30208. */
  30209. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30210. /**
  30211. * Interpolates a scalar cubically
  30212. * @param startValue Start value of the animation curve
  30213. * @param outTangent End tangent of the animation
  30214. * @param endValue End value of the animation curve
  30215. * @param inTangent Start tangent of the animation curve
  30216. * @param gradient Scalar amount to interpolate
  30217. * @returns Interpolated scalar value
  30218. */
  30219. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30220. /**
  30221. * Interpolates a quaternion using a spherical linear interpolation
  30222. * @param startValue Start value of the animation curve
  30223. * @param endValue End value of the animation curve
  30224. * @param gradient Scalar amount to interpolate
  30225. * @returns Interpolated quaternion value
  30226. */
  30227. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30228. /**
  30229. * Interpolates a quaternion cubically
  30230. * @param startValue Start value of the animation curve
  30231. * @param outTangent End tangent of the animation curve
  30232. * @param endValue End value of the animation curve
  30233. * @param inTangent Start tangent of the animation curve
  30234. * @param gradient Scalar amount to interpolate
  30235. * @returns Interpolated quaternion value
  30236. */
  30237. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30238. /**
  30239. * Interpolates a Vector3 linearl
  30240. * @param startValue Start value of the animation curve
  30241. * @param endValue End value of the animation curve
  30242. * @param gradient Scalar amount to interpolate
  30243. * @returns Interpolated scalar value
  30244. */
  30245. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30246. /**
  30247. * Interpolates a Vector3 cubically
  30248. * @param startValue Start value of the animation curve
  30249. * @param outTangent End tangent of the animation
  30250. * @param endValue End value of the animation curve
  30251. * @param inTangent Start tangent of the animation curve
  30252. * @param gradient Scalar amount to interpolate
  30253. * @returns InterpolatedVector3 value
  30254. */
  30255. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30256. /**
  30257. * Interpolates a Vector2 linearly
  30258. * @param startValue Start value of the animation curve
  30259. * @param endValue End value of the animation curve
  30260. * @param gradient Scalar amount to interpolate
  30261. * @returns Interpolated Vector2 value
  30262. */
  30263. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30264. /**
  30265. * Interpolates a Vector2 cubically
  30266. * @param startValue Start value of the animation curve
  30267. * @param outTangent End tangent of the animation
  30268. * @param endValue End value of the animation curve
  30269. * @param inTangent Start tangent of the animation curve
  30270. * @param gradient Scalar amount to interpolate
  30271. * @returns Interpolated Vector2 value
  30272. */
  30273. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30274. /**
  30275. * Interpolates a size linearly
  30276. * @param startValue Start value of the animation curve
  30277. * @param endValue End value of the animation curve
  30278. * @param gradient Scalar amount to interpolate
  30279. * @returns Interpolated Size value
  30280. */
  30281. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30282. /**
  30283. * Interpolates a Color3 linearly
  30284. * @param startValue Start value of the animation curve
  30285. * @param endValue End value of the animation curve
  30286. * @param gradient Scalar amount to interpolate
  30287. * @returns Interpolated Color3 value
  30288. */
  30289. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30290. /**
  30291. * Interpolates a Color4 linearly
  30292. * @param startValue Start value of the animation curve
  30293. * @param endValue End value of the animation curve
  30294. * @param gradient Scalar amount to interpolate
  30295. * @returns Interpolated Color3 value
  30296. */
  30297. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30298. /**
  30299. * @hidden Internal use only
  30300. */
  30301. _getKeyValue(value: any): any;
  30302. /**
  30303. * @hidden Internal use only
  30304. */
  30305. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30306. /**
  30307. * Defines the function to use to interpolate matrices
  30308. * @param startValue defines the start matrix
  30309. * @param endValue defines the end matrix
  30310. * @param gradient defines the gradient between both matrices
  30311. * @param result defines an optional target matrix where to store the interpolation
  30312. * @returns the interpolated matrix
  30313. */
  30314. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30315. /**
  30316. * Makes a copy of the animation
  30317. * @returns Cloned animation
  30318. */
  30319. clone(): Animation;
  30320. /**
  30321. * Sets the key frames of the animation
  30322. * @param values The animation key frames to set
  30323. */
  30324. setKeys(values: Array<IAnimationKey>): void;
  30325. /**
  30326. * Serializes the animation to an object
  30327. * @returns Serialized object
  30328. */
  30329. serialize(): any;
  30330. /**
  30331. * Float animation type
  30332. */
  30333. static readonly ANIMATIONTYPE_FLOAT: number;
  30334. /**
  30335. * Vector3 animation type
  30336. */
  30337. static readonly ANIMATIONTYPE_VECTOR3: number;
  30338. /**
  30339. * Quaternion animation type
  30340. */
  30341. static readonly ANIMATIONTYPE_QUATERNION: number;
  30342. /**
  30343. * Matrix animation type
  30344. */
  30345. static readonly ANIMATIONTYPE_MATRIX: number;
  30346. /**
  30347. * Color3 animation type
  30348. */
  30349. static readonly ANIMATIONTYPE_COLOR3: number;
  30350. /**
  30351. * Color3 animation type
  30352. */
  30353. static readonly ANIMATIONTYPE_COLOR4: number;
  30354. /**
  30355. * Vector2 animation type
  30356. */
  30357. static readonly ANIMATIONTYPE_VECTOR2: number;
  30358. /**
  30359. * Size animation type
  30360. */
  30361. static readonly ANIMATIONTYPE_SIZE: number;
  30362. /**
  30363. * Relative Loop Mode
  30364. */
  30365. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30366. /**
  30367. * Cycle Loop Mode
  30368. */
  30369. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30370. /**
  30371. * Constant Loop Mode
  30372. */
  30373. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30374. /** @hidden */
  30375. static _UniversalLerp(left: any, right: any, amount: number): any;
  30376. /**
  30377. * Parses an animation object and creates an animation
  30378. * @param parsedAnimation Parsed animation object
  30379. * @returns Animation object
  30380. */
  30381. static Parse(parsedAnimation: any): Animation;
  30382. /**
  30383. * Appends the serialized animations from the source animations
  30384. * @param source Source containing the animations
  30385. * @param destination Target to store the animations
  30386. */
  30387. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30388. }
  30389. }
  30390. declare module "babylonjs/Animations/animatable.interface" {
  30391. import { Nullable } from "babylonjs/types";
  30392. import { Animation } from "babylonjs/Animations/animation";
  30393. /**
  30394. * Interface containing an array of animations
  30395. */
  30396. export interface IAnimatable {
  30397. /**
  30398. * Array of animations
  30399. */
  30400. animations: Nullable<Array<Animation>>;
  30401. }
  30402. }
  30403. declare module "babylonjs/Misc/decorators" {
  30404. import { Nullable } from "babylonjs/types";
  30405. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30406. import { Scene } from "babylonjs/scene";
  30407. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30408. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30409. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30410. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30411. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30412. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30413. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30414. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30415. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30416. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30417. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30418. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30419. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30420. /**
  30421. * Decorator used to define property that can be serialized as reference to a camera
  30422. * @param sourceName defines the name of the property to decorate
  30423. */
  30424. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30425. /**
  30426. * Class used to help serialization objects
  30427. */
  30428. export class SerializationHelper {
  30429. /** @hidden */
  30430. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30431. /** @hidden */
  30432. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30433. /** @hidden */
  30434. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30435. /** @hidden */
  30436. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30437. /**
  30438. * Appends the serialized animations from the source animations
  30439. * @param source Source containing the animations
  30440. * @param destination Target to store the animations
  30441. */
  30442. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30443. /**
  30444. * Static function used to serialized a specific entity
  30445. * @param entity defines the entity to serialize
  30446. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30447. * @returns a JSON compatible object representing the serialization of the entity
  30448. */
  30449. static Serialize<T>(entity: T, serializationObject?: any): any;
  30450. /**
  30451. * Creates a new entity from a serialization data object
  30452. * @param creationFunction defines a function used to instanciated the new entity
  30453. * @param source defines the source serialization data
  30454. * @param scene defines the hosting scene
  30455. * @param rootUrl defines the root url for resources
  30456. * @returns a new entity
  30457. */
  30458. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30459. /**
  30460. * Clones an object
  30461. * @param creationFunction defines the function used to instanciate the new object
  30462. * @param source defines the source object
  30463. * @returns the cloned object
  30464. */
  30465. static Clone<T>(creationFunction: () => T, source: T): T;
  30466. /**
  30467. * Instanciates a new object based on a source one (some data will be shared between both object)
  30468. * @param creationFunction defines the function used to instanciate the new object
  30469. * @param source defines the source object
  30470. * @returns the new object
  30471. */
  30472. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30473. }
  30474. }
  30475. declare module "babylonjs/Misc/guid" {
  30476. /**
  30477. * Class used to manipulate GUIDs
  30478. */
  30479. export class GUID {
  30480. /**
  30481. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30482. * Be aware Math.random() could cause collisions, but:
  30483. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  30484. * @returns a pseudo random id
  30485. */
  30486. static RandomId(): string;
  30487. }
  30488. }
  30489. declare module "babylonjs/Materials/Textures/baseTexture" {
  30490. import { Observable } from "babylonjs/Misc/observable";
  30491. import { Nullable } from "babylonjs/types";
  30492. import { Scene } from "babylonjs/scene";
  30493. import { Matrix } from "babylonjs/Maths/math.vector";
  30494. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30495. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30496. import { ISize } from "babylonjs/Maths/math.size";
  30497. import "babylonjs/Misc/fileTools";
  30498. /**
  30499. * Base class of all the textures in babylon.
  30500. * It groups all the common properties the materials, post process, lights... might need
  30501. * in order to make a correct use of the texture.
  30502. */
  30503. export class BaseTexture implements IAnimatable {
  30504. /**
  30505. * Default anisotropic filtering level for the application.
  30506. * It is set to 4 as a good tradeoff between perf and quality.
  30507. */
  30508. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30509. /**
  30510. * Gets or sets the unique id of the texture
  30511. */
  30512. uniqueId: number;
  30513. /**
  30514. * Define the name of the texture.
  30515. */
  30516. name: string;
  30517. /**
  30518. * Gets or sets an object used to store user defined information.
  30519. */
  30520. metadata: any;
  30521. /**
  30522. * For internal use only. Please do not use.
  30523. */
  30524. reservedDataStore: any;
  30525. private _hasAlpha;
  30526. /**
  30527. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30528. */
  30529. set hasAlpha(value: boolean);
  30530. get hasAlpha(): boolean;
  30531. /**
  30532. * Defines if the alpha value should be determined via the rgb values.
  30533. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30534. */
  30535. getAlphaFromRGB: boolean;
  30536. /**
  30537. * Intensity or strength of the texture.
  30538. * It is commonly used by materials to fine tune the intensity of the texture
  30539. */
  30540. level: number;
  30541. /**
  30542. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30543. * This is part of the texture as textures usually maps to one uv set.
  30544. */
  30545. coordinatesIndex: number;
  30546. private _coordinatesMode;
  30547. /**
  30548. * How a texture is mapped.
  30549. *
  30550. * | Value | Type | Description |
  30551. * | ----- | ----------------------------------- | ----------- |
  30552. * | 0 | EXPLICIT_MODE | |
  30553. * | 1 | SPHERICAL_MODE | |
  30554. * | 2 | PLANAR_MODE | |
  30555. * | 3 | CUBIC_MODE | |
  30556. * | 4 | PROJECTION_MODE | |
  30557. * | 5 | SKYBOX_MODE | |
  30558. * | 6 | INVCUBIC_MODE | |
  30559. * | 7 | EQUIRECTANGULAR_MODE | |
  30560. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30561. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30562. */
  30563. set coordinatesMode(value: number);
  30564. get coordinatesMode(): number;
  30565. /**
  30566. * | Value | Type | Description |
  30567. * | ----- | ------------------ | ----------- |
  30568. * | 0 | CLAMP_ADDRESSMODE | |
  30569. * | 1 | WRAP_ADDRESSMODE | |
  30570. * | 2 | MIRROR_ADDRESSMODE | |
  30571. */
  30572. wrapU: number;
  30573. /**
  30574. * | Value | Type | Description |
  30575. * | ----- | ------------------ | ----------- |
  30576. * | 0 | CLAMP_ADDRESSMODE | |
  30577. * | 1 | WRAP_ADDRESSMODE | |
  30578. * | 2 | MIRROR_ADDRESSMODE | |
  30579. */
  30580. wrapV: number;
  30581. /**
  30582. * | Value | Type | Description |
  30583. * | ----- | ------------------ | ----------- |
  30584. * | 0 | CLAMP_ADDRESSMODE | |
  30585. * | 1 | WRAP_ADDRESSMODE | |
  30586. * | 2 | MIRROR_ADDRESSMODE | |
  30587. */
  30588. wrapR: number;
  30589. /**
  30590. * With compliant hardware and browser (supporting anisotropic filtering)
  30591. * this defines the level of anisotropic filtering in the texture.
  30592. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30593. */
  30594. anisotropicFilteringLevel: number;
  30595. /**
  30596. * Define if the texture is a cube texture or if false a 2d texture.
  30597. */
  30598. get isCube(): boolean;
  30599. set isCube(value: boolean);
  30600. /**
  30601. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30602. */
  30603. get is3D(): boolean;
  30604. set is3D(value: boolean);
  30605. /**
  30606. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30607. */
  30608. get is2DArray(): boolean;
  30609. set is2DArray(value: boolean);
  30610. /**
  30611. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30612. * HDR texture are usually stored in linear space.
  30613. * This only impacts the PBR and Background materials
  30614. */
  30615. gammaSpace: boolean;
  30616. /**
  30617. * Gets or sets whether or not the texture contains RGBD data.
  30618. */
  30619. get isRGBD(): boolean;
  30620. set isRGBD(value: boolean);
  30621. /**
  30622. * Is Z inverted in the texture (useful in a cube texture).
  30623. */
  30624. invertZ: boolean;
  30625. /**
  30626. * Are mip maps generated for this texture or not.
  30627. */
  30628. get noMipmap(): boolean;
  30629. /**
  30630. * @hidden
  30631. */
  30632. lodLevelInAlpha: boolean;
  30633. /**
  30634. * With prefiltered texture, defined the offset used during the prefiltering steps.
  30635. */
  30636. get lodGenerationOffset(): number;
  30637. set lodGenerationOffset(value: number);
  30638. /**
  30639. * With prefiltered texture, defined the scale used during the prefiltering steps.
  30640. */
  30641. get lodGenerationScale(): number;
  30642. set lodGenerationScale(value: number);
  30643. /**
  30644. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  30645. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  30646. * average roughness values.
  30647. */
  30648. get linearSpecularLOD(): boolean;
  30649. set linearSpecularLOD(value: boolean);
  30650. /**
  30651. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  30652. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  30653. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  30654. */
  30655. get irradianceTexture(): Nullable<BaseTexture>;
  30656. set irradianceTexture(value: Nullable<BaseTexture>);
  30657. /**
  30658. * Define if the texture is a render target.
  30659. */
  30660. isRenderTarget: boolean;
  30661. /**
  30662. * Define the unique id of the texture in the scene.
  30663. */
  30664. get uid(): string;
  30665. /**
  30666. * Return a string representation of the texture.
  30667. * @returns the texture as a string
  30668. */
  30669. toString(): string;
  30670. /**
  30671. * Get the class name of the texture.
  30672. * @returns "BaseTexture"
  30673. */
  30674. getClassName(): string;
  30675. /**
  30676. * Define the list of animation attached to the texture.
  30677. */
  30678. animations: import("babylonjs/Animations/animation").Animation[];
  30679. /**
  30680. * An event triggered when the texture is disposed.
  30681. */
  30682. onDisposeObservable: Observable<BaseTexture>;
  30683. private _onDisposeObserver;
  30684. /**
  30685. * Callback triggered when the texture has been disposed.
  30686. * Kept for back compatibility, you can use the onDisposeObservable instead.
  30687. */
  30688. set onDispose(callback: () => void);
  30689. /**
  30690. * Define the current state of the loading sequence when in delayed load mode.
  30691. */
  30692. delayLoadState: number;
  30693. private _scene;
  30694. /** @hidden */
  30695. _texture: Nullable<InternalTexture>;
  30696. private _uid;
  30697. /**
  30698. * Define if the texture is preventinga material to render or not.
  30699. * If not and the texture is not ready, the engine will use a default black texture instead.
  30700. */
  30701. get isBlocking(): boolean;
  30702. /**
  30703. * Instantiates a new BaseTexture.
  30704. * Base class of all the textures in babylon.
  30705. * It groups all the common properties the materials, post process, lights... might need
  30706. * in order to make a correct use of the texture.
  30707. * @param scene Define the scene the texture blongs to
  30708. */
  30709. constructor(scene: Nullable<Scene>);
  30710. /**
  30711. * Get the scene the texture belongs to.
  30712. * @returns the scene or null if undefined
  30713. */
  30714. getScene(): Nullable<Scene>;
  30715. /**
  30716. * Get the texture transform matrix used to offset tile the texture for istance.
  30717. * @returns the transformation matrix
  30718. */
  30719. getTextureMatrix(): Matrix;
  30720. /**
  30721. * Get the texture reflection matrix used to rotate/transform the reflection.
  30722. * @returns the reflection matrix
  30723. */
  30724. getReflectionTextureMatrix(): Matrix;
  30725. /**
  30726. * Get the underlying lower level texture from Babylon.
  30727. * @returns the insternal texture
  30728. */
  30729. getInternalTexture(): Nullable<InternalTexture>;
  30730. /**
  30731. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  30732. * @returns true if ready or not blocking
  30733. */
  30734. isReadyOrNotBlocking(): boolean;
  30735. /**
  30736. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  30737. * @returns true if fully ready
  30738. */
  30739. isReady(): boolean;
  30740. private _cachedSize;
  30741. /**
  30742. * Get the size of the texture.
  30743. * @returns the texture size.
  30744. */
  30745. getSize(): ISize;
  30746. /**
  30747. * Get the base size of the texture.
  30748. * It can be different from the size if the texture has been resized for POT for instance
  30749. * @returns the base size
  30750. */
  30751. getBaseSize(): ISize;
  30752. /**
  30753. * Update the sampling mode of the texture.
  30754. * Default is Trilinear mode.
  30755. *
  30756. * | Value | Type | Description |
  30757. * | ----- | ------------------ | ----------- |
  30758. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  30759. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  30760. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  30761. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  30762. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  30763. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  30764. * | 7 | NEAREST_LINEAR | |
  30765. * | 8 | NEAREST_NEAREST | |
  30766. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  30767. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  30768. * | 11 | LINEAR_LINEAR | |
  30769. * | 12 | LINEAR_NEAREST | |
  30770. *
  30771. * > _mag_: magnification filter (close to the viewer)
  30772. * > _min_: minification filter (far from the viewer)
  30773. * > _mip_: filter used between mip map levels
  30774. *@param samplingMode Define the new sampling mode of the texture
  30775. */
  30776. updateSamplingMode(samplingMode: number): void;
  30777. /**
  30778. * Scales the texture if is `canRescale()`
  30779. * @param ratio the resize factor we want to use to rescale
  30780. */
  30781. scale(ratio: number): void;
  30782. /**
  30783. * Get if the texture can rescale.
  30784. */
  30785. get canRescale(): boolean;
  30786. /** @hidden */
  30787. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  30788. /** @hidden */
  30789. _rebuild(): void;
  30790. /**
  30791. * Triggers the load sequence in delayed load mode.
  30792. */
  30793. delayLoad(): void;
  30794. /**
  30795. * Clones the texture.
  30796. * @returns the cloned texture
  30797. */
  30798. clone(): Nullable<BaseTexture>;
  30799. /**
  30800. * Get the texture underlying type (INT, FLOAT...)
  30801. */
  30802. get textureType(): number;
  30803. /**
  30804. * Get the texture underlying format (RGB, RGBA...)
  30805. */
  30806. get textureFormat(): number;
  30807. /**
  30808. * Indicates that textures need to be re-calculated for all materials
  30809. */
  30810. protected _markAllSubMeshesAsTexturesDirty(): void;
  30811. /**
  30812. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  30813. * This will returns an RGBA array buffer containing either in values (0-255) or
  30814. * float values (0-1) depending of the underlying buffer type.
  30815. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  30816. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  30817. * @param buffer defines a user defined buffer to fill with data (can be null)
  30818. * @returns The Array buffer containing the pixels data.
  30819. */
  30820. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  30821. /**
  30822. * Release and destroy the underlying lower level texture aka internalTexture.
  30823. */
  30824. releaseInternalTexture(): void;
  30825. /** @hidden */
  30826. get _lodTextureHigh(): Nullable<BaseTexture>;
  30827. /** @hidden */
  30828. get _lodTextureMid(): Nullable<BaseTexture>;
  30829. /** @hidden */
  30830. get _lodTextureLow(): Nullable<BaseTexture>;
  30831. /**
  30832. * Dispose the texture and release its associated resources.
  30833. */
  30834. dispose(): void;
  30835. /**
  30836. * Serialize the texture into a JSON representation that can be parsed later on.
  30837. * @returns the JSON representation of the texture
  30838. */
  30839. serialize(): any;
  30840. /**
  30841. * Helper function to be called back once a list of texture contains only ready textures.
  30842. * @param textures Define the list of textures to wait for
  30843. * @param callback Define the callback triggered once the entire list will be ready
  30844. */
  30845. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  30846. }
  30847. }
  30848. declare module "babylonjs/Materials/effect" {
  30849. import { Observable } from "babylonjs/Misc/observable";
  30850. import { Nullable } from "babylonjs/types";
  30851. import { IDisposable } from "babylonjs/scene";
  30852. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  30853. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  30854. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  30855. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  30856. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  30857. import { Engine } from "babylonjs/Engines/engine";
  30858. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30859. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30860. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30861. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30862. /**
  30863. * Options to be used when creating an effect.
  30864. */
  30865. export interface IEffectCreationOptions {
  30866. /**
  30867. * Atrributes that will be used in the shader.
  30868. */
  30869. attributes: string[];
  30870. /**
  30871. * Uniform varible names that will be set in the shader.
  30872. */
  30873. uniformsNames: string[];
  30874. /**
  30875. * Uniform buffer variable names that will be set in the shader.
  30876. */
  30877. uniformBuffersNames: string[];
  30878. /**
  30879. * Sampler texture variable names that will be set in the shader.
  30880. */
  30881. samplers: string[];
  30882. /**
  30883. * Define statements that will be set in the shader.
  30884. */
  30885. defines: any;
  30886. /**
  30887. * Possible fallbacks for this effect to improve performance when needed.
  30888. */
  30889. fallbacks: Nullable<IEffectFallbacks>;
  30890. /**
  30891. * Callback that will be called when the shader is compiled.
  30892. */
  30893. onCompiled: Nullable<(effect: Effect) => void>;
  30894. /**
  30895. * Callback that will be called if an error occurs during shader compilation.
  30896. */
  30897. onError: Nullable<(effect: Effect, errors: string) => void>;
  30898. /**
  30899. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  30900. */
  30901. indexParameters?: any;
  30902. /**
  30903. * Max number of lights that can be used in the shader.
  30904. */
  30905. maxSimultaneousLights?: number;
  30906. /**
  30907. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  30908. */
  30909. transformFeedbackVaryings?: Nullable<string[]>;
  30910. }
  30911. /**
  30912. * Effect containing vertex and fragment shader that can be executed on an object.
  30913. */
  30914. export class Effect implements IDisposable {
  30915. /**
  30916. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30917. */
  30918. static ShadersRepository: string;
  30919. /**
  30920. * Name of the effect.
  30921. */
  30922. name: any;
  30923. /**
  30924. * String container all the define statements that should be set on the shader.
  30925. */
  30926. defines: string;
  30927. /**
  30928. * Callback that will be called when the shader is compiled.
  30929. */
  30930. onCompiled: Nullable<(effect: Effect) => void>;
  30931. /**
  30932. * Callback that will be called if an error occurs during shader compilation.
  30933. */
  30934. onError: Nullable<(effect: Effect, errors: string) => void>;
  30935. /**
  30936. * Callback that will be called when effect is bound.
  30937. */
  30938. onBind: Nullable<(effect: Effect) => void>;
  30939. /**
  30940. * Unique ID of the effect.
  30941. */
  30942. uniqueId: number;
  30943. /**
  30944. * Observable that will be called when the shader is compiled.
  30945. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  30946. */
  30947. onCompileObservable: Observable<Effect>;
  30948. /**
  30949. * Observable that will be called if an error occurs during shader compilation.
  30950. */
  30951. onErrorObservable: Observable<Effect>;
  30952. /** @hidden */
  30953. _onBindObservable: Nullable<Observable<Effect>>;
  30954. /**
  30955. * @hidden
  30956. * Specifies if the effect was previously ready
  30957. */
  30958. _wasPreviouslyReady: boolean;
  30959. /**
  30960. * Observable that will be called when effect is bound.
  30961. */
  30962. get onBindObservable(): Observable<Effect>;
  30963. /** @hidden */
  30964. _bonesComputationForcedToCPU: boolean;
  30965. private static _uniqueIdSeed;
  30966. private _engine;
  30967. private _uniformBuffersNames;
  30968. private _uniformsNames;
  30969. private _samplerList;
  30970. private _samplers;
  30971. private _isReady;
  30972. private _compilationError;
  30973. private _allFallbacksProcessed;
  30974. private _attributesNames;
  30975. private _attributes;
  30976. private _attributeLocationByName;
  30977. private _uniforms;
  30978. /**
  30979. * Key for the effect.
  30980. * @hidden
  30981. */
  30982. _key: string;
  30983. private _indexParameters;
  30984. private _fallbacks;
  30985. private _vertexSourceCode;
  30986. private _fragmentSourceCode;
  30987. private _vertexSourceCodeOverride;
  30988. private _fragmentSourceCodeOverride;
  30989. private _transformFeedbackVaryings;
  30990. /**
  30991. * Compiled shader to webGL program.
  30992. * @hidden
  30993. */
  30994. _pipelineContext: Nullable<IPipelineContext>;
  30995. private _valueCache;
  30996. private static _baseCache;
  30997. /**
  30998. * Instantiates an effect.
  30999. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31000. * @param baseName Name of the effect.
  31001. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31002. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31003. * @param samplers List of sampler variables that will be passed to the shader.
  31004. * @param engine Engine to be used to render the effect
  31005. * @param defines Define statements to be added to the shader.
  31006. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31007. * @param onCompiled Callback that will be called when the shader is compiled.
  31008. * @param onError Callback that will be called if an error occurs during shader compilation.
  31009. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31010. */
  31011. constructor(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  31012. private _useFinalCode;
  31013. /**
  31014. * Unique key for this effect
  31015. */
  31016. get key(): string;
  31017. /**
  31018. * If the effect has been compiled and prepared.
  31019. * @returns if the effect is compiled and prepared.
  31020. */
  31021. isReady(): boolean;
  31022. private _isReadyInternal;
  31023. /**
  31024. * The engine the effect was initialized with.
  31025. * @returns the engine.
  31026. */
  31027. getEngine(): Engine;
  31028. /**
  31029. * The pipeline context for this effect
  31030. * @returns the associated pipeline context
  31031. */
  31032. getPipelineContext(): Nullable<IPipelineContext>;
  31033. /**
  31034. * The set of names of attribute variables for the shader.
  31035. * @returns An array of attribute names.
  31036. */
  31037. getAttributesNames(): string[];
  31038. /**
  31039. * Returns the attribute at the given index.
  31040. * @param index The index of the attribute.
  31041. * @returns The location of the attribute.
  31042. */
  31043. getAttributeLocation(index: number): number;
  31044. /**
  31045. * Returns the attribute based on the name of the variable.
  31046. * @param name of the attribute to look up.
  31047. * @returns the attribute location.
  31048. */
  31049. getAttributeLocationByName(name: string): number;
  31050. /**
  31051. * The number of attributes.
  31052. * @returns the numnber of attributes.
  31053. */
  31054. getAttributesCount(): number;
  31055. /**
  31056. * Gets the index of a uniform variable.
  31057. * @param uniformName of the uniform to look up.
  31058. * @returns the index.
  31059. */
  31060. getUniformIndex(uniformName: string): number;
  31061. /**
  31062. * Returns the attribute based on the name of the variable.
  31063. * @param uniformName of the uniform to look up.
  31064. * @returns the location of the uniform.
  31065. */
  31066. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31067. /**
  31068. * Returns an array of sampler variable names
  31069. * @returns The array of sampler variable neames.
  31070. */
  31071. getSamplers(): string[];
  31072. /**
  31073. * The error from the last compilation.
  31074. * @returns the error string.
  31075. */
  31076. getCompilationError(): string;
  31077. /**
  31078. * Gets a boolean indicating that all fallbacks were used during compilation
  31079. * @returns true if all fallbacks were used
  31080. */
  31081. allFallbacksProcessed(): boolean;
  31082. /**
  31083. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31084. * @param func The callback to be used.
  31085. */
  31086. executeWhenCompiled(func: (effect: Effect) => void): void;
  31087. private _checkIsReady;
  31088. private _loadShader;
  31089. /**
  31090. * Recompiles the webGL program
  31091. * @param vertexSourceCode The source code for the vertex shader.
  31092. * @param fragmentSourceCode The source code for the fragment shader.
  31093. * @param onCompiled Callback called when completed.
  31094. * @param onError Callback called on error.
  31095. * @hidden
  31096. */
  31097. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31098. /**
  31099. * Prepares the effect
  31100. * @hidden
  31101. */
  31102. _prepareEffect(): void;
  31103. private _processCompilationErrors;
  31104. /**
  31105. * Checks if the effect is supported. (Must be called after compilation)
  31106. */
  31107. get isSupported(): boolean;
  31108. /**
  31109. * Binds a texture to the engine to be used as output of the shader.
  31110. * @param channel Name of the output variable.
  31111. * @param texture Texture to bind.
  31112. * @hidden
  31113. */
  31114. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31115. /**
  31116. * Sets a texture on the engine to be used in the shader.
  31117. * @param channel Name of the sampler variable.
  31118. * @param texture Texture to set.
  31119. */
  31120. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31121. /**
  31122. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31123. * @param channel Name of the sampler variable.
  31124. * @param texture Texture to set.
  31125. */
  31126. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31127. /**
  31128. * Sets an array of textures on the engine to be used in the shader.
  31129. * @param channel Name of the variable.
  31130. * @param textures Textures to set.
  31131. */
  31132. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31133. /**
  31134. * Sets a texture to be the input of the specified post process. (To use the output, pass in the next post process in the pipeline)
  31135. * @param channel Name of the sampler variable.
  31136. * @param postProcess Post process to get the input texture from.
  31137. */
  31138. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31139. /**
  31140. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31141. * Sets the input texture of the passed in post process to be input of this effect. (To use the output of the passed in post process use setTextureFromPostProcessOutput)
  31142. * @param channel Name of the sampler variable.
  31143. * @param postProcess Post process to get the output texture from.
  31144. */
  31145. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31146. /** @hidden */
  31147. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31148. /** @hidden */
  31149. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31150. /** @hidden */
  31151. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31152. /** @hidden */
  31153. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31154. /**
  31155. * Binds a buffer to a uniform.
  31156. * @param buffer Buffer to bind.
  31157. * @param name Name of the uniform variable to bind to.
  31158. */
  31159. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31160. /**
  31161. * Binds block to a uniform.
  31162. * @param blockName Name of the block to bind.
  31163. * @param index Index to bind.
  31164. */
  31165. bindUniformBlock(blockName: string, index: number): void;
  31166. /**
  31167. * Sets an interger value on a uniform variable.
  31168. * @param uniformName Name of the variable.
  31169. * @param value Value to be set.
  31170. * @returns this effect.
  31171. */
  31172. setInt(uniformName: string, value: number): Effect;
  31173. /**
  31174. * Sets an int array on a uniform variable.
  31175. * @param uniformName Name of the variable.
  31176. * @param array array to be set.
  31177. * @returns this effect.
  31178. */
  31179. setIntArray(uniformName: string, array: Int32Array): Effect;
  31180. /**
  31181. * Sets an int array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  31182. * @param uniformName Name of the variable.
  31183. * @param array array to be set.
  31184. * @returns this effect.
  31185. */
  31186. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31187. /**
  31188. * Sets an int array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  31189. * @param uniformName Name of the variable.
  31190. * @param array array to be set.
  31191. * @returns this effect.
  31192. */
  31193. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31194. /**
  31195. * Sets an int array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  31196. * @param uniformName Name of the variable.
  31197. * @param array array to be set.
  31198. * @returns this effect.
  31199. */
  31200. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31201. /**
  31202. * Sets an float array on a uniform variable.
  31203. * @param uniformName Name of the variable.
  31204. * @param array array to be set.
  31205. * @returns this effect.
  31206. */
  31207. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31208. /**
  31209. * Sets an float array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  31210. * @param uniformName Name of the variable.
  31211. * @param array array to be set.
  31212. * @returns this effect.
  31213. */
  31214. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31215. /**
  31216. * Sets an float array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  31217. * @param uniformName Name of the variable.
  31218. * @param array array to be set.
  31219. * @returns this effect.
  31220. */
  31221. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31222. /**
  31223. * Sets an float array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  31224. * @param uniformName Name of the variable.
  31225. * @param array array to be set.
  31226. * @returns this effect.
  31227. */
  31228. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31229. /**
  31230. * Sets an array on a uniform variable.
  31231. * @param uniformName Name of the variable.
  31232. * @param array array to be set.
  31233. * @returns this effect.
  31234. */
  31235. setArray(uniformName: string, array: number[]): Effect;
  31236. /**
  31237. * Sets an array 2 on a uniform variable. (Array is specified as single array eg. [1,2,3,4] will result in [[1,2],[3,4]] in the shader)
  31238. * @param uniformName Name of the variable.
  31239. * @param array array to be set.
  31240. * @returns this effect.
  31241. */
  31242. setArray2(uniformName: string, array: number[]): Effect;
  31243. /**
  31244. * Sets an array 3 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6] will result in [[1,2,3],[4,5,6]] in the shader)
  31245. * @param uniformName Name of the variable.
  31246. * @param array array to be set.
  31247. * @returns this effect.
  31248. */
  31249. setArray3(uniformName: string, array: number[]): Effect;
  31250. /**
  31251. * Sets an array 4 on a uniform variable. (Array is specified as single array eg. [1,2,3,4,5,6,7,8] will result in [[1,2,3,4],[5,6,7,8]] in the shader)
  31252. * @param uniformName Name of the variable.
  31253. * @param array array to be set.
  31254. * @returns this effect.
  31255. */
  31256. setArray4(uniformName: string, array: number[]): Effect;
  31257. /**
  31258. * Sets matrices on a uniform variable.
  31259. * @param uniformName Name of the variable.
  31260. * @param matrices matrices to be set.
  31261. * @returns this effect.
  31262. */
  31263. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31264. /**
  31265. * Sets matrix on a uniform variable.
  31266. * @param uniformName Name of the variable.
  31267. * @param matrix matrix to be set.
  31268. * @returns this effect.
  31269. */
  31270. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31271. /**
  31272. * Sets a 3x3 matrix on a uniform variable. (Speicified as [1,2,3,4,5,6,7,8,9] will result in [1,2,3][4,5,6][7,8,9] matrix)
  31273. * @param uniformName Name of the variable.
  31274. * @param matrix matrix to be set.
  31275. * @returns this effect.
  31276. */
  31277. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31278. /**
  31279. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31280. * @param uniformName Name of the variable.
  31281. * @param matrix matrix to be set.
  31282. * @returns this effect.
  31283. */
  31284. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31285. /**
  31286. * Sets a float on a uniform variable.
  31287. * @param uniformName Name of the variable.
  31288. * @param value value to be set.
  31289. * @returns this effect.
  31290. */
  31291. setFloat(uniformName: string, value: number): Effect;
  31292. /**
  31293. * Sets a boolean on a uniform variable.
  31294. * @param uniformName Name of the variable.
  31295. * @param bool value to be set.
  31296. * @returns this effect.
  31297. */
  31298. setBool(uniformName: string, bool: boolean): Effect;
  31299. /**
  31300. * Sets a Vector2 on a uniform variable.
  31301. * @param uniformName Name of the variable.
  31302. * @param vector2 vector2 to be set.
  31303. * @returns this effect.
  31304. */
  31305. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31306. /**
  31307. * Sets a float2 on a uniform variable.
  31308. * @param uniformName Name of the variable.
  31309. * @param x First float in float2.
  31310. * @param y Second float in float2.
  31311. * @returns this effect.
  31312. */
  31313. setFloat2(uniformName: string, x: number, y: number): Effect;
  31314. /**
  31315. * Sets a Vector3 on a uniform variable.
  31316. * @param uniformName Name of the variable.
  31317. * @param vector3 Value to be set.
  31318. * @returns this effect.
  31319. */
  31320. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31321. /**
  31322. * Sets a float3 on a uniform variable.
  31323. * @param uniformName Name of the variable.
  31324. * @param x First float in float3.
  31325. * @param y Second float in float3.
  31326. * @param z Third float in float3.
  31327. * @returns this effect.
  31328. */
  31329. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31330. /**
  31331. * Sets a Vector4 on a uniform variable.
  31332. * @param uniformName Name of the variable.
  31333. * @param vector4 Value to be set.
  31334. * @returns this effect.
  31335. */
  31336. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31337. /**
  31338. * Sets a float4 on a uniform variable.
  31339. * @param uniformName Name of the variable.
  31340. * @param x First float in float4.
  31341. * @param y Second float in float4.
  31342. * @param z Third float in float4.
  31343. * @param w Fourth float in float4.
  31344. * @returns this effect.
  31345. */
  31346. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31347. /**
  31348. * Sets a Color3 on a uniform variable.
  31349. * @param uniformName Name of the variable.
  31350. * @param color3 Value to be set.
  31351. * @returns this effect.
  31352. */
  31353. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31354. /**
  31355. * Sets a Color4 on a uniform variable.
  31356. * @param uniformName Name of the variable.
  31357. * @param color3 Value to be set.
  31358. * @param alpha Alpha value to be set.
  31359. * @returns this effect.
  31360. */
  31361. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31362. /**
  31363. * Sets a Color4 on a uniform variable
  31364. * @param uniformName defines the name of the variable
  31365. * @param color4 defines the value to be set
  31366. * @returns this effect.
  31367. */
  31368. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31369. /** Release all associated resources */
  31370. dispose(): void;
  31371. /**
  31372. * This function will add a new shader to the shader store
  31373. * @param name the name of the shader
  31374. * @param pixelShader optional pixel shader content
  31375. * @param vertexShader optional vertex shader content
  31376. */
  31377. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31378. /**
  31379. * Store of each shader (The can be looked up using effect.key)
  31380. */
  31381. static ShadersStore: {
  31382. [key: string]: string;
  31383. };
  31384. /**
  31385. * Store of each included file for a shader (The can be looked up using effect.key)
  31386. */
  31387. static IncludesShadersStore: {
  31388. [key: string]: string;
  31389. };
  31390. /**
  31391. * Resets the cache of effects.
  31392. */
  31393. static ResetCache(): void;
  31394. }
  31395. }
  31396. declare module "babylonjs/Engines/engineCapabilities" {
  31397. /**
  31398. * Interface used to describe the capabilities of the engine relatively to the current browser
  31399. */
  31400. export interface EngineCapabilities {
  31401. /** Maximum textures units per fragment shader */
  31402. maxTexturesImageUnits: number;
  31403. /** Maximum texture units per vertex shader */
  31404. maxVertexTextureImageUnits: number;
  31405. /** Maximum textures units in the entire pipeline */
  31406. maxCombinedTexturesImageUnits: number;
  31407. /** Maximum texture size */
  31408. maxTextureSize: number;
  31409. /** Maximum texture samples */
  31410. maxSamples?: number;
  31411. /** Maximum cube texture size */
  31412. maxCubemapTextureSize: number;
  31413. /** Maximum render texture size */
  31414. maxRenderTextureSize: number;
  31415. /** Maximum number of vertex attributes */
  31416. maxVertexAttribs: number;
  31417. /** Maximum number of varyings */
  31418. maxVaryingVectors: number;
  31419. /** Maximum number of uniforms per vertex shader */
  31420. maxVertexUniformVectors: number;
  31421. /** Maximum number of uniforms per fragment shader */
  31422. maxFragmentUniformVectors: number;
  31423. /** Defines if standard derivates (dx/dy) are supported */
  31424. standardDerivatives: boolean;
  31425. /** Defines if s3tc texture compression is supported */
  31426. s3tc?: WEBGL_compressed_texture_s3tc;
  31427. /** Defines if pvrtc texture compression is supported */
  31428. pvrtc: any;
  31429. /** Defines if etc1 texture compression is supported */
  31430. etc1: any;
  31431. /** Defines if etc2 texture compression is supported */
  31432. etc2: any;
  31433. /** Defines if astc texture compression is supported */
  31434. astc: any;
  31435. /** Defines if float textures are supported */
  31436. textureFloat: boolean;
  31437. /** Defines if vertex array objects are supported */
  31438. vertexArrayObject: boolean;
  31439. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31440. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31441. /** Gets the maximum level of anisotropy supported */
  31442. maxAnisotropy: number;
  31443. /** Defines if instancing is supported */
  31444. instancedArrays: boolean;
  31445. /** Defines if 32 bits indices are supported */
  31446. uintIndices: boolean;
  31447. /** Defines if high precision shaders are supported */
  31448. highPrecisionShaderSupported: boolean;
  31449. /** Defines if depth reading in the fragment shader is supported */
  31450. fragmentDepthSupported: boolean;
  31451. /** Defines if float texture linear filtering is supported*/
  31452. textureFloatLinearFiltering: boolean;
  31453. /** Defines if rendering to float textures is supported */
  31454. textureFloatRender: boolean;
  31455. /** Defines if half float textures are supported*/
  31456. textureHalfFloat: boolean;
  31457. /** Defines if half float texture linear filtering is supported*/
  31458. textureHalfFloatLinearFiltering: boolean;
  31459. /** Defines if rendering to half float textures is supported */
  31460. textureHalfFloatRender: boolean;
  31461. /** Defines if textureLOD shader command is supported */
  31462. textureLOD: boolean;
  31463. /** Defines if draw buffers extension is supported */
  31464. drawBuffersExtension: boolean;
  31465. /** Defines if depth textures are supported */
  31466. depthTextureExtension: boolean;
  31467. /** Defines if float color buffer are supported */
  31468. colorBufferFloat: boolean;
  31469. /** Gets disjoint timer query extension (null if not supported) */
  31470. timerQuery?: EXT_disjoint_timer_query;
  31471. /** Defines if timestamp can be used with timer query */
  31472. canUseTimestampForTimerQuery: boolean;
  31473. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31474. multiview?: any;
  31475. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31476. oculusMultiview?: any;
  31477. /** Function used to let the system compiles shaders in background */
  31478. parallelShaderCompile?: {
  31479. COMPLETION_STATUS_KHR: number;
  31480. };
  31481. /** Max number of texture samples for MSAA */
  31482. maxMSAASamples: number;
  31483. /** Defines if the blend min max extension is supported */
  31484. blendMinMax: boolean;
  31485. }
  31486. }
  31487. declare module "babylonjs/States/depthCullingState" {
  31488. import { Nullable } from "babylonjs/types";
  31489. /**
  31490. * @hidden
  31491. **/
  31492. export class DepthCullingState {
  31493. private _isDepthTestDirty;
  31494. private _isDepthMaskDirty;
  31495. private _isDepthFuncDirty;
  31496. private _isCullFaceDirty;
  31497. private _isCullDirty;
  31498. private _isZOffsetDirty;
  31499. private _isFrontFaceDirty;
  31500. private _depthTest;
  31501. private _depthMask;
  31502. private _depthFunc;
  31503. private _cull;
  31504. private _cullFace;
  31505. private _zOffset;
  31506. private _frontFace;
  31507. /**
  31508. * Initializes the state.
  31509. */
  31510. constructor();
  31511. get isDirty(): boolean;
  31512. get zOffset(): number;
  31513. set zOffset(value: number);
  31514. get cullFace(): Nullable<number>;
  31515. set cullFace(value: Nullable<number>);
  31516. get cull(): Nullable<boolean>;
  31517. set cull(value: Nullable<boolean>);
  31518. get depthFunc(): Nullable<number>;
  31519. set depthFunc(value: Nullable<number>);
  31520. get depthMask(): boolean;
  31521. set depthMask(value: boolean);
  31522. get depthTest(): boolean;
  31523. set depthTest(value: boolean);
  31524. get frontFace(): Nullable<number>;
  31525. set frontFace(value: Nullable<number>);
  31526. reset(): void;
  31527. apply(gl: WebGLRenderingContext): void;
  31528. }
  31529. }
  31530. declare module "babylonjs/States/stencilState" {
  31531. /**
  31532. * @hidden
  31533. **/
  31534. export class StencilState {
  31535. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  31536. static readonly ALWAYS: number;
  31537. /** Passed to stencilOperation to specify that stencil value must be kept */
  31538. static readonly KEEP: number;
  31539. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31540. static readonly REPLACE: number;
  31541. private _isStencilTestDirty;
  31542. private _isStencilMaskDirty;
  31543. private _isStencilFuncDirty;
  31544. private _isStencilOpDirty;
  31545. private _stencilTest;
  31546. private _stencilMask;
  31547. private _stencilFunc;
  31548. private _stencilFuncRef;
  31549. private _stencilFuncMask;
  31550. private _stencilOpStencilFail;
  31551. private _stencilOpDepthFail;
  31552. private _stencilOpStencilDepthPass;
  31553. get isDirty(): boolean;
  31554. get stencilFunc(): number;
  31555. set stencilFunc(value: number);
  31556. get stencilFuncRef(): number;
  31557. set stencilFuncRef(value: number);
  31558. get stencilFuncMask(): number;
  31559. set stencilFuncMask(value: number);
  31560. get stencilOpStencilFail(): number;
  31561. set stencilOpStencilFail(value: number);
  31562. get stencilOpDepthFail(): number;
  31563. set stencilOpDepthFail(value: number);
  31564. get stencilOpStencilDepthPass(): number;
  31565. set stencilOpStencilDepthPass(value: number);
  31566. get stencilMask(): number;
  31567. set stencilMask(value: number);
  31568. get stencilTest(): boolean;
  31569. set stencilTest(value: boolean);
  31570. constructor();
  31571. reset(): void;
  31572. apply(gl: WebGLRenderingContext): void;
  31573. }
  31574. }
  31575. declare module "babylonjs/States/alphaCullingState" {
  31576. /**
  31577. * @hidden
  31578. **/
  31579. export class AlphaState {
  31580. private _isAlphaBlendDirty;
  31581. private _isBlendFunctionParametersDirty;
  31582. private _isBlendEquationParametersDirty;
  31583. private _isBlendConstantsDirty;
  31584. private _alphaBlend;
  31585. private _blendFunctionParameters;
  31586. private _blendEquationParameters;
  31587. private _blendConstants;
  31588. /**
  31589. * Initializes the state.
  31590. */
  31591. constructor();
  31592. get isDirty(): boolean;
  31593. get alphaBlend(): boolean;
  31594. set alphaBlend(value: boolean);
  31595. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31596. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31597. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31598. reset(): void;
  31599. apply(gl: WebGLRenderingContext): void;
  31600. }
  31601. }
  31602. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31603. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31604. /** @hidden */
  31605. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31606. attributeProcessor(attribute: string): string;
  31607. varyingProcessor(varying: string, isFragment: boolean): string;
  31608. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31609. }
  31610. }
  31611. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31612. /**
  31613. * Interface for attribute information associated with buffer instanciation
  31614. */
  31615. export interface InstancingAttributeInfo {
  31616. /**
  31617. * Name of the GLSL attribute
  31618. * if attribute index is not specified, this is used to retrieve the index from the effect
  31619. */
  31620. attributeName: string;
  31621. /**
  31622. * Index/offset of the attribute in the vertex shader
  31623. * if not specified, this will be computes from the name.
  31624. */
  31625. index?: number;
  31626. /**
  31627. * size of the attribute, 1, 2, 3 or 4
  31628. */
  31629. attributeSize: number;
  31630. /**
  31631. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  31632. */
  31633. offset: number;
  31634. /**
  31635. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  31636. * default to 1
  31637. */
  31638. divisor?: number;
  31639. /**
  31640. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  31641. * default is FLOAT
  31642. */
  31643. attributeType?: number;
  31644. /**
  31645. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  31646. */
  31647. normalized?: boolean;
  31648. }
  31649. }
  31650. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  31651. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31652. import { Nullable } from "babylonjs/types";
  31653. module "babylonjs/Engines/thinEngine" {
  31654. interface ThinEngine {
  31655. /**
  31656. * Update a video texture
  31657. * @param texture defines the texture to update
  31658. * @param video defines the video element to use
  31659. * @param invertY defines if data must be stored with Y axis inverted
  31660. */
  31661. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  31662. }
  31663. }
  31664. }
  31665. declare module "babylonjs/Materials/Textures/videoTexture" {
  31666. import { Observable } from "babylonjs/Misc/observable";
  31667. import { Nullable } from "babylonjs/types";
  31668. import { Scene } from "babylonjs/scene";
  31669. import { Texture } from "babylonjs/Materials/Textures/texture";
  31670. import "babylonjs/Engines/Extensions/engine.videoTexture";
  31671. /**
  31672. * Settings for finer control over video usage
  31673. */
  31674. export interface VideoTextureSettings {
  31675. /**
  31676. * Applies `autoplay` to video, if specified
  31677. */
  31678. autoPlay?: boolean;
  31679. /**
  31680. * Applies `loop` to video, if specified
  31681. */
  31682. loop?: boolean;
  31683. /**
  31684. * Automatically updates internal texture from video at every frame in the render loop
  31685. */
  31686. autoUpdateTexture: boolean;
  31687. /**
  31688. * Image src displayed during the video loading or until the user interacts with the video.
  31689. */
  31690. poster?: string;
  31691. }
  31692. /**
  31693. * If you want to display a video in your scene, this is the special texture for that.
  31694. * This special texture works similar to other textures, with the exception of a few parameters.
  31695. * @see https://doc.babylonjs.com/how_to/video_texture
  31696. */
  31697. export class VideoTexture extends Texture {
  31698. /**
  31699. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  31700. */
  31701. readonly autoUpdateTexture: boolean;
  31702. /**
  31703. * The video instance used by the texture internally
  31704. */
  31705. readonly video: HTMLVideoElement;
  31706. private _onUserActionRequestedObservable;
  31707. /**
  31708. * Event triggerd when a dom action is required by the user to play the video.
  31709. * This happens due to recent changes in browser policies preventing video to auto start.
  31710. */
  31711. get onUserActionRequestedObservable(): Observable<Texture>;
  31712. private _generateMipMaps;
  31713. private _engine;
  31714. private _stillImageCaptured;
  31715. private _displayingPosterTexture;
  31716. private _settings;
  31717. private _createInternalTextureOnEvent;
  31718. private _frameId;
  31719. private _currentSrc;
  31720. /**
  31721. * Creates a video texture.
  31722. * If you want to display a video in your scene, this is the special texture for that.
  31723. * This special texture works similar to other textures, with the exception of a few parameters.
  31724. * @see https://doc.babylonjs.com/how_to/video_texture
  31725. * @param name optional name, will detect from video source, if not defined
  31726. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  31727. * @param scene is obviously the current scene.
  31728. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  31729. * @param invertY is false by default but can be used to invert video on Y axis
  31730. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  31731. * @param settings allows finer control over video usage
  31732. */
  31733. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  31734. private _getName;
  31735. private _getVideo;
  31736. private _createInternalTexture;
  31737. private reset;
  31738. /**
  31739. * @hidden Internal method to initiate `update`.
  31740. */
  31741. _rebuild(): void;
  31742. /**
  31743. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  31744. */
  31745. update(): void;
  31746. /**
  31747. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  31748. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  31749. */
  31750. updateTexture(isVisible: boolean): void;
  31751. protected _updateInternalTexture: () => void;
  31752. /**
  31753. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  31754. * @param url New url.
  31755. */
  31756. updateURL(url: string): void;
  31757. /**
  31758. * Clones the texture.
  31759. * @returns the cloned texture
  31760. */
  31761. clone(): VideoTexture;
  31762. /**
  31763. * Dispose the texture and release its associated resources.
  31764. */
  31765. dispose(): void;
  31766. /**
  31767. * Creates a video texture straight from a stream.
  31768. * @param scene Define the scene the texture should be created in
  31769. * @param stream Define the stream the texture should be created from
  31770. * @returns The created video texture as a promise
  31771. */
  31772. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  31773. /**
  31774. * Creates a video texture straight from your WebCam video feed.
  31775. * @param scene Define the scene the texture should be created in
  31776. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31777. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31778. * @returns The created video texture as a promise
  31779. */
  31780. static CreateFromWebCamAsync(scene: Scene, constraints: {
  31781. minWidth: number;
  31782. maxWidth: number;
  31783. minHeight: number;
  31784. maxHeight: number;
  31785. deviceId: string;
  31786. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  31787. /**
  31788. * Creates a video texture straight from your WebCam video feed.
  31789. * @param scene Define the scene the texture should be created in
  31790. * @param onReady Define a callback to triggered once the texture will be ready
  31791. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  31792. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  31793. */
  31794. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  31795. minWidth: number;
  31796. maxWidth: number;
  31797. minHeight: number;
  31798. maxHeight: number;
  31799. deviceId: string;
  31800. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  31801. }
  31802. }
  31803. declare module "babylonjs/Engines/thinEngine" {
  31804. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  31805. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  31806. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31807. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31808. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  31809. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  31810. import { Observable } from "babylonjs/Misc/observable";
  31811. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  31812. import { StencilState } from "babylonjs/States/stencilState";
  31813. import { AlphaState } from "babylonjs/States/alphaCullingState";
  31814. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31815. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31816. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31817. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  31818. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31819. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31820. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  31821. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  31822. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31823. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31824. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31825. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  31826. import { WebRequest } from "babylonjs/Misc/webRequest";
  31827. import { LoadFileError } from "babylonjs/Misc/fileTools";
  31828. /**
  31829. * Defines the interface used by objects working like Scene
  31830. * @hidden
  31831. */
  31832. interface ISceneLike {
  31833. _addPendingData(data: any): void;
  31834. _removePendingData(data: any): void;
  31835. offlineProvider: IOfflineProvider;
  31836. }
  31837. /** Interface defining initialization parameters for Engine class */
  31838. export interface EngineOptions extends WebGLContextAttributes {
  31839. /**
  31840. * Defines if the engine should no exceed a specified device ratio
  31841. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  31842. */
  31843. limitDeviceRatio?: number;
  31844. /**
  31845. * Defines if webvr should be enabled automatically
  31846. * @see http://doc.babylonjs.com/how_to/webvr_camera
  31847. */
  31848. autoEnableWebVR?: boolean;
  31849. /**
  31850. * Defines if webgl2 should be turned off even if supported
  31851. * @see http://doc.babylonjs.com/features/webgl2
  31852. */
  31853. disableWebGL2Support?: boolean;
  31854. /**
  31855. * Defines if webaudio should be initialized as well
  31856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31857. */
  31858. audioEngine?: boolean;
  31859. /**
  31860. * Defines if animations should run using a deterministic lock step
  31861. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  31862. */
  31863. deterministicLockstep?: boolean;
  31864. /** Defines the maximum steps to use with deterministic lock step mode */
  31865. lockstepMaxSteps?: number;
  31866. /** Defines the seconds between each deterministic lock step */
  31867. timeStep?: number;
  31868. /**
  31869. * Defines that engine should ignore context lost events
  31870. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  31871. */
  31872. doNotHandleContextLost?: boolean;
  31873. /**
  31874. * Defines that engine should ignore modifying touch action attribute and style
  31875. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  31876. */
  31877. doNotHandleTouchAction?: boolean;
  31878. /**
  31879. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  31880. */
  31881. useHighPrecisionFloats?: boolean;
  31882. }
  31883. /**
  31884. * The base engine class (root of all engines)
  31885. */
  31886. export class ThinEngine {
  31887. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  31888. static ExceptionList: ({
  31889. key: string;
  31890. capture: string;
  31891. captureConstraint: number;
  31892. targets: string[];
  31893. } | {
  31894. key: string;
  31895. capture: null;
  31896. captureConstraint: null;
  31897. targets: string[];
  31898. })[];
  31899. /** @hidden */
  31900. static _TextureLoaders: IInternalTextureLoader[];
  31901. /**
  31902. * Returns the current npm package of the sdk
  31903. */
  31904. static get NpmPackage(): string;
  31905. /**
  31906. * Returns the current version of the framework
  31907. */
  31908. static get Version(): string;
  31909. /**
  31910. * Returns a string describing the current engine
  31911. */
  31912. get description(): string;
  31913. /**
  31914. * Gets or sets the epsilon value used by collision engine
  31915. */
  31916. static CollisionsEpsilon: number;
  31917. /**
  31918. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31919. */
  31920. static get ShadersRepository(): string;
  31921. static set ShadersRepository(value: string);
  31922. /**
  31923. * Gets or sets the textures that the engine should not attempt to load as compressed
  31924. */
  31925. protected _excludedCompressedTextures: string[];
  31926. /**
  31927. * Filters the compressed texture formats to only include
  31928. * files that are not included in the skippable list
  31929. *
  31930. * @param url the current extension
  31931. * @param textureFormatInUse the current compressed texture format
  31932. * @returns "format" string
  31933. */
  31934. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  31935. /** @hidden */
  31936. _shaderProcessor: IShaderProcessor;
  31937. /**
  31938. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  31939. */
  31940. forcePOTTextures: boolean;
  31941. /**
  31942. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  31943. */
  31944. isFullscreen: boolean;
  31945. /**
  31946. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  31947. */
  31948. cullBackFaces: boolean;
  31949. /**
  31950. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  31951. */
  31952. renderEvenInBackground: boolean;
  31953. /**
  31954. * Gets or sets a boolean indicating that cache can be kept between frames
  31955. */
  31956. preventCacheWipeBetweenFrames: boolean;
  31957. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  31958. validateShaderPrograms: boolean;
  31959. /**
  31960. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  31961. * This can provide greater z depth for distant objects.
  31962. */
  31963. useReverseDepthBuffer: boolean;
  31964. /**
  31965. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  31966. */
  31967. disableUniformBuffers: boolean;
  31968. /** @hidden */
  31969. _uniformBuffers: UniformBuffer[];
  31970. /**
  31971. * Gets a boolean indicating that the engine supports uniform buffers
  31972. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  31973. */
  31974. get supportsUniformBuffers(): boolean;
  31975. /** @hidden */
  31976. _gl: WebGLRenderingContext;
  31977. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  31978. protected _windowIsBackground: boolean;
  31979. protected _webGLVersion: number;
  31980. protected _creationOptions: EngineOptions;
  31981. protected _highPrecisionShadersAllowed: boolean;
  31982. /** @hidden */
  31983. get _shouldUseHighPrecisionShader(): boolean;
  31984. /**
  31985. * Gets a boolean indicating that only power of 2 textures are supported
  31986. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  31987. */
  31988. get needPOTTextures(): boolean;
  31989. /** @hidden */
  31990. _badOS: boolean;
  31991. /** @hidden */
  31992. _badDesktopOS: boolean;
  31993. private _hardwareScalingLevel;
  31994. /** @hidden */
  31995. _caps: EngineCapabilities;
  31996. private _isStencilEnable;
  31997. private _glVersion;
  31998. private _glRenderer;
  31999. private _glVendor;
  32000. /** @hidden */
  32001. _videoTextureSupported: boolean;
  32002. protected _renderingQueueLaunched: boolean;
  32003. protected _activeRenderLoops: (() => void)[];
  32004. /**
  32005. * Observable signaled when a context lost event is raised
  32006. */
  32007. onContextLostObservable: Observable<ThinEngine>;
  32008. /**
  32009. * Observable signaled when a context restored event is raised
  32010. */
  32011. onContextRestoredObservable: Observable<ThinEngine>;
  32012. private _onContextLost;
  32013. private _onContextRestored;
  32014. protected _contextWasLost: boolean;
  32015. /** @hidden */
  32016. _doNotHandleContextLost: boolean;
  32017. /**
  32018. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32019. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32020. */
  32021. get doNotHandleContextLost(): boolean;
  32022. set doNotHandleContextLost(value: boolean);
  32023. /**
  32024. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32025. */
  32026. disableVertexArrayObjects: boolean;
  32027. /** @hidden */
  32028. protected _colorWrite: boolean;
  32029. /** @hidden */
  32030. protected _colorWriteChanged: boolean;
  32031. /** @hidden */
  32032. protected _depthCullingState: DepthCullingState;
  32033. /** @hidden */
  32034. protected _stencilState: StencilState;
  32035. /** @hidden */
  32036. _alphaState: AlphaState;
  32037. /** @hidden */
  32038. _alphaMode: number;
  32039. /** @hidden */
  32040. _alphaEquation: number;
  32041. /** @hidden */
  32042. _internalTexturesCache: InternalTexture[];
  32043. /** @hidden */
  32044. protected _activeChannel: number;
  32045. private _currentTextureChannel;
  32046. /** @hidden */
  32047. protected _boundTexturesCache: {
  32048. [key: string]: Nullable<InternalTexture>;
  32049. };
  32050. /** @hidden */
  32051. protected _currentEffect: Nullable<Effect>;
  32052. /** @hidden */
  32053. protected _currentProgram: Nullable<WebGLProgram>;
  32054. private _compiledEffects;
  32055. private _vertexAttribArraysEnabled;
  32056. /** @hidden */
  32057. protected _cachedViewport: Nullable<IViewportLike>;
  32058. private _cachedVertexArrayObject;
  32059. /** @hidden */
  32060. protected _cachedVertexBuffers: any;
  32061. /** @hidden */
  32062. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32063. /** @hidden */
  32064. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32065. /** @hidden */
  32066. _currentRenderTarget: Nullable<InternalTexture>;
  32067. private _uintIndicesCurrentlySet;
  32068. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32069. /** @hidden */
  32070. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32071. private _currentBufferPointers;
  32072. private _currentInstanceLocations;
  32073. private _currentInstanceBuffers;
  32074. private _textureUnits;
  32075. /** @hidden */
  32076. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32077. /** @hidden */
  32078. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32079. /** @hidden */
  32080. _boundRenderFunction: any;
  32081. private _vaoRecordInProgress;
  32082. private _mustWipeVertexAttributes;
  32083. private _emptyTexture;
  32084. private _emptyCubeTexture;
  32085. private _emptyTexture3D;
  32086. private _emptyTexture2DArray;
  32087. /** @hidden */
  32088. _frameHandler: number;
  32089. private _nextFreeTextureSlots;
  32090. private _maxSimultaneousTextures;
  32091. private _activeRequests;
  32092. protected _texturesSupported: string[];
  32093. /** @hidden */
  32094. _textureFormatInUse: Nullable<string>;
  32095. protected get _supportsHardwareTextureRescaling(): boolean;
  32096. /**
  32097. * Gets the list of texture formats supported
  32098. */
  32099. get texturesSupported(): Array<string>;
  32100. /**
  32101. * Gets the list of texture formats in use
  32102. */
  32103. get textureFormatInUse(): Nullable<string>;
  32104. /**
  32105. * Gets the current viewport
  32106. */
  32107. get currentViewport(): Nullable<IViewportLike>;
  32108. /**
  32109. * Gets the default empty texture
  32110. */
  32111. get emptyTexture(): InternalTexture;
  32112. /**
  32113. * Gets the default empty 3D texture
  32114. */
  32115. get emptyTexture3D(): InternalTexture;
  32116. /**
  32117. * Gets the default empty 2D array texture
  32118. */
  32119. get emptyTexture2DArray(): InternalTexture;
  32120. /**
  32121. * Gets the default empty cube texture
  32122. */
  32123. get emptyCubeTexture(): InternalTexture;
  32124. /**
  32125. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32126. */
  32127. readonly premultipliedAlpha: boolean;
  32128. /**
  32129. * Observable event triggered before each texture is initialized
  32130. */
  32131. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32132. /**
  32133. * Creates a new engine
  32134. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  32135. * @param antialias defines enable antialiasing (default: false)
  32136. * @param options defines further options to be sent to the getContext() function
  32137. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32138. */
  32139. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32140. private _rebuildInternalTextures;
  32141. private _rebuildEffects;
  32142. /**
  32143. * Gets a boolean indicating if all created effects are ready
  32144. * @returns true if all effects are ready
  32145. */
  32146. areAllEffectsReady(): boolean;
  32147. protected _rebuildBuffers(): void;
  32148. private _initGLContext;
  32149. /**
  32150. * Gets version of the current webGL context
  32151. */
  32152. get webGLVersion(): number;
  32153. /**
  32154. * Gets a string idenfifying the name of the class
  32155. * @returns "Engine" string
  32156. */
  32157. getClassName(): string;
  32158. /**
  32159. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32160. */
  32161. get isStencilEnable(): boolean;
  32162. /** @hidden */
  32163. _prepareWorkingCanvas(): void;
  32164. /**
  32165. * Reset the texture cache to empty state
  32166. */
  32167. resetTextureCache(): void;
  32168. /**
  32169. * Gets an object containing information about the current webGL context
  32170. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32171. */
  32172. getGlInfo(): {
  32173. vendor: string;
  32174. renderer: string;
  32175. version: string;
  32176. };
  32177. /**
  32178. * Defines the hardware scaling level.
  32179. * By default the hardware scaling level is computed from the window device ratio.
  32180. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  32181. * @param level defines the level to use
  32182. */
  32183. setHardwareScalingLevel(level: number): void;
  32184. /**
  32185. * Gets the current hardware scaling level.
  32186. * By default the hardware scaling level is computed from the window device ratio.
  32187. * if level = 1 then the engine will render at the exact resolution of the canvas. If level = 0.5 then the engine will render at twice the size of the canvas.
  32188. * @returns a number indicating the current hardware scaling level
  32189. */
  32190. getHardwareScalingLevel(): number;
  32191. /**
  32192. * Gets the list of loaded textures
  32193. * @returns an array containing all loaded textures
  32194. */
  32195. getLoadedTexturesCache(): InternalTexture[];
  32196. /**
  32197. * Gets the object containing all engine capabilities
  32198. * @returns the EngineCapabilities object
  32199. */
  32200. getCaps(): EngineCapabilities;
  32201. /**
  32202. * stop executing a render loop function and remove it from the execution array
  32203. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32204. */
  32205. stopRenderLoop(renderFunction?: () => void): void;
  32206. /** @hidden */
  32207. _renderLoop(): void;
  32208. /**
  32209. * Gets the HTML canvas attached with the current webGL context
  32210. * @returns a HTML canvas
  32211. */
  32212. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32213. /**
  32214. * Gets host window
  32215. * @returns the host window object
  32216. */
  32217. getHostWindow(): Nullable<Window>;
  32218. /**
  32219. * Gets the current render width
  32220. * @param useScreen defines if screen size must be used (or the current render target if any)
  32221. * @returns a number defining the current render width
  32222. */
  32223. getRenderWidth(useScreen?: boolean): number;
  32224. /**
  32225. * Gets the current render height
  32226. * @param useScreen defines if screen size must be used (or the current render target if any)
  32227. * @returns a number defining the current render height
  32228. */
  32229. getRenderHeight(useScreen?: boolean): number;
  32230. /**
  32231. * Can be used to override the current requestAnimationFrame requester.
  32232. * @hidden
  32233. */
  32234. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32235. /**
  32236. * Register and execute a render loop. The engine can have more than one render function
  32237. * @param renderFunction defines the function to continuously execute
  32238. */
  32239. runRenderLoop(renderFunction: () => void): void;
  32240. /**
  32241. * Clear the current render buffer or the current render target (if any is set up)
  32242. * @param color defines the color to use
  32243. * @param backBuffer defines if the back buffer must be cleared
  32244. * @param depth defines if the depth buffer must be cleared
  32245. * @param stencil defines if the stencil buffer must be cleared
  32246. */
  32247. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32248. private _viewportCached;
  32249. /** @hidden */
  32250. _viewport(x: number, y: number, width: number, height: number): void;
  32251. /**
  32252. * Set the WebGL's viewport
  32253. * @param viewport defines the viewport element to be used
  32254. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32255. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32256. */
  32257. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32258. /**
  32259. * Begin a new frame
  32260. */
  32261. beginFrame(): void;
  32262. /**
  32263. * Enf the current frame
  32264. */
  32265. endFrame(): void;
  32266. /**
  32267. * Resize the view according to the canvas' size
  32268. */
  32269. resize(): void;
  32270. /**
  32271. * Force a specific size of the canvas
  32272. * @param width defines the new canvas' width
  32273. * @param height defines the new canvas' height
  32274. */
  32275. setSize(width: number, height: number): void;
  32276. /**
  32277. * Binds the frame buffer to the specified texture.
  32278. * @param texture The texture to render to or null for the default canvas
  32279. * @param faceIndex The face of the texture to render to in case of cube texture
  32280. * @param requiredWidth The width of the target to render to
  32281. * @param requiredHeight The height of the target to render to
  32282. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32283. * @param lodLevel defines the lod level to bind to the frame buffer
  32284. * @param layer defines the 2d array index to bind to frame buffer to
  32285. */
  32286. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32287. /** @hidden */
  32288. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32289. /**
  32290. * Unbind the current render target texture from the webGL context
  32291. * @param texture defines the render target texture to unbind
  32292. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32293. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32294. */
  32295. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32296. /**
  32297. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32298. */
  32299. flushFramebuffer(): void;
  32300. /**
  32301. * Unbind the current render target and bind the default framebuffer
  32302. */
  32303. restoreDefaultFramebuffer(): void;
  32304. /** @hidden */
  32305. protected _resetVertexBufferBinding(): void;
  32306. /**
  32307. * Creates a vertex buffer
  32308. * @param data the data for the vertex buffer
  32309. * @returns the new WebGL static buffer
  32310. */
  32311. createVertexBuffer(data: DataArray): DataBuffer;
  32312. private _createVertexBuffer;
  32313. /**
  32314. * Creates a dynamic vertex buffer
  32315. * @param data the data for the dynamic vertex buffer
  32316. * @returns the new WebGL dynamic buffer
  32317. */
  32318. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32319. protected _resetIndexBufferBinding(): void;
  32320. /**
  32321. * Creates a new index buffer
  32322. * @param indices defines the content of the index buffer
  32323. * @param updatable defines if the index buffer must be updatable
  32324. * @returns a new webGL buffer
  32325. */
  32326. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32327. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32328. /**
  32329. * Bind a webGL buffer to the webGL context
  32330. * @param buffer defines the buffer to bind
  32331. */
  32332. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32333. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32334. private bindBuffer;
  32335. /**
  32336. * update the bound buffer with the given data
  32337. * @param data defines the data to update
  32338. */
  32339. updateArrayBuffer(data: Float32Array): void;
  32340. private _vertexAttribPointer;
  32341. /** @hidden */
  32342. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32343. private _bindVertexBuffersAttributes;
  32344. /**
  32345. * Records a vertex array object
  32346. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32347. * @param vertexBuffers defines the list of vertex buffers to store
  32348. * @param indexBuffer defines the index buffer to store
  32349. * @param effect defines the effect to store
  32350. * @returns the new vertex array object
  32351. */
  32352. recordVertexArrayObject(vertexBuffers: {
  32353. [key: string]: VertexBuffer;
  32354. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32355. /**
  32356. * Bind a specific vertex array object
  32357. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32358. * @param vertexArrayObject defines the vertex array object to bind
  32359. * @param indexBuffer defines the index buffer to bind
  32360. */
  32361. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32362. /**
  32363. * Bind webGl buffers directly to the webGL context
  32364. * @param vertexBuffer defines the vertex buffer to bind
  32365. * @param indexBuffer defines the index buffer to bind
  32366. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32367. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32368. * @param effect defines the effect associated with the vertex buffer
  32369. */
  32370. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32371. private _unbindVertexArrayObject;
  32372. /**
  32373. * Bind a list of vertex buffers to the webGL context
  32374. * @param vertexBuffers defines the list of vertex buffers to bind
  32375. * @param indexBuffer defines the index buffer to bind
  32376. * @param effect defines the effect associated with the vertex buffers
  32377. */
  32378. bindBuffers(vertexBuffers: {
  32379. [key: string]: Nullable<VertexBuffer>;
  32380. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32381. /**
  32382. * Unbind all instance attributes
  32383. */
  32384. unbindInstanceAttributes(): void;
  32385. /**
  32386. * Release and free the memory of a vertex array object
  32387. * @param vao defines the vertex array object to delete
  32388. */
  32389. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32390. /** @hidden */
  32391. _releaseBuffer(buffer: DataBuffer): boolean;
  32392. protected _deleteBuffer(buffer: DataBuffer): void;
  32393. /**
  32394. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32395. * @param instancesBuffer defines the webGL buffer to update and bind
  32396. * @param data defines the data to store in the buffer
  32397. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32398. */
  32399. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32400. /**
  32401. * Bind the content of a webGL buffer used with instantiation
  32402. * @param instancesBuffer defines the webGL buffer to bind
  32403. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32404. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32405. */
  32406. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32407. /**
  32408. * Disable the instance attribute corresponding to the name in parameter
  32409. * @param name defines the name of the attribute to disable
  32410. */
  32411. disableInstanceAttributeByName(name: string): void;
  32412. /**
  32413. * Disable the instance attribute corresponding to the location in parameter
  32414. * @param attributeLocation defines the attribute location of the attribute to disable
  32415. */
  32416. disableInstanceAttribute(attributeLocation: number): void;
  32417. /**
  32418. * Disable the attribute corresponding to the location in parameter
  32419. * @param attributeLocation defines the attribute location of the attribute to disable
  32420. */
  32421. disableAttributeByIndex(attributeLocation: number): void;
  32422. /**
  32423. * Send a draw order
  32424. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32425. * @param indexStart defines the starting index
  32426. * @param indexCount defines the number of index to draw
  32427. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32428. */
  32429. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32430. /**
  32431. * Draw a list of points
  32432. * @param verticesStart defines the index of first vertex to draw
  32433. * @param verticesCount defines the count of vertices to draw
  32434. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32435. */
  32436. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32437. /**
  32438. * Draw a list of unindexed primitives
  32439. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32440. * @param verticesStart defines the index of first vertex to draw
  32441. * @param verticesCount defines the count of vertices to draw
  32442. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32443. */
  32444. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32445. /**
  32446. * Draw a list of indexed primitives
  32447. * @param fillMode defines the primitive to use
  32448. * @param indexStart defines the starting index
  32449. * @param indexCount defines the number of index to draw
  32450. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32451. */
  32452. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32453. /**
  32454. * Draw a list of unindexed primitives
  32455. * @param fillMode defines the primitive to use
  32456. * @param verticesStart defines the index of first vertex to draw
  32457. * @param verticesCount defines the count of vertices to draw
  32458. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32459. */
  32460. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32461. private _drawMode;
  32462. /** @hidden */
  32463. protected _reportDrawCall(): void;
  32464. /** @hidden */
  32465. _releaseEffect(effect: Effect): void;
  32466. /** @hidden */
  32467. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32468. /**
  32469. * Create a new effect (used to store vertex/fragment shaders)
  32470. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32471. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32472. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32473. * @param samplers defines an array of string used to represent textures
  32474. * @param defines defines the string containing the defines to use to compile the shaders
  32475. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32476. * @param onCompiled defines a function to call when the effect creation is successful
  32477. * @param onError defines a function to call when the effect creation has failed
  32478. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32479. * @returns the new Effect
  32480. */
  32481. createEffect(baseName: any, attributesNamesOrOptions: string[] | IEffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  32482. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32483. private _compileShader;
  32484. private _compileRawShader;
  32485. /**
  32486. * Directly creates a webGL program
  32487. * @param pipelineContext defines the pipeline context to attach to
  32488. * @param vertexCode defines the vertex shader code to use
  32489. * @param fragmentCode defines the fragment shader code to use
  32490. * @param context defines the webGL context to use (if not set, the current one will be used)
  32491. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32492. * @returns the new webGL program
  32493. */
  32494. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32495. /**
  32496. * Creates a webGL program
  32497. * @param pipelineContext defines the pipeline context to attach to
  32498. * @param vertexCode defines the vertex shader code to use
  32499. * @param fragmentCode defines the fragment shader code to use
  32500. * @param defines defines the string containing the defines to use to compile the shaders
  32501. * @param context defines the webGL context to use (if not set, the current one will be used)
  32502. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32503. * @returns the new webGL program
  32504. */
  32505. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32506. /**
  32507. * Creates a new pipeline context
  32508. * @returns the new pipeline
  32509. */
  32510. createPipelineContext(): IPipelineContext;
  32511. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32512. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32513. /** @hidden */
  32514. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32515. /** @hidden */
  32516. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32517. /** @hidden */
  32518. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32519. /**
  32520. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32521. * @param pipelineContext defines the pipeline context to use
  32522. * @param uniformsNames defines the list of uniform names
  32523. * @returns an array of webGL uniform locations
  32524. */
  32525. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32526. /**
  32527. * Gets the lsit of active attributes for a given webGL program
  32528. * @param pipelineContext defines the pipeline context to use
  32529. * @param attributesNames defines the list of attribute names to get
  32530. * @returns an array of indices indicating the offset of each attribute
  32531. */
  32532. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32533. /**
  32534. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32535. * @param effect defines the effect to activate
  32536. */
  32537. enableEffect(effect: Nullable<Effect>): void;
  32538. /**
  32539. * Set the value of an uniform to a number (int)
  32540. * @param uniform defines the webGL uniform location where to store the value
  32541. * @param value defines the int number to store
  32542. */
  32543. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32544. /**
  32545. * Set the value of an uniform to an array of int32
  32546. * @param uniform defines the webGL uniform location where to store the value
  32547. * @param array defines the array of int32 to store
  32548. */
  32549. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32550. /**
  32551. * Set the value of an uniform to an array of int32 (stored as vec2)
  32552. * @param uniform defines the webGL uniform location where to store the value
  32553. * @param array defines the array of int32 to store
  32554. */
  32555. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32556. /**
  32557. * Set the value of an uniform to an array of int32 (stored as vec3)
  32558. * @param uniform defines the webGL uniform location where to store the value
  32559. * @param array defines the array of int32 to store
  32560. */
  32561. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32562. /**
  32563. * Set the value of an uniform to an array of int32 (stored as vec4)
  32564. * @param uniform defines the webGL uniform location where to store the value
  32565. * @param array defines the array of int32 to store
  32566. */
  32567. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32568. /**
  32569. * Set the value of an uniform to an array of number
  32570. * @param uniform defines the webGL uniform location where to store the value
  32571. * @param array defines the array of number to store
  32572. */
  32573. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32574. /**
  32575. * Set the value of an uniform to an array of number (stored as vec2)
  32576. * @param uniform defines the webGL uniform location where to store the value
  32577. * @param array defines the array of number to store
  32578. */
  32579. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32580. /**
  32581. * Set the value of an uniform to an array of number (stored as vec3)
  32582. * @param uniform defines the webGL uniform location where to store the value
  32583. * @param array defines the array of number to store
  32584. */
  32585. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32586. /**
  32587. * Set the value of an uniform to an array of number (stored as vec4)
  32588. * @param uniform defines the webGL uniform location where to store the value
  32589. * @param array defines the array of number to store
  32590. */
  32591. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32592. /**
  32593. * Set the value of an uniform to an array of float32 (stored as matrices)
  32594. * @param uniform defines the webGL uniform location where to store the value
  32595. * @param matrices defines the array of float32 to store
  32596. */
  32597. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32598. /**
  32599. * Set the value of an uniform to a matrix (3x3)
  32600. * @param uniform defines the webGL uniform location where to store the value
  32601. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32602. */
  32603. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32604. /**
  32605. * Set the value of an uniform to a matrix (2x2)
  32606. * @param uniform defines the webGL uniform location where to store the value
  32607. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32608. */
  32609. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32610. /**
  32611. * Set the value of an uniform to a number (float)
  32612. * @param uniform defines the webGL uniform location where to store the value
  32613. * @param value defines the float number to store
  32614. */
  32615. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32616. /**
  32617. * Set the value of an uniform to a vec2
  32618. * @param uniform defines the webGL uniform location where to store the value
  32619. * @param x defines the 1st component of the value
  32620. * @param y defines the 2nd component of the value
  32621. */
  32622. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  32623. /**
  32624. * Set the value of an uniform to a vec3
  32625. * @param uniform defines the webGL uniform location where to store the value
  32626. * @param x defines the 1st component of the value
  32627. * @param y defines the 2nd component of the value
  32628. * @param z defines the 3rd component of the value
  32629. */
  32630. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  32631. /**
  32632. * Set the value of an uniform to a vec4
  32633. * @param uniform defines the webGL uniform location where to store the value
  32634. * @param x defines the 1st component of the value
  32635. * @param y defines the 2nd component of the value
  32636. * @param z defines the 3rd component of the value
  32637. * @param w defines the 4th component of the value
  32638. */
  32639. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  32640. /**
  32641. * Apply all cached states (depth, culling, stencil and alpha)
  32642. */
  32643. applyStates(): void;
  32644. /**
  32645. * Enable or disable color writing
  32646. * @param enable defines the state to set
  32647. */
  32648. setColorWrite(enable: boolean): void;
  32649. /**
  32650. * Gets a boolean indicating if color writing is enabled
  32651. * @returns the current color writing state
  32652. */
  32653. getColorWrite(): boolean;
  32654. /**
  32655. * Gets the depth culling state manager
  32656. */
  32657. get depthCullingState(): DepthCullingState;
  32658. /**
  32659. * Gets the alpha state manager
  32660. */
  32661. get alphaState(): AlphaState;
  32662. /**
  32663. * Gets the stencil state manager
  32664. */
  32665. get stencilState(): StencilState;
  32666. /**
  32667. * Clears the list of texture accessible through engine.
  32668. * This can help preventing texture load conflict due to name collision.
  32669. */
  32670. clearInternalTexturesCache(): void;
  32671. /**
  32672. * Force the entire cache to be cleared
  32673. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  32674. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  32675. */
  32676. wipeCaches(bruteForce?: boolean): void;
  32677. /** @hidden */
  32678. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  32679. min: number;
  32680. mag: number;
  32681. };
  32682. /** @hidden */
  32683. _createTexture(): WebGLTexture;
  32684. /**
  32685. * Usually called from Texture.ts.
  32686. * Passed information to create a WebGLTexture
  32687. * @param urlArg defines a value which contains one of the following:
  32688. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  32689. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  32690. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  32691. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  32692. * @param invertY when true, image is flipped when loaded. You probably want true. Certain compressed textures may invert this if their default is inverted (eg. ktx)
  32693. * @param scene needed for loading to the correct scene
  32694. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  32695. * @param onLoad optional callback to be called upon successful completion
  32696. * @param onError optional callback to be called upon failure
  32697. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), HTMLImageElement (image format), or a Blob
  32698. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  32699. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  32700. * @param forcedExtension defines the extension to use to pick the right loader
  32701. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  32702. * @param mimeType defines an optional mime type
  32703. * @returns a InternalTexture for assignment back into BABYLON.Texture
  32704. */
  32705. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  32706. /**
  32707. * Loads an image as an HTMLImageElement.
  32708. * @param input url string, ArrayBuffer, or Blob to load
  32709. * @param onLoad callback called when the image successfully loads
  32710. * @param onError callback called when the image fails to load
  32711. * @param offlineProvider offline provider for caching
  32712. * @param mimeType optional mime type
  32713. * @returns the HTMLImageElement of the loaded image
  32714. * @hidden
  32715. */
  32716. static _FileToolsLoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  32717. /**
  32718. * @hidden
  32719. */
  32720. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32721. /**
  32722. * Creates a raw texture
  32723. * @param data defines the data to store in the texture
  32724. * @param width defines the width of the texture
  32725. * @param height defines the height of the texture
  32726. * @param format defines the format of the data
  32727. * @param generateMipMaps defines if the engine should generate the mip levels
  32728. * @param invertY defines if data must be stored with Y axis inverted
  32729. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  32730. * @param compression defines the compression used (null by default)
  32731. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32732. * @returns the raw texture inside an InternalTexture
  32733. */
  32734. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  32735. /**
  32736. * Creates a new raw cube texture
  32737. * @param data defines the array of data to use to create each face
  32738. * @param size defines the size of the textures
  32739. * @param format defines the format of the data
  32740. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32741. * @param generateMipMaps defines if the engine should generate the mip levels
  32742. * @param invertY defines if data must be stored with Y axis inverted
  32743. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32744. * @param compression defines the compression used (null by default)
  32745. * @returns the cube texture as an InternalTexture
  32746. */
  32747. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  32748. /**
  32749. * Creates a new raw 3D texture
  32750. * @param data defines the data used to create the texture
  32751. * @param width defines the width of the texture
  32752. * @param height defines the height of the texture
  32753. * @param depth defines the depth of the texture
  32754. * @param format defines the format of the texture
  32755. * @param generateMipMaps defines if the engine must generate mip levels
  32756. * @param invertY defines if data must be stored with Y axis inverted
  32757. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32758. * @param compression defines the compressed used (can be null)
  32759. * @param textureType defines the compressed used (can be null)
  32760. * @returns a new raw 3D texture (stored in an InternalTexture)
  32761. */
  32762. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32763. /**
  32764. * Creates a new raw 2D array texture
  32765. * @param data defines the data used to create the texture
  32766. * @param width defines the width of the texture
  32767. * @param height defines the height of the texture
  32768. * @param depth defines the number of layers of the texture
  32769. * @param format defines the format of the texture
  32770. * @param generateMipMaps defines if the engine must generate mip levels
  32771. * @param invertY defines if data must be stored with Y axis inverted
  32772. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32773. * @param compression defines the compressed used (can be null)
  32774. * @param textureType defines the compressed used (can be null)
  32775. * @returns a new raw 2D array texture (stored in an InternalTexture)
  32776. */
  32777. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  32778. private _unpackFlipYCached;
  32779. /**
  32780. * In case you are sharing the context with other applications, it might
  32781. * be interested to not cache the unpack flip y state to ensure a consistent
  32782. * value would be set.
  32783. */
  32784. enableUnpackFlipYCached: boolean;
  32785. /** @hidden */
  32786. _unpackFlipY(value: boolean): void;
  32787. /** @hidden */
  32788. _getUnpackAlignement(): number;
  32789. private _getTextureTarget;
  32790. /**
  32791. * Update the sampling mode of a given texture
  32792. * @param samplingMode defines the required sampling mode
  32793. * @param texture defines the texture to update
  32794. * @param generateMipMaps defines whether to generate mipmaps for the texture
  32795. */
  32796. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  32797. /**
  32798. * Update the sampling mode of a given texture
  32799. * @param texture defines the texture to update
  32800. * @param wrapU defines the texture wrap mode of the u coordinates
  32801. * @param wrapV defines the texture wrap mode of the v coordinates
  32802. * @param wrapR defines the texture wrap mode of the r coordinates
  32803. */
  32804. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  32805. /** @hidden */
  32806. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  32807. width: number;
  32808. height: number;
  32809. layers?: number;
  32810. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  32811. /** @hidden */
  32812. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32813. /** @hidden */
  32814. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  32815. /**
  32816. * Update a portion of an internal texture
  32817. * @param texture defines the texture to update
  32818. * @param imageData defines the data to store into the texture
  32819. * @param xOffset defines the x coordinates of the update rectangle
  32820. * @param yOffset defines the y coordinates of the update rectangle
  32821. * @param width defines the width of the update rectangle
  32822. * @param height defines the height of the update rectangle
  32823. * @param faceIndex defines the face index if texture is a cube (0 by default)
  32824. * @param lod defines the lod level to update (0 by default)
  32825. */
  32826. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  32827. /** @hidden */
  32828. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  32829. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  32830. private _prepareWebGLTexture;
  32831. /** @hidden */
  32832. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  32833. private _getDepthStencilBuffer;
  32834. /** @hidden */
  32835. _releaseFramebufferObjects(texture: InternalTexture): void;
  32836. /** @hidden */
  32837. _releaseTexture(texture: InternalTexture): void;
  32838. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  32839. protected _setProgram(program: WebGLProgram): void;
  32840. protected _boundUniforms: {
  32841. [key: number]: WebGLUniformLocation;
  32842. };
  32843. /**
  32844. * Binds an effect to the webGL context
  32845. * @param effect defines the effect to bind
  32846. */
  32847. bindSamplers(effect: Effect): void;
  32848. private _activateCurrentTexture;
  32849. /** @hidden */
  32850. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  32851. /** @hidden */
  32852. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  32853. /**
  32854. * Unbind all textures from the webGL context
  32855. */
  32856. unbindAllTextures(): void;
  32857. /**
  32858. * Sets a texture to the according uniform.
  32859. * @param channel The texture channel
  32860. * @param uniform The uniform to set
  32861. * @param texture The texture to apply
  32862. */
  32863. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  32864. private _bindSamplerUniformToChannel;
  32865. private _getTextureWrapMode;
  32866. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  32867. /**
  32868. * Sets an array of texture to the webGL context
  32869. * @param channel defines the channel where the texture array must be set
  32870. * @param uniform defines the associated uniform location
  32871. * @param textures defines the array of textures to bind
  32872. */
  32873. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  32874. /** @hidden */
  32875. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  32876. private _setTextureParameterFloat;
  32877. private _setTextureParameterInteger;
  32878. /**
  32879. * Unbind all vertex attributes from the webGL context
  32880. */
  32881. unbindAllAttributes(): void;
  32882. /**
  32883. * Force the engine to release all cached effects. This means that next effect compilation will have to be done completely even if a similar effect was already compiled
  32884. */
  32885. releaseEffects(): void;
  32886. /**
  32887. * Dispose and release all associated resources
  32888. */
  32889. dispose(): void;
  32890. /**
  32891. * Attach a new callback raised when context lost event is fired
  32892. * @param callback defines the callback to call
  32893. */
  32894. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32895. /**
  32896. * Attach a new callback raised when context restored event is fired
  32897. * @param callback defines the callback to call
  32898. */
  32899. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  32900. /**
  32901. * Get the current error code of the webGL context
  32902. * @returns the error code
  32903. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  32904. */
  32905. getError(): number;
  32906. private _canRenderToFloatFramebuffer;
  32907. private _canRenderToHalfFloatFramebuffer;
  32908. private _canRenderToFramebuffer;
  32909. /** @hidden */
  32910. _getWebGLTextureType(type: number): number;
  32911. /** @hidden */
  32912. _getInternalFormat(format: number): number;
  32913. /** @hidden */
  32914. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  32915. /** @hidden */
  32916. _getRGBAMultiSampleBufferFormat(type: number): number;
  32917. /** @hidden */
  32918. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  32919. /**
  32920. * Loads a file from a url
  32921. * @param url url to load
  32922. * @param onSuccess callback called when the file successfully loads
  32923. * @param onProgress callback called while file is loading (if the server supports this mode)
  32924. * @param offlineProvider defines the offline provider for caching
  32925. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  32926. * @param onError callback called when the file fails to load
  32927. * @returns a file request object
  32928. * @hidden
  32929. */
  32930. static _FileToolsLoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  32931. /**
  32932. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32933. * @param x defines the x coordinate of the rectangle where pixels must be read
  32934. * @param y defines the y coordinate of the rectangle where pixels must be read
  32935. * @param width defines the width of the rectangle where pixels must be read
  32936. * @param height defines the height of the rectangle where pixels must be read
  32937. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  32938. * @returns a Uint8Array containing RGBA colors
  32939. */
  32940. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  32941. private static _isSupported;
  32942. /**
  32943. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  32944. * @returns true if the engine can be created
  32945. * @ignorenaming
  32946. */
  32947. static isSupported(): boolean;
  32948. /**
  32949. * Find the next highest power of two.
  32950. * @param x Number to start search from.
  32951. * @return Next highest power of two.
  32952. */
  32953. static CeilingPOT(x: number): number;
  32954. /**
  32955. * Find the next lowest power of two.
  32956. * @param x Number to start search from.
  32957. * @return Next lowest power of two.
  32958. */
  32959. static FloorPOT(x: number): number;
  32960. /**
  32961. * Find the nearest power of two.
  32962. * @param x Number to start search from.
  32963. * @return Next nearest power of two.
  32964. */
  32965. static NearestPOT(x: number): number;
  32966. /**
  32967. * Get the closest exponent of two
  32968. * @param value defines the value to approximate
  32969. * @param max defines the maximum value to return
  32970. * @param mode defines how to define the closest value
  32971. * @returns closest exponent of two of the given value
  32972. */
  32973. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  32974. /**
  32975. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  32976. * @param func - the function to be called
  32977. * @param requester - the object that will request the next frame. Falls back to window.
  32978. * @returns frame number
  32979. */
  32980. static QueueNewFrame(func: () => void, requester?: any): number;
  32981. /**
  32982. * Gets host document
  32983. * @returns the host document object
  32984. */
  32985. getHostDocument(): Nullable<Document>;
  32986. }
  32987. }
  32988. declare module "babylonjs/Maths/sphericalPolynomial" {
  32989. import { Vector3 } from "babylonjs/Maths/math.vector";
  32990. import { Color3 } from "babylonjs/Maths/math.color";
  32991. /**
  32992. * Class representing spherical harmonics coefficients to the 3rd degree
  32993. */
  32994. export class SphericalHarmonics {
  32995. /**
  32996. * Defines whether or not the harmonics have been prescaled for rendering.
  32997. */
  32998. preScaled: boolean;
  32999. /**
  33000. * The l0,0 coefficients of the spherical harmonics
  33001. */
  33002. l00: Vector3;
  33003. /**
  33004. * The l1,-1 coefficients of the spherical harmonics
  33005. */
  33006. l1_1: Vector3;
  33007. /**
  33008. * The l1,0 coefficients of the spherical harmonics
  33009. */
  33010. l10: Vector3;
  33011. /**
  33012. * The l1,1 coefficients of the spherical harmonics
  33013. */
  33014. l11: Vector3;
  33015. /**
  33016. * The l2,-2 coefficients of the spherical harmonics
  33017. */
  33018. l2_2: Vector3;
  33019. /**
  33020. * The l2,-1 coefficients of the spherical harmonics
  33021. */
  33022. l2_1: Vector3;
  33023. /**
  33024. * The l2,0 coefficients of the spherical harmonics
  33025. */
  33026. l20: Vector3;
  33027. /**
  33028. * The l2,1 coefficients of the spherical harmonics
  33029. */
  33030. l21: Vector3;
  33031. /**
  33032. * The l2,2 coefficients of the spherical harmonics
  33033. */
  33034. l22: Vector3;
  33035. /**
  33036. * Adds a light to the spherical harmonics
  33037. * @param direction the direction of the light
  33038. * @param color the color of the light
  33039. * @param deltaSolidAngle the delta solid angle of the light
  33040. */
  33041. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33042. /**
  33043. * Scales the spherical harmonics by the given amount
  33044. * @param scale the amount to scale
  33045. */
  33046. scaleInPlace(scale: number): void;
  33047. /**
  33048. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33049. *
  33050. * ```
  33051. * E_lm = A_l * L_lm
  33052. * ```
  33053. *
  33054. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33055. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33056. * the scaling factors are given in equation 9.
  33057. */
  33058. convertIncidentRadianceToIrradiance(): void;
  33059. /**
  33060. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33061. *
  33062. * ```
  33063. * L = (1/pi) * E * rho
  33064. * ```
  33065. *
  33066. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33067. */
  33068. convertIrradianceToLambertianRadiance(): void;
  33069. /**
  33070. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33071. * required operations at run time.
  33072. *
  33073. * This is simply done by scaling back the SH with Ylm constants parameter.
  33074. * The trigonometric part being applied by the shader at run time.
  33075. */
  33076. preScaleForRendering(): void;
  33077. /**
  33078. * Constructs a spherical harmonics from an array.
  33079. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33080. * @returns the spherical harmonics
  33081. */
  33082. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33083. /**
  33084. * Gets the spherical harmonics from polynomial
  33085. * @param polynomial the spherical polynomial
  33086. * @returns the spherical harmonics
  33087. */
  33088. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33089. }
  33090. /**
  33091. * Class representing spherical polynomial coefficients to the 3rd degree
  33092. */
  33093. export class SphericalPolynomial {
  33094. private _harmonics;
  33095. /**
  33096. * The spherical harmonics used to create the polynomials.
  33097. */
  33098. get preScaledHarmonics(): SphericalHarmonics;
  33099. /**
  33100. * The x coefficients of the spherical polynomial
  33101. */
  33102. x: Vector3;
  33103. /**
  33104. * The y coefficients of the spherical polynomial
  33105. */
  33106. y: Vector3;
  33107. /**
  33108. * The z coefficients of the spherical polynomial
  33109. */
  33110. z: Vector3;
  33111. /**
  33112. * The xx coefficients of the spherical polynomial
  33113. */
  33114. xx: Vector3;
  33115. /**
  33116. * The yy coefficients of the spherical polynomial
  33117. */
  33118. yy: Vector3;
  33119. /**
  33120. * The zz coefficients of the spherical polynomial
  33121. */
  33122. zz: Vector3;
  33123. /**
  33124. * The xy coefficients of the spherical polynomial
  33125. */
  33126. xy: Vector3;
  33127. /**
  33128. * The yz coefficients of the spherical polynomial
  33129. */
  33130. yz: Vector3;
  33131. /**
  33132. * The zx coefficients of the spherical polynomial
  33133. */
  33134. zx: Vector3;
  33135. /**
  33136. * Adds an ambient color to the spherical polynomial
  33137. * @param color the color to add
  33138. */
  33139. addAmbient(color: Color3): void;
  33140. /**
  33141. * Scales the spherical polynomial by the given amount
  33142. * @param scale the amount to scale
  33143. */
  33144. scaleInPlace(scale: number): void;
  33145. /**
  33146. * Gets the spherical polynomial from harmonics
  33147. * @param harmonics the spherical harmonics
  33148. * @returns the spherical polynomial
  33149. */
  33150. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33151. /**
  33152. * Constructs a spherical polynomial from an array.
  33153. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33154. * @returns the spherical polynomial
  33155. */
  33156. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33157. }
  33158. }
  33159. declare module "babylonjs/Materials/Textures/internalTexture" {
  33160. import { Observable } from "babylonjs/Misc/observable";
  33161. import { Nullable, int } from "babylonjs/types";
  33162. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33163. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33164. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33165. /**
  33166. * Defines the source of the internal texture
  33167. */
  33168. export enum InternalTextureSource {
  33169. /**
  33170. * The source of the texture data is unknown
  33171. */
  33172. Unknown = 0,
  33173. /**
  33174. * Texture data comes from an URL
  33175. */
  33176. Url = 1,
  33177. /**
  33178. * Texture data is only used for temporary storage
  33179. */
  33180. Temp = 2,
  33181. /**
  33182. * Texture data comes from raw data (ArrayBuffer)
  33183. */
  33184. Raw = 3,
  33185. /**
  33186. * Texture content is dynamic (video or dynamic texture)
  33187. */
  33188. Dynamic = 4,
  33189. /**
  33190. * Texture content is generated by rendering to it
  33191. */
  33192. RenderTarget = 5,
  33193. /**
  33194. * Texture content is part of a multi render target process
  33195. */
  33196. MultiRenderTarget = 6,
  33197. /**
  33198. * Texture data comes from a cube data file
  33199. */
  33200. Cube = 7,
  33201. /**
  33202. * Texture data comes from a raw cube data
  33203. */
  33204. CubeRaw = 8,
  33205. /**
  33206. * Texture data come from a prefiltered cube data file
  33207. */
  33208. CubePrefiltered = 9,
  33209. /**
  33210. * Texture content is raw 3D data
  33211. */
  33212. Raw3D = 10,
  33213. /**
  33214. * Texture content is raw 2D array data
  33215. */
  33216. Raw2DArray = 11,
  33217. /**
  33218. * Texture content is a depth texture
  33219. */
  33220. Depth = 12,
  33221. /**
  33222. * Texture data comes from a raw cube data encoded with RGBD
  33223. */
  33224. CubeRawRGBD = 13
  33225. }
  33226. /**
  33227. * Class used to store data associated with WebGL texture data for the engine
  33228. * This class should not be used directly
  33229. */
  33230. export class InternalTexture {
  33231. /** @hidden */
  33232. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33233. /**
  33234. * Defines if the texture is ready
  33235. */
  33236. isReady: boolean;
  33237. /**
  33238. * Defines if the texture is a cube texture
  33239. */
  33240. isCube: boolean;
  33241. /**
  33242. * Defines if the texture contains 3D data
  33243. */
  33244. is3D: boolean;
  33245. /**
  33246. * Defines if the texture contains 2D array data
  33247. */
  33248. is2DArray: boolean;
  33249. /**
  33250. * Defines if the texture contains multiview data
  33251. */
  33252. isMultiview: boolean;
  33253. /**
  33254. * Gets the URL used to load this texture
  33255. */
  33256. url: string;
  33257. /**
  33258. * Gets the sampling mode of the texture
  33259. */
  33260. samplingMode: number;
  33261. /**
  33262. * Gets a boolean indicating if the texture needs mipmaps generation
  33263. */
  33264. generateMipMaps: boolean;
  33265. /**
  33266. * Gets the number of samples used by the texture (WebGL2+ only)
  33267. */
  33268. samples: number;
  33269. /**
  33270. * Gets the type of the texture (int, float...)
  33271. */
  33272. type: number;
  33273. /**
  33274. * Gets the format of the texture (RGB, RGBA...)
  33275. */
  33276. format: number;
  33277. /**
  33278. * Observable called when the texture is loaded
  33279. */
  33280. onLoadedObservable: Observable<InternalTexture>;
  33281. /**
  33282. * Gets the width of the texture
  33283. */
  33284. width: number;
  33285. /**
  33286. * Gets the height of the texture
  33287. */
  33288. height: number;
  33289. /**
  33290. * Gets the depth of the texture
  33291. */
  33292. depth: number;
  33293. /**
  33294. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33295. */
  33296. baseWidth: number;
  33297. /**
  33298. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33299. */
  33300. baseHeight: number;
  33301. /**
  33302. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33303. */
  33304. baseDepth: number;
  33305. /**
  33306. * Gets a boolean indicating if the texture is inverted on Y axis
  33307. */
  33308. invertY: boolean;
  33309. /** @hidden */
  33310. _invertVScale: boolean;
  33311. /** @hidden */
  33312. _associatedChannel: number;
  33313. /** @hidden */
  33314. _source: InternalTextureSource;
  33315. /** @hidden */
  33316. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33317. /** @hidden */
  33318. _bufferView: Nullable<ArrayBufferView>;
  33319. /** @hidden */
  33320. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33321. /** @hidden */
  33322. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33323. /** @hidden */
  33324. _size: number;
  33325. /** @hidden */
  33326. _extension: string;
  33327. /** @hidden */
  33328. _files: Nullable<string[]>;
  33329. /** @hidden */
  33330. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33331. /** @hidden */
  33332. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33333. /** @hidden */
  33334. _framebuffer: Nullable<WebGLFramebuffer>;
  33335. /** @hidden */
  33336. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33337. /** @hidden */
  33338. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33339. /** @hidden */
  33340. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33341. /** @hidden */
  33342. _attachments: Nullable<number[]>;
  33343. /** @hidden */
  33344. _cachedCoordinatesMode: Nullable<number>;
  33345. /** @hidden */
  33346. _cachedWrapU: Nullable<number>;
  33347. /** @hidden */
  33348. _cachedWrapV: Nullable<number>;
  33349. /** @hidden */
  33350. _cachedWrapR: Nullable<number>;
  33351. /** @hidden */
  33352. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33353. /** @hidden */
  33354. _isDisabled: boolean;
  33355. /** @hidden */
  33356. _compression: Nullable<string>;
  33357. /** @hidden */
  33358. _generateStencilBuffer: boolean;
  33359. /** @hidden */
  33360. _generateDepthBuffer: boolean;
  33361. /** @hidden */
  33362. _comparisonFunction: number;
  33363. /** @hidden */
  33364. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33365. /** @hidden */
  33366. _lodGenerationScale: number;
  33367. /** @hidden */
  33368. _lodGenerationOffset: number;
  33369. /** @hidden */
  33370. _depthStencilTexture: Nullable<InternalTexture>;
  33371. /** @hidden */
  33372. _colorTextureArray: Nullable<WebGLTexture>;
  33373. /** @hidden */
  33374. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33375. /** @hidden */
  33376. _lodTextureHigh: Nullable<BaseTexture>;
  33377. /** @hidden */
  33378. _lodTextureMid: Nullable<BaseTexture>;
  33379. /** @hidden */
  33380. _lodTextureLow: Nullable<BaseTexture>;
  33381. /** @hidden */
  33382. _isRGBD: boolean;
  33383. /** @hidden */
  33384. _linearSpecularLOD: boolean;
  33385. /** @hidden */
  33386. _irradianceTexture: Nullable<BaseTexture>;
  33387. /** @hidden */
  33388. _webGLTexture: Nullable<WebGLTexture>;
  33389. /** @hidden */
  33390. _references: number;
  33391. private _engine;
  33392. /**
  33393. * Gets the Engine the texture belongs to.
  33394. * @returns The babylon engine
  33395. */
  33396. getEngine(): ThinEngine;
  33397. /**
  33398. * Gets the data source type of the texture
  33399. */
  33400. get source(): InternalTextureSource;
  33401. /**
  33402. * Creates a new InternalTexture
  33403. * @param engine defines the engine to use
  33404. * @param source defines the type of data that will be used
  33405. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33406. */
  33407. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33408. /**
  33409. * Increments the number of references (ie. the number of Texture that point to it)
  33410. */
  33411. incrementReferences(): void;
  33412. /**
  33413. * Change the size of the texture (not the size of the content)
  33414. * @param width defines the new width
  33415. * @param height defines the new height
  33416. * @param depth defines the new depth (1 by default)
  33417. */
  33418. updateSize(width: int, height: int, depth?: int): void;
  33419. /** @hidden */
  33420. _rebuild(): void;
  33421. /** @hidden */
  33422. _swapAndDie(target: InternalTexture): void;
  33423. /**
  33424. * Dispose the current allocated resources
  33425. */
  33426. dispose(): void;
  33427. }
  33428. }
  33429. declare module "babylonjs/Audio/analyser" {
  33430. import { Scene } from "babylonjs/scene";
  33431. /**
  33432. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33433. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33434. */
  33435. export class Analyser {
  33436. /**
  33437. * Gets or sets the smoothing
  33438. * @ignorenaming
  33439. */
  33440. SMOOTHING: number;
  33441. /**
  33442. * Gets or sets the FFT table size
  33443. * @ignorenaming
  33444. */
  33445. FFT_SIZE: number;
  33446. /**
  33447. * Gets or sets the bar graph amplitude
  33448. * @ignorenaming
  33449. */
  33450. BARGRAPHAMPLITUDE: number;
  33451. /**
  33452. * Gets or sets the position of the debug canvas
  33453. * @ignorenaming
  33454. */
  33455. DEBUGCANVASPOS: {
  33456. x: number;
  33457. y: number;
  33458. };
  33459. /**
  33460. * Gets or sets the debug canvas size
  33461. * @ignorenaming
  33462. */
  33463. DEBUGCANVASSIZE: {
  33464. width: number;
  33465. height: number;
  33466. };
  33467. private _byteFreqs;
  33468. private _byteTime;
  33469. private _floatFreqs;
  33470. private _webAudioAnalyser;
  33471. private _debugCanvas;
  33472. private _debugCanvasContext;
  33473. private _scene;
  33474. private _registerFunc;
  33475. private _audioEngine;
  33476. /**
  33477. * Creates a new analyser
  33478. * @param scene defines hosting scene
  33479. */
  33480. constructor(scene: Scene);
  33481. /**
  33482. * Get the number of data values you will have to play with for the visualization
  33483. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33484. * @returns a number
  33485. */
  33486. getFrequencyBinCount(): number;
  33487. /**
  33488. * Gets the current frequency data as a byte array
  33489. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33490. * @returns a Uint8Array
  33491. */
  33492. getByteFrequencyData(): Uint8Array;
  33493. /**
  33494. * Gets the current waveform as a byte array
  33495. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33496. * @returns a Uint8Array
  33497. */
  33498. getByteTimeDomainData(): Uint8Array;
  33499. /**
  33500. * Gets the current frequency data as a float array
  33501. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33502. * @returns a Float32Array
  33503. */
  33504. getFloatFrequencyData(): Float32Array;
  33505. /**
  33506. * Renders the debug canvas
  33507. */
  33508. drawDebugCanvas(): void;
  33509. /**
  33510. * Stops rendering the debug canvas and removes it
  33511. */
  33512. stopDebugCanvas(): void;
  33513. /**
  33514. * Connects two audio nodes
  33515. * @param inputAudioNode defines first node to connect
  33516. * @param outputAudioNode defines second node to connect
  33517. */
  33518. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33519. /**
  33520. * Releases all associated resources
  33521. */
  33522. dispose(): void;
  33523. }
  33524. }
  33525. declare module "babylonjs/Audio/audioEngine" {
  33526. import { IDisposable } from "babylonjs/scene";
  33527. import { Analyser } from "babylonjs/Audio/analyser";
  33528. import { Nullable } from "babylonjs/types";
  33529. import { Observable } from "babylonjs/Misc/observable";
  33530. /**
  33531. * This represents an audio engine and it is responsible
  33532. * to play, synchronize and analyse sounds throughout the application.
  33533. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33534. */
  33535. export interface IAudioEngine extends IDisposable {
  33536. /**
  33537. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33538. */
  33539. readonly canUseWebAudio: boolean;
  33540. /**
  33541. * Gets the current AudioContext if available.
  33542. */
  33543. readonly audioContext: Nullable<AudioContext>;
  33544. /**
  33545. * The master gain node defines the global audio volume of your audio engine.
  33546. */
  33547. readonly masterGain: GainNode;
  33548. /**
  33549. * Gets whether or not mp3 are supported by your browser.
  33550. */
  33551. readonly isMP3supported: boolean;
  33552. /**
  33553. * Gets whether or not ogg are supported by your browser.
  33554. */
  33555. readonly isOGGsupported: boolean;
  33556. /**
  33557. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33558. * @ignoreNaming
  33559. */
  33560. WarnedWebAudioUnsupported: boolean;
  33561. /**
  33562. * Defines if the audio engine relies on a custom unlocked button.
  33563. * In this case, the embedded button will not be displayed.
  33564. */
  33565. useCustomUnlockedButton: boolean;
  33566. /**
  33567. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33568. */
  33569. readonly unlocked: boolean;
  33570. /**
  33571. * Event raised when audio has been unlocked on the browser.
  33572. */
  33573. onAudioUnlockedObservable: Observable<AudioEngine>;
  33574. /**
  33575. * Event raised when audio has been locked on the browser.
  33576. */
  33577. onAudioLockedObservable: Observable<AudioEngine>;
  33578. /**
  33579. * Flags the audio engine in Locked state.
  33580. * This happens due to new browser policies preventing audio to autoplay.
  33581. */
  33582. lock(): void;
  33583. /**
  33584. * Unlocks the audio engine once a user action has been done on the dom.
  33585. * This is helpful to resume play once browser policies have been satisfied.
  33586. */
  33587. unlock(): void;
  33588. }
  33589. /**
  33590. * This represents the default audio engine used in babylon.
  33591. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33592. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33593. */
  33594. export class AudioEngine implements IAudioEngine {
  33595. private _audioContext;
  33596. private _audioContextInitialized;
  33597. private _muteButton;
  33598. private _hostElement;
  33599. /**
  33600. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33601. */
  33602. canUseWebAudio: boolean;
  33603. /**
  33604. * The master gain node defines the global audio volume of your audio engine.
  33605. */
  33606. masterGain: GainNode;
  33607. /**
  33608. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33609. * @ignoreNaming
  33610. */
  33611. WarnedWebAudioUnsupported: boolean;
  33612. /**
  33613. * Gets whether or not mp3 are supported by your browser.
  33614. */
  33615. isMP3supported: boolean;
  33616. /**
  33617. * Gets whether or not ogg are supported by your browser.
  33618. */
  33619. isOGGsupported: boolean;
  33620. /**
  33621. * Gets whether audio has been unlocked on the device.
  33622. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  33623. * a user interaction has happened.
  33624. */
  33625. unlocked: boolean;
  33626. /**
  33627. * Defines if the audio engine relies on a custom unlocked button.
  33628. * In this case, the embedded button will not be displayed.
  33629. */
  33630. useCustomUnlockedButton: boolean;
  33631. /**
  33632. * Event raised when audio has been unlocked on the browser.
  33633. */
  33634. onAudioUnlockedObservable: Observable<AudioEngine>;
  33635. /**
  33636. * Event raised when audio has been locked on the browser.
  33637. */
  33638. onAudioLockedObservable: Observable<AudioEngine>;
  33639. /**
  33640. * Gets the current AudioContext if available.
  33641. */
  33642. get audioContext(): Nullable<AudioContext>;
  33643. private _connectedAnalyser;
  33644. /**
  33645. * Instantiates a new audio engine.
  33646. *
  33647. * There should be only one per page as some browsers restrict the number
  33648. * of audio contexts you can create.
  33649. * @param hostElement defines the host element where to display the mute icon if necessary
  33650. */
  33651. constructor(hostElement?: Nullable<HTMLElement>);
  33652. /**
  33653. * Flags the audio engine in Locked state.
  33654. * This happens due to new browser policies preventing audio to autoplay.
  33655. */
  33656. lock(): void;
  33657. /**
  33658. * Unlocks the audio engine once a user action has been done on the dom.
  33659. * This is helpful to resume play once browser policies have been satisfied.
  33660. */
  33661. unlock(): void;
  33662. private _resumeAudioContext;
  33663. private _initializeAudioContext;
  33664. private _tryToRun;
  33665. private _triggerRunningState;
  33666. private _triggerSuspendedState;
  33667. private _displayMuteButton;
  33668. private _moveButtonToTopLeft;
  33669. private _onResize;
  33670. private _hideMuteButton;
  33671. /**
  33672. * Destroy and release the resources associated with the audio ccontext.
  33673. */
  33674. dispose(): void;
  33675. /**
  33676. * Gets the global volume sets on the master gain.
  33677. * @returns the global volume if set or -1 otherwise
  33678. */
  33679. getGlobalVolume(): number;
  33680. /**
  33681. * Sets the global volume of your experience (sets on the master gain).
  33682. * @param newVolume Defines the new global volume of the application
  33683. */
  33684. setGlobalVolume(newVolume: number): void;
  33685. /**
  33686. * Connect the audio engine to an audio analyser allowing some amazing
  33687. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33688. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33689. * @param analyser The analyser to connect to the engine
  33690. */
  33691. connectToAnalyser(analyser: Analyser): void;
  33692. }
  33693. }
  33694. declare module "babylonjs/Loading/loadingScreen" {
  33695. /**
  33696. * Interface used to present a loading screen while loading a scene
  33697. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33698. */
  33699. export interface ILoadingScreen {
  33700. /**
  33701. * Function called to display the loading screen
  33702. */
  33703. displayLoadingUI: () => void;
  33704. /**
  33705. * Function called to hide the loading screen
  33706. */
  33707. hideLoadingUI: () => void;
  33708. /**
  33709. * Gets or sets the color to use for the background
  33710. */
  33711. loadingUIBackgroundColor: string;
  33712. /**
  33713. * Gets or sets the text to display while loading
  33714. */
  33715. loadingUIText: string;
  33716. }
  33717. /**
  33718. * Class used for the default loading screen
  33719. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33720. */
  33721. export class DefaultLoadingScreen implements ILoadingScreen {
  33722. private _renderingCanvas;
  33723. private _loadingText;
  33724. private _loadingDivBackgroundColor;
  33725. private _loadingDiv;
  33726. private _loadingTextDiv;
  33727. /** Gets or sets the logo url to use for the default loading screen */
  33728. static DefaultLogoUrl: string;
  33729. /** Gets or sets the spinner url to use for the default loading screen */
  33730. static DefaultSpinnerUrl: string;
  33731. /**
  33732. * Creates a new default loading screen
  33733. * @param _renderingCanvas defines the canvas used to render the scene
  33734. * @param _loadingText defines the default text to display
  33735. * @param _loadingDivBackgroundColor defines the default background color
  33736. */
  33737. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  33738. /**
  33739. * Function called to display the loading screen
  33740. */
  33741. displayLoadingUI(): void;
  33742. /**
  33743. * Function called to hide the loading screen
  33744. */
  33745. hideLoadingUI(): void;
  33746. /**
  33747. * Gets or sets the text to display while loading
  33748. */
  33749. set loadingUIText(text: string);
  33750. get loadingUIText(): string;
  33751. /**
  33752. * Gets or sets the color to use for the background
  33753. */
  33754. get loadingUIBackgroundColor(): string;
  33755. set loadingUIBackgroundColor(color: string);
  33756. private _resizeLoadingUI;
  33757. }
  33758. }
  33759. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  33760. /**
  33761. * Interface for any object that can request an animation frame
  33762. */
  33763. export interface ICustomAnimationFrameRequester {
  33764. /**
  33765. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  33766. */
  33767. renderFunction?: Function;
  33768. /**
  33769. * Called to request the next frame to render to
  33770. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  33771. */
  33772. requestAnimationFrame: Function;
  33773. /**
  33774. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  33775. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  33776. */
  33777. requestID?: number;
  33778. }
  33779. }
  33780. declare module "babylonjs/Misc/performanceMonitor" {
  33781. /**
  33782. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  33783. */
  33784. export class PerformanceMonitor {
  33785. private _enabled;
  33786. private _rollingFrameTime;
  33787. private _lastFrameTimeMs;
  33788. /**
  33789. * constructor
  33790. * @param frameSampleSize The number of samples required to saturate the sliding window
  33791. */
  33792. constructor(frameSampleSize?: number);
  33793. /**
  33794. * Samples current frame
  33795. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  33796. */
  33797. sampleFrame(timeMs?: number): void;
  33798. /**
  33799. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33800. */
  33801. get averageFrameTime(): number;
  33802. /**
  33803. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  33804. */
  33805. get averageFrameTimeVariance(): number;
  33806. /**
  33807. * Returns the frame time of the most recent frame
  33808. */
  33809. get instantaneousFrameTime(): number;
  33810. /**
  33811. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  33812. */
  33813. get averageFPS(): number;
  33814. /**
  33815. * Returns the average framerate in frames per second using the most recent frame time
  33816. */
  33817. get instantaneousFPS(): number;
  33818. /**
  33819. * Returns true if enough samples have been taken to completely fill the sliding window
  33820. */
  33821. get isSaturated(): boolean;
  33822. /**
  33823. * Enables contributions to the sliding window sample set
  33824. */
  33825. enable(): void;
  33826. /**
  33827. * Disables contributions to the sliding window sample set
  33828. * Samples will not be interpolated over the disabled period
  33829. */
  33830. disable(): void;
  33831. /**
  33832. * Returns true if sampling is enabled
  33833. */
  33834. get isEnabled(): boolean;
  33835. /**
  33836. * Resets performance monitor
  33837. */
  33838. reset(): void;
  33839. }
  33840. /**
  33841. * RollingAverage
  33842. *
  33843. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  33844. */
  33845. export class RollingAverage {
  33846. /**
  33847. * Current average
  33848. */
  33849. average: number;
  33850. /**
  33851. * Current variance
  33852. */
  33853. variance: number;
  33854. protected _samples: Array<number>;
  33855. protected _sampleCount: number;
  33856. protected _pos: number;
  33857. protected _m2: number;
  33858. /**
  33859. * constructor
  33860. * @param length The number of samples required to saturate the sliding window
  33861. */
  33862. constructor(length: number);
  33863. /**
  33864. * Adds a sample to the sample set
  33865. * @param v The sample value
  33866. */
  33867. add(v: number): void;
  33868. /**
  33869. * Returns previously added values or null if outside of history or outside the sliding window domain
  33870. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  33871. * @return Value previously recorded with add() or null if outside of range
  33872. */
  33873. history(i: number): number;
  33874. /**
  33875. * Returns true if enough samples have been taken to completely fill the sliding window
  33876. * @return true if sample-set saturated
  33877. */
  33878. isSaturated(): boolean;
  33879. /**
  33880. * Resets the rolling average (equivalent to 0 samples taken so far)
  33881. */
  33882. reset(): void;
  33883. /**
  33884. * Wraps a value around the sample range boundaries
  33885. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  33886. * @return Wrapped position in sample range
  33887. */
  33888. protected _wrapPosition(i: number): number;
  33889. }
  33890. }
  33891. declare module "babylonjs/Misc/perfCounter" {
  33892. /**
  33893. * This class is used to track a performance counter which is number based.
  33894. * The user has access to many properties which give statistics of different nature.
  33895. *
  33896. * The implementer can track two kinds of Performance Counter: time and count.
  33897. * For time you can optionally call fetchNewFrame() to notify the start of a new frame to monitor, then call beginMonitoring() to start and endMonitoring() to record the lapsed time. endMonitoring takes a newFrame parameter for you to specify if the monitored time should be set for a new frame or accumulated to the current frame being monitored.
  33898. * For count you first have to call fetchNewFrame() to notify the start of a new frame to monitor, then call addCount() how many time required to increment the count value you monitor.
  33899. */
  33900. export class PerfCounter {
  33901. /**
  33902. * Gets or sets a global boolean to turn on and off all the counters
  33903. */
  33904. static Enabled: boolean;
  33905. /**
  33906. * Returns the smallest value ever
  33907. */
  33908. get min(): number;
  33909. /**
  33910. * Returns the biggest value ever
  33911. */
  33912. get max(): number;
  33913. /**
  33914. * Returns the average value since the performance counter is running
  33915. */
  33916. get average(): number;
  33917. /**
  33918. * Returns the average value of the last second the counter was monitored
  33919. */
  33920. get lastSecAverage(): number;
  33921. /**
  33922. * Returns the current value
  33923. */
  33924. get current(): number;
  33925. /**
  33926. * Gets the accumulated total
  33927. */
  33928. get total(): number;
  33929. /**
  33930. * Gets the total value count
  33931. */
  33932. get count(): number;
  33933. /**
  33934. * Creates a new counter
  33935. */
  33936. constructor();
  33937. /**
  33938. * Call this method to start monitoring a new frame.
  33939. * This scenario is typically used when you accumulate monitoring time many times for a single frame, you call this method at the start of the frame, then beginMonitoring to start recording and endMonitoring(false) to accumulated the recorded time to the PerfCounter or addCount() to accumulate a monitored count.
  33940. */
  33941. fetchNewFrame(): void;
  33942. /**
  33943. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  33944. * @param newCount the count value to add to the monitored count
  33945. * @param fetchResult true when it's the last time in the frame you add to the counter and you wish to update the statistics properties (min/max/average), false if you only want to update statistics.
  33946. */
  33947. addCount(newCount: number, fetchResult: boolean): void;
  33948. /**
  33949. * Start monitoring this performance counter
  33950. */
  33951. beginMonitoring(): void;
  33952. /**
  33953. * Compute the time lapsed since the previous beginMonitoring() call.
  33954. * @param newFrame true by default to fetch the result and monitor a new frame, if false the time monitored will be added to the current frame counter
  33955. */
  33956. endMonitoring(newFrame?: boolean): void;
  33957. private _fetchResult;
  33958. private _startMonitoringTime;
  33959. private _min;
  33960. private _max;
  33961. private _average;
  33962. private _current;
  33963. private _totalValueCount;
  33964. private _totalAccumulated;
  33965. private _lastSecAverage;
  33966. private _lastSecAccumulated;
  33967. private _lastSecTime;
  33968. private _lastSecValueCount;
  33969. }
  33970. }
  33971. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  33972. module "babylonjs/Engines/thinEngine" {
  33973. interface ThinEngine {
  33974. /**
  33975. * Sets alpha constants used by some alpha blending modes
  33976. * @param r defines the red component
  33977. * @param g defines the green component
  33978. * @param b defines the blue component
  33979. * @param a defines the alpha component
  33980. */
  33981. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  33982. /**
  33983. * Sets the current alpha mode
  33984. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  33985. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  33986. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33987. */
  33988. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  33989. /**
  33990. * Gets the current alpha mode
  33991. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  33992. * @returns the current alpha mode
  33993. */
  33994. getAlphaMode(): number;
  33995. /**
  33996. * Sets the current alpha equation
  33997. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  33998. */
  33999. setAlphaEquation(equation: number): void;
  34000. /**
  34001. * Gets the current alpha equation.
  34002. * @returns the current alpha equation
  34003. */
  34004. getAlphaEquation(): number;
  34005. }
  34006. }
  34007. }
  34008. declare module "babylonjs/Engines/engine" {
  34009. import { Observable } from "babylonjs/Misc/observable";
  34010. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34011. import { Scene } from "babylonjs/scene";
  34012. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34013. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34014. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34015. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34016. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34017. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34018. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34019. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34020. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34021. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34022. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34023. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34024. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34025. import "babylonjs/Engines/Extensions/engine.alpha";
  34026. import { Material } from "babylonjs/Materials/material";
  34027. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34028. /**
  34029. * Defines the interface used by display changed events
  34030. */
  34031. export interface IDisplayChangedEventArgs {
  34032. /** Gets the vrDisplay object (if any) */
  34033. vrDisplay: Nullable<any>;
  34034. /** Gets a boolean indicating if webVR is supported */
  34035. vrSupported: boolean;
  34036. }
  34037. /**
  34038. * Defines the interface used by objects containing a viewport (like a camera)
  34039. */
  34040. interface IViewportOwnerLike {
  34041. /**
  34042. * Gets or sets the viewport
  34043. */
  34044. viewport: IViewportLike;
  34045. }
  34046. /**
  34047. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34048. */
  34049. export class Engine extends ThinEngine {
  34050. /** Defines that alpha blending is disabled */
  34051. static readonly ALPHA_DISABLE: number;
  34052. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34053. static readonly ALPHA_ADD: number;
  34054. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34055. static readonly ALPHA_COMBINE: number;
  34056. /** Defines that alpha blending to DEST - SRC * DEST */
  34057. static readonly ALPHA_SUBTRACT: number;
  34058. /** Defines that alpha blending to SRC * DEST */
  34059. static readonly ALPHA_MULTIPLY: number;
  34060. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34061. static readonly ALPHA_MAXIMIZED: number;
  34062. /** Defines that alpha blending to SRC + DEST */
  34063. static readonly ALPHA_ONEONE: number;
  34064. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34065. static readonly ALPHA_PREMULTIPLIED: number;
  34066. /**
  34067. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34068. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34069. */
  34070. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34071. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34072. static readonly ALPHA_INTERPOLATE: number;
  34073. /**
  34074. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34075. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34076. */
  34077. static readonly ALPHA_SCREENMODE: number;
  34078. /** Defines that the ressource is not delayed*/
  34079. static readonly DELAYLOADSTATE_NONE: number;
  34080. /** Defines that the ressource was successfully delay loaded */
  34081. static readonly DELAYLOADSTATE_LOADED: number;
  34082. /** Defines that the ressource is currently delay loading */
  34083. static readonly DELAYLOADSTATE_LOADING: number;
  34084. /** Defines that the ressource is delayed and has not started loading */
  34085. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34086. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34087. static readonly NEVER: number;
  34088. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  34089. static readonly ALWAYS: number;
  34090. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34091. static readonly LESS: number;
  34092. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34093. static readonly EQUAL: number;
  34094. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  34095. static readonly LEQUAL: number;
  34096. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34097. static readonly GREATER: number;
  34098. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  34099. static readonly GEQUAL: number;
  34100. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  34101. static readonly NOTEQUAL: number;
  34102. /** Passed to stencilOperation to specify that stencil value must be kept */
  34103. static readonly KEEP: number;
  34104. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34105. static readonly REPLACE: number;
  34106. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34107. static readonly INCR: number;
  34108. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34109. static readonly DECR: number;
  34110. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34111. static readonly INVERT: number;
  34112. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34113. static readonly INCR_WRAP: number;
  34114. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34115. static readonly DECR_WRAP: number;
  34116. /** Texture is not repeating outside of 0..1 UVs */
  34117. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34118. /** Texture is repeating outside of 0..1 UVs */
  34119. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34120. /** Texture is repeating and mirrored */
  34121. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34122. /** ALPHA */
  34123. static readonly TEXTUREFORMAT_ALPHA: number;
  34124. /** LUMINANCE */
  34125. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34126. /** LUMINANCE_ALPHA */
  34127. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34128. /** RGB */
  34129. static readonly TEXTUREFORMAT_RGB: number;
  34130. /** RGBA */
  34131. static readonly TEXTUREFORMAT_RGBA: number;
  34132. /** RED */
  34133. static readonly TEXTUREFORMAT_RED: number;
  34134. /** RED (2nd reference) */
  34135. static readonly TEXTUREFORMAT_R: number;
  34136. /** RG */
  34137. static readonly TEXTUREFORMAT_RG: number;
  34138. /** RED_INTEGER */
  34139. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34140. /** RED_INTEGER (2nd reference) */
  34141. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34142. /** RG_INTEGER */
  34143. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34144. /** RGB_INTEGER */
  34145. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34146. /** RGBA_INTEGER */
  34147. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34148. /** UNSIGNED_BYTE */
  34149. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34150. /** UNSIGNED_BYTE (2nd reference) */
  34151. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34152. /** FLOAT */
  34153. static readonly TEXTURETYPE_FLOAT: number;
  34154. /** HALF_FLOAT */
  34155. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34156. /** BYTE */
  34157. static readonly TEXTURETYPE_BYTE: number;
  34158. /** SHORT */
  34159. static readonly TEXTURETYPE_SHORT: number;
  34160. /** UNSIGNED_SHORT */
  34161. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34162. /** INT */
  34163. static readonly TEXTURETYPE_INT: number;
  34164. /** UNSIGNED_INT */
  34165. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34166. /** UNSIGNED_SHORT_4_4_4_4 */
  34167. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34168. /** UNSIGNED_SHORT_5_5_5_1 */
  34169. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34170. /** UNSIGNED_SHORT_5_6_5 */
  34171. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34172. /** UNSIGNED_INT_2_10_10_10_REV */
  34173. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34174. /** UNSIGNED_INT_24_8 */
  34175. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34176. /** UNSIGNED_INT_10F_11F_11F_REV */
  34177. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34178. /** UNSIGNED_INT_5_9_9_9_REV */
  34179. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34180. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34181. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34182. /** nearest is mag = nearest and min = nearest and mip = linear */
  34183. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34184. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34185. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34186. /** Trilinear is mag = linear and min = linear and mip = linear */
  34187. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34188. /** nearest is mag = nearest and min = nearest and mip = linear */
  34189. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34190. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34191. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34192. /** Trilinear is mag = linear and min = linear and mip = linear */
  34193. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34194. /** mag = nearest and min = nearest and mip = nearest */
  34195. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34196. /** mag = nearest and min = linear and mip = nearest */
  34197. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34198. /** mag = nearest and min = linear and mip = linear */
  34199. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34200. /** mag = nearest and min = linear and mip = none */
  34201. static readonly TEXTURE_NEAREST_LINEAR: number;
  34202. /** mag = nearest and min = nearest and mip = none */
  34203. static readonly TEXTURE_NEAREST_NEAREST: number;
  34204. /** mag = linear and min = nearest and mip = nearest */
  34205. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34206. /** mag = linear and min = nearest and mip = linear */
  34207. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34208. /** mag = linear and min = linear and mip = none */
  34209. static readonly TEXTURE_LINEAR_LINEAR: number;
  34210. /** mag = linear and min = nearest and mip = none */
  34211. static readonly TEXTURE_LINEAR_NEAREST: number;
  34212. /** Explicit coordinates mode */
  34213. static readonly TEXTURE_EXPLICIT_MODE: number;
  34214. /** Spherical coordinates mode */
  34215. static readonly TEXTURE_SPHERICAL_MODE: number;
  34216. /** Planar coordinates mode */
  34217. static readonly TEXTURE_PLANAR_MODE: number;
  34218. /** Cubic coordinates mode */
  34219. static readonly TEXTURE_CUBIC_MODE: number;
  34220. /** Projection coordinates mode */
  34221. static readonly TEXTURE_PROJECTION_MODE: number;
  34222. /** Skybox coordinates mode */
  34223. static readonly TEXTURE_SKYBOX_MODE: number;
  34224. /** Inverse Cubic coordinates mode */
  34225. static readonly TEXTURE_INVCUBIC_MODE: number;
  34226. /** Equirectangular coordinates mode */
  34227. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34228. /** Equirectangular Fixed coordinates mode */
  34229. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34230. /** Equirectangular Fixed Mirrored coordinates mode */
  34231. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34232. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34233. static readonly SCALEMODE_FLOOR: number;
  34234. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34235. static readonly SCALEMODE_NEAREST: number;
  34236. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34237. static readonly SCALEMODE_CEILING: number;
  34238. /**
  34239. * Returns the current npm package of the sdk
  34240. */
  34241. static get NpmPackage(): string;
  34242. /**
  34243. * Returns the current version of the framework
  34244. */
  34245. static get Version(): string;
  34246. /** Gets the list of created engines */
  34247. static get Instances(): Engine[];
  34248. /**
  34249. * Gets the latest created engine
  34250. */
  34251. static get LastCreatedEngine(): Nullable<Engine>;
  34252. /**
  34253. * Gets the latest created scene
  34254. */
  34255. static get LastCreatedScene(): Nullable<Scene>;
  34256. /**
  34257. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34258. * @param flag defines which part of the materials must be marked as dirty
  34259. * @param predicate defines a predicate used to filter which materials should be affected
  34260. */
  34261. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34262. /**
  34263. * Method called to create the default loading screen.
  34264. * This can be overriden in your own app.
  34265. * @param canvas The rendering canvas element
  34266. * @returns The loading screen
  34267. */
  34268. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34269. /**
  34270. * Method called to create the default rescale post process on each engine.
  34271. */
  34272. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34273. /**
  34274. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34275. **/
  34276. enableOfflineSupport: boolean;
  34277. /**
  34278. * Gets or sets a boolean to enable/disable checking manifest if IndexedDB support is enabled (js will always consider the database is up to date)
  34279. **/
  34280. disableManifestCheck: boolean;
  34281. /**
  34282. * Gets the list of created scenes
  34283. */
  34284. scenes: Scene[];
  34285. /**
  34286. * Event raised when a new scene is created
  34287. */
  34288. onNewSceneAddedObservable: Observable<Scene>;
  34289. /**
  34290. * Gets the list of created postprocesses
  34291. */
  34292. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34293. /**
  34294. * Gets a boolean indicating if the pointer is currently locked
  34295. */
  34296. isPointerLock: boolean;
  34297. /**
  34298. * Observable event triggered each time the rendering canvas is resized
  34299. */
  34300. onResizeObservable: Observable<Engine>;
  34301. /**
  34302. * Observable event triggered each time the canvas loses focus
  34303. */
  34304. onCanvasBlurObservable: Observable<Engine>;
  34305. /**
  34306. * Observable event triggered each time the canvas gains focus
  34307. */
  34308. onCanvasFocusObservable: Observable<Engine>;
  34309. /**
  34310. * Observable event triggered each time the canvas receives pointerout event
  34311. */
  34312. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34313. /**
  34314. * Observable raised when the engine begins a new frame
  34315. */
  34316. onBeginFrameObservable: Observable<Engine>;
  34317. /**
  34318. * If set, will be used to request the next animation frame for the render loop
  34319. */
  34320. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34321. /**
  34322. * Observable raised when the engine ends the current frame
  34323. */
  34324. onEndFrameObservable: Observable<Engine>;
  34325. /**
  34326. * Observable raised when the engine is about to compile a shader
  34327. */
  34328. onBeforeShaderCompilationObservable: Observable<Engine>;
  34329. /**
  34330. * Observable raised when the engine has jsut compiled a shader
  34331. */
  34332. onAfterShaderCompilationObservable: Observable<Engine>;
  34333. /**
  34334. * Gets the audio engine
  34335. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34336. * @ignorenaming
  34337. */
  34338. static audioEngine: IAudioEngine;
  34339. /**
  34340. * Default AudioEngine factory responsible of creating the Audio Engine.
  34341. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34342. */
  34343. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34344. /**
  34345. * Default offline support factory responsible of creating a tool used to store data locally.
  34346. * By default, this will create a Database object if the workload has been embedded.
  34347. */
  34348. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34349. private _loadingScreen;
  34350. private _pointerLockRequested;
  34351. private _dummyFramebuffer;
  34352. private _rescalePostProcess;
  34353. private _deterministicLockstep;
  34354. private _lockstepMaxSteps;
  34355. private _timeStep;
  34356. protected get _supportsHardwareTextureRescaling(): boolean;
  34357. private _fps;
  34358. private _deltaTime;
  34359. /** @hidden */
  34360. _drawCalls: PerfCounter;
  34361. /** Gets or sets the tab index to set to the rendering canvas. 1 is the minimum value to set to be able to capture keyboard events */
  34362. canvasTabIndex: number;
  34363. /**
  34364. * Turn this value on if you want to pause FPS computation when in background
  34365. */
  34366. disablePerformanceMonitorInBackground: boolean;
  34367. private _performanceMonitor;
  34368. /**
  34369. * Gets the performance monitor attached to this engine
  34370. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34371. */
  34372. get performanceMonitor(): PerformanceMonitor;
  34373. private _onFocus;
  34374. private _onBlur;
  34375. private _onCanvasPointerOut;
  34376. private _onCanvasBlur;
  34377. private _onCanvasFocus;
  34378. private _onFullscreenChange;
  34379. private _onPointerLockChange;
  34380. /**
  34381. * Gets the HTML element used to attach event listeners
  34382. * @returns a HTML element
  34383. */
  34384. getInputElement(): Nullable<HTMLElement>;
  34385. /**
  34386. * Creates a new engine
  34387. * @param canvasOrContext defines the canvas or WebGL context to use for rendering. If you provide a WebGL context, Babylon.js will not hook events on the canvas (like pointers, keyboards, etc...) so no event observables will be available. This is mostly used when Babylon.js is used as a plugin on a system which alreay used the WebGL context
  34388. * @param antialias defines enable antialiasing (default: false)
  34389. * @param options defines further options to be sent to the getContext() function
  34390. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34391. */
  34392. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34393. /**
  34394. * Gets current aspect ratio
  34395. * @param viewportOwner defines the camera to use to get the aspect ratio
  34396. * @param useScreen defines if screen size must be used (or the current render target if any)
  34397. * @returns a number defining the aspect ratio
  34398. */
  34399. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34400. /**
  34401. * Gets current screen aspect ratio
  34402. * @returns a number defining the aspect ratio
  34403. */
  34404. getScreenAspectRatio(): number;
  34405. /**
  34406. * Gets the client rect of the HTML canvas attached with the current webGL context
  34407. * @returns a client rectanglee
  34408. */
  34409. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34410. /**
  34411. * Gets the client rect of the HTML element used for events
  34412. * @returns a client rectanglee
  34413. */
  34414. getInputElementClientRect(): Nullable<ClientRect>;
  34415. /**
  34416. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34417. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34418. * @returns true if engine is in deterministic lock step mode
  34419. */
  34420. isDeterministicLockStep(): boolean;
  34421. /**
  34422. * Gets the max steps when engine is running in deterministic lock step
  34423. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34424. * @returns the max steps
  34425. */
  34426. getLockstepMaxSteps(): number;
  34427. /**
  34428. * Returns the time in ms between steps when using deterministic lock step.
  34429. * @returns time step in (ms)
  34430. */
  34431. getTimeStep(): number;
  34432. /**
  34433. * Force the mipmap generation for the given render target texture
  34434. * @param texture defines the render target texture to use
  34435. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34436. */
  34437. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34438. /** States */
  34439. /**
  34440. * Set various states to the webGL context
  34441. * @param culling defines backface culling state
  34442. * @param zOffset defines the value to apply to zOffset (0 by default)
  34443. * @param force defines if states must be applied even if cache is up to date
  34444. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34445. */
  34446. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34447. /**
  34448. * Set the z offset to apply to current rendering
  34449. * @param value defines the offset to apply
  34450. */
  34451. setZOffset(value: number): void;
  34452. /**
  34453. * Gets the current value of the zOffset
  34454. * @returns the current zOffset state
  34455. */
  34456. getZOffset(): number;
  34457. /**
  34458. * Enable or disable depth buffering
  34459. * @param enable defines the state to set
  34460. */
  34461. setDepthBuffer(enable: boolean): void;
  34462. /**
  34463. * Gets a boolean indicating if depth writing is enabled
  34464. * @returns the current depth writing state
  34465. */
  34466. getDepthWrite(): boolean;
  34467. /**
  34468. * Enable or disable depth writing
  34469. * @param enable defines the state to set
  34470. */
  34471. setDepthWrite(enable: boolean): void;
  34472. /**
  34473. * Gets a boolean indicating if stencil buffer is enabled
  34474. * @returns the current stencil buffer state
  34475. */
  34476. getStencilBuffer(): boolean;
  34477. /**
  34478. * Enable or disable the stencil buffer
  34479. * @param enable defines if the stencil buffer must be enabled or disabled
  34480. */
  34481. setStencilBuffer(enable: boolean): void;
  34482. /**
  34483. * Gets the current stencil mask
  34484. * @returns a number defining the new stencil mask to use
  34485. */
  34486. getStencilMask(): number;
  34487. /**
  34488. * Sets the current stencil mask
  34489. * @param mask defines the new stencil mask to use
  34490. */
  34491. setStencilMask(mask: number): void;
  34492. /**
  34493. * Gets the current stencil function
  34494. * @returns a number defining the stencil function to use
  34495. */
  34496. getStencilFunction(): number;
  34497. /**
  34498. * Gets the current stencil reference value
  34499. * @returns a number defining the stencil reference value to use
  34500. */
  34501. getStencilFunctionReference(): number;
  34502. /**
  34503. * Gets the current stencil mask
  34504. * @returns a number defining the stencil mask to use
  34505. */
  34506. getStencilFunctionMask(): number;
  34507. /**
  34508. * Sets the current stencil function
  34509. * @param stencilFunc defines the new stencil function to use
  34510. */
  34511. setStencilFunction(stencilFunc: number): void;
  34512. /**
  34513. * Sets the current stencil reference
  34514. * @param reference defines the new stencil reference to use
  34515. */
  34516. setStencilFunctionReference(reference: number): void;
  34517. /**
  34518. * Sets the current stencil mask
  34519. * @param mask defines the new stencil mask to use
  34520. */
  34521. setStencilFunctionMask(mask: number): void;
  34522. /**
  34523. * Gets the current stencil operation when stencil fails
  34524. * @returns a number defining stencil operation to use when stencil fails
  34525. */
  34526. getStencilOperationFail(): number;
  34527. /**
  34528. * Gets the current stencil operation when depth fails
  34529. * @returns a number defining stencil operation to use when depth fails
  34530. */
  34531. getStencilOperationDepthFail(): number;
  34532. /**
  34533. * Gets the current stencil operation when stencil passes
  34534. * @returns a number defining stencil operation to use when stencil passes
  34535. */
  34536. getStencilOperationPass(): number;
  34537. /**
  34538. * Sets the stencil operation to use when stencil fails
  34539. * @param operation defines the stencil operation to use when stencil fails
  34540. */
  34541. setStencilOperationFail(operation: number): void;
  34542. /**
  34543. * Sets the stencil operation to use when depth fails
  34544. * @param operation defines the stencil operation to use when depth fails
  34545. */
  34546. setStencilOperationDepthFail(operation: number): void;
  34547. /**
  34548. * Sets the stencil operation to use when stencil passes
  34549. * @param operation defines the stencil operation to use when stencil passes
  34550. */
  34551. setStencilOperationPass(operation: number): void;
  34552. /**
  34553. * Sets a boolean indicating if the dithering state is enabled or disabled
  34554. * @param value defines the dithering state
  34555. */
  34556. setDitheringState(value: boolean): void;
  34557. /**
  34558. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34559. * @param value defines the rasterizer state
  34560. */
  34561. setRasterizerState(value: boolean): void;
  34562. /**
  34563. * Gets the current depth function
  34564. * @returns a number defining the depth function
  34565. */
  34566. getDepthFunction(): Nullable<number>;
  34567. /**
  34568. * Sets the current depth function
  34569. * @param depthFunc defines the function to use
  34570. */
  34571. setDepthFunction(depthFunc: number): void;
  34572. /**
  34573. * Sets the current depth function to GREATER
  34574. */
  34575. setDepthFunctionToGreater(): void;
  34576. /**
  34577. * Sets the current depth function to GEQUAL
  34578. */
  34579. setDepthFunctionToGreaterOrEqual(): void;
  34580. /**
  34581. * Sets the current depth function to LESS
  34582. */
  34583. setDepthFunctionToLess(): void;
  34584. /**
  34585. * Sets the current depth function to LEQUAL
  34586. */
  34587. setDepthFunctionToLessOrEqual(): void;
  34588. private _cachedStencilBuffer;
  34589. private _cachedStencilFunction;
  34590. private _cachedStencilMask;
  34591. private _cachedStencilOperationPass;
  34592. private _cachedStencilOperationFail;
  34593. private _cachedStencilOperationDepthFail;
  34594. private _cachedStencilReference;
  34595. /**
  34596. * Caches the the state of the stencil buffer
  34597. */
  34598. cacheStencilState(): void;
  34599. /**
  34600. * Restores the state of the stencil buffer
  34601. */
  34602. restoreStencilState(): void;
  34603. /**
  34604. * Directly set the WebGL Viewport
  34605. * @param x defines the x coordinate of the viewport (in screen space)
  34606. * @param y defines the y coordinate of the viewport (in screen space)
  34607. * @param width defines the width of the viewport (in screen space)
  34608. * @param height defines the height of the viewport (in screen space)
  34609. * @return the current viewport Object (if any) that is being replaced by this call. You can restore this viewport later on to go back to the original state
  34610. */
  34611. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  34612. /**
  34613. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  34614. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34615. * @param y defines the y-coordinate of the corner of the clear rectangle
  34616. * @param width defines the width of the clear rectangle
  34617. * @param height defines the height of the clear rectangle
  34618. * @param clearColor defines the clear color
  34619. */
  34620. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  34621. /**
  34622. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  34623. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  34624. * @param y defines the y-coordinate of the corner of the clear rectangle
  34625. * @param width defines the width of the clear rectangle
  34626. * @param height defines the height of the clear rectangle
  34627. */
  34628. enableScissor(x: number, y: number, width: number, height: number): void;
  34629. /**
  34630. * Disable previously set scissor test rectangle
  34631. */
  34632. disableScissor(): void;
  34633. protected _reportDrawCall(): void;
  34634. /**
  34635. * Initializes a webVR display and starts listening to display change events
  34636. * The onVRDisplayChangedObservable will be notified upon these changes
  34637. * @returns The onVRDisplayChangedObservable
  34638. */
  34639. initWebVR(): Observable<IDisplayChangedEventArgs>;
  34640. /** @hidden */
  34641. _prepareVRComponent(): void;
  34642. /** @hidden */
  34643. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  34644. /** @hidden */
  34645. _submitVRFrame(): void;
  34646. /**
  34647. * Call this function to leave webVR mode
  34648. * Will do nothing if webVR is not supported or if there is no webVR device
  34649. * @see http://doc.babylonjs.com/how_to/webvr_camera
  34650. */
  34651. disableVR(): void;
  34652. /**
  34653. * Gets a boolean indicating that the system is in VR mode and is presenting
  34654. * @returns true if VR mode is engaged
  34655. */
  34656. isVRPresenting(): boolean;
  34657. /** @hidden */
  34658. _requestVRFrame(): void;
  34659. /** @hidden */
  34660. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34661. /**
  34662. * Gets the source code of the vertex shader associated with a specific webGL program
  34663. * @param program defines the program to use
  34664. * @returns a string containing the source code of the vertex shader associated with the program
  34665. */
  34666. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  34667. /**
  34668. * Gets the source code of the fragment shader associated with a specific webGL program
  34669. * @param program defines the program to use
  34670. * @returns a string containing the source code of the fragment shader associated with the program
  34671. */
  34672. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  34673. /**
  34674. * Sets a depth stencil texture from a render target to the according uniform.
  34675. * @param channel The texture channel
  34676. * @param uniform The uniform to set
  34677. * @param texture The render target texture containing the depth stencil texture to apply
  34678. */
  34679. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  34680. /**
  34681. * Sets a texture to the webGL context from a postprocess
  34682. * @param channel defines the channel to use
  34683. * @param postProcess defines the source postprocess
  34684. */
  34685. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  34686. /**
  34687. * Binds the output of the passed in post process to the texture channel specified
  34688. * @param channel The channel the texture should be bound to
  34689. * @param postProcess The post process which's output should be bound
  34690. */
  34691. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  34692. /** @hidden */
  34693. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  34694. protected _rebuildBuffers(): void;
  34695. /** @hidden */
  34696. _renderFrame(): void;
  34697. _renderLoop(): void;
  34698. /** @hidden */
  34699. _renderViews(): boolean;
  34700. /**
  34701. * Toggle full screen mode
  34702. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34703. */
  34704. switchFullscreen(requestPointerLock: boolean): void;
  34705. /**
  34706. * Enters full screen mode
  34707. * @param requestPointerLock defines if a pointer lock should be requested from the user
  34708. */
  34709. enterFullscreen(requestPointerLock: boolean): void;
  34710. /**
  34711. * Exits full screen mode
  34712. */
  34713. exitFullscreen(): void;
  34714. /**
  34715. * Enters Pointerlock mode
  34716. */
  34717. enterPointerlock(): void;
  34718. /**
  34719. * Exits Pointerlock mode
  34720. */
  34721. exitPointerlock(): void;
  34722. /**
  34723. * Begin a new frame
  34724. */
  34725. beginFrame(): void;
  34726. /**
  34727. * Enf the current frame
  34728. */
  34729. endFrame(): void;
  34730. resize(): void;
  34731. /**
  34732. * Set the compressed texture format to use, based on the formats you have, and the formats
  34733. * supported by the hardware / browser.
  34734. *
  34735. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  34736. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  34737. * to API arguments needed to compressed textures. This puts the burden on the container
  34738. * generator to house the arcane code for determining these for current & future formats.
  34739. *
  34740. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  34741. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  34742. *
  34743. * Note: The result of this call is not taken into account when a texture is base64.
  34744. *
  34745. * @param formatsAvailable defines the list of those format families you have created
  34746. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  34747. *
  34748. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  34749. * @returns The extension selected.
  34750. */
  34751. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  34752. /**
  34753. * Set the compressed texture extensions or file names to skip.
  34754. *
  34755. * @param skippedFiles defines the list of those texture files you want to skip
  34756. * Example: [".dds", ".env", "myfile.png"]
  34757. */
  34758. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  34759. /**
  34760. * Force a specific size of the canvas
  34761. * @param width defines the new canvas' width
  34762. * @param height defines the new canvas' height
  34763. */
  34764. setSize(width: number, height: number): void;
  34765. /**
  34766. * Updates a dynamic vertex buffer.
  34767. * @param vertexBuffer the vertex buffer to update
  34768. * @param data the data used to update the vertex buffer
  34769. * @param byteOffset the byte offset of the data
  34770. * @param byteLength the byte length of the data
  34771. */
  34772. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  34773. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  34774. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34775. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  34776. _releaseTexture(texture: InternalTexture): void;
  34777. /**
  34778. * @hidden
  34779. * Rescales a texture
  34780. * @param source input texutre
  34781. * @param destination destination texture
  34782. * @param scene scene to use to render the resize
  34783. * @param internalFormat format to use when resizing
  34784. * @param onComplete callback to be called when resize has completed
  34785. */
  34786. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  34787. /**
  34788. * Gets the current framerate
  34789. * @returns a number representing the framerate
  34790. */
  34791. getFps(): number;
  34792. /**
  34793. * Gets the time spent between current and previous frame
  34794. * @returns a number representing the delta time in ms
  34795. */
  34796. getDeltaTime(): number;
  34797. private _measureFps;
  34798. /** @hidden */
  34799. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  34800. /**
  34801. * Update a dynamic index buffer
  34802. * @param indexBuffer defines the target index buffer
  34803. * @param indices defines the data to update
  34804. * @param offset defines the offset in the target index buffer where update should start
  34805. */
  34806. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  34807. /**
  34808. * Updates the sample count of a render target texture
  34809. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  34810. * @param texture defines the texture to update
  34811. * @param samples defines the sample count to set
  34812. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  34813. */
  34814. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  34815. /**
  34816. * Updates a depth texture Comparison Mode and Function.
  34817. * If the comparison Function is equal to 0, the mode will be set to none.
  34818. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  34819. * @param texture The texture to set the comparison function for
  34820. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  34821. */
  34822. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  34823. /**
  34824. * Creates a webGL buffer to use with instanciation
  34825. * @param capacity defines the size of the buffer
  34826. * @returns the webGL buffer
  34827. */
  34828. createInstancesBuffer(capacity: number): DataBuffer;
  34829. /**
  34830. * Delete a webGL buffer used with instanciation
  34831. * @param buffer defines the webGL buffer to delete
  34832. */
  34833. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  34834. /** @hidden */
  34835. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  34836. dispose(): void;
  34837. private _disableTouchAction;
  34838. /**
  34839. * Display the loading screen
  34840. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34841. */
  34842. displayLoadingUI(): void;
  34843. /**
  34844. * Hide the loading screen
  34845. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34846. */
  34847. hideLoadingUI(): void;
  34848. /**
  34849. * Gets the current loading screen object
  34850. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34851. */
  34852. get loadingScreen(): ILoadingScreen;
  34853. /**
  34854. * Sets the current loading screen object
  34855. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34856. */
  34857. set loadingScreen(loadingScreen: ILoadingScreen);
  34858. /**
  34859. * Sets the current loading screen text
  34860. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34861. */
  34862. set loadingUIText(text: string);
  34863. /**
  34864. * Sets the current loading screen background color
  34865. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34866. */
  34867. set loadingUIBackgroundColor(color: string);
  34868. /** Pointerlock and fullscreen */
  34869. /**
  34870. * Ask the browser to promote the current element to pointerlock mode
  34871. * @param element defines the DOM element to promote
  34872. */
  34873. static _RequestPointerlock(element: HTMLElement): void;
  34874. /**
  34875. * Asks the browser to exit pointerlock mode
  34876. */
  34877. static _ExitPointerlock(): void;
  34878. /**
  34879. * Ask the browser to promote the current element to fullscreen rendering mode
  34880. * @param element defines the DOM element to promote
  34881. */
  34882. static _RequestFullscreen(element: HTMLElement): void;
  34883. /**
  34884. * Asks the browser to exit fullscreen mode
  34885. */
  34886. static _ExitFullscreen(): void;
  34887. }
  34888. }
  34889. declare module "babylonjs/Engines/engineStore" {
  34890. import { Nullable } from "babylonjs/types";
  34891. import { Engine } from "babylonjs/Engines/engine";
  34892. import { Scene } from "babylonjs/scene";
  34893. /**
  34894. * The engine store class is responsible to hold all the instances of Engine and Scene created
  34895. * during the life time of the application.
  34896. */
  34897. export class EngineStore {
  34898. /** Gets the list of created engines */
  34899. static Instances: import("babylonjs/Engines/engine").Engine[];
  34900. /** @hidden */
  34901. static _LastCreatedScene: Nullable<Scene>;
  34902. /**
  34903. * Gets the latest created engine
  34904. */
  34905. static get LastCreatedEngine(): Nullable<Engine>;
  34906. /**
  34907. * Gets the latest created scene
  34908. */
  34909. static get LastCreatedScene(): Nullable<Scene>;
  34910. /**
  34911. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  34912. * @ignorenaming
  34913. */
  34914. static UseFallbackTexture: boolean;
  34915. /**
  34916. * Texture content used if a texture cannot loaded
  34917. * @ignorenaming
  34918. */
  34919. static FallbackTexture: string;
  34920. }
  34921. }
  34922. declare module "babylonjs/Misc/promise" {
  34923. /**
  34924. * Helper class that provides a small promise polyfill
  34925. */
  34926. export class PromisePolyfill {
  34927. /**
  34928. * Static function used to check if the polyfill is required
  34929. * If this is the case then the function will inject the polyfill to window.Promise
  34930. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  34931. */
  34932. static Apply(force?: boolean): void;
  34933. }
  34934. }
  34935. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  34936. /**
  34937. * Interface for screenshot methods with describe argument called `size` as object with options
  34938. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  34939. */
  34940. export interface IScreenshotSize {
  34941. /**
  34942. * number in pixels for canvas height
  34943. */
  34944. height?: number;
  34945. /**
  34946. * multiplier allowing render at a higher or lower resolution
  34947. * If value is defined then height and width will be ignored and taken from camera
  34948. */
  34949. precision?: number;
  34950. /**
  34951. * number in pixels for canvas width
  34952. */
  34953. width?: number;
  34954. }
  34955. }
  34956. declare module "babylonjs/Misc/tools" {
  34957. import { Nullable, float } from "babylonjs/types";
  34958. import { DomManagement } from "babylonjs/Misc/domManagement";
  34959. import { WebRequest } from "babylonjs/Misc/webRequest";
  34960. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  34961. import { ReadFileError } from "babylonjs/Misc/fileTools";
  34962. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34963. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  34964. import { Camera } from "babylonjs/Cameras/camera";
  34965. import { Engine } from "babylonjs/Engines/engine";
  34966. interface IColor4Like {
  34967. r: float;
  34968. g: float;
  34969. b: float;
  34970. a: float;
  34971. }
  34972. /**
  34973. * Class containing a set of static utilities functions
  34974. */
  34975. export class Tools {
  34976. /**
  34977. * Gets or sets the base URL to use to load assets
  34978. */
  34979. static get BaseUrl(): string;
  34980. static set BaseUrl(value: string);
  34981. /**
  34982. * Enable/Disable Custom HTTP Request Headers globally.
  34983. * default = false
  34984. * @see CustomRequestHeaders
  34985. */
  34986. static UseCustomRequestHeaders: boolean;
  34987. /**
  34988. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  34989. * i.e. when loading files, where the server/service expects an Authorization header
  34990. */
  34991. static CustomRequestHeaders: {
  34992. [key: string]: string;
  34993. };
  34994. /**
  34995. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  34996. */
  34997. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  34998. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  34999. /**
  35000. * Default behaviour for cors in the application.
  35001. * It can be a string if the expected behavior is identical in the entire app.
  35002. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35003. */
  35004. static CorsBehavior: string | ((url: string | string[]) => string);
  35005. /**
  35006. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35007. * @ignorenaming
  35008. */
  35009. static get UseFallbackTexture(): boolean;
  35010. static set UseFallbackTexture(value: boolean);
  35011. /**
  35012. * Use this object to register external classes like custom textures or material
  35013. * to allow the laoders to instantiate them
  35014. */
  35015. static get RegisteredExternalClasses(): {
  35016. [key: string]: Object;
  35017. };
  35018. static set RegisteredExternalClasses(classes: {
  35019. [key: string]: Object;
  35020. });
  35021. /**
  35022. * Texture content used if a texture cannot loaded
  35023. * @ignorenaming
  35024. */
  35025. static get fallbackTexture(): string;
  35026. static set fallbackTexture(value: string);
  35027. /**
  35028. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35029. * @param u defines the coordinate on X axis
  35030. * @param v defines the coordinate on Y axis
  35031. * @param width defines the width of the source data
  35032. * @param height defines the height of the source data
  35033. * @param pixels defines the source byte array
  35034. * @param color defines the output color
  35035. */
  35036. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35037. /**
  35038. * Interpolates between a and b via alpha
  35039. * @param a The lower value (returned when alpha = 0)
  35040. * @param b The upper value (returned when alpha = 1)
  35041. * @param alpha The interpolation-factor
  35042. * @return The mixed value
  35043. */
  35044. static Mix(a: number, b: number, alpha: number): number;
  35045. /**
  35046. * Tries to instantiate a new object from a given class name
  35047. * @param className defines the class name to instantiate
  35048. * @returns the new object or null if the system was not able to do the instantiation
  35049. */
  35050. static Instantiate(className: string): any;
  35051. /**
  35052. * Provides a slice function that will work even on IE
  35053. * @param data defines the array to slice
  35054. * @param start defines the start of the data (optional)
  35055. * @param end defines the end of the data (optional)
  35056. * @returns the new sliced array
  35057. */
  35058. static Slice<T>(data: T, start?: number, end?: number): T;
  35059. /**
  35060. * Polyfill for setImmediate
  35061. * @param action defines the action to execute after the current execution block
  35062. */
  35063. static SetImmediate(action: () => void): void;
  35064. /**
  35065. * Function indicating if a number is an exponent of 2
  35066. * @param value defines the value to test
  35067. * @returns true if the value is an exponent of 2
  35068. */
  35069. static IsExponentOfTwo(value: number): boolean;
  35070. private static _tmpFloatArray;
  35071. /**
  35072. * Returns the nearest 32-bit single precision float representation of a Number
  35073. * @param value A Number. If the parameter is of a different type, it will get converted
  35074. * to a number or to NaN if it cannot be converted
  35075. * @returns number
  35076. */
  35077. static FloatRound(value: number): number;
  35078. /**
  35079. * Extracts the filename from a path
  35080. * @param path defines the path to use
  35081. * @returns the filename
  35082. */
  35083. static GetFilename(path: string): string;
  35084. /**
  35085. * Extracts the "folder" part of a path (everything before the filename).
  35086. * @param uri The URI to extract the info from
  35087. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35088. * @returns The "folder" part of the path
  35089. */
  35090. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35091. /**
  35092. * Extracts text content from a DOM element hierarchy
  35093. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35094. */
  35095. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35096. /**
  35097. * Convert an angle in radians to degrees
  35098. * @param angle defines the angle to convert
  35099. * @returns the angle in degrees
  35100. */
  35101. static ToDegrees(angle: number): number;
  35102. /**
  35103. * Convert an angle in degrees to radians
  35104. * @param angle defines the angle to convert
  35105. * @returns the angle in radians
  35106. */
  35107. static ToRadians(angle: number): number;
  35108. /**
  35109. * Returns an array if obj is not an array
  35110. * @param obj defines the object to evaluate as an array
  35111. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35112. * @returns either obj directly if obj is an array or a new array containing obj
  35113. */
  35114. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35115. /**
  35116. * Gets the pointer prefix to use
  35117. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35118. */
  35119. static GetPointerPrefix(): string;
  35120. /**
  35121. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35122. * @param url define the url we are trying
  35123. * @param element define the dom element where to configure the cors policy
  35124. */
  35125. static SetCorsBehavior(url: string | string[], element: {
  35126. crossOrigin: string | null;
  35127. }): void;
  35128. /**
  35129. * Removes unwanted characters from an url
  35130. * @param url defines the url to clean
  35131. * @returns the cleaned url
  35132. */
  35133. static CleanUrl(url: string): string;
  35134. /**
  35135. * Gets or sets a function used to pre-process url before using them to load assets
  35136. */
  35137. static get PreprocessUrl(): (url: string) => string;
  35138. static set PreprocessUrl(processor: (url: string) => string);
  35139. /**
  35140. * Loads an image as an HTMLImageElement.
  35141. * @param input url string, ArrayBuffer, or Blob to load
  35142. * @param onLoad callback called when the image successfully loads
  35143. * @param onError callback called when the image fails to load
  35144. * @param offlineProvider offline provider for caching
  35145. * @param mimeType optional mime type
  35146. * @returns the HTMLImageElement of the loaded image
  35147. */
  35148. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35149. /**
  35150. * Loads a file from a url
  35151. * @param url url string, ArrayBuffer, or Blob to load
  35152. * @param onSuccess callback called when the file successfully loads
  35153. * @param onProgress callback called while file is loading (if the server supports this mode)
  35154. * @param offlineProvider defines the offline provider for caching
  35155. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35156. * @param onError callback called when the file fails to load
  35157. * @returns a file request object
  35158. */
  35159. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  35160. /**
  35161. * Loads a file from a url
  35162. * @param url the file url to load
  35163. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35164. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35165. */
  35166. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35167. /**
  35168. * Load a script (identified by an url). When the url returns, the
  35169. * content of this file is added into a new script element, attached to the DOM (body element)
  35170. * @param scriptUrl defines the url of the script to laod
  35171. * @param onSuccess defines the callback called when the script is loaded
  35172. * @param onError defines the callback to call if an error occurs
  35173. * @param scriptId defines the id of the script element
  35174. */
  35175. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35176. /**
  35177. * Load an asynchronous script (identified by an url). When the url returns, the
  35178. * content of this file is added into a new script element, attached to the DOM (body element)
  35179. * @param scriptUrl defines the url of the script to laod
  35180. * @param scriptId defines the id of the script element
  35181. * @returns a promise request object
  35182. */
  35183. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35184. /**
  35185. * Loads a file from a blob
  35186. * @param fileToLoad defines the blob to use
  35187. * @param callback defines the callback to call when data is loaded
  35188. * @param progressCallback defines the callback to call during loading process
  35189. * @returns a file request object
  35190. */
  35191. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35192. /**
  35193. * Reads a file from a File object
  35194. * @param file defines the file to load
  35195. * @param onSuccess defines the callback to call when data is loaded
  35196. * @param onProgress defines the callback to call during loading process
  35197. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35198. * @param onError defines the callback to call when an error occurs
  35199. * @returns a file request object
  35200. */
  35201. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35202. /**
  35203. * Creates a data url from a given string content
  35204. * @param content defines the content to convert
  35205. * @returns the new data url link
  35206. */
  35207. static FileAsURL(content: string): string;
  35208. /**
  35209. * Format the given number to a specific decimal format
  35210. * @param value defines the number to format
  35211. * @param decimals defines the number of decimals to use
  35212. * @returns the formatted string
  35213. */
  35214. static Format(value: number, decimals?: number): string;
  35215. /**
  35216. * Tries to copy an object by duplicating every property
  35217. * @param source defines the source object
  35218. * @param destination defines the target object
  35219. * @param doNotCopyList defines a list of properties to avoid
  35220. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35221. */
  35222. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35223. /**
  35224. * Gets a boolean indicating if the given object has no own property
  35225. * @param obj defines the object to test
  35226. * @returns true if object has no own property
  35227. */
  35228. static IsEmpty(obj: any): boolean;
  35229. /**
  35230. * Function used to register events at window level
  35231. * @param windowElement defines the Window object to use
  35232. * @param events defines the events to register
  35233. */
  35234. static RegisterTopRootEvents(windowElement: Window, events: {
  35235. name: string;
  35236. handler: Nullable<(e: FocusEvent) => any>;
  35237. }[]): void;
  35238. /**
  35239. * Function used to unregister events from window level
  35240. * @param windowElement defines the Window object to use
  35241. * @param events defines the events to unregister
  35242. */
  35243. static UnregisterTopRootEvents(windowElement: Window, events: {
  35244. name: string;
  35245. handler: Nullable<(e: FocusEvent) => any>;
  35246. }[]): void;
  35247. /**
  35248. * @ignore
  35249. */
  35250. static _ScreenshotCanvas: HTMLCanvasElement;
  35251. /**
  35252. * Dumps the current bound framebuffer
  35253. * @param width defines the rendering width
  35254. * @param height defines the rendering height
  35255. * @param engine defines the hosting engine
  35256. * @param successCallback defines the callback triggered once the data are available
  35257. * @param mimeType defines the mime type of the result
  35258. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35259. */
  35260. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35261. /**
  35262. * Converts the canvas data to blob.
  35263. * This acts as a polyfill for browsers not supporting the to blob function.
  35264. * @param canvas Defines the canvas to extract the data from
  35265. * @param successCallback Defines the callback triggered once the data are available
  35266. * @param mimeType Defines the mime type of the result
  35267. */
  35268. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35269. /**
  35270. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35271. * @param successCallback defines the callback triggered once the data are available
  35272. * @param mimeType defines the mime type of the result
  35273. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35274. */
  35275. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35276. /**
  35277. * Downloads a blob in the browser
  35278. * @param blob defines the blob to download
  35279. * @param fileName defines the name of the downloaded file
  35280. */
  35281. static Download(blob: Blob, fileName: string): void;
  35282. /**
  35283. * Captures a screenshot of the current rendering
  35284. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35285. * @param engine defines the rendering engine
  35286. * @param camera defines the source camera
  35287. * @param size This parameter can be set to a single number or to an object with the
  35288. * following (optional) properties: precision, width, height. If a single number is passed,
  35289. * it will be used for both width and height. If an object is passed, the screenshot size
  35290. * will be derived from the parameters. The precision property is a multiplier allowing
  35291. * rendering at a higher or lower resolution
  35292. * @param successCallback defines the callback receives a single parameter which contains the
  35293. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35294. * src parameter of an <img> to display it
  35295. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35296. * Check your browser for supported MIME types
  35297. */
  35298. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35299. /**
  35300. * Captures a screenshot of the current rendering
  35301. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35302. * @param engine defines the rendering engine
  35303. * @param camera defines the source camera
  35304. * @param size This parameter can be set to a single number or to an object with the
  35305. * following (optional) properties: precision, width, height. If a single number is passed,
  35306. * it will be used for both width and height. If an object is passed, the screenshot size
  35307. * will be derived from the parameters. The precision property is a multiplier allowing
  35308. * rendering at a higher or lower resolution
  35309. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35310. * Check your browser for supported MIME types
  35311. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35312. * to the src parameter of an <img> to display it
  35313. */
  35314. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35315. /**
  35316. * Generates an image screenshot from the specified camera.
  35317. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35318. * @param engine The engine to use for rendering
  35319. * @param camera The camera to use for rendering
  35320. * @param size This parameter can be set to a single number or to an object with the
  35321. * following (optional) properties: precision, width, height. If a single number is passed,
  35322. * it will be used for both width and height. If an object is passed, the screenshot size
  35323. * will be derived from the parameters. The precision property is a multiplier allowing
  35324. * rendering at a higher or lower resolution
  35325. * @param successCallback The callback receives a single parameter which contains the
  35326. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35327. * src parameter of an <img> to display it
  35328. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35329. * Check your browser for supported MIME types
  35330. * @param samples Texture samples (default: 1)
  35331. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35332. * @param fileName A name for for the downloaded file.
  35333. */
  35334. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35335. /**
  35336. * Generates an image screenshot from the specified camera.
  35337. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35338. * @param engine The engine to use for rendering
  35339. * @param camera The camera to use for rendering
  35340. * @param size This parameter can be set to a single number or to an object with the
  35341. * following (optional) properties: precision, width, height. If a single number is passed,
  35342. * it will be used for both width and height. If an object is passed, the screenshot size
  35343. * will be derived from the parameters. The precision property is a multiplier allowing
  35344. * rendering at a higher or lower resolution
  35345. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35346. * Check your browser for supported MIME types
  35347. * @param samples Texture samples (default: 1)
  35348. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35349. * @param fileName A name for for the downloaded file.
  35350. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35351. * to the src parameter of an <img> to display it
  35352. */
  35353. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35354. /**
  35355. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35356. * Be aware Math.random() could cause collisions, but:
  35357. * "All but 6 of the 128 bits of the ID are randomly generated, which means that for any two ids, there's a 1 in 2^^122 (or 5.3x10^^36) chance they'll collide"
  35358. * @returns a pseudo random id
  35359. */
  35360. static RandomId(): string;
  35361. /**
  35362. * Test if the given uri is a base64 string
  35363. * @param uri The uri to test
  35364. * @return True if the uri is a base64 string or false otherwise
  35365. */
  35366. static IsBase64(uri: string): boolean;
  35367. /**
  35368. * Decode the given base64 uri.
  35369. * @param uri The uri to decode
  35370. * @return The decoded base64 data.
  35371. */
  35372. static DecodeBase64(uri: string): ArrayBuffer;
  35373. /**
  35374. * Gets the absolute url.
  35375. * @param url the input url
  35376. * @return the absolute url
  35377. */
  35378. static GetAbsoluteUrl(url: string): string;
  35379. /**
  35380. * No log
  35381. */
  35382. static readonly NoneLogLevel: number;
  35383. /**
  35384. * Only message logs
  35385. */
  35386. static readonly MessageLogLevel: number;
  35387. /**
  35388. * Only warning logs
  35389. */
  35390. static readonly WarningLogLevel: number;
  35391. /**
  35392. * Only error logs
  35393. */
  35394. static readonly ErrorLogLevel: number;
  35395. /**
  35396. * All logs
  35397. */
  35398. static readonly AllLogLevel: number;
  35399. /**
  35400. * Gets a value indicating the number of loading errors
  35401. * @ignorenaming
  35402. */
  35403. static get errorsCount(): number;
  35404. /**
  35405. * Callback called when a new log is added
  35406. */
  35407. static OnNewCacheEntry: (entry: string) => void;
  35408. /**
  35409. * Log a message to the console
  35410. * @param message defines the message to log
  35411. */
  35412. static Log(message: string): void;
  35413. /**
  35414. * Write a warning message to the console
  35415. * @param message defines the message to log
  35416. */
  35417. static Warn(message: string): void;
  35418. /**
  35419. * Write an error message to the console
  35420. * @param message defines the message to log
  35421. */
  35422. static Error(message: string): void;
  35423. /**
  35424. * Gets current log cache (list of logs)
  35425. */
  35426. static get LogCache(): string;
  35427. /**
  35428. * Clears the log cache
  35429. */
  35430. static ClearLogCache(): void;
  35431. /**
  35432. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35433. */
  35434. static set LogLevels(level: number);
  35435. /**
  35436. * Checks if the window object exists
  35437. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35438. */
  35439. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35440. /**
  35441. * No performance log
  35442. */
  35443. static readonly PerformanceNoneLogLevel: number;
  35444. /**
  35445. * Use user marks to log performance
  35446. */
  35447. static readonly PerformanceUserMarkLogLevel: number;
  35448. /**
  35449. * Log performance to the console
  35450. */
  35451. static readonly PerformanceConsoleLogLevel: number;
  35452. private static _performance;
  35453. /**
  35454. * Sets the current performance log level
  35455. */
  35456. static set PerformanceLogLevel(level: number);
  35457. private static _StartPerformanceCounterDisabled;
  35458. private static _EndPerformanceCounterDisabled;
  35459. private static _StartUserMark;
  35460. private static _EndUserMark;
  35461. private static _StartPerformanceConsole;
  35462. private static _EndPerformanceConsole;
  35463. /**
  35464. * Starts a performance counter
  35465. */
  35466. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35467. /**
  35468. * Ends a specific performance coutner
  35469. */
  35470. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35471. /**
  35472. * Gets either window.performance.now() if supported or Date.now() else
  35473. */
  35474. static get Now(): number;
  35475. /**
  35476. * This method will return the name of the class used to create the instance of the given object.
  35477. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35478. * @param object the object to get the class name from
  35479. * @param isType defines if the object is actually a type
  35480. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35481. */
  35482. static GetClassName(object: any, isType?: boolean): string;
  35483. /**
  35484. * Gets the first element of an array satisfying a given predicate
  35485. * @param array defines the array to browse
  35486. * @param predicate defines the predicate to use
  35487. * @returns null if not found or the element
  35488. */
  35489. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35490. /**
  35491. * This method will return the name of the full name of the class, including its owning module (if any).
  35492. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator or implementing a method getClassName():string (in which case the module won't be specified).
  35493. * @param object the object to get the class name from
  35494. * @param isType defines if the object is actually a type
  35495. * @return a string that can have two forms: "moduleName.className" if module was specified when the class' Name was registered or "className" if there was not module specified.
  35496. * @ignorenaming
  35497. */
  35498. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35499. /**
  35500. * Returns a promise that resolves after the given amount of time.
  35501. * @param delay Number of milliseconds to delay
  35502. * @returns Promise that resolves after the given amount of time
  35503. */
  35504. static DelayAsync(delay: number): Promise<void>;
  35505. /**
  35506. * Utility function to detect if the current user agent is Safari
  35507. * @returns whether or not the current user agent is safari
  35508. */
  35509. static IsSafari(): boolean;
  35510. }
  35511. /**
  35512. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35513. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35514. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35515. * @param name The name of the class, case should be preserved
  35516. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35517. */
  35518. export function className(name: string, module?: string): (target: Object) => void;
  35519. /**
  35520. * An implementation of a loop for asynchronous functions.
  35521. */
  35522. export class AsyncLoop {
  35523. /**
  35524. * Defines the number of iterations for the loop
  35525. */
  35526. iterations: number;
  35527. /**
  35528. * Defines the current index of the loop.
  35529. */
  35530. index: number;
  35531. private _done;
  35532. private _fn;
  35533. private _successCallback;
  35534. /**
  35535. * Constructor.
  35536. * @param iterations the number of iterations.
  35537. * @param func the function to run each iteration
  35538. * @param successCallback the callback that will be called upon succesful execution
  35539. * @param offset starting offset.
  35540. */
  35541. constructor(
  35542. /**
  35543. * Defines the number of iterations for the loop
  35544. */
  35545. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35546. /**
  35547. * Execute the next iteration. Must be called after the last iteration was finished.
  35548. */
  35549. executeNext(): void;
  35550. /**
  35551. * Break the loop and run the success callback.
  35552. */
  35553. breakLoop(): void;
  35554. /**
  35555. * Create and run an async loop.
  35556. * @param iterations the number of iterations.
  35557. * @param fn the function to run each iteration
  35558. * @param successCallback the callback that will be called upon succesful execution
  35559. * @param offset starting offset.
  35560. * @returns the created async loop object
  35561. */
  35562. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35563. /**
  35564. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35565. * @param iterations total number of iterations
  35566. * @param syncedIterations number of synchronous iterations in each async iteration.
  35567. * @param fn the function to call each iteration.
  35568. * @param callback a success call back that will be called when iterating stops.
  35569. * @param breakFunction a break condition (optional)
  35570. * @param timeout timeout settings for the setTimeout function. default - 0.
  35571. * @returns the created async loop object
  35572. */
  35573. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35574. }
  35575. }
  35576. declare module "babylonjs/Misc/stringDictionary" {
  35577. import { Nullable } from "babylonjs/types";
  35578. /**
  35579. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35580. * The underlying implementation relies on an associative array to ensure the best performances.
  35581. * The value can be anything including 'null' but except 'undefined'
  35582. */
  35583. export class StringDictionary<T> {
  35584. /**
  35585. * This will clear this dictionary and copy the content from the 'source' one.
  35586. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35587. * @param source the dictionary to take the content from and copy to this dictionary
  35588. */
  35589. copyFrom(source: StringDictionary<T>): void;
  35590. /**
  35591. * Get a value based from its key
  35592. * @param key the given key to get the matching value from
  35593. * @return the value if found, otherwise undefined is returned
  35594. */
  35595. get(key: string): T | undefined;
  35596. /**
  35597. * Get a value from its key or add it if it doesn't exist.
  35598. * This method will ensure you that a given key/data will be present in the dictionary.
  35599. * @param key the given key to get the matching value from
  35600. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35601. * The factory will only be invoked if there's no data for the given key.
  35602. * @return the value corresponding to the key.
  35603. */
  35604. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35605. /**
  35606. * Get a value from its key if present in the dictionary otherwise add it
  35607. * @param key the key to get the value from
  35608. * @param val if there's no such key/value pair in the dictionary add it with this value
  35609. * @return the value corresponding to the key
  35610. */
  35611. getOrAdd(key: string, val: T): T;
  35612. /**
  35613. * Check if there's a given key in the dictionary
  35614. * @param key the key to check for
  35615. * @return true if the key is present, false otherwise
  35616. */
  35617. contains(key: string): boolean;
  35618. /**
  35619. * Add a new key and its corresponding value
  35620. * @param key the key to add
  35621. * @param value the value corresponding to the key
  35622. * @return true if the operation completed successfully, false if we couldn't insert the key/value because there was already this key in the dictionary
  35623. */
  35624. add(key: string, value: T): boolean;
  35625. /**
  35626. * Update a specific value associated to a key
  35627. * @param key defines the key to use
  35628. * @param value defines the value to store
  35629. * @returns true if the value was updated (or false if the key was not found)
  35630. */
  35631. set(key: string, value: T): boolean;
  35632. /**
  35633. * Get the element of the given key and remove it from the dictionary
  35634. * @param key defines the key to search
  35635. * @returns the value associated with the key or null if not found
  35636. */
  35637. getAndRemove(key: string): Nullable<T>;
  35638. /**
  35639. * Remove a key/value from the dictionary.
  35640. * @param key the key to remove
  35641. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  35642. */
  35643. remove(key: string): boolean;
  35644. /**
  35645. * Clear the whole content of the dictionary
  35646. */
  35647. clear(): void;
  35648. /**
  35649. * Gets the current count
  35650. */
  35651. get count(): number;
  35652. /**
  35653. * Execute a callback on each key/val of the dictionary.
  35654. * Note that you can remove any element in this dictionary in the callback implementation
  35655. * @param callback the callback to execute on a given key/value pair
  35656. */
  35657. forEach(callback: (key: string, val: T) => void): void;
  35658. /**
  35659. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  35660. * If the callback returns null or undefined the method will iterate to the next key/value pair
  35661. * Note that you can remove any element in this dictionary in the callback implementation
  35662. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  35663. * @returns the first item
  35664. */
  35665. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  35666. private _count;
  35667. private _data;
  35668. }
  35669. }
  35670. declare module "babylonjs/Collisions/collisionCoordinator" {
  35671. import { Nullable } from "babylonjs/types";
  35672. import { Scene } from "babylonjs/scene";
  35673. import { Vector3 } from "babylonjs/Maths/math.vector";
  35674. import { Collider } from "babylonjs/Collisions/collider";
  35675. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35676. /** @hidden */
  35677. export interface ICollisionCoordinator {
  35678. createCollider(): Collider;
  35679. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35680. init(scene: Scene): void;
  35681. }
  35682. /** @hidden */
  35683. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  35684. private _scene;
  35685. private _scaledPosition;
  35686. private _scaledVelocity;
  35687. private _finalPosition;
  35688. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  35689. createCollider(): Collider;
  35690. init(scene: Scene): void;
  35691. private _collideWithWorld;
  35692. }
  35693. }
  35694. declare module "babylonjs/Inputs/scene.inputManager" {
  35695. import { Nullable } from "babylonjs/types";
  35696. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  35697. import { Vector2 } from "babylonjs/Maths/math.vector";
  35698. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35699. import { Scene } from "babylonjs/scene";
  35700. /**
  35701. * Class used to manage all inputs for the scene.
  35702. */
  35703. export class InputManager {
  35704. /** The distance in pixel that you have to move to prevent some events */
  35705. static DragMovementThreshold: number;
  35706. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  35707. static LongPressDelay: number;
  35708. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  35709. static DoubleClickDelay: number;
  35710. /** If you need to check double click without raising a single click at first click, enable this flag */
  35711. static ExclusiveDoubleClickMode: boolean;
  35712. private _wheelEventName;
  35713. private _onPointerMove;
  35714. private _onPointerDown;
  35715. private _onPointerUp;
  35716. private _initClickEvent;
  35717. private _initActionManager;
  35718. private _delayedSimpleClick;
  35719. private _delayedSimpleClickTimeout;
  35720. private _previousDelayedSimpleClickTimeout;
  35721. private _meshPickProceed;
  35722. private _previousButtonPressed;
  35723. private _currentPickResult;
  35724. private _previousPickResult;
  35725. private _totalPointersPressed;
  35726. private _doubleClickOccured;
  35727. private _pointerOverMesh;
  35728. private _pickedDownMesh;
  35729. private _pickedUpMesh;
  35730. private _pointerX;
  35731. private _pointerY;
  35732. private _unTranslatedPointerX;
  35733. private _unTranslatedPointerY;
  35734. private _startingPointerPosition;
  35735. private _previousStartingPointerPosition;
  35736. private _startingPointerTime;
  35737. private _previousStartingPointerTime;
  35738. private _pointerCaptures;
  35739. private _onKeyDown;
  35740. private _onKeyUp;
  35741. private _onCanvasFocusObserver;
  35742. private _onCanvasBlurObserver;
  35743. private _scene;
  35744. /**
  35745. * Creates a new InputManager
  35746. * @param scene defines the hosting scene
  35747. */
  35748. constructor(scene: Scene);
  35749. /**
  35750. * Gets the mesh that is currently under the pointer
  35751. */
  35752. get meshUnderPointer(): Nullable<AbstractMesh>;
  35753. /**
  35754. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  35755. */
  35756. get unTranslatedPointer(): Vector2;
  35757. /**
  35758. * Gets or sets the current on-screen X position of the pointer
  35759. */
  35760. get pointerX(): number;
  35761. set pointerX(value: number);
  35762. /**
  35763. * Gets or sets the current on-screen Y position of the pointer
  35764. */
  35765. get pointerY(): number;
  35766. set pointerY(value: number);
  35767. private _updatePointerPosition;
  35768. private _processPointerMove;
  35769. private _setRayOnPointerInfo;
  35770. private _checkPrePointerObservable;
  35771. /**
  35772. * Use this method to simulate a pointer move on a mesh
  35773. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35774. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35775. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35776. */
  35777. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35778. /**
  35779. * Use this method to simulate a pointer down on a mesh
  35780. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35781. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35782. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35783. */
  35784. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  35785. private _processPointerDown;
  35786. /** @hidden */
  35787. _isPointerSwiping(): boolean;
  35788. /**
  35789. * Use this method to simulate a pointer up on a mesh
  35790. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  35791. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  35792. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  35793. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  35794. */
  35795. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  35796. private _processPointerUp;
  35797. /**
  35798. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  35799. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  35800. * @returns true if the pointer was captured
  35801. */
  35802. isPointerCaptured(pointerId?: number): boolean;
  35803. /**
  35804. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  35805. * @param attachUp defines if you want to attach events to pointerup
  35806. * @param attachDown defines if you want to attach events to pointerdown
  35807. * @param attachMove defines if you want to attach events to pointermove
  35808. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  35809. */
  35810. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  35811. /**
  35812. * Detaches all event handlers
  35813. */
  35814. detachControl(): void;
  35815. /**
  35816. * Force the value of meshUnderPointer
  35817. * @param mesh defines the mesh to use
  35818. */
  35819. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35820. /**
  35821. * Gets the mesh under the pointer
  35822. * @returns a Mesh or null if no mesh is under the pointer
  35823. */
  35824. getPointerOverMesh(): Nullable<AbstractMesh>;
  35825. }
  35826. }
  35827. declare module "babylonjs/Misc/uniqueIdGenerator" {
  35828. /**
  35829. * Helper class used to generate session unique ID
  35830. */
  35831. export class UniqueIdGenerator {
  35832. private static _UniqueIdCounter;
  35833. /**
  35834. * Gets an unique (relatively to the current scene) Id
  35835. */
  35836. static get UniqueId(): number;
  35837. }
  35838. }
  35839. declare module "babylonjs/Animations/animationGroup" {
  35840. import { Animatable } from "babylonjs/Animations/animatable";
  35841. import { Animation } from "babylonjs/Animations/animation";
  35842. import { Scene, IDisposable } from "babylonjs/scene";
  35843. import { Observable } from "babylonjs/Misc/observable";
  35844. import { Nullable } from "babylonjs/types";
  35845. import "babylonjs/Animations/animatable";
  35846. /**
  35847. * This class defines the direct association between an animation and a target
  35848. */
  35849. export class TargetedAnimation {
  35850. /**
  35851. * Animation to perform
  35852. */
  35853. animation: Animation;
  35854. /**
  35855. * Target to animate
  35856. */
  35857. target: any;
  35858. /**
  35859. * Serialize the object
  35860. * @returns the JSON object representing the current entity
  35861. */
  35862. serialize(): any;
  35863. }
  35864. /**
  35865. * Use this class to create coordinated animations on multiple targets
  35866. */
  35867. export class AnimationGroup implements IDisposable {
  35868. /** The name of the animation group */
  35869. name: string;
  35870. private _scene;
  35871. private _targetedAnimations;
  35872. private _animatables;
  35873. private _from;
  35874. private _to;
  35875. private _isStarted;
  35876. private _isPaused;
  35877. private _speedRatio;
  35878. private _loopAnimation;
  35879. /**
  35880. * Gets or sets the unique id of the node
  35881. */
  35882. uniqueId: number;
  35883. /**
  35884. * This observable will notify when one animation have ended
  35885. */
  35886. onAnimationEndObservable: Observable<TargetedAnimation>;
  35887. /**
  35888. * Observer raised when one animation loops
  35889. */
  35890. onAnimationLoopObservable: Observable<TargetedAnimation>;
  35891. /**
  35892. * Observer raised when all animations have looped
  35893. */
  35894. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  35895. /**
  35896. * This observable will notify when all animations have ended.
  35897. */
  35898. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  35899. /**
  35900. * This observable will notify when all animations have paused.
  35901. */
  35902. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  35903. /**
  35904. * This observable will notify when all animations are playing.
  35905. */
  35906. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  35907. /**
  35908. * Gets the first frame
  35909. */
  35910. get from(): number;
  35911. /**
  35912. * Gets the last frame
  35913. */
  35914. get to(): number;
  35915. /**
  35916. * Define if the animations are started
  35917. */
  35918. get isStarted(): boolean;
  35919. /**
  35920. * Gets a value indicating that the current group is playing
  35921. */
  35922. get isPlaying(): boolean;
  35923. /**
  35924. * Gets or sets the speed ratio to use for all animations
  35925. */
  35926. get speedRatio(): number;
  35927. /**
  35928. * Gets or sets the speed ratio to use for all animations
  35929. */
  35930. set speedRatio(value: number);
  35931. /**
  35932. * Gets or sets if all animations should loop or not
  35933. */
  35934. get loopAnimation(): boolean;
  35935. set loopAnimation(value: boolean);
  35936. /**
  35937. * Gets the targeted animations for this animation group
  35938. */
  35939. get targetedAnimations(): Array<TargetedAnimation>;
  35940. /**
  35941. * returning the list of animatables controlled by this animation group.
  35942. */
  35943. get animatables(): Array<Animatable>;
  35944. /**
  35945. * Instantiates a new Animation Group.
  35946. * This helps managing several animations at once.
  35947. * @see http://doc.babylonjs.com/how_to/group
  35948. * @param name Defines the name of the group
  35949. * @param scene Defines the scene the group belongs to
  35950. */
  35951. constructor(
  35952. /** The name of the animation group */
  35953. name: string, scene?: Nullable<Scene>);
  35954. /**
  35955. * Add an animation (with its target) in the group
  35956. * @param animation defines the animation we want to add
  35957. * @param target defines the target of the animation
  35958. * @returns the TargetedAnimation object
  35959. */
  35960. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  35961. /**
  35962. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  35963. * It can add constant keys at begin or end
  35964. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  35965. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  35966. * @returns the animation group
  35967. */
  35968. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  35969. private _animationLoopCount;
  35970. private _animationLoopFlags;
  35971. private _processLoop;
  35972. /**
  35973. * Start all animations on given targets
  35974. * @param loop defines if animations must loop
  35975. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  35976. * @param from defines the from key (optional)
  35977. * @param to defines the to key (optional)
  35978. * @returns the current animation group
  35979. */
  35980. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  35981. /**
  35982. * Pause all animations
  35983. * @returns the animation group
  35984. */
  35985. pause(): AnimationGroup;
  35986. /**
  35987. * Play all animations to initial state
  35988. * This function will start() the animations if they were not started or will restart() them if they were paused
  35989. * @param loop defines if animations must loop
  35990. * @returns the animation group
  35991. */
  35992. play(loop?: boolean): AnimationGroup;
  35993. /**
  35994. * Reset all animations to initial state
  35995. * @returns the animation group
  35996. */
  35997. reset(): AnimationGroup;
  35998. /**
  35999. * Restart animations from key 0
  36000. * @returns the animation group
  36001. */
  36002. restart(): AnimationGroup;
  36003. /**
  36004. * Stop all animations
  36005. * @returns the animation group
  36006. */
  36007. stop(): AnimationGroup;
  36008. /**
  36009. * Set animation weight for all animatables
  36010. * @param weight defines the weight to use
  36011. * @return the animationGroup
  36012. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36013. */
  36014. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36015. /**
  36016. * Synchronize and normalize all animatables with a source animatable
  36017. * @param root defines the root animatable to synchronize with
  36018. * @return the animationGroup
  36019. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36020. */
  36021. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36022. /**
  36023. * Goes to a specific frame in this animation group
  36024. * @param frame the frame number to go to
  36025. * @return the animationGroup
  36026. */
  36027. goToFrame(frame: number): AnimationGroup;
  36028. /**
  36029. * Dispose all associated resources
  36030. */
  36031. dispose(): void;
  36032. private _checkAnimationGroupEnded;
  36033. /**
  36034. * Clone the current animation group and returns a copy
  36035. * @param newName defines the name of the new group
  36036. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36037. * @returns the new aniamtion group
  36038. */
  36039. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36040. /**
  36041. * Serializes the animationGroup to an object
  36042. * @returns Serialized object
  36043. */
  36044. serialize(): any;
  36045. /**
  36046. * Returns a new AnimationGroup object parsed from the source provided.
  36047. * @param parsedAnimationGroup defines the source
  36048. * @param scene defines the scene that will receive the animationGroup
  36049. * @returns a new AnimationGroup
  36050. */
  36051. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36052. /**
  36053. * Returns the string "AnimationGroup"
  36054. * @returns "AnimationGroup"
  36055. */
  36056. getClassName(): string;
  36057. /**
  36058. * Creates a detailled string about the object
  36059. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36060. * @returns a string representing the object
  36061. */
  36062. toString(fullDetails?: boolean): string;
  36063. }
  36064. }
  36065. declare module "babylonjs/scene" {
  36066. import { Nullable } from "babylonjs/types";
  36067. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36068. import { Observable } from "babylonjs/Misc/observable";
  36069. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36070. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36071. import { Geometry } from "babylonjs/Meshes/geometry";
  36072. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36073. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36075. import { Mesh } from "babylonjs/Meshes/mesh";
  36076. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36077. import { Bone } from "babylonjs/Bones/bone";
  36078. import { Skeleton } from "babylonjs/Bones/skeleton";
  36079. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36080. import { Camera } from "babylonjs/Cameras/camera";
  36081. import { AbstractScene } from "babylonjs/abstractScene";
  36082. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36083. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36084. import { Material } from "babylonjs/Materials/material";
  36085. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36086. import { Effect } from "babylonjs/Materials/effect";
  36087. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36088. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36089. import { Light } from "babylonjs/Lights/light";
  36090. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36091. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36092. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36093. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36094. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36095. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36096. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36097. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36098. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36099. import { Engine } from "babylonjs/Engines/engine";
  36100. import { Node } from "babylonjs/node";
  36101. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36102. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36103. import { WebRequest } from "babylonjs/Misc/webRequest";
  36104. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36105. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36106. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36107. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36108. import { Plane } from "babylonjs/Maths/math.plane";
  36109. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36110. import { Ray } from "babylonjs/Culling/ray";
  36111. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36112. import { Animation } from "babylonjs/Animations/animation";
  36113. import { Animatable } from "babylonjs/Animations/animatable";
  36114. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36115. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36116. import { Collider } from "babylonjs/Collisions/collider";
  36117. /**
  36118. * Define an interface for all classes that will hold resources
  36119. */
  36120. export interface IDisposable {
  36121. /**
  36122. * Releases all held resources
  36123. */
  36124. dispose(): void;
  36125. }
  36126. /** Interface defining initialization parameters for Scene class */
  36127. export interface SceneOptions {
  36128. /**
  36129. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36130. * It will improve performance when the number of geometries becomes important.
  36131. */
  36132. useGeometryUniqueIdsMap?: boolean;
  36133. /**
  36134. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36135. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36136. */
  36137. useMaterialMeshMap?: boolean;
  36138. /**
  36139. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36140. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36141. */
  36142. useClonedMeshMap?: boolean;
  36143. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36144. virtual?: boolean;
  36145. }
  36146. /**
  36147. * Represents a scene to be rendered by the engine.
  36148. * @see http://doc.babylonjs.com/features/scene
  36149. */
  36150. export class Scene extends AbstractScene implements IAnimatable {
  36151. /** The fog is deactivated */
  36152. static readonly FOGMODE_NONE: number;
  36153. /** The fog density is following an exponential function */
  36154. static readonly FOGMODE_EXP: number;
  36155. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36156. static readonly FOGMODE_EXP2: number;
  36157. /** The fog density is following a linear function. */
  36158. static readonly FOGMODE_LINEAR: number;
  36159. /**
  36160. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36161. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36162. */
  36163. static MinDeltaTime: number;
  36164. /**
  36165. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36166. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36167. */
  36168. static MaxDeltaTime: number;
  36169. /**
  36170. * Factory used to create the default material.
  36171. * @param name The name of the material to create
  36172. * @param scene The scene to create the material for
  36173. * @returns The default material
  36174. */
  36175. static DefaultMaterialFactory(scene: Scene): Material;
  36176. /**
  36177. * Factory used to create the a collision coordinator.
  36178. * @returns The collision coordinator
  36179. */
  36180. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36181. /** @hidden */
  36182. _inputManager: InputManager;
  36183. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36184. cameraToUseForPointers: Nullable<Camera>;
  36185. /** @hidden */
  36186. readonly _isScene: boolean;
  36187. /** @hidden */
  36188. _blockEntityCollection: boolean;
  36189. /**
  36190. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36191. */
  36192. autoClear: boolean;
  36193. /**
  36194. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36195. */
  36196. autoClearDepthAndStencil: boolean;
  36197. /**
  36198. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36199. */
  36200. clearColor: Color4;
  36201. /**
  36202. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36203. */
  36204. ambientColor: Color3;
  36205. /**
  36206. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36207. * It should only be one of the following (if not the default embedded one):
  36208. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36209. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36210. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36211. * The material properties need to be setup according to the type of texture in use.
  36212. */
  36213. environmentBRDFTexture: BaseTexture;
  36214. /** @hidden */
  36215. protected _environmentTexture: Nullable<BaseTexture>;
  36216. /**
  36217. * Texture used in all pbr material as the reflection texture.
  36218. * As in the majority of the scene they are the same (exception for multi room and so on),
  36219. * this is easier to reference from here than from all the materials.
  36220. */
  36221. get environmentTexture(): Nullable<BaseTexture>;
  36222. /**
  36223. * Texture used in all pbr material as the reflection texture.
  36224. * As in the majority of the scene they are the same (exception for multi room and so on),
  36225. * this is easier to set here than in all the materials.
  36226. */
  36227. set environmentTexture(value: Nullable<BaseTexture>);
  36228. /** @hidden */
  36229. protected _environmentIntensity: number;
  36230. /**
  36231. * Intensity of the environment in all pbr material.
  36232. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36233. * As in the majority of the scene they are the same (exception for multi room and so on),
  36234. * this is easier to reference from here than from all the materials.
  36235. */
  36236. get environmentIntensity(): number;
  36237. /**
  36238. * Intensity of the environment in all pbr material.
  36239. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36240. * As in the majority of the scene they are the same (exception for multi room and so on),
  36241. * this is easier to set here than in all the materials.
  36242. */
  36243. set environmentIntensity(value: number);
  36244. /** @hidden */
  36245. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36246. /**
  36247. * Default image processing configuration used either in the rendering
  36248. * Forward main pass or through the imageProcessingPostProcess if present.
  36249. * As in the majority of the scene they are the same (exception for multi camera),
  36250. * this is easier to reference from here than from all the materials and post process.
  36251. *
  36252. * No setter as we it is a shared configuration, you can set the values instead.
  36253. */
  36254. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36255. private _forceWireframe;
  36256. /**
  36257. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36258. */
  36259. set forceWireframe(value: boolean);
  36260. get forceWireframe(): boolean;
  36261. private _skipFrustumClipping;
  36262. /**
  36263. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36264. */
  36265. set skipFrustumClipping(value: boolean);
  36266. get skipFrustumClipping(): boolean;
  36267. private _forcePointsCloud;
  36268. /**
  36269. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36270. */
  36271. set forcePointsCloud(value: boolean);
  36272. get forcePointsCloud(): boolean;
  36273. /**
  36274. * Gets or sets the active clipplane 1
  36275. */
  36276. clipPlane: Nullable<Plane>;
  36277. /**
  36278. * Gets or sets the active clipplane 2
  36279. */
  36280. clipPlane2: Nullable<Plane>;
  36281. /**
  36282. * Gets or sets the active clipplane 3
  36283. */
  36284. clipPlane3: Nullable<Plane>;
  36285. /**
  36286. * Gets or sets the active clipplane 4
  36287. */
  36288. clipPlane4: Nullable<Plane>;
  36289. /**
  36290. * Gets or sets the active clipplane 5
  36291. */
  36292. clipPlane5: Nullable<Plane>;
  36293. /**
  36294. * Gets or sets the active clipplane 6
  36295. */
  36296. clipPlane6: Nullable<Plane>;
  36297. /**
  36298. * Gets or sets a boolean indicating if animations are enabled
  36299. */
  36300. animationsEnabled: boolean;
  36301. private _animationPropertiesOverride;
  36302. /**
  36303. * Gets or sets the animation properties override
  36304. */
  36305. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36306. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36307. /**
  36308. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36309. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36310. */
  36311. useConstantAnimationDeltaTime: boolean;
  36312. /**
  36313. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36314. * Please note that it requires to run a ray cast through the scene on every frame
  36315. */
  36316. constantlyUpdateMeshUnderPointer: boolean;
  36317. /**
  36318. * Defines the HTML cursor to use when hovering over interactive elements
  36319. */
  36320. hoverCursor: string;
  36321. /**
  36322. * Defines the HTML default cursor to use (empty by default)
  36323. */
  36324. defaultCursor: string;
  36325. /**
  36326. * Defines whether cursors are handled by the scene.
  36327. */
  36328. doNotHandleCursors: boolean;
  36329. /**
  36330. * This is used to call preventDefault() on pointer down
  36331. * in order to block unwanted artifacts like system double clicks
  36332. */
  36333. preventDefaultOnPointerDown: boolean;
  36334. /**
  36335. * This is used to call preventDefault() on pointer up
  36336. * in order to block unwanted artifacts like system double clicks
  36337. */
  36338. preventDefaultOnPointerUp: boolean;
  36339. /**
  36340. * Gets or sets user defined metadata
  36341. */
  36342. metadata: any;
  36343. /**
  36344. * For internal use only. Please do not use.
  36345. */
  36346. reservedDataStore: any;
  36347. /**
  36348. * Gets the name of the plugin used to load this scene (null by default)
  36349. */
  36350. loadingPluginName: string;
  36351. /**
  36352. * Use this array to add regular expressions used to disable offline support for specific urls
  36353. */
  36354. disableOfflineSupportExceptionRules: RegExp[];
  36355. /**
  36356. * An event triggered when the scene is disposed.
  36357. */
  36358. onDisposeObservable: Observable<Scene>;
  36359. private _onDisposeObserver;
  36360. /** Sets a function to be executed when this scene is disposed. */
  36361. set onDispose(callback: () => void);
  36362. /**
  36363. * An event triggered before rendering the scene (right after animations and physics)
  36364. */
  36365. onBeforeRenderObservable: Observable<Scene>;
  36366. private _onBeforeRenderObserver;
  36367. /** Sets a function to be executed before rendering this scene */
  36368. set beforeRender(callback: Nullable<() => void>);
  36369. /**
  36370. * An event triggered after rendering the scene
  36371. */
  36372. onAfterRenderObservable: Observable<Scene>;
  36373. /**
  36374. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36375. */
  36376. onAfterRenderCameraObservable: Observable<Camera>;
  36377. private _onAfterRenderObserver;
  36378. /** Sets a function to be executed after rendering this scene */
  36379. set afterRender(callback: Nullable<() => void>);
  36380. /**
  36381. * An event triggered before animating the scene
  36382. */
  36383. onBeforeAnimationsObservable: Observable<Scene>;
  36384. /**
  36385. * An event triggered after animations processing
  36386. */
  36387. onAfterAnimationsObservable: Observable<Scene>;
  36388. /**
  36389. * An event triggered before draw calls are ready to be sent
  36390. */
  36391. onBeforeDrawPhaseObservable: Observable<Scene>;
  36392. /**
  36393. * An event triggered after draw calls have been sent
  36394. */
  36395. onAfterDrawPhaseObservable: Observable<Scene>;
  36396. /**
  36397. * An event triggered when the scene is ready
  36398. */
  36399. onReadyObservable: Observable<Scene>;
  36400. /**
  36401. * An event triggered before rendering a camera
  36402. */
  36403. onBeforeCameraRenderObservable: Observable<Camera>;
  36404. private _onBeforeCameraRenderObserver;
  36405. /** Sets a function to be executed before rendering a camera*/
  36406. set beforeCameraRender(callback: () => void);
  36407. /**
  36408. * An event triggered after rendering a camera
  36409. */
  36410. onAfterCameraRenderObservable: Observable<Camera>;
  36411. private _onAfterCameraRenderObserver;
  36412. /** Sets a function to be executed after rendering a camera*/
  36413. set afterCameraRender(callback: () => void);
  36414. /**
  36415. * An event triggered when active meshes evaluation is about to start
  36416. */
  36417. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36418. /**
  36419. * An event triggered when active meshes evaluation is done
  36420. */
  36421. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36422. /**
  36423. * An event triggered when particles rendering is about to start
  36424. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36425. */
  36426. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36427. /**
  36428. * An event triggered when particles rendering is done
  36429. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36430. */
  36431. onAfterParticlesRenderingObservable: Observable<Scene>;
  36432. /**
  36433. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36434. */
  36435. onDataLoadedObservable: Observable<Scene>;
  36436. /**
  36437. * An event triggered when a camera is created
  36438. */
  36439. onNewCameraAddedObservable: Observable<Camera>;
  36440. /**
  36441. * An event triggered when a camera is removed
  36442. */
  36443. onCameraRemovedObservable: Observable<Camera>;
  36444. /**
  36445. * An event triggered when a light is created
  36446. */
  36447. onNewLightAddedObservable: Observable<Light>;
  36448. /**
  36449. * An event triggered when a light is removed
  36450. */
  36451. onLightRemovedObservable: Observable<Light>;
  36452. /**
  36453. * An event triggered when a geometry is created
  36454. */
  36455. onNewGeometryAddedObservable: Observable<Geometry>;
  36456. /**
  36457. * An event triggered when a geometry is removed
  36458. */
  36459. onGeometryRemovedObservable: Observable<Geometry>;
  36460. /**
  36461. * An event triggered when a transform node is created
  36462. */
  36463. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36464. /**
  36465. * An event triggered when a transform node is removed
  36466. */
  36467. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36468. /**
  36469. * An event triggered when a mesh is created
  36470. */
  36471. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36472. /**
  36473. * An event triggered when a mesh is removed
  36474. */
  36475. onMeshRemovedObservable: Observable<AbstractMesh>;
  36476. /**
  36477. * An event triggered when a skeleton is created
  36478. */
  36479. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36480. /**
  36481. * An event triggered when a skeleton is removed
  36482. */
  36483. onSkeletonRemovedObservable: Observable<Skeleton>;
  36484. /**
  36485. * An event triggered when a material is created
  36486. */
  36487. onNewMaterialAddedObservable: Observable<Material>;
  36488. /**
  36489. * An event triggered when a material is removed
  36490. */
  36491. onMaterialRemovedObservable: Observable<Material>;
  36492. /**
  36493. * An event triggered when a texture is created
  36494. */
  36495. onNewTextureAddedObservable: Observable<BaseTexture>;
  36496. /**
  36497. * An event triggered when a texture is removed
  36498. */
  36499. onTextureRemovedObservable: Observable<BaseTexture>;
  36500. /**
  36501. * An event triggered when render targets are about to be rendered
  36502. * Can happen multiple times per frame.
  36503. */
  36504. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36505. /**
  36506. * An event triggered when render targets were rendered.
  36507. * Can happen multiple times per frame.
  36508. */
  36509. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36510. /**
  36511. * An event triggered before calculating deterministic simulation step
  36512. */
  36513. onBeforeStepObservable: Observable<Scene>;
  36514. /**
  36515. * An event triggered after calculating deterministic simulation step
  36516. */
  36517. onAfterStepObservable: Observable<Scene>;
  36518. /**
  36519. * An event triggered when the activeCamera property is updated
  36520. */
  36521. onActiveCameraChanged: Observable<Scene>;
  36522. /**
  36523. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36524. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36525. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  36526. */
  36527. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36528. /**
  36529. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36530. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36531. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  36532. */
  36533. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36534. /**
  36535. * This Observable will when a mesh has been imported into the scene.
  36536. */
  36537. onMeshImportedObservable: Observable<AbstractMesh>;
  36538. /**
  36539. * This Observable will when an animation file has been imported into the scene.
  36540. */
  36541. onAnimationFileImportedObservable: Observable<Scene>;
  36542. /**
  36543. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36544. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36545. */
  36546. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36547. /** @hidden */
  36548. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36549. /**
  36550. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36551. */
  36552. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36553. /**
  36554. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36555. */
  36556. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36557. /**
  36558. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36559. */
  36560. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36561. /** Callback called when a pointer move is detected */
  36562. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36563. /** Callback called when a pointer down is detected */
  36564. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36565. /** Callback called when a pointer up is detected */
  36566. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36567. /** Callback called when a pointer pick is detected */
  36568. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36569. /**
  36570. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  36571. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36572. */
  36573. onPrePointerObservable: Observable<PointerInfoPre>;
  36574. /**
  36575. * Observable event triggered each time an input event is received from the rendering canvas
  36576. */
  36577. onPointerObservable: Observable<PointerInfo>;
  36578. /**
  36579. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36580. */
  36581. get unTranslatedPointer(): Vector2;
  36582. /**
  36583. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36584. */
  36585. static get DragMovementThreshold(): number;
  36586. static set DragMovementThreshold(value: number);
  36587. /**
  36588. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36589. */
  36590. static get LongPressDelay(): number;
  36591. static set LongPressDelay(value: number);
  36592. /**
  36593. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36594. */
  36595. static get DoubleClickDelay(): number;
  36596. static set DoubleClickDelay(value: number);
  36597. /** If you need to check double click without raising a single click at first click, enable this flag */
  36598. static get ExclusiveDoubleClickMode(): boolean;
  36599. static set ExclusiveDoubleClickMode(value: boolean);
  36600. /** @hidden */
  36601. _mirroredCameraPosition: Nullable<Vector3>;
  36602. /**
  36603. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36604. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36605. */
  36606. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36607. /**
  36608. * Observable event triggered each time an keyboard event is received from the hosting window
  36609. */
  36610. onKeyboardObservable: Observable<KeyboardInfo>;
  36611. private _useRightHandedSystem;
  36612. /**
  36613. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  36614. */
  36615. set useRightHandedSystem(value: boolean);
  36616. get useRightHandedSystem(): boolean;
  36617. private _timeAccumulator;
  36618. private _currentStepId;
  36619. private _currentInternalStep;
  36620. /**
  36621. * Sets the step Id used by deterministic lock step
  36622. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36623. * @param newStepId defines the step Id
  36624. */
  36625. setStepId(newStepId: number): void;
  36626. /**
  36627. * Gets the step Id used by deterministic lock step
  36628. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36629. * @returns the step Id
  36630. */
  36631. getStepId(): number;
  36632. /**
  36633. * Gets the internal step used by deterministic lock step
  36634. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36635. * @returns the internal step
  36636. */
  36637. getInternalStep(): number;
  36638. private _fogEnabled;
  36639. /**
  36640. * Gets or sets a boolean indicating if fog is enabled on this scene
  36641. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36642. * (Default is true)
  36643. */
  36644. set fogEnabled(value: boolean);
  36645. get fogEnabled(): boolean;
  36646. private _fogMode;
  36647. /**
  36648. * Gets or sets the fog mode to use
  36649. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36650. * | mode | value |
  36651. * | --- | --- |
  36652. * | FOGMODE_NONE | 0 |
  36653. * | FOGMODE_EXP | 1 |
  36654. * | FOGMODE_EXP2 | 2 |
  36655. * | FOGMODE_LINEAR | 3 |
  36656. */
  36657. set fogMode(value: number);
  36658. get fogMode(): number;
  36659. /**
  36660. * Gets or sets the fog color to use
  36661. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36662. * (Default is Color3(0.2, 0.2, 0.3))
  36663. */
  36664. fogColor: Color3;
  36665. /**
  36666. * Gets or sets the fog density to use
  36667. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36668. * (Default is 0.1)
  36669. */
  36670. fogDensity: number;
  36671. /**
  36672. * Gets or sets the fog start distance to use
  36673. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36674. * (Default is 0)
  36675. */
  36676. fogStart: number;
  36677. /**
  36678. * Gets or sets the fog end distance to use
  36679. * @see http://doc.babylonjs.com/babylon101/environment#fog
  36680. * (Default is 1000)
  36681. */
  36682. fogEnd: number;
  36683. private _shadowsEnabled;
  36684. /**
  36685. * Gets or sets a boolean indicating if shadows are enabled on this scene
  36686. */
  36687. set shadowsEnabled(value: boolean);
  36688. get shadowsEnabled(): boolean;
  36689. private _lightsEnabled;
  36690. /**
  36691. * Gets or sets a boolean indicating if lights are enabled on this scene
  36692. */
  36693. set lightsEnabled(value: boolean);
  36694. get lightsEnabled(): boolean;
  36695. /** All of the active cameras added to this scene. */
  36696. activeCameras: Camera[];
  36697. /** @hidden */
  36698. _activeCamera: Nullable<Camera>;
  36699. /** Gets or sets the current active camera */
  36700. get activeCamera(): Nullable<Camera>;
  36701. set activeCamera(value: Nullable<Camera>);
  36702. private _defaultMaterial;
  36703. /** The default material used on meshes when no material is affected */
  36704. get defaultMaterial(): Material;
  36705. /** The default material used on meshes when no material is affected */
  36706. set defaultMaterial(value: Material);
  36707. private _texturesEnabled;
  36708. /**
  36709. * Gets or sets a boolean indicating if textures are enabled on this scene
  36710. */
  36711. set texturesEnabled(value: boolean);
  36712. get texturesEnabled(): boolean;
  36713. /**
  36714. * Gets or sets a boolean indicating if particles are enabled on this scene
  36715. */
  36716. particlesEnabled: boolean;
  36717. /**
  36718. * Gets or sets a boolean indicating if sprites are enabled on this scene
  36719. */
  36720. spritesEnabled: boolean;
  36721. private _skeletonsEnabled;
  36722. /**
  36723. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  36724. */
  36725. set skeletonsEnabled(value: boolean);
  36726. get skeletonsEnabled(): boolean;
  36727. /**
  36728. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  36729. */
  36730. lensFlaresEnabled: boolean;
  36731. /**
  36732. * Gets or sets a boolean indicating if collisions are enabled on this scene
  36733. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36734. */
  36735. collisionsEnabled: boolean;
  36736. private _collisionCoordinator;
  36737. /** @hidden */
  36738. get collisionCoordinator(): ICollisionCoordinator;
  36739. /**
  36740. * Defines the gravity applied to this scene (used only for collisions)
  36741. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  36742. */
  36743. gravity: Vector3;
  36744. /**
  36745. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  36746. */
  36747. postProcessesEnabled: boolean;
  36748. /**
  36749. * The list of postprocesses added to the scene
  36750. */
  36751. postProcesses: PostProcess[];
  36752. /**
  36753. * Gets the current postprocess manager
  36754. */
  36755. postProcessManager: PostProcessManager;
  36756. /**
  36757. * Gets or sets a boolean indicating if render targets are enabled on this scene
  36758. */
  36759. renderTargetsEnabled: boolean;
  36760. /**
  36761. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  36762. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  36763. */
  36764. dumpNextRenderTargets: boolean;
  36765. /**
  36766. * The list of user defined render targets added to the scene
  36767. */
  36768. customRenderTargets: RenderTargetTexture[];
  36769. /**
  36770. * Defines if texture loading must be delayed
  36771. * If true, textures will only be loaded when they need to be rendered
  36772. */
  36773. useDelayedTextureLoading: boolean;
  36774. /**
  36775. * Gets the list of meshes imported to the scene through SceneLoader
  36776. */
  36777. importedMeshesFiles: String[];
  36778. /**
  36779. * Gets or sets a boolean indicating if probes are enabled on this scene
  36780. */
  36781. probesEnabled: boolean;
  36782. /**
  36783. * Gets or sets the current offline provider to use to store scene data
  36784. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  36785. */
  36786. offlineProvider: IOfflineProvider;
  36787. /**
  36788. * Gets or sets the action manager associated with the scene
  36789. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36790. */
  36791. actionManager: AbstractActionManager;
  36792. private _meshesForIntersections;
  36793. /**
  36794. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  36795. */
  36796. proceduralTexturesEnabled: boolean;
  36797. private _engine;
  36798. private _totalVertices;
  36799. /** @hidden */
  36800. _activeIndices: PerfCounter;
  36801. /** @hidden */
  36802. _activeParticles: PerfCounter;
  36803. /** @hidden */
  36804. _activeBones: PerfCounter;
  36805. private _animationRatio;
  36806. /** @hidden */
  36807. _animationTimeLast: number;
  36808. /** @hidden */
  36809. _animationTime: number;
  36810. /**
  36811. * Gets or sets a general scale for animation speed
  36812. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  36813. */
  36814. animationTimeScale: number;
  36815. /** @hidden */
  36816. _cachedMaterial: Nullable<Material>;
  36817. /** @hidden */
  36818. _cachedEffect: Nullable<Effect>;
  36819. /** @hidden */
  36820. _cachedVisibility: Nullable<number>;
  36821. private _renderId;
  36822. private _frameId;
  36823. private _executeWhenReadyTimeoutId;
  36824. private _intermediateRendering;
  36825. private _viewUpdateFlag;
  36826. private _projectionUpdateFlag;
  36827. /** @hidden */
  36828. _toBeDisposed: Nullable<IDisposable>[];
  36829. private _activeRequests;
  36830. /** @hidden */
  36831. _pendingData: any[];
  36832. private _isDisposed;
  36833. /**
  36834. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  36835. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  36836. */
  36837. dispatchAllSubMeshesOfActiveMeshes: boolean;
  36838. private _activeMeshes;
  36839. private _processedMaterials;
  36840. private _renderTargets;
  36841. /** @hidden */
  36842. _activeParticleSystems: SmartArray<IParticleSystem>;
  36843. private _activeSkeletons;
  36844. private _softwareSkinnedMeshes;
  36845. private _renderingManager;
  36846. /** @hidden */
  36847. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  36848. private _transformMatrix;
  36849. private _sceneUbo;
  36850. /** @hidden */
  36851. _viewMatrix: Matrix;
  36852. private _projectionMatrix;
  36853. /** @hidden */
  36854. _forcedViewPosition: Nullable<Vector3>;
  36855. /** @hidden */
  36856. _frustumPlanes: Plane[];
  36857. /**
  36858. * Gets the list of frustum planes (built from the active camera)
  36859. */
  36860. get frustumPlanes(): Plane[];
  36861. /**
  36862. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  36863. * This is useful if there are more lights that the maximum simulteanous authorized
  36864. */
  36865. requireLightSorting: boolean;
  36866. /** @hidden */
  36867. readonly useMaterialMeshMap: boolean;
  36868. /** @hidden */
  36869. readonly useClonedMeshMap: boolean;
  36870. private _externalData;
  36871. private _uid;
  36872. /**
  36873. * @hidden
  36874. * Backing store of defined scene components.
  36875. */
  36876. _components: ISceneComponent[];
  36877. /**
  36878. * @hidden
  36879. * Backing store of defined scene components.
  36880. */
  36881. _serializableComponents: ISceneSerializableComponent[];
  36882. /**
  36883. * List of components to register on the next registration step.
  36884. */
  36885. private _transientComponents;
  36886. /**
  36887. * Registers the transient components if needed.
  36888. */
  36889. private _registerTransientComponents;
  36890. /**
  36891. * @hidden
  36892. * Add a component to the scene.
  36893. * Note that the ccomponent could be registered on th next frame if this is called after
  36894. * the register component stage.
  36895. * @param component Defines the component to add to the scene
  36896. */
  36897. _addComponent(component: ISceneComponent): void;
  36898. /**
  36899. * @hidden
  36900. * Gets a component from the scene.
  36901. * @param name defines the name of the component to retrieve
  36902. * @returns the component or null if not present
  36903. */
  36904. _getComponent(name: string): Nullable<ISceneComponent>;
  36905. /**
  36906. * @hidden
  36907. * Defines the actions happening before camera updates.
  36908. */
  36909. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  36910. /**
  36911. * @hidden
  36912. * Defines the actions happening before clear the canvas.
  36913. */
  36914. _beforeClearStage: Stage<SimpleStageAction>;
  36915. /**
  36916. * @hidden
  36917. * Defines the actions when collecting render targets for the frame.
  36918. */
  36919. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36920. /**
  36921. * @hidden
  36922. * Defines the actions happening for one camera in the frame.
  36923. */
  36924. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  36925. /**
  36926. * @hidden
  36927. * Defines the actions happening during the per mesh ready checks.
  36928. */
  36929. _isReadyForMeshStage: Stage<MeshStageAction>;
  36930. /**
  36931. * @hidden
  36932. * Defines the actions happening before evaluate active mesh checks.
  36933. */
  36934. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  36935. /**
  36936. * @hidden
  36937. * Defines the actions happening during the evaluate sub mesh checks.
  36938. */
  36939. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  36940. /**
  36941. * @hidden
  36942. * Defines the actions happening during the active mesh stage.
  36943. */
  36944. _activeMeshStage: Stage<ActiveMeshStageAction>;
  36945. /**
  36946. * @hidden
  36947. * Defines the actions happening during the per camera render target step.
  36948. */
  36949. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  36950. /**
  36951. * @hidden
  36952. * Defines the actions happening just before the active camera is drawing.
  36953. */
  36954. _beforeCameraDrawStage: Stage<CameraStageAction>;
  36955. /**
  36956. * @hidden
  36957. * Defines the actions happening just before a render target is drawing.
  36958. */
  36959. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36960. /**
  36961. * @hidden
  36962. * Defines the actions happening just before a rendering group is drawing.
  36963. */
  36964. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36965. /**
  36966. * @hidden
  36967. * Defines the actions happening just before a mesh is drawing.
  36968. */
  36969. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36970. /**
  36971. * @hidden
  36972. * Defines the actions happening just after a mesh has been drawn.
  36973. */
  36974. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  36975. /**
  36976. * @hidden
  36977. * Defines the actions happening just after a rendering group has been drawn.
  36978. */
  36979. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  36980. /**
  36981. * @hidden
  36982. * Defines the actions happening just after the active camera has been drawn.
  36983. */
  36984. _afterCameraDrawStage: Stage<CameraStageAction>;
  36985. /**
  36986. * @hidden
  36987. * Defines the actions happening just after a render target has been drawn.
  36988. */
  36989. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  36990. /**
  36991. * @hidden
  36992. * Defines the actions happening just after rendering all cameras and computing intersections.
  36993. */
  36994. _afterRenderStage: Stage<SimpleStageAction>;
  36995. /**
  36996. * @hidden
  36997. * Defines the actions happening when a pointer move event happens.
  36998. */
  36999. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37000. /**
  37001. * @hidden
  37002. * Defines the actions happening when a pointer down event happens.
  37003. */
  37004. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37005. /**
  37006. * @hidden
  37007. * Defines the actions happening when a pointer up event happens.
  37008. */
  37009. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37010. /**
  37011. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37012. */
  37013. private geometriesByUniqueId;
  37014. /**
  37015. * Creates a new Scene
  37016. * @param engine defines the engine to use to render this scene
  37017. * @param options defines the scene options
  37018. */
  37019. constructor(engine: Engine, options?: SceneOptions);
  37020. /**
  37021. * Gets a string idenfifying the name of the class
  37022. * @returns "Scene" string
  37023. */
  37024. getClassName(): string;
  37025. private _defaultMeshCandidates;
  37026. /**
  37027. * @hidden
  37028. */
  37029. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37030. private _defaultSubMeshCandidates;
  37031. /**
  37032. * @hidden
  37033. */
  37034. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37035. /**
  37036. * Sets the default candidate providers for the scene.
  37037. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37038. * and getCollidingSubMeshCandidates to their default function
  37039. */
  37040. setDefaultCandidateProviders(): void;
  37041. /**
  37042. * Gets the mesh that is currently under the pointer
  37043. */
  37044. get meshUnderPointer(): Nullable<AbstractMesh>;
  37045. /**
  37046. * Gets or sets the current on-screen X position of the pointer
  37047. */
  37048. get pointerX(): number;
  37049. set pointerX(value: number);
  37050. /**
  37051. * Gets or sets the current on-screen Y position of the pointer
  37052. */
  37053. get pointerY(): number;
  37054. set pointerY(value: number);
  37055. /**
  37056. * Gets the cached material (ie. the latest rendered one)
  37057. * @returns the cached material
  37058. */
  37059. getCachedMaterial(): Nullable<Material>;
  37060. /**
  37061. * Gets the cached effect (ie. the latest rendered one)
  37062. * @returns the cached effect
  37063. */
  37064. getCachedEffect(): Nullable<Effect>;
  37065. /**
  37066. * Gets the cached visibility state (ie. the latest rendered one)
  37067. * @returns the cached visibility state
  37068. */
  37069. getCachedVisibility(): Nullable<number>;
  37070. /**
  37071. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37072. * @param material defines the current material
  37073. * @param effect defines the current effect
  37074. * @param visibility defines the current visibility state
  37075. * @returns true if one parameter is not cached
  37076. */
  37077. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37078. /**
  37079. * Gets the engine associated with the scene
  37080. * @returns an Engine
  37081. */
  37082. getEngine(): Engine;
  37083. /**
  37084. * Gets the total number of vertices rendered per frame
  37085. * @returns the total number of vertices rendered per frame
  37086. */
  37087. getTotalVertices(): number;
  37088. /**
  37089. * Gets the performance counter for total vertices
  37090. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37091. */
  37092. get totalVerticesPerfCounter(): PerfCounter;
  37093. /**
  37094. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37095. * @returns the total number of active indices rendered per frame
  37096. */
  37097. getActiveIndices(): number;
  37098. /**
  37099. * Gets the performance counter for active indices
  37100. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37101. */
  37102. get totalActiveIndicesPerfCounter(): PerfCounter;
  37103. /**
  37104. * Gets the total number of active particles rendered per frame
  37105. * @returns the total number of active particles rendered per frame
  37106. */
  37107. getActiveParticles(): number;
  37108. /**
  37109. * Gets the performance counter for active particles
  37110. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37111. */
  37112. get activeParticlesPerfCounter(): PerfCounter;
  37113. /**
  37114. * Gets the total number of active bones rendered per frame
  37115. * @returns the total number of active bones rendered per frame
  37116. */
  37117. getActiveBones(): number;
  37118. /**
  37119. * Gets the performance counter for active bones
  37120. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37121. */
  37122. get activeBonesPerfCounter(): PerfCounter;
  37123. /**
  37124. * Gets the array of active meshes
  37125. * @returns an array of AbstractMesh
  37126. */
  37127. getActiveMeshes(): SmartArray<AbstractMesh>;
  37128. /**
  37129. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37130. * @returns a number
  37131. */
  37132. getAnimationRatio(): number;
  37133. /**
  37134. * Gets an unique Id for the current render phase
  37135. * @returns a number
  37136. */
  37137. getRenderId(): number;
  37138. /**
  37139. * Gets an unique Id for the current frame
  37140. * @returns a number
  37141. */
  37142. getFrameId(): number;
  37143. /** Call this function if you want to manually increment the render Id*/
  37144. incrementRenderId(): void;
  37145. private _createUbo;
  37146. /**
  37147. * Use this method to simulate a pointer move on a mesh
  37148. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37149. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37150. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37151. * @returns the current scene
  37152. */
  37153. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37154. /**
  37155. * Use this method to simulate a pointer down on a mesh
  37156. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37157. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37158. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37159. * @returns the current scene
  37160. */
  37161. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37162. /**
  37163. * Use this method to simulate a pointer up on a mesh
  37164. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37165. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37166. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37167. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37168. * @returns the current scene
  37169. */
  37170. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37171. /**
  37172. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37173. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37174. * @returns true if the pointer was captured
  37175. */
  37176. isPointerCaptured(pointerId?: number): boolean;
  37177. /**
  37178. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37179. * @param attachUp defines if you want to attach events to pointerup
  37180. * @param attachDown defines if you want to attach events to pointerdown
  37181. * @param attachMove defines if you want to attach events to pointermove
  37182. */
  37183. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37184. /** Detaches all event handlers*/
  37185. detachControl(): void;
  37186. /**
  37187. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37188. * Delay loaded resources are not taking in account
  37189. * @return true if all required resources are ready
  37190. */
  37191. isReady(): boolean;
  37192. /** Resets all cached information relative to material (including effect and visibility) */
  37193. resetCachedMaterial(): void;
  37194. /**
  37195. * Registers a function to be called before every frame render
  37196. * @param func defines the function to register
  37197. */
  37198. registerBeforeRender(func: () => void): void;
  37199. /**
  37200. * Unregisters a function called before every frame render
  37201. * @param func defines the function to unregister
  37202. */
  37203. unregisterBeforeRender(func: () => void): void;
  37204. /**
  37205. * Registers a function to be called after every frame render
  37206. * @param func defines the function to register
  37207. */
  37208. registerAfterRender(func: () => void): void;
  37209. /**
  37210. * Unregisters a function called after every frame render
  37211. * @param func defines the function to unregister
  37212. */
  37213. unregisterAfterRender(func: () => void): void;
  37214. private _executeOnceBeforeRender;
  37215. /**
  37216. * The provided function will run before render once and will be disposed afterwards.
  37217. * A timeout delay can be provided so that the function will be executed in N ms.
  37218. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37219. * @param func The function to be executed.
  37220. * @param timeout optional delay in ms
  37221. */
  37222. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37223. /** @hidden */
  37224. _addPendingData(data: any): void;
  37225. /** @hidden */
  37226. _removePendingData(data: any): void;
  37227. /**
  37228. * Returns the number of items waiting to be loaded
  37229. * @returns the number of items waiting to be loaded
  37230. */
  37231. getWaitingItemsCount(): number;
  37232. /**
  37233. * Returns a boolean indicating if the scene is still loading data
  37234. */
  37235. get isLoading(): boolean;
  37236. /**
  37237. * Registers a function to be executed when the scene is ready
  37238. * @param {Function} func - the function to be executed
  37239. */
  37240. executeWhenReady(func: () => void): void;
  37241. /**
  37242. * Returns a promise that resolves when the scene is ready
  37243. * @returns A promise that resolves when the scene is ready
  37244. */
  37245. whenReadyAsync(): Promise<void>;
  37246. /** @hidden */
  37247. _checkIsReady(): void;
  37248. /**
  37249. * Gets all animatable attached to the scene
  37250. */
  37251. get animatables(): Animatable[];
  37252. /**
  37253. * Resets the last animation time frame.
  37254. * Useful to override when animations start running when loading a scene for the first time.
  37255. */
  37256. resetLastAnimationTimeFrame(): void;
  37257. /**
  37258. * Gets the current view matrix
  37259. * @returns a Matrix
  37260. */
  37261. getViewMatrix(): Matrix;
  37262. /**
  37263. * Gets the current projection matrix
  37264. * @returns a Matrix
  37265. */
  37266. getProjectionMatrix(): Matrix;
  37267. /**
  37268. * Gets the current transform matrix
  37269. * @returns a Matrix made of View * Projection
  37270. */
  37271. getTransformMatrix(): Matrix;
  37272. /**
  37273. * Sets the current transform matrix
  37274. * @param viewL defines the View matrix to use
  37275. * @param projectionL defines the Projection matrix to use
  37276. * @param viewR defines the right View matrix to use (if provided)
  37277. * @param projectionR defines the right Projection matrix to use (if provided)
  37278. */
  37279. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37280. /**
  37281. * Gets the uniform buffer used to store scene data
  37282. * @returns a UniformBuffer
  37283. */
  37284. getSceneUniformBuffer(): UniformBuffer;
  37285. /**
  37286. * Gets an unique (relatively to the current scene) Id
  37287. * @returns an unique number for the scene
  37288. */
  37289. getUniqueId(): number;
  37290. /**
  37291. * Add a mesh to the list of scene's meshes
  37292. * @param newMesh defines the mesh to add
  37293. * @param recursive if all child meshes should also be added to the scene
  37294. */
  37295. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37296. /**
  37297. * Remove a mesh for the list of scene's meshes
  37298. * @param toRemove defines the mesh to remove
  37299. * @param recursive if all child meshes should also be removed from the scene
  37300. * @returns the index where the mesh was in the mesh list
  37301. */
  37302. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37303. /**
  37304. * Add a transform node to the list of scene's transform nodes
  37305. * @param newTransformNode defines the transform node to add
  37306. */
  37307. addTransformNode(newTransformNode: TransformNode): void;
  37308. /**
  37309. * Remove a transform node for the list of scene's transform nodes
  37310. * @param toRemove defines the transform node to remove
  37311. * @returns the index where the transform node was in the transform node list
  37312. */
  37313. removeTransformNode(toRemove: TransformNode): number;
  37314. /**
  37315. * Remove a skeleton for the list of scene's skeletons
  37316. * @param toRemove defines the skeleton to remove
  37317. * @returns the index where the skeleton was in the skeleton list
  37318. */
  37319. removeSkeleton(toRemove: Skeleton): number;
  37320. /**
  37321. * Remove a morph target for the list of scene's morph targets
  37322. * @param toRemove defines the morph target to remove
  37323. * @returns the index where the morph target was in the morph target list
  37324. */
  37325. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37326. /**
  37327. * Remove a light for the list of scene's lights
  37328. * @param toRemove defines the light to remove
  37329. * @returns the index where the light was in the light list
  37330. */
  37331. removeLight(toRemove: Light): number;
  37332. /**
  37333. * Remove a camera for the list of scene's cameras
  37334. * @param toRemove defines the camera to remove
  37335. * @returns the index where the camera was in the camera list
  37336. */
  37337. removeCamera(toRemove: Camera): number;
  37338. /**
  37339. * Remove a particle system for the list of scene's particle systems
  37340. * @param toRemove defines the particle system to remove
  37341. * @returns the index where the particle system was in the particle system list
  37342. */
  37343. removeParticleSystem(toRemove: IParticleSystem): number;
  37344. /**
  37345. * Remove a animation for the list of scene's animations
  37346. * @param toRemove defines the animation to remove
  37347. * @returns the index where the animation was in the animation list
  37348. */
  37349. removeAnimation(toRemove: Animation): number;
  37350. /**
  37351. * Will stop the animation of the given target
  37352. * @param target - the target
  37353. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37354. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  37355. */
  37356. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37357. /**
  37358. * Removes the given animation group from this scene.
  37359. * @param toRemove The animation group to remove
  37360. * @returns The index of the removed animation group
  37361. */
  37362. removeAnimationGroup(toRemove: AnimationGroup): number;
  37363. /**
  37364. * Removes the given multi-material from this scene.
  37365. * @param toRemove The multi-material to remove
  37366. * @returns The index of the removed multi-material
  37367. */
  37368. removeMultiMaterial(toRemove: MultiMaterial): number;
  37369. /**
  37370. * Removes the given material from this scene.
  37371. * @param toRemove The material to remove
  37372. * @returns The index of the removed material
  37373. */
  37374. removeMaterial(toRemove: Material): number;
  37375. /**
  37376. * Removes the given action manager from this scene.
  37377. * @param toRemove The action manager to remove
  37378. * @returns The index of the removed action manager
  37379. */
  37380. removeActionManager(toRemove: AbstractActionManager): number;
  37381. /**
  37382. * Removes the given texture from this scene.
  37383. * @param toRemove The texture to remove
  37384. * @returns The index of the removed texture
  37385. */
  37386. removeTexture(toRemove: BaseTexture): number;
  37387. /**
  37388. * Adds the given light to this scene
  37389. * @param newLight The light to add
  37390. */
  37391. addLight(newLight: Light): void;
  37392. /**
  37393. * Sorts the list list based on light priorities
  37394. */
  37395. sortLightsByPriority(): void;
  37396. /**
  37397. * Adds the given camera to this scene
  37398. * @param newCamera The camera to add
  37399. */
  37400. addCamera(newCamera: Camera): void;
  37401. /**
  37402. * Adds the given skeleton to this scene
  37403. * @param newSkeleton The skeleton to add
  37404. */
  37405. addSkeleton(newSkeleton: Skeleton): void;
  37406. /**
  37407. * Adds the given particle system to this scene
  37408. * @param newParticleSystem The particle system to add
  37409. */
  37410. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37411. /**
  37412. * Adds the given animation to this scene
  37413. * @param newAnimation The animation to add
  37414. */
  37415. addAnimation(newAnimation: Animation): void;
  37416. /**
  37417. * Adds the given animation group to this scene.
  37418. * @param newAnimationGroup The animation group to add
  37419. */
  37420. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37421. /**
  37422. * Adds the given multi-material to this scene
  37423. * @param newMultiMaterial The multi-material to add
  37424. */
  37425. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37426. /**
  37427. * Adds the given material to this scene
  37428. * @param newMaterial The material to add
  37429. */
  37430. addMaterial(newMaterial: Material): void;
  37431. /**
  37432. * Adds the given morph target to this scene
  37433. * @param newMorphTargetManager The morph target to add
  37434. */
  37435. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37436. /**
  37437. * Adds the given geometry to this scene
  37438. * @param newGeometry The geometry to add
  37439. */
  37440. addGeometry(newGeometry: Geometry): void;
  37441. /**
  37442. * Adds the given action manager to this scene
  37443. * @param newActionManager The action manager to add
  37444. */
  37445. addActionManager(newActionManager: AbstractActionManager): void;
  37446. /**
  37447. * Adds the given texture to this scene.
  37448. * @param newTexture The texture to add
  37449. */
  37450. addTexture(newTexture: BaseTexture): void;
  37451. /**
  37452. * Switch active camera
  37453. * @param newCamera defines the new active camera
  37454. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37455. */
  37456. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37457. /**
  37458. * sets the active camera of the scene using its ID
  37459. * @param id defines the camera's ID
  37460. * @return the new active camera or null if none found.
  37461. */
  37462. setActiveCameraByID(id: string): Nullable<Camera>;
  37463. /**
  37464. * sets the active camera of the scene using its name
  37465. * @param name defines the camera's name
  37466. * @returns the new active camera or null if none found.
  37467. */
  37468. setActiveCameraByName(name: string): Nullable<Camera>;
  37469. /**
  37470. * get an animation group using its name
  37471. * @param name defines the material's name
  37472. * @return the animation group or null if none found.
  37473. */
  37474. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37475. /**
  37476. * Get a material using its unique id
  37477. * @param uniqueId defines the material's unique id
  37478. * @return the material or null if none found.
  37479. */
  37480. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37481. /**
  37482. * get a material using its id
  37483. * @param id defines the material's ID
  37484. * @return the material or null if none found.
  37485. */
  37486. getMaterialByID(id: string): Nullable<Material>;
  37487. /**
  37488. * Gets a the last added material using a given id
  37489. * @param id defines the material's ID
  37490. * @return the last material with the given id or null if none found.
  37491. */
  37492. getLastMaterialByID(id: string): Nullable<Material>;
  37493. /**
  37494. * Gets a material using its name
  37495. * @param name defines the material's name
  37496. * @return the material or null if none found.
  37497. */
  37498. getMaterialByName(name: string): Nullable<Material>;
  37499. /**
  37500. * Get a texture using its unique id
  37501. * @param uniqueId defines the texture's unique id
  37502. * @return the texture or null if none found.
  37503. */
  37504. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37505. /**
  37506. * Gets a camera using its id
  37507. * @param id defines the id to look for
  37508. * @returns the camera or null if not found
  37509. */
  37510. getCameraByID(id: string): Nullable<Camera>;
  37511. /**
  37512. * Gets a camera using its unique id
  37513. * @param uniqueId defines the unique id to look for
  37514. * @returns the camera or null if not found
  37515. */
  37516. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37517. /**
  37518. * Gets a camera using its name
  37519. * @param name defines the camera's name
  37520. * @return the camera or null if none found.
  37521. */
  37522. getCameraByName(name: string): Nullable<Camera>;
  37523. /**
  37524. * Gets a bone using its id
  37525. * @param id defines the bone's id
  37526. * @return the bone or null if not found
  37527. */
  37528. getBoneByID(id: string): Nullable<Bone>;
  37529. /**
  37530. * Gets a bone using its id
  37531. * @param name defines the bone's name
  37532. * @return the bone or null if not found
  37533. */
  37534. getBoneByName(name: string): Nullable<Bone>;
  37535. /**
  37536. * Gets a light node using its name
  37537. * @param name defines the the light's name
  37538. * @return the light or null if none found.
  37539. */
  37540. getLightByName(name: string): Nullable<Light>;
  37541. /**
  37542. * Gets a light node using its id
  37543. * @param id defines the light's id
  37544. * @return the light or null if none found.
  37545. */
  37546. getLightByID(id: string): Nullable<Light>;
  37547. /**
  37548. * Gets a light node using its scene-generated unique ID
  37549. * @param uniqueId defines the light's unique id
  37550. * @return the light or null if none found.
  37551. */
  37552. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37553. /**
  37554. * Gets a particle system by id
  37555. * @param id defines the particle system id
  37556. * @return the corresponding system or null if none found
  37557. */
  37558. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37559. /**
  37560. * Gets a geometry using its ID
  37561. * @param id defines the geometry's id
  37562. * @return the geometry or null if none found.
  37563. */
  37564. getGeometryByID(id: string): Nullable<Geometry>;
  37565. private _getGeometryByUniqueID;
  37566. /**
  37567. * Add a new geometry to this scene
  37568. * @param geometry defines the geometry to be added to the scene.
  37569. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37570. * @return a boolean defining if the geometry was added or not
  37571. */
  37572. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37573. /**
  37574. * Removes an existing geometry
  37575. * @param geometry defines the geometry to be removed from the scene
  37576. * @return a boolean defining if the geometry was removed or not
  37577. */
  37578. removeGeometry(geometry: Geometry): boolean;
  37579. /**
  37580. * Gets the list of geometries attached to the scene
  37581. * @returns an array of Geometry
  37582. */
  37583. getGeometries(): Geometry[];
  37584. /**
  37585. * Gets the first added mesh found of a given ID
  37586. * @param id defines the id to search for
  37587. * @return the mesh found or null if not found at all
  37588. */
  37589. getMeshByID(id: string): Nullable<AbstractMesh>;
  37590. /**
  37591. * Gets a list of meshes using their id
  37592. * @param id defines the id to search for
  37593. * @returns a list of meshes
  37594. */
  37595. getMeshesByID(id: string): Array<AbstractMesh>;
  37596. /**
  37597. * Gets the first added transform node found of a given ID
  37598. * @param id defines the id to search for
  37599. * @return the found transform node or null if not found at all.
  37600. */
  37601. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37602. /**
  37603. * Gets a transform node with its auto-generated unique id
  37604. * @param uniqueId efines the unique id to search for
  37605. * @return the found transform node or null if not found at all.
  37606. */
  37607. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37608. /**
  37609. * Gets a list of transform nodes using their id
  37610. * @param id defines the id to search for
  37611. * @returns a list of transform nodes
  37612. */
  37613. getTransformNodesByID(id: string): Array<TransformNode>;
  37614. /**
  37615. * Gets a mesh with its auto-generated unique id
  37616. * @param uniqueId defines the unique id to search for
  37617. * @return the found mesh or null if not found at all.
  37618. */
  37619. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  37620. /**
  37621. * Gets a the last added mesh using a given id
  37622. * @param id defines the id to search for
  37623. * @return the found mesh or null if not found at all.
  37624. */
  37625. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  37626. /**
  37627. * Gets a the last added node (Mesh, Camera, Light) using a given id
  37628. * @param id defines the id to search for
  37629. * @return the found node or null if not found at all
  37630. */
  37631. getLastEntryByID(id: string): Nullable<Node>;
  37632. /**
  37633. * Gets a node (Mesh, Camera, Light) using a given id
  37634. * @param id defines the id to search for
  37635. * @return the found node or null if not found at all
  37636. */
  37637. getNodeByID(id: string): Nullable<Node>;
  37638. /**
  37639. * Gets a node (Mesh, Camera, Light) using a given name
  37640. * @param name defines the name to search for
  37641. * @return the found node or null if not found at all.
  37642. */
  37643. getNodeByName(name: string): Nullable<Node>;
  37644. /**
  37645. * Gets a mesh using a given name
  37646. * @param name defines the name to search for
  37647. * @return the found mesh or null if not found at all.
  37648. */
  37649. getMeshByName(name: string): Nullable<AbstractMesh>;
  37650. /**
  37651. * Gets a transform node using a given name
  37652. * @param name defines the name to search for
  37653. * @return the found transform node or null if not found at all.
  37654. */
  37655. getTransformNodeByName(name: string): Nullable<TransformNode>;
  37656. /**
  37657. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  37658. * @param id defines the id to search for
  37659. * @return the found skeleton or null if not found at all.
  37660. */
  37661. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  37662. /**
  37663. * Gets a skeleton using a given auto generated unique id
  37664. * @param uniqueId defines the unique id to search for
  37665. * @return the found skeleton or null if not found at all.
  37666. */
  37667. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  37668. /**
  37669. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  37670. * @param id defines the id to search for
  37671. * @return the found skeleton or null if not found at all.
  37672. */
  37673. getSkeletonById(id: string): Nullable<Skeleton>;
  37674. /**
  37675. * Gets a skeleton using a given name
  37676. * @param name defines the name to search for
  37677. * @return the found skeleton or null if not found at all.
  37678. */
  37679. getSkeletonByName(name: string): Nullable<Skeleton>;
  37680. /**
  37681. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  37682. * @param id defines the id to search for
  37683. * @return the found morph target manager or null if not found at all.
  37684. */
  37685. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  37686. /**
  37687. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  37688. * @param id defines the id to search for
  37689. * @return the found morph target or null if not found at all.
  37690. */
  37691. getMorphTargetById(id: string): Nullable<MorphTarget>;
  37692. /**
  37693. * Gets a boolean indicating if the given mesh is active
  37694. * @param mesh defines the mesh to look for
  37695. * @returns true if the mesh is in the active list
  37696. */
  37697. isActiveMesh(mesh: AbstractMesh): boolean;
  37698. /**
  37699. * Return a unique id as a string which can serve as an identifier for the scene
  37700. */
  37701. get uid(): string;
  37702. /**
  37703. * Add an externaly attached data from its key.
  37704. * This method call will fail and return false, if such key already exists.
  37705. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  37706. * @param key the unique key that identifies the data
  37707. * @param data the data object to associate to the key for this Engine instance
  37708. * @return true if no such key were already present and the data was added successfully, false otherwise
  37709. */
  37710. addExternalData<T>(key: string, data: T): boolean;
  37711. /**
  37712. * Get an externaly attached data from its key
  37713. * @param key the unique key that identifies the data
  37714. * @return the associated data, if present (can be null), or undefined if not present
  37715. */
  37716. getExternalData<T>(key: string): Nullable<T>;
  37717. /**
  37718. * Get an externaly attached data from its key, create it using a factory if it's not already present
  37719. * @param key the unique key that identifies the data
  37720. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  37721. * @return the associated data, can be null if the factory returned null.
  37722. */
  37723. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  37724. /**
  37725. * Remove an externaly attached data from the Engine instance
  37726. * @param key the unique key that identifies the data
  37727. * @return true if the data was successfully removed, false if it doesn't exist
  37728. */
  37729. removeExternalData(key: string): boolean;
  37730. private _evaluateSubMesh;
  37731. /**
  37732. * Clear the processed materials smart array preventing retention point in material dispose.
  37733. */
  37734. freeProcessedMaterials(): void;
  37735. private _preventFreeActiveMeshesAndRenderingGroups;
  37736. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  37737. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  37738. * when disposing several meshes in a row or a hierarchy of meshes.
  37739. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  37740. */
  37741. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  37742. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  37743. /**
  37744. * Clear the active meshes smart array preventing retention point in mesh dispose.
  37745. */
  37746. freeActiveMeshes(): void;
  37747. /**
  37748. * Clear the info related to rendering groups preventing retention points during dispose.
  37749. */
  37750. freeRenderingGroups(): void;
  37751. /** @hidden */
  37752. _isInIntermediateRendering(): boolean;
  37753. /**
  37754. * Lambda returning the list of potentially active meshes.
  37755. */
  37756. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  37757. /**
  37758. * Lambda returning the list of potentially active sub meshes.
  37759. */
  37760. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  37761. /**
  37762. * Lambda returning the list of potentially intersecting sub meshes.
  37763. */
  37764. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  37765. /**
  37766. * Lambda returning the list of potentially colliding sub meshes.
  37767. */
  37768. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  37769. private _activeMeshesFrozen;
  37770. private _skipEvaluateActiveMeshesCompletely;
  37771. /**
  37772. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  37773. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  37774. * @returns the current scene
  37775. */
  37776. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  37777. /**
  37778. * Use this function to restart evaluating active meshes on every frame
  37779. * @returns the current scene
  37780. */
  37781. unfreezeActiveMeshes(): Scene;
  37782. private _evaluateActiveMeshes;
  37783. private _activeMesh;
  37784. /**
  37785. * Update the transform matrix to update from the current active camera
  37786. * @param force defines a boolean used to force the update even if cache is up to date
  37787. */
  37788. updateTransformMatrix(force?: boolean): void;
  37789. private _bindFrameBuffer;
  37790. /** @hidden */
  37791. _allowPostProcessClearColor: boolean;
  37792. /** @hidden */
  37793. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  37794. private _processSubCameras;
  37795. private _checkIntersections;
  37796. /** @hidden */
  37797. _advancePhysicsEngineStep(step: number): void;
  37798. /**
  37799. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  37800. */
  37801. getDeterministicFrameTime: () => number;
  37802. /** @hidden */
  37803. _animate(): void;
  37804. /** Execute all animations (for a frame) */
  37805. animate(): void;
  37806. /**
  37807. * Render the scene
  37808. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  37809. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  37810. */
  37811. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  37812. /**
  37813. * Freeze all materials
  37814. * A frozen material will not be updatable but should be faster to render
  37815. */
  37816. freezeMaterials(): void;
  37817. /**
  37818. * Unfreeze all materials
  37819. * A frozen material will not be updatable but should be faster to render
  37820. */
  37821. unfreezeMaterials(): void;
  37822. /**
  37823. * Releases all held ressources
  37824. */
  37825. dispose(): void;
  37826. /**
  37827. * Gets if the scene is already disposed
  37828. */
  37829. get isDisposed(): boolean;
  37830. /**
  37831. * Call this function to reduce memory footprint of the scene.
  37832. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  37833. */
  37834. clearCachedVertexData(): void;
  37835. /**
  37836. * This function will remove the local cached buffer data from texture.
  37837. * It will save memory but will prevent the texture from being rebuilt
  37838. */
  37839. cleanCachedTextureBuffer(): void;
  37840. /**
  37841. * Get the world extend vectors with an optional filter
  37842. *
  37843. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  37844. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  37845. */
  37846. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  37847. min: Vector3;
  37848. max: Vector3;
  37849. };
  37850. /**
  37851. * Creates a ray that can be used to pick in the scene
  37852. * @param x defines the x coordinate of the origin (on-screen)
  37853. * @param y defines the y coordinate of the origin (on-screen)
  37854. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37855. * @param camera defines the camera to use for the picking
  37856. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37857. * @returns a Ray
  37858. */
  37859. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  37860. /**
  37861. * Creates a ray that can be used to pick in the scene
  37862. * @param x defines the x coordinate of the origin (on-screen)
  37863. * @param y defines the y coordinate of the origin (on-screen)
  37864. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  37865. * @param result defines the ray where to store the picking ray
  37866. * @param camera defines the camera to use for the picking
  37867. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  37868. * @returns the current scene
  37869. */
  37870. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  37871. /**
  37872. * Creates a ray that can be used to pick in the scene
  37873. * @param x defines the x coordinate of the origin (on-screen)
  37874. * @param y defines the y coordinate of the origin (on-screen)
  37875. * @param camera defines the camera to use for the picking
  37876. * @returns a Ray
  37877. */
  37878. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  37879. /**
  37880. * Creates a ray that can be used to pick in the scene
  37881. * @param x defines the x coordinate of the origin (on-screen)
  37882. * @param y defines the y coordinate of the origin (on-screen)
  37883. * @param result defines the ray where to store the picking ray
  37884. * @param camera defines the camera to use for the picking
  37885. * @returns the current scene
  37886. */
  37887. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  37888. /** Launch a ray to try to pick a mesh in the scene
  37889. * @param x position on screen
  37890. * @param y position on screen
  37891. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  37892. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  37893. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37894. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37895. * @returns a PickingInfo
  37896. */
  37897. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37898. /** Use the given ray to pick a mesh in the scene
  37899. * @param ray The ray to use to pick meshes
  37900. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  37901. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  37902. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37903. * @returns a PickingInfo
  37904. */
  37905. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  37906. /**
  37907. * Launch a ray to try to pick a mesh in the scene
  37908. * @param x X position on screen
  37909. * @param y Y position on screen
  37910. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  37911. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  37912. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37913. * @returns an array of PickingInfo
  37914. */
  37915. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37916. /**
  37917. * Launch a ray to try to pick a mesh in the scene
  37918. * @param ray Ray to use
  37919. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  37920. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  37921. * @returns an array of PickingInfo
  37922. */
  37923. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  37924. /**
  37925. * Force the value of meshUnderPointer
  37926. * @param mesh defines the mesh to use
  37927. */
  37928. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  37929. /**
  37930. * Gets the mesh under the pointer
  37931. * @returns a Mesh or null if no mesh is under the pointer
  37932. */
  37933. getPointerOverMesh(): Nullable<AbstractMesh>;
  37934. /** @hidden */
  37935. _rebuildGeometries(): void;
  37936. /** @hidden */
  37937. _rebuildTextures(): void;
  37938. private _getByTags;
  37939. /**
  37940. * Get a list of meshes by tags
  37941. * @param tagsQuery defines the tags query to use
  37942. * @param forEach defines a predicate used to filter results
  37943. * @returns an array of Mesh
  37944. */
  37945. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  37946. /**
  37947. * Get a list of cameras by tags
  37948. * @param tagsQuery defines the tags query to use
  37949. * @param forEach defines a predicate used to filter results
  37950. * @returns an array of Camera
  37951. */
  37952. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  37953. /**
  37954. * Get a list of lights by tags
  37955. * @param tagsQuery defines the tags query to use
  37956. * @param forEach defines a predicate used to filter results
  37957. * @returns an array of Light
  37958. */
  37959. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  37960. /**
  37961. * Get a list of materials by tags
  37962. * @param tagsQuery defines the tags query to use
  37963. * @param forEach defines a predicate used to filter results
  37964. * @returns an array of Material
  37965. */
  37966. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  37967. /**
  37968. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  37969. * This allowed control for front to back rendering or reversly depending of the special needs.
  37970. *
  37971. * @param renderingGroupId The rendering group id corresponding to its index
  37972. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  37973. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  37974. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  37975. */
  37976. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  37977. /**
  37978. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  37979. *
  37980. * @param renderingGroupId The rendering group id corresponding to its index
  37981. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  37982. * @param depth Automatically clears depth between groups if true and autoClear is true.
  37983. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  37984. */
  37985. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  37986. /**
  37987. * Gets the current auto clear configuration for one rendering group of the rendering
  37988. * manager.
  37989. * @param index the rendering group index to get the information for
  37990. * @returns The auto clear setup for the requested rendering group
  37991. */
  37992. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  37993. private _blockMaterialDirtyMechanism;
  37994. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  37995. get blockMaterialDirtyMechanism(): boolean;
  37996. set blockMaterialDirtyMechanism(value: boolean);
  37997. /**
  37998. * Will flag all materials as dirty to trigger new shader compilation
  37999. * @param flag defines the flag used to specify which material part must be marked as dirty
  38000. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38001. */
  38002. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38003. /** @hidden */
  38004. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: LoadFileError) => void): IFileRequest;
  38005. /** @hidden */
  38006. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38007. /** @hidden */
  38008. _requestFile(url: string, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  38009. /** @hidden */
  38010. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38011. /** @hidden */
  38012. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38013. /** @hidden */
  38014. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38015. }
  38016. }
  38017. declare module "babylonjs/assetContainer" {
  38018. import { AbstractScene } from "babylonjs/abstractScene";
  38019. import { Scene } from "babylonjs/scene";
  38020. import { Mesh } from "babylonjs/Meshes/mesh";
  38021. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38022. import { Skeleton } from "babylonjs/Bones/skeleton";
  38023. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38024. import { Animatable } from "babylonjs/Animations/animatable";
  38025. import { Nullable } from "babylonjs/types";
  38026. import { Node } from "babylonjs/node";
  38027. /**
  38028. * Set of assets to keep when moving a scene into an asset container.
  38029. */
  38030. export class KeepAssets extends AbstractScene {
  38031. }
  38032. /**
  38033. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38034. */
  38035. export class InstantiatedEntries {
  38036. /**
  38037. * List of new root nodes (eg. nodes with no parent)
  38038. */
  38039. rootNodes: TransformNode[];
  38040. /**
  38041. * List of new skeletons
  38042. */
  38043. skeletons: Skeleton[];
  38044. /**
  38045. * List of new animation groups
  38046. */
  38047. animationGroups: AnimationGroup[];
  38048. }
  38049. /**
  38050. * Container with a set of assets that can be added or removed from a scene.
  38051. */
  38052. export class AssetContainer extends AbstractScene {
  38053. private _wasAddedToScene;
  38054. /**
  38055. * The scene the AssetContainer belongs to.
  38056. */
  38057. scene: Scene;
  38058. /**
  38059. * Instantiates an AssetContainer.
  38060. * @param scene The scene the AssetContainer belongs to.
  38061. */
  38062. constructor(scene: Scene);
  38063. /**
  38064. * Instantiate or clone all meshes and add the new ones to the scene.
  38065. * Skeletons and animation groups will all be cloned
  38066. * @param nameFunction defines an optional function used to get new names for clones
  38067. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38068. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38069. */
  38070. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38071. /**
  38072. * Adds all the assets from the container to the scene.
  38073. */
  38074. addAllToScene(): void;
  38075. /**
  38076. * Removes all the assets in the container from the scene
  38077. */
  38078. removeAllFromScene(): void;
  38079. /**
  38080. * Disposes all the assets in the container
  38081. */
  38082. dispose(): void;
  38083. private _moveAssets;
  38084. /**
  38085. * Removes all the assets contained in the scene and adds them to the container.
  38086. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38087. */
  38088. moveAllFromScene(keepAssets?: KeepAssets): void;
  38089. /**
  38090. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  38091. * @returns the root mesh
  38092. */
  38093. createRootMesh(): Mesh;
  38094. /**
  38095. * Merge animations from this asset container into a scene
  38096. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38097. * @param animatables set of animatables to retarget to a node from the scene
  38098. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38099. */
  38100. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38101. }
  38102. }
  38103. declare module "babylonjs/abstractScene" {
  38104. import { Scene } from "babylonjs/scene";
  38105. import { Nullable } from "babylonjs/types";
  38106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38107. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38108. import { Geometry } from "babylonjs/Meshes/geometry";
  38109. import { Skeleton } from "babylonjs/Bones/skeleton";
  38110. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38111. import { AssetContainer } from "babylonjs/assetContainer";
  38112. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38113. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38114. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38115. import { Material } from "babylonjs/Materials/material";
  38116. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38117. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38118. import { Camera } from "babylonjs/Cameras/camera";
  38119. import { Light } from "babylonjs/Lights/light";
  38120. import { Node } from "babylonjs/node";
  38121. import { Animation } from "babylonjs/Animations/animation";
  38122. /**
  38123. * Defines how the parser contract is defined.
  38124. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38125. */
  38126. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38127. /**
  38128. * Defines how the individual parser contract is defined.
  38129. * These parser can parse an individual asset
  38130. */
  38131. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38132. /**
  38133. * Base class of the scene acting as a container for the different elements composing a scene.
  38134. * This class is dynamically extended by the different components of the scene increasing
  38135. * flexibility and reducing coupling
  38136. */
  38137. export abstract class AbstractScene {
  38138. /**
  38139. * Stores the list of available parsers in the application.
  38140. */
  38141. private static _BabylonFileParsers;
  38142. /**
  38143. * Stores the list of available individual parsers in the application.
  38144. */
  38145. private static _IndividualBabylonFileParsers;
  38146. /**
  38147. * Adds a parser in the list of available ones
  38148. * @param name Defines the name of the parser
  38149. * @param parser Defines the parser to add
  38150. */
  38151. static AddParser(name: string, parser: BabylonFileParser): void;
  38152. /**
  38153. * Gets a general parser from the list of avaialble ones
  38154. * @param name Defines the name of the parser
  38155. * @returns the requested parser or null
  38156. */
  38157. static GetParser(name: string): Nullable<BabylonFileParser>;
  38158. /**
  38159. * Adds n individual parser in the list of available ones
  38160. * @param name Defines the name of the parser
  38161. * @param parser Defines the parser to add
  38162. */
  38163. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38164. /**
  38165. * Gets an individual parser from the list of avaialble ones
  38166. * @param name Defines the name of the parser
  38167. * @returns the requested parser or null
  38168. */
  38169. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38170. /**
  38171. * Parser json data and populate both a scene and its associated container object
  38172. * @param jsonData Defines the data to parse
  38173. * @param scene Defines the scene to parse the data for
  38174. * @param container Defines the container attached to the parsing sequence
  38175. * @param rootUrl Defines the root url of the data
  38176. */
  38177. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38178. /**
  38179. * Gets the list of root nodes (ie. nodes with no parent)
  38180. */
  38181. rootNodes: Node[];
  38182. /** All of the cameras added to this scene
  38183. * @see http://doc.babylonjs.com/babylon101/cameras
  38184. */
  38185. cameras: Camera[];
  38186. /**
  38187. * All of the lights added to this scene
  38188. * @see http://doc.babylonjs.com/babylon101/lights
  38189. */
  38190. lights: Light[];
  38191. /**
  38192. * All of the (abstract) meshes added to this scene
  38193. */
  38194. meshes: AbstractMesh[];
  38195. /**
  38196. * The list of skeletons added to the scene
  38197. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38198. */
  38199. skeletons: Skeleton[];
  38200. /**
  38201. * All of the particle systems added to this scene
  38202. * @see http://doc.babylonjs.com/babylon101/particles
  38203. */
  38204. particleSystems: IParticleSystem[];
  38205. /**
  38206. * Gets a list of Animations associated with the scene
  38207. */
  38208. animations: Animation[];
  38209. /**
  38210. * All of the animation groups added to this scene
  38211. * @see http://doc.babylonjs.com/how_to/group
  38212. */
  38213. animationGroups: AnimationGroup[];
  38214. /**
  38215. * All of the multi-materials added to this scene
  38216. * @see http://doc.babylonjs.com/how_to/multi_materials
  38217. */
  38218. multiMaterials: MultiMaterial[];
  38219. /**
  38220. * All of the materials added to this scene
  38221. * In the context of a Scene, it is not supposed to be modified manually.
  38222. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38223. * Note also that the order of the Material within the array is not significant and might change.
  38224. * @see http://doc.babylonjs.com/babylon101/materials
  38225. */
  38226. materials: Material[];
  38227. /**
  38228. * The list of morph target managers added to the scene
  38229. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38230. */
  38231. morphTargetManagers: MorphTargetManager[];
  38232. /**
  38233. * The list of geometries used in the scene.
  38234. */
  38235. geometries: Geometry[];
  38236. /**
  38237. * All of the tranform nodes added to this scene
  38238. * In the context of a Scene, it is not supposed to be modified manually.
  38239. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38240. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38241. * @see http://doc.babylonjs.com/how_to/transformnode
  38242. */
  38243. transformNodes: TransformNode[];
  38244. /**
  38245. * ActionManagers available on the scene.
  38246. */
  38247. actionManagers: AbstractActionManager[];
  38248. /**
  38249. * Textures to keep.
  38250. */
  38251. textures: BaseTexture[];
  38252. /**
  38253. * Environment texture for the scene
  38254. */
  38255. environmentTexture: Nullable<BaseTexture>;
  38256. /**
  38257. * @returns all meshes, lights, cameras, transformNodes and bones
  38258. */
  38259. getNodes(): Array<Node>;
  38260. }
  38261. }
  38262. declare module "babylonjs/Audio/sound" {
  38263. import { Observable } from "babylonjs/Misc/observable";
  38264. import { Vector3 } from "babylonjs/Maths/math.vector";
  38265. import { Nullable } from "babylonjs/types";
  38266. import { Scene } from "babylonjs/scene";
  38267. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38268. /**
  38269. * Interface used to define options for Sound class
  38270. */
  38271. export interface ISoundOptions {
  38272. /**
  38273. * Does the sound autoplay once loaded.
  38274. */
  38275. autoplay?: boolean;
  38276. /**
  38277. * Does the sound loop after it finishes playing once.
  38278. */
  38279. loop?: boolean;
  38280. /**
  38281. * Sound's volume
  38282. */
  38283. volume?: number;
  38284. /**
  38285. * Is it a spatial sound?
  38286. */
  38287. spatialSound?: boolean;
  38288. /**
  38289. * Maximum distance to hear that sound
  38290. */
  38291. maxDistance?: number;
  38292. /**
  38293. * Uses user defined attenuation function
  38294. */
  38295. useCustomAttenuation?: boolean;
  38296. /**
  38297. * Define the roll off factor of spatial sounds.
  38298. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38299. */
  38300. rolloffFactor?: number;
  38301. /**
  38302. * Define the reference distance the sound should be heard perfectly.
  38303. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38304. */
  38305. refDistance?: number;
  38306. /**
  38307. * Define the distance attenuation model the sound will follow.
  38308. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38309. */
  38310. distanceModel?: string;
  38311. /**
  38312. * Defines the playback speed (1 by default)
  38313. */
  38314. playbackRate?: number;
  38315. /**
  38316. * Defines if the sound is from a streaming source
  38317. */
  38318. streaming?: boolean;
  38319. /**
  38320. * Defines an optional length (in seconds) inside the sound file
  38321. */
  38322. length?: number;
  38323. /**
  38324. * Defines an optional offset (in seconds) inside the sound file
  38325. */
  38326. offset?: number;
  38327. /**
  38328. * If true, URLs will not be required to state the audio file codec to use.
  38329. */
  38330. skipCodecCheck?: boolean;
  38331. }
  38332. /**
  38333. * Defines a sound that can be played in the application.
  38334. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38335. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38336. */
  38337. export class Sound {
  38338. /**
  38339. * The name of the sound in the scene.
  38340. */
  38341. name: string;
  38342. /**
  38343. * Does the sound autoplay once loaded.
  38344. */
  38345. autoplay: boolean;
  38346. /**
  38347. * Does the sound loop after it finishes playing once.
  38348. */
  38349. loop: boolean;
  38350. /**
  38351. * Does the sound use a custom attenuation curve to simulate the falloff
  38352. * happening when the source gets further away from the camera.
  38353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38354. */
  38355. useCustomAttenuation: boolean;
  38356. /**
  38357. * The sound track id this sound belongs to.
  38358. */
  38359. soundTrackId: number;
  38360. /**
  38361. * Is this sound currently played.
  38362. */
  38363. isPlaying: boolean;
  38364. /**
  38365. * Is this sound currently paused.
  38366. */
  38367. isPaused: boolean;
  38368. /**
  38369. * Does this sound enables spatial sound.
  38370. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38371. */
  38372. spatialSound: boolean;
  38373. /**
  38374. * Define the reference distance the sound should be heard perfectly.
  38375. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38376. */
  38377. refDistance: number;
  38378. /**
  38379. * Define the roll off factor of spatial sounds.
  38380. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38381. */
  38382. rolloffFactor: number;
  38383. /**
  38384. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38385. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38386. */
  38387. maxDistance: number;
  38388. /**
  38389. * Define the distance attenuation model the sound will follow.
  38390. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38391. */
  38392. distanceModel: string;
  38393. /**
  38394. * @hidden
  38395. * Back Compat
  38396. **/
  38397. onended: () => any;
  38398. /**
  38399. * Observable event when the current playing sound finishes.
  38400. */
  38401. onEndedObservable: Observable<Sound>;
  38402. private _panningModel;
  38403. private _playbackRate;
  38404. private _streaming;
  38405. private _startTime;
  38406. private _startOffset;
  38407. private _position;
  38408. /** @hidden */
  38409. _positionInEmitterSpace: boolean;
  38410. private _localDirection;
  38411. private _volume;
  38412. private _isReadyToPlay;
  38413. private _isDirectional;
  38414. private _readyToPlayCallback;
  38415. private _audioBuffer;
  38416. private _soundSource;
  38417. private _streamingSource;
  38418. private _soundPanner;
  38419. private _soundGain;
  38420. private _inputAudioNode;
  38421. private _outputAudioNode;
  38422. private _coneInnerAngle;
  38423. private _coneOuterAngle;
  38424. private _coneOuterGain;
  38425. private _scene;
  38426. private _connectedTransformNode;
  38427. private _customAttenuationFunction;
  38428. private _registerFunc;
  38429. private _isOutputConnected;
  38430. private _htmlAudioElement;
  38431. private _urlType;
  38432. private _length?;
  38433. private _offset?;
  38434. /** @hidden */
  38435. static _SceneComponentInitialization: (scene: Scene) => void;
  38436. /**
  38437. * Create a sound and attach it to a scene
  38438. * @param name Name of your sound
  38439. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38440. * @param scene defines the scene the sound belongs to
  38441. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38442. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38443. */
  38444. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38445. /**
  38446. * Release the sound and its associated resources
  38447. */
  38448. dispose(): void;
  38449. /**
  38450. * Gets if the sounds is ready to be played or not.
  38451. * @returns true if ready, otherwise false
  38452. */
  38453. isReady(): boolean;
  38454. private _soundLoaded;
  38455. /**
  38456. * Sets the data of the sound from an audiobuffer
  38457. * @param audioBuffer The audioBuffer containing the data
  38458. */
  38459. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38460. /**
  38461. * Updates the current sounds options such as maxdistance, loop...
  38462. * @param options A JSON object containing values named as the object properties
  38463. */
  38464. updateOptions(options: ISoundOptions): void;
  38465. private _createSpatialParameters;
  38466. private _updateSpatialParameters;
  38467. /**
  38468. * Switch the panning model to HRTF:
  38469. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38470. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38471. */
  38472. switchPanningModelToHRTF(): void;
  38473. /**
  38474. * Switch the panning model to Equal Power:
  38475. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38477. */
  38478. switchPanningModelToEqualPower(): void;
  38479. private _switchPanningModel;
  38480. /**
  38481. * Connect this sound to a sound track audio node like gain...
  38482. * @param soundTrackAudioNode the sound track audio node to connect to
  38483. */
  38484. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38485. /**
  38486. * Transform this sound into a directional source
  38487. * @param coneInnerAngle Size of the inner cone in degree
  38488. * @param coneOuterAngle Size of the outer cone in degree
  38489. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38490. */
  38491. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38492. /**
  38493. * Gets or sets the inner angle for the directional cone.
  38494. */
  38495. get directionalConeInnerAngle(): number;
  38496. /**
  38497. * Gets or sets the inner angle for the directional cone.
  38498. */
  38499. set directionalConeInnerAngle(value: number);
  38500. /**
  38501. * Gets or sets the outer angle for the directional cone.
  38502. */
  38503. get directionalConeOuterAngle(): number;
  38504. /**
  38505. * Gets or sets the outer angle for the directional cone.
  38506. */
  38507. set directionalConeOuterAngle(value: number);
  38508. /**
  38509. * Sets the position of the emitter if spatial sound is enabled
  38510. * @param newPosition Defines the new posisiton
  38511. */
  38512. setPosition(newPosition: Vector3): void;
  38513. /**
  38514. * Sets the local direction of the emitter if spatial sound is enabled
  38515. * @param newLocalDirection Defines the new local direction
  38516. */
  38517. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38518. private _updateDirection;
  38519. /** @hidden */
  38520. updateDistanceFromListener(): void;
  38521. /**
  38522. * Sets a new custom attenuation function for the sound.
  38523. * @param callback Defines the function used for the attenuation
  38524. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38525. */
  38526. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38527. /**
  38528. * Play the sound
  38529. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38530. * @param offset (optional) Start the sound at a specific time in seconds
  38531. * @param length (optional) Sound duration (in seconds)
  38532. */
  38533. play(time?: number, offset?: number, length?: number): void;
  38534. private _onended;
  38535. /**
  38536. * Stop the sound
  38537. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38538. */
  38539. stop(time?: number): void;
  38540. /**
  38541. * Put the sound in pause
  38542. */
  38543. pause(): void;
  38544. /**
  38545. * Sets a dedicated volume for this sounds
  38546. * @param newVolume Define the new volume of the sound
  38547. * @param time Define time for gradual change to new volume
  38548. */
  38549. setVolume(newVolume: number, time?: number): void;
  38550. /**
  38551. * Set the sound play back rate
  38552. * @param newPlaybackRate Define the playback rate the sound should be played at
  38553. */
  38554. setPlaybackRate(newPlaybackRate: number): void;
  38555. /**
  38556. * Gets the volume of the sound.
  38557. * @returns the volume of the sound
  38558. */
  38559. getVolume(): number;
  38560. /**
  38561. * Attach the sound to a dedicated mesh
  38562. * @param transformNode The transform node to connect the sound with
  38563. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38564. */
  38565. attachToMesh(transformNode: TransformNode): void;
  38566. /**
  38567. * Detach the sound from the previously attached mesh
  38568. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38569. */
  38570. detachFromMesh(): void;
  38571. private _onRegisterAfterWorldMatrixUpdate;
  38572. /**
  38573. * Clone the current sound in the scene.
  38574. * @returns the new sound clone
  38575. */
  38576. clone(): Nullable<Sound>;
  38577. /**
  38578. * Gets the current underlying audio buffer containing the data
  38579. * @returns the audio buffer
  38580. */
  38581. getAudioBuffer(): Nullable<AudioBuffer>;
  38582. /**
  38583. * Serializes the Sound in a JSON representation
  38584. * @returns the JSON representation of the sound
  38585. */
  38586. serialize(): any;
  38587. /**
  38588. * Parse a JSON representation of a sound to innstantiate in a given scene
  38589. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38590. * @param scene Define the scene the new parsed sound should be created in
  38591. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38592. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38593. * @returns the newly parsed sound
  38594. */
  38595. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38596. }
  38597. }
  38598. declare module "babylonjs/Actions/directAudioActions" {
  38599. import { Action } from "babylonjs/Actions/action";
  38600. import { Condition } from "babylonjs/Actions/condition";
  38601. import { Sound } from "babylonjs/Audio/sound";
  38602. /**
  38603. * This defines an action helpful to play a defined sound on a triggered action.
  38604. */
  38605. export class PlaySoundAction extends Action {
  38606. private _sound;
  38607. /**
  38608. * Instantiate the action
  38609. * @param triggerOptions defines the trigger options
  38610. * @param sound defines the sound to play
  38611. * @param condition defines the trigger related conditions
  38612. */
  38613. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38614. /** @hidden */
  38615. _prepare(): void;
  38616. /**
  38617. * Execute the action and play the sound.
  38618. */
  38619. execute(): void;
  38620. /**
  38621. * Serializes the actions and its related information.
  38622. * @param parent defines the object to serialize in
  38623. * @returns the serialized object
  38624. */
  38625. serialize(parent: any): any;
  38626. }
  38627. /**
  38628. * This defines an action helpful to stop a defined sound on a triggered action.
  38629. */
  38630. export class StopSoundAction extends Action {
  38631. private _sound;
  38632. /**
  38633. * Instantiate the action
  38634. * @param triggerOptions defines the trigger options
  38635. * @param sound defines the sound to stop
  38636. * @param condition defines the trigger related conditions
  38637. */
  38638. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  38639. /** @hidden */
  38640. _prepare(): void;
  38641. /**
  38642. * Execute the action and stop the sound.
  38643. */
  38644. execute(): void;
  38645. /**
  38646. * Serializes the actions and its related information.
  38647. * @param parent defines the object to serialize in
  38648. * @returns the serialized object
  38649. */
  38650. serialize(parent: any): any;
  38651. }
  38652. }
  38653. declare module "babylonjs/Actions/interpolateValueAction" {
  38654. import { Action } from "babylonjs/Actions/action";
  38655. import { Condition } from "babylonjs/Actions/condition";
  38656. import { Observable } from "babylonjs/Misc/observable";
  38657. /**
  38658. * This defines an action responsible to change the value of a property
  38659. * by interpolating between its current value and the newly set one once triggered.
  38660. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  38661. */
  38662. export class InterpolateValueAction extends Action {
  38663. /**
  38664. * Defines the path of the property where the value should be interpolated
  38665. */
  38666. propertyPath: string;
  38667. /**
  38668. * Defines the target value at the end of the interpolation.
  38669. */
  38670. value: any;
  38671. /**
  38672. * Defines the time it will take for the property to interpolate to the value.
  38673. */
  38674. duration: number;
  38675. /**
  38676. * Defines if the other scene animations should be stopped when the action has been triggered
  38677. */
  38678. stopOtherAnimations?: boolean;
  38679. /**
  38680. * Defines a callback raised once the interpolation animation has been done.
  38681. */
  38682. onInterpolationDone?: () => void;
  38683. /**
  38684. * Observable triggered once the interpolation animation has been done.
  38685. */
  38686. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  38687. private _target;
  38688. private _effectiveTarget;
  38689. private _property;
  38690. /**
  38691. * Instantiate the action
  38692. * @param triggerOptions defines the trigger options
  38693. * @param target defines the object containing the value to interpolate
  38694. * @param propertyPath defines the path to the property in the target object
  38695. * @param value defines the target value at the end of the interpolation
  38696. * @param duration deines the time it will take for the property to interpolate to the value.
  38697. * @param condition defines the trigger related conditions
  38698. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  38699. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  38700. */
  38701. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  38702. /** @hidden */
  38703. _prepare(): void;
  38704. /**
  38705. * Execute the action starts the value interpolation.
  38706. */
  38707. execute(): void;
  38708. /**
  38709. * Serializes the actions and its related information.
  38710. * @param parent defines the object to serialize in
  38711. * @returns the serialized object
  38712. */
  38713. serialize(parent: any): any;
  38714. }
  38715. }
  38716. declare module "babylonjs/Actions/index" {
  38717. export * from "babylonjs/Actions/abstractActionManager";
  38718. export * from "babylonjs/Actions/action";
  38719. export * from "babylonjs/Actions/actionEvent";
  38720. export * from "babylonjs/Actions/actionManager";
  38721. export * from "babylonjs/Actions/condition";
  38722. export * from "babylonjs/Actions/directActions";
  38723. export * from "babylonjs/Actions/directAudioActions";
  38724. export * from "babylonjs/Actions/interpolateValueAction";
  38725. }
  38726. declare module "babylonjs/Animations/index" {
  38727. export * from "babylonjs/Animations/animatable";
  38728. export * from "babylonjs/Animations/animation";
  38729. export * from "babylonjs/Animations/animationGroup";
  38730. export * from "babylonjs/Animations/animationPropertiesOverride";
  38731. export * from "babylonjs/Animations/easing";
  38732. export * from "babylonjs/Animations/runtimeAnimation";
  38733. export * from "babylonjs/Animations/animationEvent";
  38734. export * from "babylonjs/Animations/animationGroup";
  38735. export * from "babylonjs/Animations/animationKey";
  38736. export * from "babylonjs/Animations/animationRange";
  38737. export * from "babylonjs/Animations/animatable.interface";
  38738. }
  38739. declare module "babylonjs/Audio/soundTrack" {
  38740. import { Sound } from "babylonjs/Audio/sound";
  38741. import { Analyser } from "babylonjs/Audio/analyser";
  38742. import { Scene } from "babylonjs/scene";
  38743. /**
  38744. * Options allowed during the creation of a sound track.
  38745. */
  38746. export interface ISoundTrackOptions {
  38747. /**
  38748. * The volume the sound track should take during creation
  38749. */
  38750. volume?: number;
  38751. /**
  38752. * Define if the sound track is the main sound track of the scene
  38753. */
  38754. mainTrack?: boolean;
  38755. }
  38756. /**
  38757. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  38758. * It will be also used in a future release to apply effects on a specific track.
  38759. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38760. */
  38761. export class SoundTrack {
  38762. /**
  38763. * The unique identifier of the sound track in the scene.
  38764. */
  38765. id: number;
  38766. /**
  38767. * The list of sounds included in the sound track.
  38768. */
  38769. soundCollection: Array<Sound>;
  38770. private _outputAudioNode;
  38771. private _scene;
  38772. private _connectedAnalyser;
  38773. private _options;
  38774. private _isInitialized;
  38775. /**
  38776. * Creates a new sound track.
  38777. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  38778. * @param scene Define the scene the sound track belongs to
  38779. * @param options
  38780. */
  38781. constructor(scene: Scene, options?: ISoundTrackOptions);
  38782. private _initializeSoundTrackAudioGraph;
  38783. /**
  38784. * Release the sound track and its associated resources
  38785. */
  38786. dispose(): void;
  38787. /**
  38788. * Adds a sound to this sound track
  38789. * @param sound define the cound to add
  38790. * @ignoreNaming
  38791. */
  38792. AddSound(sound: Sound): void;
  38793. /**
  38794. * Removes a sound to this sound track
  38795. * @param sound define the cound to remove
  38796. * @ignoreNaming
  38797. */
  38798. RemoveSound(sound: Sound): void;
  38799. /**
  38800. * Set a global volume for the full sound track.
  38801. * @param newVolume Define the new volume of the sound track
  38802. */
  38803. setVolume(newVolume: number): void;
  38804. /**
  38805. * Switch the panning model to HRTF:
  38806. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38807. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38808. */
  38809. switchPanningModelToHRTF(): void;
  38810. /**
  38811. * Switch the panning model to Equal Power:
  38812. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38813. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38814. */
  38815. switchPanningModelToEqualPower(): void;
  38816. /**
  38817. * Connect the sound track to an audio analyser allowing some amazing
  38818. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38819. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38820. * @param analyser The analyser to connect to the engine
  38821. */
  38822. connectToAnalyser(analyser: Analyser): void;
  38823. }
  38824. }
  38825. declare module "babylonjs/Audio/audioSceneComponent" {
  38826. import { Sound } from "babylonjs/Audio/sound";
  38827. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  38828. import { Nullable } from "babylonjs/types";
  38829. import { Vector3 } from "babylonjs/Maths/math.vector";
  38830. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  38831. import { Scene } from "babylonjs/scene";
  38832. import { AbstractScene } from "babylonjs/abstractScene";
  38833. import "babylonjs/Audio/audioEngine";
  38834. module "babylonjs/abstractScene" {
  38835. interface AbstractScene {
  38836. /**
  38837. * The list of sounds used in the scene.
  38838. */
  38839. sounds: Nullable<Array<Sound>>;
  38840. }
  38841. }
  38842. module "babylonjs/scene" {
  38843. interface Scene {
  38844. /**
  38845. * @hidden
  38846. * Backing field
  38847. */
  38848. _mainSoundTrack: SoundTrack;
  38849. /**
  38850. * The main sound track played by the scene.
  38851. * It cotains your primary collection of sounds.
  38852. */
  38853. mainSoundTrack: SoundTrack;
  38854. /**
  38855. * The list of sound tracks added to the scene
  38856. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38857. */
  38858. soundTracks: Nullable<Array<SoundTrack>>;
  38859. /**
  38860. * Gets a sound using a given name
  38861. * @param name defines the name to search for
  38862. * @return the found sound or null if not found at all.
  38863. */
  38864. getSoundByName(name: string): Nullable<Sound>;
  38865. /**
  38866. * Gets or sets if audio support is enabled
  38867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38868. */
  38869. audioEnabled: boolean;
  38870. /**
  38871. * Gets or sets if audio will be output to headphones
  38872. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38873. */
  38874. headphone: boolean;
  38875. /**
  38876. * Gets or sets custom audio listener position provider
  38877. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38878. */
  38879. audioListenerPositionProvider: Nullable<() => Vector3>;
  38880. /**
  38881. * Gets or sets a refresh rate when using 3D audio positioning
  38882. */
  38883. audioPositioningRefreshRate: number;
  38884. }
  38885. }
  38886. /**
  38887. * Defines the sound scene component responsible to manage any sounds
  38888. * in a given scene.
  38889. */
  38890. export class AudioSceneComponent implements ISceneSerializableComponent {
  38891. /**
  38892. * The component name helpfull to identify the component in the list of scene components.
  38893. */
  38894. readonly name: string;
  38895. /**
  38896. * The scene the component belongs to.
  38897. */
  38898. scene: Scene;
  38899. private _audioEnabled;
  38900. /**
  38901. * Gets whether audio is enabled or not.
  38902. * Please use related enable/disable method to switch state.
  38903. */
  38904. get audioEnabled(): boolean;
  38905. private _headphone;
  38906. /**
  38907. * Gets whether audio is outputing to headphone or not.
  38908. * Please use the according Switch methods to change output.
  38909. */
  38910. get headphone(): boolean;
  38911. /**
  38912. * Gets or sets a refresh rate when using 3D audio positioning
  38913. */
  38914. audioPositioningRefreshRate: number;
  38915. private _audioListenerPositionProvider;
  38916. /**
  38917. * Gets the current audio listener position provider
  38918. */
  38919. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  38920. /**
  38921. * Sets a custom listener position for all sounds in the scene
  38922. * By default, this is the position of the first active camera
  38923. */
  38924. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  38925. /**
  38926. * Creates a new instance of the component for the given scene
  38927. * @param scene Defines the scene to register the component in
  38928. */
  38929. constructor(scene: Scene);
  38930. /**
  38931. * Registers the component in a given scene
  38932. */
  38933. register(): void;
  38934. /**
  38935. * Rebuilds the elements related to this component in case of
  38936. * context lost for instance.
  38937. */
  38938. rebuild(): void;
  38939. /**
  38940. * Serializes the component data to the specified json object
  38941. * @param serializationObject The object to serialize to
  38942. */
  38943. serialize(serializationObject: any): void;
  38944. /**
  38945. * Adds all the elements from the container to the scene
  38946. * @param container the container holding the elements
  38947. */
  38948. addFromContainer(container: AbstractScene): void;
  38949. /**
  38950. * Removes all the elements in the container from the scene
  38951. * @param container contains the elements to remove
  38952. * @param dispose if the removed element should be disposed (default: false)
  38953. */
  38954. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  38955. /**
  38956. * Disposes the component and the associated ressources.
  38957. */
  38958. dispose(): void;
  38959. /**
  38960. * Disables audio in the associated scene.
  38961. */
  38962. disableAudio(): void;
  38963. /**
  38964. * Enables audio in the associated scene.
  38965. */
  38966. enableAudio(): void;
  38967. /**
  38968. * Switch audio to headphone output.
  38969. */
  38970. switchAudioModeForHeadphones(): void;
  38971. /**
  38972. * Switch audio to normal speakers.
  38973. */
  38974. switchAudioModeForNormalSpeakers(): void;
  38975. private _cachedCameraDirection;
  38976. private _cachedCameraPosition;
  38977. private _lastCheck;
  38978. private _afterRender;
  38979. }
  38980. }
  38981. declare module "babylonjs/Audio/weightedsound" {
  38982. import { Sound } from "babylonjs/Audio/sound";
  38983. /**
  38984. * Wraps one or more Sound objects and selects one with random weight for playback.
  38985. */
  38986. export class WeightedSound {
  38987. /** When true a Sound will be selected and played when the current playing Sound completes. */
  38988. loop: boolean;
  38989. private _coneInnerAngle;
  38990. private _coneOuterAngle;
  38991. private _volume;
  38992. /** A Sound is currently playing. */
  38993. isPlaying: boolean;
  38994. /** A Sound is currently paused. */
  38995. isPaused: boolean;
  38996. private _sounds;
  38997. private _weights;
  38998. private _currentIndex?;
  38999. /**
  39000. * Creates a new WeightedSound from the list of sounds given.
  39001. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39002. * @param sounds Array of Sounds that will be selected from.
  39003. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39004. */
  39005. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39006. /**
  39007. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39008. */
  39009. get directionalConeInnerAngle(): number;
  39010. /**
  39011. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39012. */
  39013. set directionalConeInnerAngle(value: number);
  39014. /**
  39015. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39016. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39017. */
  39018. get directionalConeOuterAngle(): number;
  39019. /**
  39020. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39021. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39022. */
  39023. set directionalConeOuterAngle(value: number);
  39024. /**
  39025. * Playback volume.
  39026. */
  39027. get volume(): number;
  39028. /**
  39029. * Playback volume.
  39030. */
  39031. set volume(value: number);
  39032. private _onended;
  39033. /**
  39034. * Suspend playback
  39035. */
  39036. pause(): void;
  39037. /**
  39038. * Stop playback
  39039. */
  39040. stop(): void;
  39041. /**
  39042. * Start playback.
  39043. * @param startOffset Position the clip head at a specific time in seconds.
  39044. */
  39045. play(startOffset?: number): void;
  39046. }
  39047. }
  39048. declare module "babylonjs/Audio/index" {
  39049. export * from "babylonjs/Audio/analyser";
  39050. export * from "babylonjs/Audio/audioEngine";
  39051. export * from "babylonjs/Audio/audioSceneComponent";
  39052. export * from "babylonjs/Audio/sound";
  39053. export * from "babylonjs/Audio/soundTrack";
  39054. export * from "babylonjs/Audio/weightedsound";
  39055. }
  39056. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39057. import { Behavior } from "babylonjs/Behaviors/behavior";
  39058. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39059. import { BackEase } from "babylonjs/Animations/easing";
  39060. /**
  39061. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39062. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39063. */
  39064. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39065. /**
  39066. * Gets the name of the behavior.
  39067. */
  39068. get name(): string;
  39069. /**
  39070. * The easing function used by animations
  39071. */
  39072. static EasingFunction: BackEase;
  39073. /**
  39074. * The easing mode used by animations
  39075. */
  39076. static EasingMode: number;
  39077. /**
  39078. * The duration of the animation, in milliseconds
  39079. */
  39080. transitionDuration: number;
  39081. /**
  39082. * Length of the distance animated by the transition when lower radius is reached
  39083. */
  39084. lowerRadiusTransitionRange: number;
  39085. /**
  39086. * Length of the distance animated by the transition when upper radius is reached
  39087. */
  39088. upperRadiusTransitionRange: number;
  39089. private _autoTransitionRange;
  39090. /**
  39091. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39092. */
  39093. get autoTransitionRange(): boolean;
  39094. /**
  39095. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39096. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39097. */
  39098. set autoTransitionRange(value: boolean);
  39099. private _attachedCamera;
  39100. private _onAfterCheckInputsObserver;
  39101. private _onMeshTargetChangedObserver;
  39102. /**
  39103. * Initializes the behavior.
  39104. */
  39105. init(): void;
  39106. /**
  39107. * Attaches the behavior to its arc rotate camera.
  39108. * @param camera Defines the camera to attach the behavior to
  39109. */
  39110. attach(camera: ArcRotateCamera): void;
  39111. /**
  39112. * Detaches the behavior from its current arc rotate camera.
  39113. */
  39114. detach(): void;
  39115. private _radiusIsAnimating;
  39116. private _radiusBounceTransition;
  39117. private _animatables;
  39118. private _cachedWheelPrecision;
  39119. /**
  39120. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39121. * @param radiusLimit The limit to check against.
  39122. * @return Bool to indicate if at limit.
  39123. */
  39124. private _isRadiusAtLimit;
  39125. /**
  39126. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39127. * @param radiusDelta The delta by which to animate to. Can be negative.
  39128. */
  39129. private _applyBoundRadiusAnimation;
  39130. /**
  39131. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39132. */
  39133. protected _clearAnimationLocks(): void;
  39134. /**
  39135. * Stops and removes all animations that have been applied to the camera
  39136. */
  39137. stopAllAnimations(): void;
  39138. }
  39139. }
  39140. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39141. import { Behavior } from "babylonjs/Behaviors/behavior";
  39142. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39143. import { ExponentialEase } from "babylonjs/Animations/easing";
  39144. import { Nullable } from "babylonjs/types";
  39145. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39146. import { Vector3 } from "babylonjs/Maths/math.vector";
  39147. /**
  39148. * The framing behavior (FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  39149. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39150. */
  39151. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39152. /**
  39153. * Gets the name of the behavior.
  39154. */
  39155. get name(): string;
  39156. private _mode;
  39157. private _radiusScale;
  39158. private _positionScale;
  39159. private _defaultElevation;
  39160. private _elevationReturnTime;
  39161. private _elevationReturnWaitTime;
  39162. private _zoomStopsAnimation;
  39163. private _framingTime;
  39164. /**
  39165. * The easing function used by animations
  39166. */
  39167. static EasingFunction: ExponentialEase;
  39168. /**
  39169. * The easing mode used by animations
  39170. */
  39171. static EasingMode: number;
  39172. /**
  39173. * Sets the current mode used by the behavior
  39174. */
  39175. set mode(mode: number);
  39176. /**
  39177. * Gets current mode used by the behavior.
  39178. */
  39179. get mode(): number;
  39180. /**
  39181. * Sets the scale applied to the radius (1 by default)
  39182. */
  39183. set radiusScale(radius: number);
  39184. /**
  39185. * Gets the scale applied to the radius
  39186. */
  39187. get radiusScale(): number;
  39188. /**
  39189. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39190. */
  39191. set positionScale(scale: number);
  39192. /**
  39193. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39194. */
  39195. get positionScale(): number;
  39196. /**
  39197. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39198. * behaviour is triggered, in radians.
  39199. */
  39200. set defaultElevation(elevation: number);
  39201. /**
  39202. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39203. * behaviour is triggered, in radians.
  39204. */
  39205. get defaultElevation(): number;
  39206. /**
  39207. * Sets the time (in milliseconds) taken to return to the default beta position.
  39208. * Negative value indicates camera should not return to default.
  39209. */
  39210. set elevationReturnTime(speed: number);
  39211. /**
  39212. * Gets the time (in milliseconds) taken to return to the default beta position.
  39213. * Negative value indicates camera should not return to default.
  39214. */
  39215. get elevationReturnTime(): number;
  39216. /**
  39217. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39218. */
  39219. set elevationReturnWaitTime(time: number);
  39220. /**
  39221. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39222. */
  39223. get elevationReturnWaitTime(): number;
  39224. /**
  39225. * Sets the flag that indicates if user zooming should stop animation.
  39226. */
  39227. set zoomStopsAnimation(flag: boolean);
  39228. /**
  39229. * Gets the flag that indicates if user zooming should stop animation.
  39230. */
  39231. get zoomStopsAnimation(): boolean;
  39232. /**
  39233. * Sets the transition time when framing the mesh, in milliseconds
  39234. */
  39235. set framingTime(time: number);
  39236. /**
  39237. * Gets the transition time when framing the mesh, in milliseconds
  39238. */
  39239. get framingTime(): number;
  39240. /**
  39241. * Define if the behavior should automatically change the configured
  39242. * camera limits and sensibilities.
  39243. */
  39244. autoCorrectCameraLimitsAndSensibility: boolean;
  39245. private _onPrePointerObservableObserver;
  39246. private _onAfterCheckInputsObserver;
  39247. private _onMeshTargetChangedObserver;
  39248. private _attachedCamera;
  39249. private _isPointerDown;
  39250. private _lastInteractionTime;
  39251. /**
  39252. * Initializes the behavior.
  39253. */
  39254. init(): void;
  39255. /**
  39256. * Attaches the behavior to its arc rotate camera.
  39257. * @param camera Defines the camera to attach the behavior to
  39258. */
  39259. attach(camera: ArcRotateCamera): void;
  39260. /**
  39261. * Detaches the behavior from its current arc rotate camera.
  39262. */
  39263. detach(): void;
  39264. private _animatables;
  39265. private _betaIsAnimating;
  39266. private _betaTransition;
  39267. private _radiusTransition;
  39268. private _vectorTransition;
  39269. /**
  39270. * Targets the given mesh and updates zoom level accordingly.
  39271. * @param mesh The mesh to target.
  39272. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39273. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39274. */
  39275. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39276. /**
  39277. * Targets the given mesh with its children and updates zoom level accordingly.
  39278. * @param mesh The mesh to target.
  39279. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39280. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39281. */
  39282. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39283. /**
  39284. * Targets the given meshes with their children and updates zoom level accordingly.
  39285. * @param meshes The mesh to target.
  39286. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39287. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39288. */
  39289. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39290. /**
  39291. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39292. * @param minimumWorld Determines the smaller position of the bounding box extend
  39293. * @param maximumWorld Determines the bigger position of the bounding box extend
  39294. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39295. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39296. */
  39297. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39298. /**
  39299. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39300. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39301. * frustum width.
  39302. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39303. * to fully enclose the mesh in the viewing frustum.
  39304. */
  39305. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39306. /**
  39307. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39308. * is automatically returned to its default position (expected to be above ground plane).
  39309. */
  39310. private _maintainCameraAboveGround;
  39311. /**
  39312. * Returns the frustum slope based on the canvas ratio and camera FOV
  39313. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39314. */
  39315. private _getFrustumSlope;
  39316. /**
  39317. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39318. */
  39319. private _clearAnimationLocks;
  39320. /**
  39321. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39322. */
  39323. private _applyUserInteraction;
  39324. /**
  39325. * Stops and removes all animations that have been applied to the camera
  39326. */
  39327. stopAllAnimations(): void;
  39328. /**
  39329. * Gets a value indicating if the user is moving the camera
  39330. */
  39331. get isUserIsMoving(): boolean;
  39332. /**
  39333. * The camera can move all the way towards the mesh.
  39334. */
  39335. static IgnoreBoundsSizeMode: number;
  39336. /**
  39337. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39338. */
  39339. static FitFrustumSidesMode: number;
  39340. }
  39341. }
  39342. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39343. import { Nullable } from "babylonjs/types";
  39344. import { Camera } from "babylonjs/Cameras/camera";
  39345. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39346. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39347. /**
  39348. * Base class for Camera Pointer Inputs.
  39349. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39350. * for example usage.
  39351. */
  39352. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39353. /**
  39354. * Defines the camera the input is attached to.
  39355. */
  39356. abstract camera: Camera;
  39357. /**
  39358. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39359. */
  39360. protected _altKey: boolean;
  39361. protected _ctrlKey: boolean;
  39362. protected _metaKey: boolean;
  39363. protected _shiftKey: boolean;
  39364. /**
  39365. * Which mouse buttons were pressed at time of last mouse event.
  39366. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39367. */
  39368. protected _buttonsPressed: number;
  39369. /**
  39370. * Defines the buttons associated with the input to handle camera move.
  39371. */
  39372. buttons: number[];
  39373. /**
  39374. * Attach the input controls to a specific dom element to get the input from.
  39375. * @param element Defines the element the controls should be listened from
  39376. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39377. */
  39378. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39379. /**
  39380. * Detach the current controls from the specified dom element.
  39381. * @param element Defines the element to stop listening the inputs from
  39382. */
  39383. detachControl(element: Nullable<HTMLElement>): void;
  39384. /**
  39385. * Gets the class name of the current input.
  39386. * @returns the class name
  39387. */
  39388. getClassName(): string;
  39389. /**
  39390. * Get the friendly name associated with the input class.
  39391. * @returns the input friendly name
  39392. */
  39393. getSimpleName(): string;
  39394. /**
  39395. * Called on pointer POINTERDOUBLETAP event.
  39396. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39397. */
  39398. protected onDoubleTap(type: string): void;
  39399. /**
  39400. * Called on pointer POINTERMOVE event if only a single touch is active.
  39401. * Override this method to provide functionality.
  39402. */
  39403. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39404. /**
  39405. * Called on pointer POINTERMOVE event if multiple touches are active.
  39406. * Override this method to provide functionality.
  39407. */
  39408. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39409. /**
  39410. * Called on JS contextmenu event.
  39411. * Override this method to provide functionality.
  39412. */
  39413. protected onContextMenu(evt: PointerEvent): void;
  39414. /**
  39415. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39416. * press.
  39417. * Override this method to provide functionality.
  39418. */
  39419. protected onButtonDown(evt: PointerEvent): void;
  39420. /**
  39421. * Called each time a new POINTERUP event occurs. Ie, for each button
  39422. * release.
  39423. * Override this method to provide functionality.
  39424. */
  39425. protected onButtonUp(evt: PointerEvent): void;
  39426. /**
  39427. * Called when window becomes inactive.
  39428. * Override this method to provide functionality.
  39429. */
  39430. protected onLostFocus(): void;
  39431. private _pointerInput;
  39432. private _observer;
  39433. private _onLostFocus;
  39434. private pointA;
  39435. private pointB;
  39436. }
  39437. }
  39438. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39439. import { Nullable } from "babylonjs/types";
  39440. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39441. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39442. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39443. /**
  39444. * Manage the pointers inputs to control an arc rotate camera.
  39445. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39446. */
  39447. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39448. /**
  39449. * Defines the camera the input is attached to.
  39450. */
  39451. camera: ArcRotateCamera;
  39452. /**
  39453. * Gets the class name of the current input.
  39454. * @returns the class name
  39455. */
  39456. getClassName(): string;
  39457. /**
  39458. * Defines the buttons associated with the input to handle camera move.
  39459. */
  39460. buttons: number[];
  39461. /**
  39462. * Defines the pointer angular sensibility along the X axis or how fast is
  39463. * the camera rotating.
  39464. */
  39465. angularSensibilityX: number;
  39466. /**
  39467. * Defines the pointer angular sensibility along the Y axis or how fast is
  39468. * the camera rotating.
  39469. */
  39470. angularSensibilityY: number;
  39471. /**
  39472. * Defines the pointer pinch precision or how fast is the camera zooming.
  39473. */
  39474. pinchPrecision: number;
  39475. /**
  39476. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39477. * from 0.
  39478. * It defines the percentage of current camera.radius to use as delta when
  39479. * pinch zoom is used.
  39480. */
  39481. pinchDeltaPercentage: number;
  39482. /**
  39483. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39484. * that any object in the plane at the camera's target point will scale
  39485. * perfectly with finger motion.
  39486. * Overrides pinchDeltaPercentage and pinchPrecision.
  39487. */
  39488. useNaturalPinchZoom: boolean;
  39489. /**
  39490. * Defines the pointer panning sensibility or how fast is the camera moving.
  39491. */
  39492. panningSensibility: number;
  39493. /**
  39494. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39495. */
  39496. multiTouchPanning: boolean;
  39497. /**
  39498. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39499. * zoom (pinch) through multitouch.
  39500. */
  39501. multiTouchPanAndZoom: boolean;
  39502. /**
  39503. * Revers pinch action direction.
  39504. */
  39505. pinchInwards: boolean;
  39506. private _isPanClick;
  39507. private _twoFingerActivityCount;
  39508. private _isPinching;
  39509. /**
  39510. * Called on pointer POINTERMOVE event if only a single touch is active.
  39511. */
  39512. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39513. /**
  39514. * Called on pointer POINTERDOUBLETAP event.
  39515. */
  39516. protected onDoubleTap(type: string): void;
  39517. /**
  39518. * Called on pointer POINTERMOVE event if multiple touches are active.
  39519. */
  39520. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39521. /**
  39522. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39523. * press.
  39524. */
  39525. protected onButtonDown(evt: PointerEvent): void;
  39526. /**
  39527. * Called each time a new POINTERUP event occurs. Ie, for each button
  39528. * release.
  39529. */
  39530. protected onButtonUp(evt: PointerEvent): void;
  39531. /**
  39532. * Called when window becomes inactive.
  39533. */
  39534. protected onLostFocus(): void;
  39535. }
  39536. }
  39537. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39538. import { Nullable } from "babylonjs/types";
  39539. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39540. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39541. /**
  39542. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39543. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39544. */
  39545. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39546. /**
  39547. * Defines the camera the input is attached to.
  39548. */
  39549. camera: ArcRotateCamera;
  39550. /**
  39551. * Defines the list of key codes associated with the up action (increase alpha)
  39552. */
  39553. keysUp: number[];
  39554. /**
  39555. * Defines the list of key codes associated with the down action (decrease alpha)
  39556. */
  39557. keysDown: number[];
  39558. /**
  39559. * Defines the list of key codes associated with the left action (increase beta)
  39560. */
  39561. keysLeft: number[];
  39562. /**
  39563. * Defines the list of key codes associated with the right action (decrease beta)
  39564. */
  39565. keysRight: number[];
  39566. /**
  39567. * Defines the list of key codes associated with the reset action.
  39568. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39569. */
  39570. keysReset: number[];
  39571. /**
  39572. * Defines the panning sensibility of the inputs.
  39573. * (How fast is the camera panning)
  39574. */
  39575. panningSensibility: number;
  39576. /**
  39577. * Defines the zooming sensibility of the inputs.
  39578. * (How fast is the camera zooming)
  39579. */
  39580. zoomingSensibility: number;
  39581. /**
  39582. * Defines whether maintaining the alt key down switch the movement mode from
  39583. * orientation to zoom.
  39584. */
  39585. useAltToZoom: boolean;
  39586. /**
  39587. * Rotation speed of the camera
  39588. */
  39589. angularSpeed: number;
  39590. private _keys;
  39591. private _ctrlPressed;
  39592. private _altPressed;
  39593. private _onCanvasBlurObserver;
  39594. private _onKeyboardObserver;
  39595. private _engine;
  39596. private _scene;
  39597. /**
  39598. * Attach the input controls to a specific dom element to get the input from.
  39599. * @param element Defines the element the controls should be listened from
  39600. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39601. */
  39602. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39603. /**
  39604. * Detach the current controls from the specified dom element.
  39605. * @param element Defines the element to stop listening the inputs from
  39606. */
  39607. detachControl(element: Nullable<HTMLElement>): void;
  39608. /**
  39609. * Update the current camera state depending on the inputs that have been used this frame.
  39610. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39611. */
  39612. checkInputs(): void;
  39613. /**
  39614. * Gets the class name of the current intput.
  39615. * @returns the class name
  39616. */
  39617. getClassName(): string;
  39618. /**
  39619. * Get the friendly name associated with the input class.
  39620. * @returns the input friendly name
  39621. */
  39622. getSimpleName(): string;
  39623. }
  39624. }
  39625. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  39626. import { Nullable } from "babylonjs/types";
  39627. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39628. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39629. /**
  39630. * Manage the mouse wheel inputs to control an arc rotate camera.
  39631. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39632. */
  39633. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  39634. /**
  39635. * Defines the camera the input is attached to.
  39636. */
  39637. camera: ArcRotateCamera;
  39638. /**
  39639. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39640. */
  39641. wheelPrecision: number;
  39642. /**
  39643. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39644. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39645. */
  39646. wheelDeltaPercentage: number;
  39647. private _wheel;
  39648. private _observer;
  39649. private computeDeltaFromMouseWheelLegacyEvent;
  39650. /**
  39651. * Attach the input controls to a specific dom element to get the input from.
  39652. * @param element Defines the element the controls should be listened from
  39653. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39654. */
  39655. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39656. /**
  39657. * Detach the current controls from the specified dom element.
  39658. * @param element Defines the element to stop listening the inputs from
  39659. */
  39660. detachControl(element: Nullable<HTMLElement>): void;
  39661. /**
  39662. * Gets the class name of the current intput.
  39663. * @returns the class name
  39664. */
  39665. getClassName(): string;
  39666. /**
  39667. * Get the friendly name associated with the input class.
  39668. * @returns the input friendly name
  39669. */
  39670. getSimpleName(): string;
  39671. }
  39672. }
  39673. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  39674. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39675. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39676. /**
  39677. * Default Inputs manager for the ArcRotateCamera.
  39678. * It groups all the default supported inputs for ease of use.
  39679. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39680. */
  39681. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  39682. /**
  39683. * Instantiates a new ArcRotateCameraInputsManager.
  39684. * @param camera Defines the camera the inputs belong to
  39685. */
  39686. constructor(camera: ArcRotateCamera);
  39687. /**
  39688. * Add mouse wheel input support to the input manager.
  39689. * @returns the current input manager
  39690. */
  39691. addMouseWheel(): ArcRotateCameraInputsManager;
  39692. /**
  39693. * Add pointers input support to the input manager.
  39694. * @returns the current input manager
  39695. */
  39696. addPointers(): ArcRotateCameraInputsManager;
  39697. /**
  39698. * Add keyboard input support to the input manager.
  39699. * @returns the current input manager
  39700. */
  39701. addKeyboard(): ArcRotateCameraInputsManager;
  39702. }
  39703. }
  39704. declare module "babylonjs/Cameras/arcRotateCamera" {
  39705. import { Observable } from "babylonjs/Misc/observable";
  39706. import { Nullable } from "babylonjs/types";
  39707. import { Scene } from "babylonjs/scene";
  39708. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  39709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39710. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  39711. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  39712. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  39713. import { Camera } from "babylonjs/Cameras/camera";
  39714. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39715. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  39716. import { Collider } from "babylonjs/Collisions/collider";
  39717. /**
  39718. * This represents an orbital type of camera.
  39719. *
  39720. * 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.
  39721. * 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.
  39722. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  39723. */
  39724. export class ArcRotateCamera extends TargetCamera {
  39725. /**
  39726. * Defines the rotation angle of the camera along the longitudinal axis.
  39727. */
  39728. alpha: number;
  39729. /**
  39730. * Defines the rotation angle of the camera along the latitudinal axis.
  39731. */
  39732. beta: number;
  39733. /**
  39734. * Defines the radius of the camera from it s target point.
  39735. */
  39736. radius: number;
  39737. protected _target: Vector3;
  39738. protected _targetHost: Nullable<AbstractMesh>;
  39739. /**
  39740. * Defines the target point of the camera.
  39741. * The camera looks towards it form the radius distance.
  39742. */
  39743. get target(): Vector3;
  39744. set target(value: Vector3);
  39745. /**
  39746. * Define the current local position of the camera in the scene
  39747. */
  39748. get position(): Vector3;
  39749. set position(newPosition: Vector3);
  39750. protected _upVector: Vector3;
  39751. protected _upToYMatrix: Matrix;
  39752. protected _YToUpMatrix: Matrix;
  39753. /**
  39754. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  39755. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  39756. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  39757. */
  39758. set upVector(vec: Vector3);
  39759. get upVector(): Vector3;
  39760. /**
  39761. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  39762. */
  39763. setMatUp(): void;
  39764. /**
  39765. * Current inertia value on the longitudinal axis.
  39766. * The bigger this number the longer it will take for the camera to stop.
  39767. */
  39768. inertialAlphaOffset: number;
  39769. /**
  39770. * Current inertia value on the latitudinal axis.
  39771. * The bigger this number the longer it will take for the camera to stop.
  39772. */
  39773. inertialBetaOffset: number;
  39774. /**
  39775. * Current inertia value on the radius axis.
  39776. * The bigger this number the longer it will take for the camera to stop.
  39777. */
  39778. inertialRadiusOffset: number;
  39779. /**
  39780. * Minimum allowed angle on the longitudinal axis.
  39781. * This can help limiting how the Camera is able to move in the scene.
  39782. */
  39783. lowerAlphaLimit: Nullable<number>;
  39784. /**
  39785. * Maximum allowed angle on the longitudinal axis.
  39786. * This can help limiting how the Camera is able to move in the scene.
  39787. */
  39788. upperAlphaLimit: Nullable<number>;
  39789. /**
  39790. * Minimum allowed angle on the latitudinal axis.
  39791. * This can help limiting how the Camera is able to move in the scene.
  39792. */
  39793. lowerBetaLimit: number;
  39794. /**
  39795. * Maximum allowed angle on the latitudinal axis.
  39796. * This can help limiting how the Camera is able to move in the scene.
  39797. */
  39798. upperBetaLimit: number;
  39799. /**
  39800. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  39801. * This can help limiting how the Camera is able to move in the scene.
  39802. */
  39803. lowerRadiusLimit: Nullable<number>;
  39804. /**
  39805. * Maximum allowed distance of the camera to the target (The camera can not get further).
  39806. * This can help limiting how the Camera is able to move in the scene.
  39807. */
  39808. upperRadiusLimit: Nullable<number>;
  39809. /**
  39810. * Defines the current inertia value used during panning of the camera along the X axis.
  39811. */
  39812. inertialPanningX: number;
  39813. /**
  39814. * Defines the current inertia value used during panning of the camera along the Y axis.
  39815. */
  39816. inertialPanningY: number;
  39817. /**
  39818. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  39819. * Basically if your fingers moves away from more than this distance you will be considered
  39820. * in pinch mode.
  39821. */
  39822. pinchToPanMaxDistance: number;
  39823. /**
  39824. * Defines the maximum distance the camera can pan.
  39825. * This could help keeping the cammera always in your scene.
  39826. */
  39827. panningDistanceLimit: Nullable<number>;
  39828. /**
  39829. * Defines the target of the camera before paning.
  39830. */
  39831. panningOriginTarget: Vector3;
  39832. /**
  39833. * Defines the value of the inertia used during panning.
  39834. * 0 would mean stop inertia and one would mean no decelleration at all.
  39835. */
  39836. panningInertia: number;
  39837. /**
  39838. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  39839. */
  39840. get angularSensibilityX(): number;
  39841. set angularSensibilityX(value: number);
  39842. /**
  39843. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  39844. */
  39845. get angularSensibilityY(): number;
  39846. set angularSensibilityY(value: number);
  39847. /**
  39848. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  39849. */
  39850. get pinchPrecision(): number;
  39851. set pinchPrecision(value: number);
  39852. /**
  39853. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  39854. * It will be used instead of pinchDeltaPrecision if different from 0.
  39855. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39856. */
  39857. get pinchDeltaPercentage(): number;
  39858. set pinchDeltaPercentage(value: number);
  39859. /**
  39860. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  39861. * and pinch delta percentage.
  39862. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39863. * that any object in the plane at the camera's target point will scale
  39864. * perfectly with finger motion.
  39865. */
  39866. get useNaturalPinchZoom(): boolean;
  39867. set useNaturalPinchZoom(value: boolean);
  39868. /**
  39869. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  39870. */
  39871. get panningSensibility(): number;
  39872. set panningSensibility(value: number);
  39873. /**
  39874. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  39875. */
  39876. get keysUp(): number[];
  39877. set keysUp(value: number[]);
  39878. /**
  39879. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  39880. */
  39881. get keysDown(): number[];
  39882. set keysDown(value: number[]);
  39883. /**
  39884. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  39885. */
  39886. get keysLeft(): number[];
  39887. set keysLeft(value: number[]);
  39888. /**
  39889. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  39890. */
  39891. get keysRight(): number[];
  39892. set keysRight(value: number[]);
  39893. /**
  39894. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  39895. */
  39896. get wheelPrecision(): number;
  39897. set wheelPrecision(value: number);
  39898. /**
  39899. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  39900. * It will be used instead of pinchDeltaPrecision if different from 0.
  39901. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  39902. */
  39903. get wheelDeltaPercentage(): number;
  39904. set wheelDeltaPercentage(value: number);
  39905. /**
  39906. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  39907. */
  39908. zoomOnFactor: number;
  39909. /**
  39910. * Defines a screen offset for the camera position.
  39911. */
  39912. targetScreenOffset: Vector2;
  39913. /**
  39914. * Allows the camera to be completely reversed.
  39915. * If false the camera can not arrive upside down.
  39916. */
  39917. allowUpsideDown: boolean;
  39918. /**
  39919. * Define if double tap/click is used to restore the previously saved state of the camera.
  39920. */
  39921. useInputToRestoreState: boolean;
  39922. /** @hidden */
  39923. _viewMatrix: Matrix;
  39924. /** @hidden */
  39925. _useCtrlForPanning: boolean;
  39926. /** @hidden */
  39927. _panningMouseButton: number;
  39928. /**
  39929. * Defines the input associated to the camera.
  39930. */
  39931. inputs: ArcRotateCameraInputsManager;
  39932. /** @hidden */
  39933. _reset: () => void;
  39934. /**
  39935. * Defines the allowed panning axis.
  39936. */
  39937. panningAxis: Vector3;
  39938. protected _localDirection: Vector3;
  39939. protected _transformedDirection: Vector3;
  39940. private _bouncingBehavior;
  39941. /**
  39942. * Gets the bouncing behavior of the camera if it has been enabled.
  39943. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39944. */
  39945. get bouncingBehavior(): Nullable<BouncingBehavior>;
  39946. /**
  39947. * Defines if the bouncing behavior of the camera is enabled on the camera.
  39948. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39949. */
  39950. get useBouncingBehavior(): boolean;
  39951. set useBouncingBehavior(value: boolean);
  39952. private _framingBehavior;
  39953. /**
  39954. * Gets the framing behavior of the camera if it has been enabled.
  39955. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39956. */
  39957. get framingBehavior(): Nullable<FramingBehavior>;
  39958. /**
  39959. * Defines if the framing behavior of the camera is enabled on the camera.
  39960. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39961. */
  39962. get useFramingBehavior(): boolean;
  39963. set useFramingBehavior(value: boolean);
  39964. private _autoRotationBehavior;
  39965. /**
  39966. * Gets the auto rotation behavior of the camera if it has been enabled.
  39967. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39968. */
  39969. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  39970. /**
  39971. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  39972. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  39973. */
  39974. get useAutoRotationBehavior(): boolean;
  39975. set useAutoRotationBehavior(value: boolean);
  39976. /**
  39977. * Observable triggered when the mesh target has been changed on the camera.
  39978. */
  39979. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  39980. /**
  39981. * Event raised when the camera is colliding with a mesh.
  39982. */
  39983. onCollide: (collidedMesh: AbstractMesh) => void;
  39984. /**
  39985. * Defines whether the camera should check collision with the objects oh the scene.
  39986. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  39987. */
  39988. checkCollisions: boolean;
  39989. /**
  39990. * Defines the collision radius of the camera.
  39991. * This simulates a sphere around the camera.
  39992. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  39993. */
  39994. collisionRadius: Vector3;
  39995. protected _collider: Collider;
  39996. protected _previousPosition: Vector3;
  39997. protected _collisionVelocity: Vector3;
  39998. protected _newPosition: Vector3;
  39999. protected _previousAlpha: number;
  40000. protected _previousBeta: number;
  40001. protected _previousRadius: number;
  40002. protected _collisionTriggered: boolean;
  40003. protected _targetBoundingCenter: Nullable<Vector3>;
  40004. private _computationVector;
  40005. /**
  40006. * Instantiates a new ArcRotateCamera in a given scene
  40007. * @param name Defines the name of the camera
  40008. * @param alpha Defines the camera rotation along the logitudinal axis
  40009. * @param beta Defines the camera rotation along the latitudinal axis
  40010. * @param radius Defines the camera distance from its target
  40011. * @param target Defines the camera target
  40012. * @param scene Defines the scene the camera belongs to
  40013. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40014. */
  40015. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40016. /** @hidden */
  40017. _initCache(): void;
  40018. /** @hidden */
  40019. _updateCache(ignoreParentClass?: boolean): void;
  40020. protected _getTargetPosition(): Vector3;
  40021. private _storedAlpha;
  40022. private _storedBeta;
  40023. private _storedRadius;
  40024. private _storedTarget;
  40025. private _storedTargetScreenOffset;
  40026. /**
  40027. * Stores the current state of the camera (alpha, beta, radius and target)
  40028. * @returns the camera itself
  40029. */
  40030. storeState(): Camera;
  40031. /**
  40032. * @hidden
  40033. * Restored camera state. You must call storeState() first
  40034. */
  40035. _restoreStateValues(): boolean;
  40036. /** @hidden */
  40037. _isSynchronizedViewMatrix(): boolean;
  40038. /**
  40039. * Attached controls to the current camera.
  40040. * @param element Defines the element the controls should be listened from
  40041. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40042. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40043. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40044. */
  40045. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40046. /**
  40047. * Detach the current controls from the camera.
  40048. * The camera will stop reacting to inputs.
  40049. * @param element Defines the element to stop listening the inputs from
  40050. */
  40051. detachControl(element: HTMLElement): void;
  40052. /** @hidden */
  40053. _checkInputs(): void;
  40054. protected _checkLimits(): void;
  40055. /**
  40056. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40057. */
  40058. rebuildAnglesAndRadius(): void;
  40059. /**
  40060. * Use a position to define the current camera related information like alpha, beta and radius
  40061. * @param position Defines the position to set the camera at
  40062. */
  40063. setPosition(position: Vector3): void;
  40064. /**
  40065. * Defines the target the camera should look at.
  40066. * This will automatically adapt alpha beta and radius to fit within the new target.
  40067. * @param target Defines the new target as a Vector or a mesh
  40068. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40069. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40070. */
  40071. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40072. /** @hidden */
  40073. _getViewMatrix(): Matrix;
  40074. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40075. /**
  40076. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40077. * @param meshes Defines the mesh to zoom on
  40078. * @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)
  40079. */
  40080. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40081. /**
  40082. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40083. * The target will be changed but the radius
  40084. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40085. * @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)
  40086. */
  40087. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40088. min: Vector3;
  40089. max: Vector3;
  40090. distance: number;
  40091. }, doNotUpdateMaxZ?: boolean): void;
  40092. /**
  40093. * @override
  40094. * Override Camera.createRigCamera
  40095. */
  40096. createRigCamera(name: string, cameraIndex: number): Camera;
  40097. /**
  40098. * @hidden
  40099. * @override
  40100. * Override Camera._updateRigCameras
  40101. */
  40102. _updateRigCameras(): void;
  40103. /**
  40104. * Destroy the camera and release the current resources hold by it.
  40105. */
  40106. dispose(): void;
  40107. /**
  40108. * Gets the current object class name.
  40109. * @return the class name
  40110. */
  40111. getClassName(): string;
  40112. }
  40113. }
  40114. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40115. import { Behavior } from "babylonjs/Behaviors/behavior";
  40116. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40117. /**
  40118. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40119. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40120. */
  40121. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40122. /**
  40123. * Gets the name of the behavior.
  40124. */
  40125. get name(): string;
  40126. private _zoomStopsAnimation;
  40127. private _idleRotationSpeed;
  40128. private _idleRotationWaitTime;
  40129. private _idleRotationSpinupTime;
  40130. /**
  40131. * Sets the flag that indicates if user zooming should stop animation.
  40132. */
  40133. set zoomStopsAnimation(flag: boolean);
  40134. /**
  40135. * Gets the flag that indicates if user zooming should stop animation.
  40136. */
  40137. get zoomStopsAnimation(): boolean;
  40138. /**
  40139. * Sets the default speed at which the camera rotates around the model.
  40140. */
  40141. set idleRotationSpeed(speed: number);
  40142. /**
  40143. * Gets the default speed at which the camera rotates around the model.
  40144. */
  40145. get idleRotationSpeed(): number;
  40146. /**
  40147. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40148. */
  40149. set idleRotationWaitTime(time: number);
  40150. /**
  40151. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40152. */
  40153. get idleRotationWaitTime(): number;
  40154. /**
  40155. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40156. */
  40157. set idleRotationSpinupTime(time: number);
  40158. /**
  40159. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40160. */
  40161. get idleRotationSpinupTime(): number;
  40162. /**
  40163. * Gets a value indicating if the camera is currently rotating because of this behavior
  40164. */
  40165. get rotationInProgress(): boolean;
  40166. private _onPrePointerObservableObserver;
  40167. private _onAfterCheckInputsObserver;
  40168. private _attachedCamera;
  40169. private _isPointerDown;
  40170. private _lastFrameTime;
  40171. private _lastInteractionTime;
  40172. private _cameraRotationSpeed;
  40173. /**
  40174. * Initializes the behavior.
  40175. */
  40176. init(): void;
  40177. /**
  40178. * Attaches the behavior to its arc rotate camera.
  40179. * @param camera Defines the camera to attach the behavior to
  40180. */
  40181. attach(camera: ArcRotateCamera): void;
  40182. /**
  40183. * Detaches the behavior from its current arc rotate camera.
  40184. */
  40185. detach(): void;
  40186. /**
  40187. * Returns true if user is scrolling.
  40188. * @return true if user is scrolling.
  40189. */
  40190. private _userIsZooming;
  40191. private _lastFrameRadius;
  40192. private _shouldAnimationStopForInteraction;
  40193. /**
  40194. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40195. */
  40196. private _applyUserInteraction;
  40197. private _userIsMoving;
  40198. }
  40199. }
  40200. declare module "babylonjs/Behaviors/Cameras/index" {
  40201. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40202. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40203. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40204. }
  40205. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40206. import { Mesh } from "babylonjs/Meshes/mesh";
  40207. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40208. import { Behavior } from "babylonjs/Behaviors/behavior";
  40209. /**
  40210. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40211. */
  40212. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40213. private ui;
  40214. /**
  40215. * The name of the behavior
  40216. */
  40217. name: string;
  40218. /**
  40219. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40220. */
  40221. distanceAwayFromFace: number;
  40222. /**
  40223. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40224. */
  40225. distanceAwayFromBottomOfFace: number;
  40226. private _faceVectors;
  40227. private _target;
  40228. private _scene;
  40229. private _onRenderObserver;
  40230. private _tmpMatrix;
  40231. private _tmpVector;
  40232. /**
  40233. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40234. * @param ui The transform node that should be attched to the mesh
  40235. */
  40236. constructor(ui: TransformNode);
  40237. /**
  40238. * Initializes the behavior
  40239. */
  40240. init(): void;
  40241. private _closestFace;
  40242. private _zeroVector;
  40243. private _lookAtTmpMatrix;
  40244. private _lookAtToRef;
  40245. /**
  40246. * Attaches the AttachToBoxBehavior to the passed in mesh
  40247. * @param target The mesh that the specified node will be attached to
  40248. */
  40249. attach(target: Mesh): void;
  40250. /**
  40251. * Detaches the behavior from the mesh
  40252. */
  40253. detach(): void;
  40254. }
  40255. }
  40256. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40257. import { Behavior } from "babylonjs/Behaviors/behavior";
  40258. import { Mesh } from "babylonjs/Meshes/mesh";
  40259. /**
  40260. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40261. */
  40262. export class FadeInOutBehavior implements Behavior<Mesh> {
  40263. /**
  40264. * Time in milliseconds to delay before fading in (Default: 0)
  40265. */
  40266. delay: number;
  40267. /**
  40268. * Time in milliseconds for the mesh to fade in (Default: 300)
  40269. */
  40270. fadeInTime: number;
  40271. private _millisecondsPerFrame;
  40272. private _hovered;
  40273. private _hoverValue;
  40274. private _ownerNode;
  40275. /**
  40276. * Instatiates the FadeInOutBehavior
  40277. */
  40278. constructor();
  40279. /**
  40280. * The name of the behavior
  40281. */
  40282. get name(): string;
  40283. /**
  40284. * Initializes the behavior
  40285. */
  40286. init(): void;
  40287. /**
  40288. * Attaches the fade behavior on the passed in mesh
  40289. * @param ownerNode The mesh that will be faded in/out once attached
  40290. */
  40291. attach(ownerNode: Mesh): void;
  40292. /**
  40293. * Detaches the behavior from the mesh
  40294. */
  40295. detach(): void;
  40296. /**
  40297. * Triggers the mesh to begin fading in or out
  40298. * @param value if the object should fade in or out (true to fade in)
  40299. */
  40300. fadeIn(value: boolean): void;
  40301. private _update;
  40302. private _setAllVisibility;
  40303. }
  40304. }
  40305. declare module "babylonjs/Misc/pivotTools" {
  40306. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40307. /**
  40308. * Class containing a set of static utilities functions for managing Pivots
  40309. * @hidden
  40310. */
  40311. export class PivotTools {
  40312. private static _PivotCached;
  40313. private static _OldPivotPoint;
  40314. private static _PivotTranslation;
  40315. private static _PivotTmpVector;
  40316. /** @hidden */
  40317. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40318. /** @hidden */
  40319. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40320. }
  40321. }
  40322. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40323. import { Scene } from "babylonjs/scene";
  40324. import { Vector4 } from "babylonjs/Maths/math.vector";
  40325. import { Mesh } from "babylonjs/Meshes/mesh";
  40326. import { Nullable } from "babylonjs/types";
  40327. import { Plane } from "babylonjs/Maths/math.plane";
  40328. /**
  40329. * Class containing static functions to help procedurally build meshes
  40330. */
  40331. export class PlaneBuilder {
  40332. /**
  40333. * Creates a plane mesh
  40334. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40335. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40336. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40337. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40338. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40339. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40340. * @param name defines the name of the mesh
  40341. * @param options defines the options used to create the mesh
  40342. * @param scene defines the hosting scene
  40343. * @returns the plane mesh
  40344. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40345. */
  40346. static CreatePlane(name: string, options: {
  40347. size?: number;
  40348. width?: number;
  40349. height?: number;
  40350. sideOrientation?: number;
  40351. frontUVs?: Vector4;
  40352. backUVs?: Vector4;
  40353. updatable?: boolean;
  40354. sourcePlane?: Plane;
  40355. }, scene?: Nullable<Scene>): Mesh;
  40356. }
  40357. }
  40358. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40359. import { Behavior } from "babylonjs/Behaviors/behavior";
  40360. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40361. import { Observable } from "babylonjs/Misc/observable";
  40362. import { Vector3 } from "babylonjs/Maths/math.vector";
  40363. import { Ray } from "babylonjs/Culling/ray";
  40364. import "babylonjs/Meshes/Builders/planeBuilder";
  40365. /**
  40366. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40367. */
  40368. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40369. private static _AnyMouseID;
  40370. /**
  40371. * Abstract mesh the behavior is set on
  40372. */
  40373. attachedNode: AbstractMesh;
  40374. private _dragPlane;
  40375. private _scene;
  40376. private _pointerObserver;
  40377. private _beforeRenderObserver;
  40378. private static _planeScene;
  40379. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40380. /**
  40381. * 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)
  40382. */
  40383. maxDragAngle: number;
  40384. /**
  40385. * @hidden
  40386. */
  40387. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40388. /**
  40389. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40390. */
  40391. currentDraggingPointerID: number;
  40392. /**
  40393. * The last position where the pointer hit the drag plane in world space
  40394. */
  40395. lastDragPosition: Vector3;
  40396. /**
  40397. * If the behavior is currently in a dragging state
  40398. */
  40399. dragging: boolean;
  40400. /**
  40401. * 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)
  40402. */
  40403. dragDeltaRatio: number;
  40404. /**
  40405. * If the drag plane orientation should be updated during the dragging (Default: true)
  40406. */
  40407. updateDragPlane: boolean;
  40408. private _debugMode;
  40409. private _moving;
  40410. /**
  40411. * Fires each time the attached mesh is dragged with the pointer
  40412. * * delta between last drag position and current drag position in world space
  40413. * * dragDistance along the drag axis
  40414. * * dragPlaneNormal normal of the current drag plane used during the drag
  40415. * * dragPlanePoint in world space where the drag intersects the drag plane
  40416. */
  40417. onDragObservable: Observable<{
  40418. delta: Vector3;
  40419. dragPlanePoint: Vector3;
  40420. dragPlaneNormal: Vector3;
  40421. dragDistance: number;
  40422. pointerId: number;
  40423. }>;
  40424. /**
  40425. * Fires each time a drag begins (eg. mouse down on mesh)
  40426. */
  40427. onDragStartObservable: Observable<{
  40428. dragPlanePoint: Vector3;
  40429. pointerId: number;
  40430. }>;
  40431. /**
  40432. * Fires each time a drag ends (eg. mouse release after drag)
  40433. */
  40434. onDragEndObservable: Observable<{
  40435. dragPlanePoint: Vector3;
  40436. pointerId: number;
  40437. }>;
  40438. /**
  40439. * If the attached mesh should be moved when dragged
  40440. */
  40441. moveAttached: boolean;
  40442. /**
  40443. * If the drag behavior will react to drag events (Default: true)
  40444. */
  40445. enabled: boolean;
  40446. /**
  40447. * If pointer events should start and release the drag (Default: true)
  40448. */
  40449. startAndReleaseDragOnPointerEvents: boolean;
  40450. /**
  40451. * If camera controls should be detached during the drag
  40452. */
  40453. detachCameraControls: boolean;
  40454. /**
  40455. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40456. */
  40457. useObjectOrientationForDragging: boolean;
  40458. private _options;
  40459. /**
  40460. * Gets the options used by the behavior
  40461. */
  40462. get options(): {
  40463. dragAxis?: Vector3;
  40464. dragPlaneNormal?: Vector3;
  40465. };
  40466. /**
  40467. * Sets the options used by the behavior
  40468. */
  40469. set options(options: {
  40470. dragAxis?: Vector3;
  40471. dragPlaneNormal?: Vector3;
  40472. });
  40473. /**
  40474. * Creates a pointer drag behavior that can be attached to a mesh
  40475. * @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)
  40476. */
  40477. constructor(options?: {
  40478. dragAxis?: Vector3;
  40479. dragPlaneNormal?: Vector3;
  40480. });
  40481. /**
  40482. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40483. */
  40484. validateDrag: (targetPosition: Vector3) => boolean;
  40485. /**
  40486. * The name of the behavior
  40487. */
  40488. get name(): string;
  40489. /**
  40490. * Initializes the behavior
  40491. */
  40492. init(): void;
  40493. private _tmpVector;
  40494. private _alternatePickedPoint;
  40495. private _worldDragAxis;
  40496. private _targetPosition;
  40497. private _attachedElement;
  40498. /**
  40499. * Attaches the drag behavior the passed in mesh
  40500. * @param ownerNode The mesh that will be dragged around once attached
  40501. * @param predicate Predicate to use for pick filtering
  40502. */
  40503. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40504. /**
  40505. * Force relase the drag action by code.
  40506. */
  40507. releaseDrag(): void;
  40508. private _startDragRay;
  40509. private _lastPointerRay;
  40510. /**
  40511. * Simulates the start of a pointer drag event on the behavior
  40512. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40513. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40514. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40515. */
  40516. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40517. private _startDrag;
  40518. private _dragDelta;
  40519. private _moveDrag;
  40520. private _pickWithRayOnDragPlane;
  40521. private _pointA;
  40522. private _pointB;
  40523. private _pointC;
  40524. private _lineA;
  40525. private _lineB;
  40526. private _localAxis;
  40527. private _lookAt;
  40528. private _updateDragPlanePosition;
  40529. /**
  40530. * Detaches the behavior from the mesh
  40531. */
  40532. detach(): void;
  40533. }
  40534. }
  40535. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40536. import { Mesh } from "babylonjs/Meshes/mesh";
  40537. import { Behavior } from "babylonjs/Behaviors/behavior";
  40538. /**
  40539. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40540. */
  40541. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40542. private _dragBehaviorA;
  40543. private _dragBehaviorB;
  40544. private _startDistance;
  40545. private _initialScale;
  40546. private _targetScale;
  40547. private _ownerNode;
  40548. private _sceneRenderObserver;
  40549. /**
  40550. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40551. */
  40552. constructor();
  40553. /**
  40554. * The name of the behavior
  40555. */
  40556. get name(): string;
  40557. /**
  40558. * Initializes the behavior
  40559. */
  40560. init(): void;
  40561. private _getCurrentDistance;
  40562. /**
  40563. * Attaches the scale behavior the passed in mesh
  40564. * @param ownerNode The mesh that will be scaled around once attached
  40565. */
  40566. attach(ownerNode: Mesh): void;
  40567. /**
  40568. * Detaches the behavior from the mesh
  40569. */
  40570. detach(): void;
  40571. }
  40572. }
  40573. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40574. import { Behavior } from "babylonjs/Behaviors/behavior";
  40575. import { Mesh } from "babylonjs/Meshes/mesh";
  40576. import { Observable } from "babylonjs/Misc/observable";
  40577. /**
  40578. * 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
  40579. */
  40580. export class SixDofDragBehavior implements Behavior<Mesh> {
  40581. private static _virtualScene;
  40582. private _ownerNode;
  40583. private _sceneRenderObserver;
  40584. private _scene;
  40585. private _targetPosition;
  40586. private _virtualOriginMesh;
  40587. private _virtualDragMesh;
  40588. private _pointerObserver;
  40589. private _moving;
  40590. private _startingOrientation;
  40591. /**
  40592. * 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)
  40593. */
  40594. private zDragFactor;
  40595. /**
  40596. * If the object should rotate to face the drag origin
  40597. */
  40598. rotateDraggedObject: boolean;
  40599. /**
  40600. * If the behavior is currently in a dragging state
  40601. */
  40602. dragging: boolean;
  40603. /**
  40604. * 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)
  40605. */
  40606. dragDeltaRatio: number;
  40607. /**
  40608. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40609. */
  40610. currentDraggingPointerID: number;
  40611. /**
  40612. * If camera controls should be detached during the drag
  40613. */
  40614. detachCameraControls: boolean;
  40615. /**
  40616. * Fires each time a drag starts
  40617. */
  40618. onDragStartObservable: Observable<{}>;
  40619. /**
  40620. * Fires each time a drag ends (eg. mouse release after drag)
  40621. */
  40622. onDragEndObservable: Observable<{}>;
  40623. /**
  40624. * 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
  40625. */
  40626. constructor();
  40627. /**
  40628. * The name of the behavior
  40629. */
  40630. get name(): string;
  40631. /**
  40632. * Initializes the behavior
  40633. */
  40634. init(): void;
  40635. /**
  40636. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  40637. */
  40638. private get _pointerCamera();
  40639. /**
  40640. * Attaches the scale behavior the passed in mesh
  40641. * @param ownerNode The mesh that will be scaled around once attached
  40642. */
  40643. attach(ownerNode: Mesh): void;
  40644. /**
  40645. * Detaches the behavior from the mesh
  40646. */
  40647. detach(): void;
  40648. }
  40649. }
  40650. declare module "babylonjs/Behaviors/Meshes/index" {
  40651. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  40652. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  40653. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  40654. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  40655. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  40656. }
  40657. declare module "babylonjs/Behaviors/index" {
  40658. export * from "babylonjs/Behaviors/behavior";
  40659. export * from "babylonjs/Behaviors/Cameras/index";
  40660. export * from "babylonjs/Behaviors/Meshes/index";
  40661. }
  40662. declare module "babylonjs/Bones/boneIKController" {
  40663. import { Bone } from "babylonjs/Bones/bone";
  40664. import { Vector3 } from "babylonjs/Maths/math.vector";
  40665. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40666. import { Nullable } from "babylonjs/types";
  40667. /**
  40668. * Class used to apply inverse kinematics to bones
  40669. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  40670. */
  40671. export class BoneIKController {
  40672. private static _tmpVecs;
  40673. private static _tmpQuat;
  40674. private static _tmpMats;
  40675. /**
  40676. * Gets or sets the target mesh
  40677. */
  40678. targetMesh: AbstractMesh;
  40679. /** Gets or sets the mesh used as pole */
  40680. poleTargetMesh: AbstractMesh;
  40681. /**
  40682. * Gets or sets the bone used as pole
  40683. */
  40684. poleTargetBone: Nullable<Bone>;
  40685. /**
  40686. * Gets or sets the target position
  40687. */
  40688. targetPosition: Vector3;
  40689. /**
  40690. * Gets or sets the pole target position
  40691. */
  40692. poleTargetPosition: Vector3;
  40693. /**
  40694. * Gets or sets the pole target local offset
  40695. */
  40696. poleTargetLocalOffset: Vector3;
  40697. /**
  40698. * Gets or sets the pole angle
  40699. */
  40700. poleAngle: number;
  40701. /**
  40702. * Gets or sets the mesh associated with the controller
  40703. */
  40704. mesh: AbstractMesh;
  40705. /**
  40706. * 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)
  40707. */
  40708. slerpAmount: number;
  40709. private _bone1Quat;
  40710. private _bone1Mat;
  40711. private _bone2Ang;
  40712. private _bone1;
  40713. private _bone2;
  40714. private _bone1Length;
  40715. private _bone2Length;
  40716. private _maxAngle;
  40717. private _maxReach;
  40718. private _rightHandedSystem;
  40719. private _bendAxis;
  40720. private _slerping;
  40721. private _adjustRoll;
  40722. /**
  40723. * Gets or sets maximum allowed angle
  40724. */
  40725. get maxAngle(): number;
  40726. set maxAngle(value: number);
  40727. /**
  40728. * Creates a new BoneIKController
  40729. * @param mesh defines the mesh to control
  40730. * @param bone defines the bone to control
  40731. * @param options defines options to set up the controller
  40732. */
  40733. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  40734. targetMesh?: AbstractMesh;
  40735. poleTargetMesh?: AbstractMesh;
  40736. poleTargetBone?: Bone;
  40737. poleTargetLocalOffset?: Vector3;
  40738. poleAngle?: number;
  40739. bendAxis?: Vector3;
  40740. maxAngle?: number;
  40741. slerpAmount?: number;
  40742. });
  40743. private _setMaxAngle;
  40744. /**
  40745. * Force the controller to update the bones
  40746. */
  40747. update(): void;
  40748. }
  40749. }
  40750. declare module "babylonjs/Bones/boneLookController" {
  40751. import { Vector3 } from "babylonjs/Maths/math.vector";
  40752. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40753. import { Bone } from "babylonjs/Bones/bone";
  40754. import { Space } from "babylonjs/Maths/math.axis";
  40755. /**
  40756. * Class used to make a bone look toward a point in space
  40757. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  40758. */
  40759. export class BoneLookController {
  40760. private static _tmpVecs;
  40761. private static _tmpQuat;
  40762. private static _tmpMats;
  40763. /**
  40764. * The target Vector3 that the bone will look at
  40765. */
  40766. target: Vector3;
  40767. /**
  40768. * The mesh that the bone is attached to
  40769. */
  40770. mesh: AbstractMesh;
  40771. /**
  40772. * The bone that will be looking to the target
  40773. */
  40774. bone: Bone;
  40775. /**
  40776. * The up axis of the coordinate system that is used when the bone is rotated
  40777. */
  40778. upAxis: Vector3;
  40779. /**
  40780. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  40781. */
  40782. upAxisSpace: Space;
  40783. /**
  40784. * Used to make an adjustment to the yaw of the bone
  40785. */
  40786. adjustYaw: number;
  40787. /**
  40788. * Used to make an adjustment to the pitch of the bone
  40789. */
  40790. adjustPitch: number;
  40791. /**
  40792. * Used to make an adjustment to the roll of the bone
  40793. */
  40794. adjustRoll: number;
  40795. /**
  40796. * 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)
  40797. */
  40798. slerpAmount: number;
  40799. private _minYaw;
  40800. private _maxYaw;
  40801. private _minPitch;
  40802. private _maxPitch;
  40803. private _minYawSin;
  40804. private _minYawCos;
  40805. private _maxYawSin;
  40806. private _maxYawCos;
  40807. private _midYawConstraint;
  40808. private _minPitchTan;
  40809. private _maxPitchTan;
  40810. private _boneQuat;
  40811. private _slerping;
  40812. private _transformYawPitch;
  40813. private _transformYawPitchInv;
  40814. private _firstFrameSkipped;
  40815. private _yawRange;
  40816. private _fowardAxis;
  40817. /**
  40818. * Gets or sets the minimum yaw angle that the bone can look to
  40819. */
  40820. get minYaw(): number;
  40821. set minYaw(value: number);
  40822. /**
  40823. * Gets or sets the maximum yaw angle that the bone can look to
  40824. */
  40825. get maxYaw(): number;
  40826. set maxYaw(value: number);
  40827. /**
  40828. * Gets or sets the minimum pitch angle that the bone can look to
  40829. */
  40830. get minPitch(): number;
  40831. set minPitch(value: number);
  40832. /**
  40833. * Gets or sets the maximum pitch angle that the bone can look to
  40834. */
  40835. get maxPitch(): number;
  40836. set maxPitch(value: number);
  40837. /**
  40838. * Create a BoneLookController
  40839. * @param mesh the mesh that the bone belongs to
  40840. * @param bone the bone that will be looking to the target
  40841. * @param target the target Vector3 to look at
  40842. * @param options optional settings:
  40843. * * maxYaw: the maximum angle the bone will yaw to
  40844. * * minYaw: the minimum angle the bone will yaw to
  40845. * * maxPitch: the maximum angle the bone will pitch to
  40846. * * minPitch: the minimum angle the bone will yaw to
  40847. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  40848. * * upAxis: the up axis of the coordinate system
  40849. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  40850. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  40851. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  40852. * * adjustYaw: used to make an adjustment to the yaw of the bone
  40853. * * adjustPitch: used to make an adjustment to the pitch of the bone
  40854. * * adjustRoll: used to make an adjustment to the roll of the bone
  40855. **/
  40856. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  40857. maxYaw?: number;
  40858. minYaw?: number;
  40859. maxPitch?: number;
  40860. minPitch?: number;
  40861. slerpAmount?: number;
  40862. upAxis?: Vector3;
  40863. upAxisSpace?: Space;
  40864. yawAxis?: Vector3;
  40865. pitchAxis?: Vector3;
  40866. adjustYaw?: number;
  40867. adjustPitch?: number;
  40868. adjustRoll?: number;
  40869. });
  40870. /**
  40871. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  40872. */
  40873. update(): void;
  40874. private _getAngleDiff;
  40875. private _getAngleBetween;
  40876. private _isAngleBetween;
  40877. }
  40878. }
  40879. declare module "babylonjs/Bones/index" {
  40880. export * from "babylonjs/Bones/bone";
  40881. export * from "babylonjs/Bones/boneIKController";
  40882. export * from "babylonjs/Bones/boneLookController";
  40883. export * from "babylonjs/Bones/skeleton";
  40884. }
  40885. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  40886. import { Nullable } from "babylonjs/types";
  40887. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40888. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40889. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40890. /**
  40891. * Manage the gamepad inputs to control an arc rotate camera.
  40892. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40893. */
  40894. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  40895. /**
  40896. * Defines the camera the input is attached to.
  40897. */
  40898. camera: ArcRotateCamera;
  40899. /**
  40900. * Defines the gamepad the input is gathering event from.
  40901. */
  40902. gamepad: Nullable<Gamepad>;
  40903. /**
  40904. * Defines the gamepad rotation sensiblity.
  40905. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40906. */
  40907. gamepadRotationSensibility: number;
  40908. /**
  40909. * Defines the gamepad move sensiblity.
  40910. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40911. */
  40912. gamepadMoveSensibility: number;
  40913. private _yAxisScale;
  40914. /**
  40915. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  40916. */
  40917. get invertYAxis(): boolean;
  40918. set invertYAxis(value: boolean);
  40919. private _onGamepadConnectedObserver;
  40920. private _onGamepadDisconnectedObserver;
  40921. /**
  40922. * Attach the input controls to a specific dom element to get the input from.
  40923. * @param element Defines the element the controls should be listened from
  40924. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40925. */
  40926. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40927. /**
  40928. * Detach the current controls from the specified dom element.
  40929. * @param element Defines the element to stop listening the inputs from
  40930. */
  40931. detachControl(element: Nullable<HTMLElement>): void;
  40932. /**
  40933. * Update the current camera state depending on the inputs that have been used this frame.
  40934. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40935. */
  40936. checkInputs(): void;
  40937. /**
  40938. * Gets the class name of the current intput.
  40939. * @returns the class name
  40940. */
  40941. getClassName(): string;
  40942. /**
  40943. * Get the friendly name associated with the input class.
  40944. * @returns the input friendly name
  40945. */
  40946. getSimpleName(): string;
  40947. }
  40948. }
  40949. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  40950. import { Nullable } from "babylonjs/types";
  40951. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40952. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40953. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40954. interface ArcRotateCameraInputsManager {
  40955. /**
  40956. * Add orientation input support to the input manager.
  40957. * @returns the current input manager
  40958. */
  40959. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  40960. }
  40961. }
  40962. /**
  40963. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  40964. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40965. */
  40966. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  40967. /**
  40968. * Defines the camera the input is attached to.
  40969. */
  40970. camera: ArcRotateCamera;
  40971. /**
  40972. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  40973. */
  40974. alphaCorrection: number;
  40975. /**
  40976. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  40977. */
  40978. gammaCorrection: number;
  40979. private _alpha;
  40980. private _gamma;
  40981. private _dirty;
  40982. private _deviceOrientationHandler;
  40983. /**
  40984. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  40985. */
  40986. constructor();
  40987. /**
  40988. * Attach the input controls to a specific dom element to get the input from.
  40989. * @param element Defines the element the controls should be listened from
  40990. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40991. */
  40992. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40993. /** @hidden */
  40994. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  40995. /**
  40996. * Update the current camera state depending on the inputs that have been used this frame.
  40997. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40998. */
  40999. checkInputs(): void;
  41000. /**
  41001. * Detach the current controls from the specified dom element.
  41002. * @param element Defines the element to stop listening the inputs from
  41003. */
  41004. detachControl(element: Nullable<HTMLElement>): void;
  41005. /**
  41006. * Gets the class name of the current intput.
  41007. * @returns the class name
  41008. */
  41009. getClassName(): string;
  41010. /**
  41011. * Get the friendly name associated with the input class.
  41012. * @returns the input friendly name
  41013. */
  41014. getSimpleName(): string;
  41015. }
  41016. }
  41017. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41018. import { Nullable } from "babylonjs/types";
  41019. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41020. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41021. /**
  41022. * Listen to mouse events to control the camera.
  41023. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41024. */
  41025. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41026. /**
  41027. * Defines the camera the input is attached to.
  41028. */
  41029. camera: FlyCamera;
  41030. /**
  41031. * Defines if touch is enabled. (Default is true.)
  41032. */
  41033. touchEnabled: boolean;
  41034. /**
  41035. * Defines the buttons associated with the input to handle camera rotation.
  41036. */
  41037. buttons: number[];
  41038. /**
  41039. * Assign buttons for Yaw control.
  41040. */
  41041. buttonsYaw: number[];
  41042. /**
  41043. * Assign buttons for Pitch control.
  41044. */
  41045. buttonsPitch: number[];
  41046. /**
  41047. * Assign buttons for Roll control.
  41048. */
  41049. buttonsRoll: number[];
  41050. /**
  41051. * Detect if any button is being pressed while mouse is moved.
  41052. * -1 = Mouse locked.
  41053. * 0 = Left button.
  41054. * 1 = Middle Button.
  41055. * 2 = Right Button.
  41056. */
  41057. activeButton: number;
  41058. /**
  41059. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41060. * Higher values reduce its sensitivity.
  41061. */
  41062. angularSensibility: number;
  41063. private _mousemoveCallback;
  41064. private _observer;
  41065. private _rollObserver;
  41066. private previousPosition;
  41067. private noPreventDefault;
  41068. private element;
  41069. /**
  41070. * Listen to mouse events to control the camera.
  41071. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41072. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41073. */
  41074. constructor(touchEnabled?: boolean);
  41075. /**
  41076. * Attach the mouse control to the HTML DOM element.
  41077. * @param element Defines the element that listens to the input events.
  41078. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41079. */
  41080. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41081. /**
  41082. * Detach the current controls from the specified dom element.
  41083. * @param element Defines the element to stop listening the inputs from
  41084. */
  41085. detachControl(element: Nullable<HTMLElement>): void;
  41086. /**
  41087. * Gets the class name of the current input.
  41088. * @returns the class name.
  41089. */
  41090. getClassName(): string;
  41091. /**
  41092. * Get the friendly name associated with the input class.
  41093. * @returns the input's friendly name.
  41094. */
  41095. getSimpleName(): string;
  41096. private _pointerInput;
  41097. private _onMouseMove;
  41098. /**
  41099. * Rotate camera by mouse offset.
  41100. */
  41101. private rotateCamera;
  41102. }
  41103. }
  41104. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41105. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41106. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41107. /**
  41108. * Default Inputs manager for the FlyCamera.
  41109. * It groups all the default supported inputs for ease of use.
  41110. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41111. */
  41112. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41113. /**
  41114. * Instantiates a new FlyCameraInputsManager.
  41115. * @param camera Defines the camera the inputs belong to.
  41116. */
  41117. constructor(camera: FlyCamera);
  41118. /**
  41119. * Add keyboard input support to the input manager.
  41120. * @returns the new FlyCameraKeyboardMoveInput().
  41121. */
  41122. addKeyboard(): FlyCameraInputsManager;
  41123. /**
  41124. * Add mouse input support to the input manager.
  41125. * @param touchEnabled Enable touch screen support.
  41126. * @returns the new FlyCameraMouseInput().
  41127. */
  41128. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41129. }
  41130. }
  41131. declare module "babylonjs/Cameras/flyCamera" {
  41132. import { Scene } from "babylonjs/scene";
  41133. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41134. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41135. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41136. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41137. /**
  41138. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41139. * such as in a 3D Space Shooter or a Flight Simulator.
  41140. */
  41141. export class FlyCamera extends TargetCamera {
  41142. /**
  41143. * Define the collision ellipsoid of the camera.
  41144. * This is helpful for simulating a camera body, like a player's body.
  41145. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41146. */
  41147. ellipsoid: Vector3;
  41148. /**
  41149. * Define an offset for the position of the ellipsoid around the camera.
  41150. * This can be helpful if the camera is attached away from the player's body center,
  41151. * such as at its head.
  41152. */
  41153. ellipsoidOffset: Vector3;
  41154. /**
  41155. * Enable or disable collisions of the camera with the rest of the scene objects.
  41156. */
  41157. checkCollisions: boolean;
  41158. /**
  41159. * Enable or disable gravity on the camera.
  41160. */
  41161. applyGravity: boolean;
  41162. /**
  41163. * Define the current direction the camera is moving to.
  41164. */
  41165. cameraDirection: Vector3;
  41166. /**
  41167. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41168. * This overrides and empties cameraRotation.
  41169. */
  41170. rotationQuaternion: Quaternion;
  41171. /**
  41172. * Track Roll to maintain the wanted Rolling when looking around.
  41173. */
  41174. _trackRoll: number;
  41175. /**
  41176. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41177. */
  41178. rollCorrect: number;
  41179. /**
  41180. * Mimic a banked turn, Rolling the camera when Yawing.
  41181. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41182. */
  41183. bankedTurn: boolean;
  41184. /**
  41185. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41186. */
  41187. bankedTurnLimit: number;
  41188. /**
  41189. * Value of 0 disables the banked Roll.
  41190. * Value of 1 is equal to the Yaw angle in radians.
  41191. */
  41192. bankedTurnMultiplier: number;
  41193. /**
  41194. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41195. */
  41196. inputs: FlyCameraInputsManager;
  41197. /**
  41198. * Gets the input sensibility for mouse input.
  41199. * Higher values reduce sensitivity.
  41200. */
  41201. get angularSensibility(): number;
  41202. /**
  41203. * Sets the input sensibility for a mouse input.
  41204. * Higher values reduce sensitivity.
  41205. */
  41206. set angularSensibility(value: number);
  41207. /**
  41208. * Get the keys for camera movement forward.
  41209. */
  41210. get keysForward(): number[];
  41211. /**
  41212. * Set the keys for camera movement forward.
  41213. */
  41214. set keysForward(value: number[]);
  41215. /**
  41216. * Get the keys for camera movement backward.
  41217. */
  41218. get keysBackward(): number[];
  41219. set keysBackward(value: number[]);
  41220. /**
  41221. * Get the keys for camera movement up.
  41222. */
  41223. get keysUp(): number[];
  41224. /**
  41225. * Set the keys for camera movement up.
  41226. */
  41227. set keysUp(value: number[]);
  41228. /**
  41229. * Get the keys for camera movement down.
  41230. */
  41231. get keysDown(): number[];
  41232. /**
  41233. * Set the keys for camera movement down.
  41234. */
  41235. set keysDown(value: number[]);
  41236. /**
  41237. * Get the keys for camera movement left.
  41238. */
  41239. get keysLeft(): number[];
  41240. /**
  41241. * Set the keys for camera movement left.
  41242. */
  41243. set keysLeft(value: number[]);
  41244. /**
  41245. * Set the keys for camera movement right.
  41246. */
  41247. get keysRight(): number[];
  41248. /**
  41249. * Set the keys for camera movement right.
  41250. */
  41251. set keysRight(value: number[]);
  41252. /**
  41253. * Event raised when the camera collides with a mesh in the scene.
  41254. */
  41255. onCollide: (collidedMesh: AbstractMesh) => void;
  41256. private _collider;
  41257. private _needMoveForGravity;
  41258. private _oldPosition;
  41259. private _diffPosition;
  41260. private _newPosition;
  41261. /** @hidden */
  41262. _localDirection: Vector3;
  41263. /** @hidden */
  41264. _transformedDirection: Vector3;
  41265. /**
  41266. * Instantiates a FlyCamera.
  41267. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41268. * such as in a 3D Space Shooter or a Flight Simulator.
  41269. * @param name Define the name of the camera in the scene.
  41270. * @param position Define the starting position of the camera in the scene.
  41271. * @param scene Define the scene the camera belongs to.
  41272. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41273. */
  41274. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41275. /**
  41276. * Attach a control to the HTML DOM element.
  41277. * @param element Defines the element that listens to the input events.
  41278. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41279. */
  41280. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41281. /**
  41282. * Detach a control from the HTML DOM element.
  41283. * The camera will stop reacting to that input.
  41284. * @param element Defines the element that listens to the input events.
  41285. */
  41286. detachControl(element: HTMLElement): void;
  41287. private _collisionMask;
  41288. /**
  41289. * Get the mask that the camera ignores in collision events.
  41290. */
  41291. get collisionMask(): number;
  41292. /**
  41293. * Set the mask that the camera ignores in collision events.
  41294. */
  41295. set collisionMask(mask: number);
  41296. /** @hidden */
  41297. _collideWithWorld(displacement: Vector3): void;
  41298. /** @hidden */
  41299. private _onCollisionPositionChange;
  41300. /** @hidden */
  41301. _checkInputs(): void;
  41302. /** @hidden */
  41303. _decideIfNeedsToMove(): boolean;
  41304. /** @hidden */
  41305. _updatePosition(): void;
  41306. /**
  41307. * Restore the Roll to its target value at the rate specified.
  41308. * @param rate - Higher means slower restoring.
  41309. * @hidden
  41310. */
  41311. restoreRoll(rate: number): void;
  41312. /**
  41313. * Destroy the camera and release the current resources held by it.
  41314. */
  41315. dispose(): void;
  41316. /**
  41317. * Get the current object class name.
  41318. * @returns the class name.
  41319. */
  41320. getClassName(): string;
  41321. }
  41322. }
  41323. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41324. import { Nullable } from "babylonjs/types";
  41325. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41326. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41327. /**
  41328. * Listen to keyboard events to control the camera.
  41329. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41330. */
  41331. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41332. /**
  41333. * Defines the camera the input is attached to.
  41334. */
  41335. camera: FlyCamera;
  41336. /**
  41337. * The list of keyboard keys used to control the forward move of the camera.
  41338. */
  41339. keysForward: number[];
  41340. /**
  41341. * The list of keyboard keys used to control the backward move of the camera.
  41342. */
  41343. keysBackward: number[];
  41344. /**
  41345. * The list of keyboard keys used to control the forward move of the camera.
  41346. */
  41347. keysUp: number[];
  41348. /**
  41349. * The list of keyboard keys used to control the backward move of the camera.
  41350. */
  41351. keysDown: number[];
  41352. /**
  41353. * The list of keyboard keys used to control the right strafe move of the camera.
  41354. */
  41355. keysRight: number[];
  41356. /**
  41357. * The list of keyboard keys used to control the left strafe move of the camera.
  41358. */
  41359. keysLeft: number[];
  41360. private _keys;
  41361. private _onCanvasBlurObserver;
  41362. private _onKeyboardObserver;
  41363. private _engine;
  41364. private _scene;
  41365. /**
  41366. * Attach the input controls to a specific dom element to get the input from.
  41367. * @param element Defines the element the controls should be listened from
  41368. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41369. */
  41370. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41371. /**
  41372. * Detach the current controls from the specified dom element.
  41373. * @param element Defines the element to stop listening the inputs from
  41374. */
  41375. detachControl(element: Nullable<HTMLElement>): void;
  41376. /**
  41377. * Gets the class name of the current intput.
  41378. * @returns the class name
  41379. */
  41380. getClassName(): string;
  41381. /** @hidden */
  41382. _onLostFocus(e: FocusEvent): void;
  41383. /**
  41384. * Get the friendly name associated with the input class.
  41385. * @returns the input friendly name
  41386. */
  41387. getSimpleName(): string;
  41388. /**
  41389. * Update the current camera state depending on the inputs that have been used this frame.
  41390. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41391. */
  41392. checkInputs(): void;
  41393. }
  41394. }
  41395. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41396. import { Nullable } from "babylonjs/types";
  41397. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41398. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41399. /**
  41400. * Manage the mouse wheel inputs to control a follow camera.
  41401. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41402. */
  41403. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41404. /**
  41405. * Defines the camera the input is attached to.
  41406. */
  41407. camera: FollowCamera;
  41408. /**
  41409. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41410. */
  41411. axisControlRadius: boolean;
  41412. /**
  41413. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41414. */
  41415. axisControlHeight: boolean;
  41416. /**
  41417. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41418. */
  41419. axisControlRotation: boolean;
  41420. /**
  41421. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41422. * relation to mouseWheel events.
  41423. */
  41424. wheelPrecision: number;
  41425. /**
  41426. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41427. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41428. */
  41429. wheelDeltaPercentage: number;
  41430. private _wheel;
  41431. private _observer;
  41432. /**
  41433. * Attach the input controls to a specific dom element to get the input from.
  41434. * @param element Defines the element the controls should be listened from
  41435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41436. */
  41437. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41438. /**
  41439. * Detach the current controls from the specified dom element.
  41440. * @param element Defines the element to stop listening the inputs from
  41441. */
  41442. detachControl(element: Nullable<HTMLElement>): void;
  41443. /**
  41444. * Gets the class name of the current intput.
  41445. * @returns the class name
  41446. */
  41447. getClassName(): string;
  41448. /**
  41449. * Get the friendly name associated with the input class.
  41450. * @returns the input friendly name
  41451. */
  41452. getSimpleName(): string;
  41453. }
  41454. }
  41455. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41456. import { Nullable } from "babylonjs/types";
  41457. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41458. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41459. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41460. /**
  41461. * Manage the pointers inputs to control an follow camera.
  41462. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41463. */
  41464. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41465. /**
  41466. * Defines the camera the input is attached to.
  41467. */
  41468. camera: FollowCamera;
  41469. /**
  41470. * Gets the class name of the current input.
  41471. * @returns the class name
  41472. */
  41473. getClassName(): string;
  41474. /**
  41475. * Defines the pointer angular sensibility along the X axis or how fast is
  41476. * the camera rotating.
  41477. * A negative number will reverse the axis direction.
  41478. */
  41479. angularSensibilityX: number;
  41480. /**
  41481. * Defines the pointer angular sensibility along the Y axis or how fast is
  41482. * the camera rotating.
  41483. * A negative number will reverse the axis direction.
  41484. */
  41485. angularSensibilityY: number;
  41486. /**
  41487. * Defines the pointer pinch precision or how fast is the camera zooming.
  41488. * A negative number will reverse the axis direction.
  41489. */
  41490. pinchPrecision: number;
  41491. /**
  41492. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41493. * from 0.
  41494. * It defines the percentage of current camera.radius to use as delta when
  41495. * pinch zoom is used.
  41496. */
  41497. pinchDeltaPercentage: number;
  41498. /**
  41499. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41500. */
  41501. axisXControlRadius: boolean;
  41502. /**
  41503. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41504. */
  41505. axisXControlHeight: boolean;
  41506. /**
  41507. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41508. */
  41509. axisXControlRotation: boolean;
  41510. /**
  41511. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41512. */
  41513. axisYControlRadius: boolean;
  41514. /**
  41515. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41516. */
  41517. axisYControlHeight: boolean;
  41518. /**
  41519. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41520. */
  41521. axisYControlRotation: boolean;
  41522. /**
  41523. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41524. */
  41525. axisPinchControlRadius: boolean;
  41526. /**
  41527. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41528. */
  41529. axisPinchControlHeight: boolean;
  41530. /**
  41531. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41532. */
  41533. axisPinchControlRotation: boolean;
  41534. /**
  41535. * Log error messages if basic misconfiguration has occurred.
  41536. */
  41537. warningEnable: boolean;
  41538. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41539. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41540. private _warningCounter;
  41541. private _warning;
  41542. }
  41543. }
  41544. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41545. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41546. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41547. /**
  41548. * Default Inputs manager for the FollowCamera.
  41549. * It groups all the default supported inputs for ease of use.
  41550. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41551. */
  41552. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41553. /**
  41554. * Instantiates a new FollowCameraInputsManager.
  41555. * @param camera Defines the camera the inputs belong to
  41556. */
  41557. constructor(camera: FollowCamera);
  41558. /**
  41559. * Add keyboard input support to the input manager.
  41560. * @returns the current input manager
  41561. */
  41562. addKeyboard(): FollowCameraInputsManager;
  41563. /**
  41564. * Add mouse wheel input support to the input manager.
  41565. * @returns the current input manager
  41566. */
  41567. addMouseWheel(): FollowCameraInputsManager;
  41568. /**
  41569. * Add pointers input support to the input manager.
  41570. * @returns the current input manager
  41571. */
  41572. addPointers(): FollowCameraInputsManager;
  41573. /**
  41574. * Add orientation input support to the input manager.
  41575. * @returns the current input manager
  41576. */
  41577. addVRDeviceOrientation(): FollowCameraInputsManager;
  41578. }
  41579. }
  41580. declare module "babylonjs/Cameras/followCamera" {
  41581. import { Nullable } from "babylonjs/types";
  41582. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41583. import { Scene } from "babylonjs/scene";
  41584. import { Vector3 } from "babylonjs/Maths/math.vector";
  41585. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41586. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41587. /**
  41588. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41589. * an arc rotate version arcFollowCamera are available.
  41590. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41591. */
  41592. export class FollowCamera extends TargetCamera {
  41593. /**
  41594. * Distance the follow camera should follow an object at
  41595. */
  41596. radius: number;
  41597. /**
  41598. * Minimum allowed distance of the camera to the axis of rotation
  41599. * (The camera can not get closer).
  41600. * This can help limiting how the Camera is able to move in the scene.
  41601. */
  41602. lowerRadiusLimit: Nullable<number>;
  41603. /**
  41604. * Maximum allowed distance of the camera to the axis of rotation
  41605. * (The camera can not get further).
  41606. * This can help limiting how the Camera is able to move in the scene.
  41607. */
  41608. upperRadiusLimit: Nullable<number>;
  41609. /**
  41610. * Define a rotation offset between the camera and the object it follows
  41611. */
  41612. rotationOffset: number;
  41613. /**
  41614. * Minimum allowed angle to camera position relative to target object.
  41615. * This can help limiting how the Camera is able to move in the scene.
  41616. */
  41617. lowerRotationOffsetLimit: Nullable<number>;
  41618. /**
  41619. * Maximum allowed angle to camera position relative to target object.
  41620. * This can help limiting how the Camera is able to move in the scene.
  41621. */
  41622. upperRotationOffsetLimit: Nullable<number>;
  41623. /**
  41624. * Define a height offset between the camera and the object it follows.
  41625. * It can help following an object from the top (like a car chaing a plane)
  41626. */
  41627. heightOffset: number;
  41628. /**
  41629. * Minimum allowed height of camera position relative to target object.
  41630. * This can help limiting how the Camera is able to move in the scene.
  41631. */
  41632. lowerHeightOffsetLimit: Nullable<number>;
  41633. /**
  41634. * Maximum allowed height of camera position relative to target object.
  41635. * This can help limiting how the Camera is able to move in the scene.
  41636. */
  41637. upperHeightOffsetLimit: Nullable<number>;
  41638. /**
  41639. * Define how fast the camera can accelerate to follow it s target.
  41640. */
  41641. cameraAcceleration: number;
  41642. /**
  41643. * Define the speed limit of the camera following an object.
  41644. */
  41645. maxCameraSpeed: number;
  41646. /**
  41647. * Define the target of the camera.
  41648. */
  41649. lockedTarget: Nullable<AbstractMesh>;
  41650. /**
  41651. * Defines the input associated with the camera.
  41652. */
  41653. inputs: FollowCameraInputsManager;
  41654. /**
  41655. * Instantiates the follow camera.
  41656. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41657. * @param name Define the name of the camera in the scene
  41658. * @param position Define the position of the camera
  41659. * @param scene Define the scene the camera belong to
  41660. * @param lockedTarget Define the target of the camera
  41661. */
  41662. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  41663. private _follow;
  41664. /**
  41665. * Attached controls to the current camera.
  41666. * @param element Defines the element the controls should be listened from
  41667. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41668. */
  41669. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41670. /**
  41671. * Detach the current controls from the camera.
  41672. * The camera will stop reacting to inputs.
  41673. * @param element Defines the element to stop listening the inputs from
  41674. */
  41675. detachControl(element: HTMLElement): void;
  41676. /** @hidden */
  41677. _checkInputs(): void;
  41678. private _checkLimits;
  41679. /**
  41680. * Gets the camera class name.
  41681. * @returns the class name
  41682. */
  41683. getClassName(): string;
  41684. }
  41685. /**
  41686. * Arc Rotate version of the follow camera.
  41687. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  41688. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41689. */
  41690. export class ArcFollowCamera extends TargetCamera {
  41691. /** The longitudinal angle of the camera */
  41692. alpha: number;
  41693. /** The latitudinal angle of the camera */
  41694. beta: number;
  41695. /** The radius of the camera from its target */
  41696. radius: number;
  41697. /** Define the camera target (the messh it should follow) */
  41698. target: Nullable<AbstractMesh>;
  41699. private _cartesianCoordinates;
  41700. /**
  41701. * Instantiates a new ArcFollowCamera
  41702. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41703. * @param name Define the name of the camera
  41704. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  41705. * @param beta Define the rotation angle of the camera around the elevation axis
  41706. * @param radius Define the radius of the camera from its target point
  41707. * @param target Define the target of the camera
  41708. * @param scene Define the scene the camera belongs to
  41709. */
  41710. constructor(name: string,
  41711. /** The longitudinal angle of the camera */
  41712. alpha: number,
  41713. /** The latitudinal angle of the camera */
  41714. beta: number,
  41715. /** The radius of the camera from its target */
  41716. radius: number,
  41717. /** Define the camera target (the messh it should follow) */
  41718. target: Nullable<AbstractMesh>, scene: Scene);
  41719. private _follow;
  41720. /** @hidden */
  41721. _checkInputs(): void;
  41722. /**
  41723. * Returns the class name of the object.
  41724. * It is mostly used internally for serialization purposes.
  41725. */
  41726. getClassName(): string;
  41727. }
  41728. }
  41729. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  41730. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41731. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41732. import { Nullable } from "babylonjs/types";
  41733. /**
  41734. * Manage the keyboard inputs to control the movement of a follow camera.
  41735. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41736. */
  41737. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  41738. /**
  41739. * Defines the camera the input is attached to.
  41740. */
  41741. camera: FollowCamera;
  41742. /**
  41743. * Defines the list of key codes associated with the up action (increase heightOffset)
  41744. */
  41745. keysHeightOffsetIncr: number[];
  41746. /**
  41747. * Defines the list of key codes associated with the down action (decrease heightOffset)
  41748. */
  41749. keysHeightOffsetDecr: number[];
  41750. /**
  41751. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  41752. */
  41753. keysHeightOffsetModifierAlt: boolean;
  41754. /**
  41755. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  41756. */
  41757. keysHeightOffsetModifierCtrl: boolean;
  41758. /**
  41759. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  41760. */
  41761. keysHeightOffsetModifierShift: boolean;
  41762. /**
  41763. * Defines the list of key codes associated with the left action (increase rotationOffset)
  41764. */
  41765. keysRotationOffsetIncr: number[];
  41766. /**
  41767. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  41768. */
  41769. keysRotationOffsetDecr: number[];
  41770. /**
  41771. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  41772. */
  41773. keysRotationOffsetModifierAlt: boolean;
  41774. /**
  41775. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  41776. */
  41777. keysRotationOffsetModifierCtrl: boolean;
  41778. /**
  41779. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  41780. */
  41781. keysRotationOffsetModifierShift: boolean;
  41782. /**
  41783. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  41784. */
  41785. keysRadiusIncr: number[];
  41786. /**
  41787. * Defines the list of key codes associated with the zoom-out action (increase radius)
  41788. */
  41789. keysRadiusDecr: number[];
  41790. /**
  41791. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  41792. */
  41793. keysRadiusModifierAlt: boolean;
  41794. /**
  41795. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  41796. */
  41797. keysRadiusModifierCtrl: boolean;
  41798. /**
  41799. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  41800. */
  41801. keysRadiusModifierShift: boolean;
  41802. /**
  41803. * Defines the rate of change of heightOffset.
  41804. */
  41805. heightSensibility: number;
  41806. /**
  41807. * Defines the rate of change of rotationOffset.
  41808. */
  41809. rotationSensibility: number;
  41810. /**
  41811. * Defines the rate of change of radius.
  41812. */
  41813. radiusSensibility: number;
  41814. private _keys;
  41815. private _ctrlPressed;
  41816. private _altPressed;
  41817. private _shiftPressed;
  41818. private _onCanvasBlurObserver;
  41819. private _onKeyboardObserver;
  41820. private _engine;
  41821. private _scene;
  41822. /**
  41823. * Attach the input controls to a specific dom element to get the input from.
  41824. * @param element Defines the element the controls should be listened from
  41825. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41826. */
  41827. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41828. /**
  41829. * Detach the current controls from the specified dom element.
  41830. * @param element Defines the element to stop listening the inputs from
  41831. */
  41832. detachControl(element: Nullable<HTMLElement>): void;
  41833. /**
  41834. * Update the current camera state depending on the inputs that have been used this frame.
  41835. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41836. */
  41837. checkInputs(): void;
  41838. /**
  41839. * Gets the class name of the current input.
  41840. * @returns the class name
  41841. */
  41842. getClassName(): string;
  41843. /**
  41844. * Get the friendly name associated with the input class.
  41845. * @returns the input friendly name
  41846. */
  41847. getSimpleName(): string;
  41848. /**
  41849. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41850. * allow modification of the heightOffset value.
  41851. */
  41852. private _modifierHeightOffset;
  41853. /**
  41854. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41855. * allow modification of the rotationOffset value.
  41856. */
  41857. private _modifierRotationOffset;
  41858. /**
  41859. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  41860. * allow modification of the radius value.
  41861. */
  41862. private _modifierRadius;
  41863. }
  41864. }
  41865. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  41866. import { Nullable } from "babylonjs/types";
  41867. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41868. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41869. import { Observable } from "babylonjs/Misc/observable";
  41870. module "babylonjs/Cameras/freeCameraInputsManager" {
  41871. interface FreeCameraInputsManager {
  41872. /**
  41873. * @hidden
  41874. */
  41875. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  41876. /**
  41877. * Add orientation input support to the input manager.
  41878. * @returns the current input manager
  41879. */
  41880. addDeviceOrientation(): FreeCameraInputsManager;
  41881. }
  41882. }
  41883. /**
  41884. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  41885. * Screen rotation is taken into account.
  41886. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41887. */
  41888. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  41889. private _camera;
  41890. private _screenOrientationAngle;
  41891. private _constantTranform;
  41892. private _screenQuaternion;
  41893. private _alpha;
  41894. private _beta;
  41895. private _gamma;
  41896. /**
  41897. * Can be used to detect if a device orientation sensor is available on a device
  41898. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  41899. * @returns a promise that will resolve on orientation change
  41900. */
  41901. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  41902. /**
  41903. * @hidden
  41904. */
  41905. _onDeviceOrientationChangedObservable: Observable<void>;
  41906. /**
  41907. * Instantiates a new input
  41908. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41909. */
  41910. constructor();
  41911. /**
  41912. * Define the camera controlled by the input.
  41913. */
  41914. get camera(): FreeCamera;
  41915. set camera(camera: FreeCamera);
  41916. /**
  41917. * Attach the input controls to a specific dom element to get the input from.
  41918. * @param element Defines the element the controls should be listened from
  41919. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41920. */
  41921. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41922. private _orientationChanged;
  41923. private _deviceOrientation;
  41924. /**
  41925. * Detach the current controls from the specified dom element.
  41926. * @param element Defines the element to stop listening the inputs from
  41927. */
  41928. detachControl(element: Nullable<HTMLElement>): void;
  41929. /**
  41930. * Update the current camera state depending on the inputs that have been used this frame.
  41931. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41932. */
  41933. checkInputs(): void;
  41934. /**
  41935. * Gets the class name of the current intput.
  41936. * @returns the class name
  41937. */
  41938. getClassName(): string;
  41939. /**
  41940. * Get the friendly name associated with the input class.
  41941. * @returns the input friendly name
  41942. */
  41943. getSimpleName(): string;
  41944. }
  41945. }
  41946. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  41947. import { Nullable } from "babylonjs/types";
  41948. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41949. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41950. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41951. /**
  41952. * Manage the gamepad inputs to control a free camera.
  41953. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41954. */
  41955. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  41956. /**
  41957. * Define the camera the input is attached to.
  41958. */
  41959. camera: FreeCamera;
  41960. /**
  41961. * Define the Gamepad controlling the input
  41962. */
  41963. gamepad: Nullable<Gamepad>;
  41964. /**
  41965. * Defines the gamepad rotation sensiblity.
  41966. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41967. */
  41968. gamepadAngularSensibility: number;
  41969. /**
  41970. * Defines the gamepad move sensiblity.
  41971. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41972. */
  41973. gamepadMoveSensibility: number;
  41974. private _yAxisScale;
  41975. /**
  41976. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41977. */
  41978. get invertYAxis(): boolean;
  41979. set invertYAxis(value: boolean);
  41980. private _onGamepadConnectedObserver;
  41981. private _onGamepadDisconnectedObserver;
  41982. private _cameraTransform;
  41983. private _deltaTransform;
  41984. private _vector3;
  41985. private _vector2;
  41986. /**
  41987. * Attach the input controls to a specific dom element to get the input from.
  41988. * @param element Defines the element the controls should be listened from
  41989. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41990. */
  41991. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41992. /**
  41993. * Detach the current controls from the specified dom element.
  41994. * @param element Defines the element to stop listening the inputs from
  41995. */
  41996. detachControl(element: Nullable<HTMLElement>): void;
  41997. /**
  41998. * Update the current camera state depending on the inputs that have been used this frame.
  41999. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42000. */
  42001. checkInputs(): void;
  42002. /**
  42003. * Gets the class name of the current intput.
  42004. * @returns the class name
  42005. */
  42006. getClassName(): string;
  42007. /**
  42008. * Get the friendly name associated with the input class.
  42009. * @returns the input friendly name
  42010. */
  42011. getSimpleName(): string;
  42012. }
  42013. }
  42014. declare module "babylonjs/Misc/virtualJoystick" {
  42015. import { Nullable } from "babylonjs/types";
  42016. import { Vector3 } from "babylonjs/Maths/math.vector";
  42017. /**
  42018. * Defines the potential axis of a Joystick
  42019. */
  42020. export enum JoystickAxis {
  42021. /** X axis */
  42022. X = 0,
  42023. /** Y axis */
  42024. Y = 1,
  42025. /** Z axis */
  42026. Z = 2
  42027. }
  42028. /**
  42029. * Class used to define virtual joystick (used in touch mode)
  42030. */
  42031. export class VirtualJoystick {
  42032. /**
  42033. * Gets or sets a boolean indicating that left and right values must be inverted
  42034. */
  42035. reverseLeftRight: boolean;
  42036. /**
  42037. * Gets or sets a boolean indicating that up and down values must be inverted
  42038. */
  42039. reverseUpDown: boolean;
  42040. /**
  42041. * Gets the offset value for the position (ie. the change of the position value)
  42042. */
  42043. deltaPosition: Vector3;
  42044. /**
  42045. * Gets a boolean indicating if the virtual joystick was pressed
  42046. */
  42047. pressed: boolean;
  42048. /**
  42049. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42050. */
  42051. static Canvas: Nullable<HTMLCanvasElement>;
  42052. private static _globalJoystickIndex;
  42053. private static vjCanvasContext;
  42054. private static vjCanvasWidth;
  42055. private static vjCanvasHeight;
  42056. private static halfWidth;
  42057. private _action;
  42058. private _axisTargetedByLeftAndRight;
  42059. private _axisTargetedByUpAndDown;
  42060. private _joystickSensibility;
  42061. private _inversedSensibility;
  42062. private _joystickPointerID;
  42063. private _joystickColor;
  42064. private _joystickPointerPos;
  42065. private _joystickPreviousPointerPos;
  42066. private _joystickPointerStartPos;
  42067. private _deltaJoystickVector;
  42068. private _leftJoystick;
  42069. private _touches;
  42070. private _onPointerDownHandlerRef;
  42071. private _onPointerMoveHandlerRef;
  42072. private _onPointerUpHandlerRef;
  42073. private _onResize;
  42074. /**
  42075. * Creates a new virtual joystick
  42076. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42077. */
  42078. constructor(leftJoystick?: boolean);
  42079. /**
  42080. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42081. * @param newJoystickSensibility defines the new sensibility
  42082. */
  42083. setJoystickSensibility(newJoystickSensibility: number): void;
  42084. private _onPointerDown;
  42085. private _onPointerMove;
  42086. private _onPointerUp;
  42087. /**
  42088. * Change the color of the virtual joystick
  42089. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42090. */
  42091. setJoystickColor(newColor: string): void;
  42092. /**
  42093. * Defines a callback to call when the joystick is touched
  42094. * @param action defines the callback
  42095. */
  42096. setActionOnTouch(action: () => any): void;
  42097. /**
  42098. * Defines which axis you'd like to control for left & right
  42099. * @param axis defines the axis to use
  42100. */
  42101. setAxisForLeftRight(axis: JoystickAxis): void;
  42102. /**
  42103. * Defines which axis you'd like to control for up & down
  42104. * @param axis defines the axis to use
  42105. */
  42106. setAxisForUpDown(axis: JoystickAxis): void;
  42107. private _drawVirtualJoystick;
  42108. /**
  42109. * Release internal HTML canvas
  42110. */
  42111. releaseCanvas(): void;
  42112. }
  42113. }
  42114. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42115. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42116. import { Nullable } from "babylonjs/types";
  42117. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42118. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42119. module "babylonjs/Cameras/freeCameraInputsManager" {
  42120. interface FreeCameraInputsManager {
  42121. /**
  42122. * Add virtual joystick input support to the input manager.
  42123. * @returns the current input manager
  42124. */
  42125. addVirtualJoystick(): FreeCameraInputsManager;
  42126. }
  42127. }
  42128. /**
  42129. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42130. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42131. */
  42132. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42133. /**
  42134. * Defines the camera the input is attached to.
  42135. */
  42136. camera: FreeCamera;
  42137. private _leftjoystick;
  42138. private _rightjoystick;
  42139. /**
  42140. * Gets the left stick of the virtual joystick.
  42141. * @returns The virtual Joystick
  42142. */
  42143. getLeftJoystick(): VirtualJoystick;
  42144. /**
  42145. * Gets the right stick of the virtual joystick.
  42146. * @returns The virtual Joystick
  42147. */
  42148. getRightJoystick(): VirtualJoystick;
  42149. /**
  42150. * Update the current camera state depending on the inputs that have been used this frame.
  42151. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42152. */
  42153. checkInputs(): void;
  42154. /**
  42155. * Attach the input controls to a specific dom element to get the input from.
  42156. * @param element Defines the element the controls should be listened from
  42157. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42158. */
  42159. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42160. /**
  42161. * Detach the current controls from the specified dom element.
  42162. * @param element Defines the element to stop listening the inputs from
  42163. */
  42164. detachControl(element: Nullable<HTMLElement>): void;
  42165. /**
  42166. * Gets the class name of the current intput.
  42167. * @returns the class name
  42168. */
  42169. getClassName(): string;
  42170. /**
  42171. * Get the friendly name associated with the input class.
  42172. * @returns the input friendly name
  42173. */
  42174. getSimpleName(): string;
  42175. }
  42176. }
  42177. declare module "babylonjs/Cameras/Inputs/index" {
  42178. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42179. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42180. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42181. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42182. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42183. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42184. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42185. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42186. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42187. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42188. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42189. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42190. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42191. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42192. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42193. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42194. }
  42195. declare module "babylonjs/Cameras/touchCamera" {
  42196. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42197. import { Scene } from "babylonjs/scene";
  42198. import { Vector3 } from "babylonjs/Maths/math.vector";
  42199. /**
  42200. * This represents a FPS type of camera controlled by touch.
  42201. * This is like a universal camera minus the Gamepad controls.
  42202. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42203. */
  42204. export class TouchCamera extends FreeCamera {
  42205. /**
  42206. * Defines the touch sensibility for rotation.
  42207. * The higher the faster.
  42208. */
  42209. get touchAngularSensibility(): number;
  42210. set touchAngularSensibility(value: number);
  42211. /**
  42212. * Defines the touch sensibility for move.
  42213. * The higher the faster.
  42214. */
  42215. get touchMoveSensibility(): number;
  42216. set touchMoveSensibility(value: number);
  42217. /**
  42218. * Instantiates a new touch camera.
  42219. * This represents a FPS type of camera controlled by touch.
  42220. * This is like a universal camera minus the Gamepad controls.
  42221. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42222. * @param name Define the name of the camera in the scene
  42223. * @param position Define the start position of the camera in the scene
  42224. * @param scene Define the scene the camera belongs to
  42225. */
  42226. constructor(name: string, position: Vector3, scene: Scene);
  42227. /**
  42228. * Gets the current object class name.
  42229. * @return the class name
  42230. */
  42231. getClassName(): string;
  42232. /** @hidden */
  42233. _setupInputs(): void;
  42234. }
  42235. }
  42236. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42237. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42238. import { Scene } from "babylonjs/scene";
  42239. import { Vector3 } from "babylonjs/Maths/math.vector";
  42240. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42241. import { Axis } from "babylonjs/Maths/math.axis";
  42242. /**
  42243. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42244. * being tilted forward or back and left or right.
  42245. */
  42246. export class DeviceOrientationCamera extends FreeCamera {
  42247. private _initialQuaternion;
  42248. private _quaternionCache;
  42249. private _tmpDragQuaternion;
  42250. private _disablePointerInputWhenUsingDeviceOrientation;
  42251. /**
  42252. * Creates a new device orientation camera
  42253. * @param name The name of the camera
  42254. * @param position The start position camera
  42255. * @param scene The scene the camera belongs to
  42256. */
  42257. constructor(name: string, position: Vector3, scene: Scene);
  42258. /**
  42259. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42260. */
  42261. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42262. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42263. private _dragFactor;
  42264. /**
  42265. * Enabled turning on the y axis when the orientation sensor is active
  42266. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42267. */
  42268. enableHorizontalDragging(dragFactor?: number): void;
  42269. /**
  42270. * Gets the current instance class name ("DeviceOrientationCamera").
  42271. * This helps avoiding instanceof at run time.
  42272. * @returns the class name
  42273. */
  42274. getClassName(): string;
  42275. /**
  42276. * @hidden
  42277. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42278. */
  42279. _checkInputs(): void;
  42280. /**
  42281. * Reset the camera to its default orientation on the specified axis only.
  42282. * @param axis The axis to reset
  42283. */
  42284. resetToCurrentRotation(axis?: Axis): void;
  42285. }
  42286. }
  42287. declare module "babylonjs/Gamepads/xboxGamepad" {
  42288. import { Observable } from "babylonjs/Misc/observable";
  42289. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42290. /**
  42291. * Defines supported buttons for XBox360 compatible gamepads
  42292. */
  42293. export enum Xbox360Button {
  42294. /** A */
  42295. A = 0,
  42296. /** B */
  42297. B = 1,
  42298. /** X */
  42299. X = 2,
  42300. /** Y */
  42301. Y = 3,
  42302. /** Start */
  42303. Start = 4,
  42304. /** Back */
  42305. Back = 5,
  42306. /** Left button */
  42307. LB = 6,
  42308. /** Right button */
  42309. RB = 7,
  42310. /** Left stick */
  42311. LeftStick = 8,
  42312. /** Right stick */
  42313. RightStick = 9
  42314. }
  42315. /** Defines values for XBox360 DPad */
  42316. export enum Xbox360Dpad {
  42317. /** Up */
  42318. Up = 0,
  42319. /** Down */
  42320. Down = 1,
  42321. /** Left */
  42322. Left = 2,
  42323. /** Right */
  42324. Right = 3
  42325. }
  42326. /**
  42327. * Defines a XBox360 gamepad
  42328. */
  42329. export class Xbox360Pad extends Gamepad {
  42330. private _leftTrigger;
  42331. private _rightTrigger;
  42332. private _onlefttriggerchanged;
  42333. private _onrighttriggerchanged;
  42334. private _onbuttondown;
  42335. private _onbuttonup;
  42336. private _ondpaddown;
  42337. private _ondpadup;
  42338. /** Observable raised when a button is pressed */
  42339. onButtonDownObservable: Observable<Xbox360Button>;
  42340. /** Observable raised when a button is released */
  42341. onButtonUpObservable: Observable<Xbox360Button>;
  42342. /** Observable raised when a pad is pressed */
  42343. onPadDownObservable: Observable<Xbox360Dpad>;
  42344. /** Observable raised when a pad is released */
  42345. onPadUpObservable: Observable<Xbox360Dpad>;
  42346. private _buttonA;
  42347. private _buttonB;
  42348. private _buttonX;
  42349. private _buttonY;
  42350. private _buttonBack;
  42351. private _buttonStart;
  42352. private _buttonLB;
  42353. private _buttonRB;
  42354. private _buttonLeftStick;
  42355. private _buttonRightStick;
  42356. private _dPadUp;
  42357. private _dPadDown;
  42358. private _dPadLeft;
  42359. private _dPadRight;
  42360. private _isXboxOnePad;
  42361. /**
  42362. * Creates a new XBox360 gamepad object
  42363. * @param id defines the id of this gamepad
  42364. * @param index defines its index
  42365. * @param gamepad defines the internal HTML gamepad object
  42366. * @param xboxOne defines if it is a XBox One gamepad
  42367. */
  42368. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42369. /**
  42370. * Defines the callback to call when left trigger is pressed
  42371. * @param callback defines the callback to use
  42372. */
  42373. onlefttriggerchanged(callback: (value: number) => void): void;
  42374. /**
  42375. * Defines the callback to call when right trigger is pressed
  42376. * @param callback defines the callback to use
  42377. */
  42378. onrighttriggerchanged(callback: (value: number) => void): void;
  42379. /**
  42380. * Gets the left trigger value
  42381. */
  42382. get leftTrigger(): number;
  42383. /**
  42384. * Sets the left trigger value
  42385. */
  42386. set leftTrigger(newValue: number);
  42387. /**
  42388. * Gets the right trigger value
  42389. */
  42390. get rightTrigger(): number;
  42391. /**
  42392. * Sets the right trigger value
  42393. */
  42394. set rightTrigger(newValue: number);
  42395. /**
  42396. * Defines the callback to call when a button is pressed
  42397. * @param callback defines the callback to use
  42398. */
  42399. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42400. /**
  42401. * Defines the callback to call when a button is released
  42402. * @param callback defines the callback to use
  42403. */
  42404. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42405. /**
  42406. * Defines the callback to call when a pad is pressed
  42407. * @param callback defines the callback to use
  42408. */
  42409. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42410. /**
  42411. * Defines the callback to call when a pad is released
  42412. * @param callback defines the callback to use
  42413. */
  42414. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42415. private _setButtonValue;
  42416. private _setDPadValue;
  42417. /**
  42418. * Gets the value of the `A` button
  42419. */
  42420. get buttonA(): number;
  42421. /**
  42422. * Sets the value of the `A` button
  42423. */
  42424. set buttonA(value: number);
  42425. /**
  42426. * Gets the value of the `B` button
  42427. */
  42428. get buttonB(): number;
  42429. /**
  42430. * Sets the value of the `B` button
  42431. */
  42432. set buttonB(value: number);
  42433. /**
  42434. * Gets the value of the `X` button
  42435. */
  42436. get buttonX(): number;
  42437. /**
  42438. * Sets the value of the `X` button
  42439. */
  42440. set buttonX(value: number);
  42441. /**
  42442. * Gets the value of the `Y` button
  42443. */
  42444. get buttonY(): number;
  42445. /**
  42446. * Sets the value of the `Y` button
  42447. */
  42448. set buttonY(value: number);
  42449. /**
  42450. * Gets the value of the `Start` button
  42451. */
  42452. get buttonStart(): number;
  42453. /**
  42454. * Sets the value of the `Start` button
  42455. */
  42456. set buttonStart(value: number);
  42457. /**
  42458. * Gets the value of the `Back` button
  42459. */
  42460. get buttonBack(): number;
  42461. /**
  42462. * Sets the value of the `Back` button
  42463. */
  42464. set buttonBack(value: number);
  42465. /**
  42466. * Gets the value of the `Left` button
  42467. */
  42468. get buttonLB(): number;
  42469. /**
  42470. * Sets the value of the `Left` button
  42471. */
  42472. set buttonLB(value: number);
  42473. /**
  42474. * Gets the value of the `Right` button
  42475. */
  42476. get buttonRB(): number;
  42477. /**
  42478. * Sets the value of the `Right` button
  42479. */
  42480. set buttonRB(value: number);
  42481. /**
  42482. * Gets the value of the Left joystick
  42483. */
  42484. get buttonLeftStick(): number;
  42485. /**
  42486. * Sets the value of the Left joystick
  42487. */
  42488. set buttonLeftStick(value: number);
  42489. /**
  42490. * Gets the value of the Right joystick
  42491. */
  42492. get buttonRightStick(): number;
  42493. /**
  42494. * Sets the value of the Right joystick
  42495. */
  42496. set buttonRightStick(value: number);
  42497. /**
  42498. * Gets the value of D-pad up
  42499. */
  42500. get dPadUp(): number;
  42501. /**
  42502. * Sets the value of D-pad up
  42503. */
  42504. set dPadUp(value: number);
  42505. /**
  42506. * Gets the value of D-pad down
  42507. */
  42508. get dPadDown(): number;
  42509. /**
  42510. * Sets the value of D-pad down
  42511. */
  42512. set dPadDown(value: number);
  42513. /**
  42514. * Gets the value of D-pad left
  42515. */
  42516. get dPadLeft(): number;
  42517. /**
  42518. * Sets the value of D-pad left
  42519. */
  42520. set dPadLeft(value: number);
  42521. /**
  42522. * Gets the value of D-pad right
  42523. */
  42524. get dPadRight(): number;
  42525. /**
  42526. * Sets the value of D-pad right
  42527. */
  42528. set dPadRight(value: number);
  42529. /**
  42530. * Force the gamepad to synchronize with device values
  42531. */
  42532. update(): void;
  42533. /**
  42534. * Disposes the gamepad
  42535. */
  42536. dispose(): void;
  42537. }
  42538. }
  42539. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42540. import { Observable } from "babylonjs/Misc/observable";
  42541. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42542. /**
  42543. * Defines supported buttons for DualShock compatible gamepads
  42544. */
  42545. export enum DualShockButton {
  42546. /** Cross */
  42547. Cross = 0,
  42548. /** Circle */
  42549. Circle = 1,
  42550. /** Square */
  42551. Square = 2,
  42552. /** Triangle */
  42553. Triangle = 3,
  42554. /** Options */
  42555. Options = 4,
  42556. /** Share */
  42557. Share = 5,
  42558. /** L1 */
  42559. L1 = 6,
  42560. /** R1 */
  42561. R1 = 7,
  42562. /** Left stick */
  42563. LeftStick = 8,
  42564. /** Right stick */
  42565. RightStick = 9
  42566. }
  42567. /** Defines values for DualShock DPad */
  42568. export enum DualShockDpad {
  42569. /** Up */
  42570. Up = 0,
  42571. /** Down */
  42572. Down = 1,
  42573. /** Left */
  42574. Left = 2,
  42575. /** Right */
  42576. Right = 3
  42577. }
  42578. /**
  42579. * Defines a DualShock gamepad
  42580. */
  42581. export class DualShockPad extends Gamepad {
  42582. private _leftTrigger;
  42583. private _rightTrigger;
  42584. private _onlefttriggerchanged;
  42585. private _onrighttriggerchanged;
  42586. private _onbuttondown;
  42587. private _onbuttonup;
  42588. private _ondpaddown;
  42589. private _ondpadup;
  42590. /** Observable raised when a button is pressed */
  42591. onButtonDownObservable: Observable<DualShockButton>;
  42592. /** Observable raised when a button is released */
  42593. onButtonUpObservable: Observable<DualShockButton>;
  42594. /** Observable raised when a pad is pressed */
  42595. onPadDownObservable: Observable<DualShockDpad>;
  42596. /** Observable raised when a pad is released */
  42597. onPadUpObservable: Observable<DualShockDpad>;
  42598. private _buttonCross;
  42599. private _buttonCircle;
  42600. private _buttonSquare;
  42601. private _buttonTriangle;
  42602. private _buttonShare;
  42603. private _buttonOptions;
  42604. private _buttonL1;
  42605. private _buttonR1;
  42606. private _buttonLeftStick;
  42607. private _buttonRightStick;
  42608. private _dPadUp;
  42609. private _dPadDown;
  42610. private _dPadLeft;
  42611. private _dPadRight;
  42612. /**
  42613. * Creates a new DualShock gamepad object
  42614. * @param id defines the id of this gamepad
  42615. * @param index defines its index
  42616. * @param gamepad defines the internal HTML gamepad object
  42617. */
  42618. constructor(id: string, index: number, gamepad: any);
  42619. /**
  42620. * Defines the callback to call when left trigger is pressed
  42621. * @param callback defines the callback to use
  42622. */
  42623. onlefttriggerchanged(callback: (value: number) => void): void;
  42624. /**
  42625. * Defines the callback to call when right trigger is pressed
  42626. * @param callback defines the callback to use
  42627. */
  42628. onrighttriggerchanged(callback: (value: number) => void): void;
  42629. /**
  42630. * Gets the left trigger value
  42631. */
  42632. get leftTrigger(): number;
  42633. /**
  42634. * Sets the left trigger value
  42635. */
  42636. set leftTrigger(newValue: number);
  42637. /**
  42638. * Gets the right trigger value
  42639. */
  42640. get rightTrigger(): number;
  42641. /**
  42642. * Sets the right trigger value
  42643. */
  42644. set rightTrigger(newValue: number);
  42645. /**
  42646. * Defines the callback to call when a button is pressed
  42647. * @param callback defines the callback to use
  42648. */
  42649. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  42650. /**
  42651. * Defines the callback to call when a button is released
  42652. * @param callback defines the callback to use
  42653. */
  42654. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  42655. /**
  42656. * Defines the callback to call when a pad is pressed
  42657. * @param callback defines the callback to use
  42658. */
  42659. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  42660. /**
  42661. * Defines the callback to call when a pad is released
  42662. * @param callback defines the callback to use
  42663. */
  42664. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  42665. private _setButtonValue;
  42666. private _setDPadValue;
  42667. /**
  42668. * Gets the value of the `Cross` button
  42669. */
  42670. get buttonCross(): number;
  42671. /**
  42672. * Sets the value of the `Cross` button
  42673. */
  42674. set buttonCross(value: number);
  42675. /**
  42676. * Gets the value of the `Circle` button
  42677. */
  42678. get buttonCircle(): number;
  42679. /**
  42680. * Sets the value of the `Circle` button
  42681. */
  42682. set buttonCircle(value: number);
  42683. /**
  42684. * Gets the value of the `Square` button
  42685. */
  42686. get buttonSquare(): number;
  42687. /**
  42688. * Sets the value of the `Square` button
  42689. */
  42690. set buttonSquare(value: number);
  42691. /**
  42692. * Gets the value of the `Triangle` button
  42693. */
  42694. get buttonTriangle(): number;
  42695. /**
  42696. * Sets the value of the `Triangle` button
  42697. */
  42698. set buttonTriangle(value: number);
  42699. /**
  42700. * Gets the value of the `Options` button
  42701. */
  42702. get buttonOptions(): number;
  42703. /**
  42704. * Sets the value of the `Options` button
  42705. */
  42706. set buttonOptions(value: number);
  42707. /**
  42708. * Gets the value of the `Share` button
  42709. */
  42710. get buttonShare(): number;
  42711. /**
  42712. * Sets the value of the `Share` button
  42713. */
  42714. set buttonShare(value: number);
  42715. /**
  42716. * Gets the value of the `L1` button
  42717. */
  42718. get buttonL1(): number;
  42719. /**
  42720. * Sets the value of the `L1` button
  42721. */
  42722. set buttonL1(value: number);
  42723. /**
  42724. * Gets the value of the `R1` button
  42725. */
  42726. get buttonR1(): number;
  42727. /**
  42728. * Sets the value of the `R1` button
  42729. */
  42730. set buttonR1(value: number);
  42731. /**
  42732. * Gets the value of the Left joystick
  42733. */
  42734. get buttonLeftStick(): number;
  42735. /**
  42736. * Sets the value of the Left joystick
  42737. */
  42738. set buttonLeftStick(value: number);
  42739. /**
  42740. * Gets the value of the Right joystick
  42741. */
  42742. get buttonRightStick(): number;
  42743. /**
  42744. * Sets the value of the Right joystick
  42745. */
  42746. set buttonRightStick(value: number);
  42747. /**
  42748. * Gets the value of D-pad up
  42749. */
  42750. get dPadUp(): number;
  42751. /**
  42752. * Sets the value of D-pad up
  42753. */
  42754. set dPadUp(value: number);
  42755. /**
  42756. * Gets the value of D-pad down
  42757. */
  42758. get dPadDown(): number;
  42759. /**
  42760. * Sets the value of D-pad down
  42761. */
  42762. set dPadDown(value: number);
  42763. /**
  42764. * Gets the value of D-pad left
  42765. */
  42766. get dPadLeft(): number;
  42767. /**
  42768. * Sets the value of D-pad left
  42769. */
  42770. set dPadLeft(value: number);
  42771. /**
  42772. * Gets the value of D-pad right
  42773. */
  42774. get dPadRight(): number;
  42775. /**
  42776. * Sets the value of D-pad right
  42777. */
  42778. set dPadRight(value: number);
  42779. /**
  42780. * Force the gamepad to synchronize with device values
  42781. */
  42782. update(): void;
  42783. /**
  42784. * Disposes the gamepad
  42785. */
  42786. dispose(): void;
  42787. }
  42788. }
  42789. declare module "babylonjs/Gamepads/gamepadManager" {
  42790. import { Observable } from "babylonjs/Misc/observable";
  42791. import { Nullable } from "babylonjs/types";
  42792. import { Scene } from "babylonjs/scene";
  42793. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42794. /**
  42795. * Manager for handling gamepads
  42796. */
  42797. export class GamepadManager {
  42798. private _scene?;
  42799. private _babylonGamepads;
  42800. private _oneGamepadConnected;
  42801. /** @hidden */
  42802. _isMonitoring: boolean;
  42803. private _gamepadEventSupported;
  42804. private _gamepadSupport?;
  42805. /**
  42806. * observable to be triggered when the gamepad controller has been connected
  42807. */
  42808. onGamepadConnectedObservable: Observable<Gamepad>;
  42809. /**
  42810. * observable to be triggered when the gamepad controller has been disconnected
  42811. */
  42812. onGamepadDisconnectedObservable: Observable<Gamepad>;
  42813. private _onGamepadConnectedEvent;
  42814. private _onGamepadDisconnectedEvent;
  42815. /**
  42816. * Initializes the gamepad manager
  42817. * @param _scene BabylonJS scene
  42818. */
  42819. constructor(_scene?: Scene | undefined);
  42820. /**
  42821. * The gamepads in the game pad manager
  42822. */
  42823. get gamepads(): Gamepad[];
  42824. /**
  42825. * Get the gamepad controllers based on type
  42826. * @param type The type of gamepad controller
  42827. * @returns Nullable gamepad
  42828. */
  42829. getGamepadByType(type?: number): Nullable<Gamepad>;
  42830. /**
  42831. * Disposes the gamepad manager
  42832. */
  42833. dispose(): void;
  42834. private _addNewGamepad;
  42835. private _startMonitoringGamepads;
  42836. private _stopMonitoringGamepads;
  42837. /** @hidden */
  42838. _checkGamepadsStatus(): void;
  42839. private _updateGamepadObjects;
  42840. }
  42841. }
  42842. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  42843. import { Nullable } from "babylonjs/types";
  42844. import { Scene } from "babylonjs/scene";
  42845. import { ISceneComponent } from "babylonjs/sceneComponent";
  42846. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  42847. module "babylonjs/scene" {
  42848. interface Scene {
  42849. /** @hidden */
  42850. _gamepadManager: Nullable<GamepadManager>;
  42851. /**
  42852. * Gets the gamepad manager associated with the scene
  42853. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  42854. */
  42855. gamepadManager: GamepadManager;
  42856. }
  42857. }
  42858. module "babylonjs/Cameras/freeCameraInputsManager" {
  42859. /**
  42860. * Interface representing a free camera inputs manager
  42861. */
  42862. interface FreeCameraInputsManager {
  42863. /**
  42864. * Adds gamepad input support to the FreeCameraInputsManager.
  42865. * @returns the FreeCameraInputsManager
  42866. */
  42867. addGamepad(): FreeCameraInputsManager;
  42868. }
  42869. }
  42870. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  42871. /**
  42872. * Interface representing an arc rotate camera inputs manager
  42873. */
  42874. interface ArcRotateCameraInputsManager {
  42875. /**
  42876. * Adds gamepad input support to the ArcRotateCamera InputManager.
  42877. * @returns the camera inputs manager
  42878. */
  42879. addGamepad(): ArcRotateCameraInputsManager;
  42880. }
  42881. }
  42882. /**
  42883. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  42884. */
  42885. export class GamepadSystemSceneComponent implements ISceneComponent {
  42886. /**
  42887. * The component name helpfull to identify the component in the list of scene components.
  42888. */
  42889. readonly name: string;
  42890. /**
  42891. * The scene the component belongs to.
  42892. */
  42893. scene: Scene;
  42894. /**
  42895. * Creates a new instance of the component for the given scene
  42896. * @param scene Defines the scene to register the component in
  42897. */
  42898. constructor(scene: Scene);
  42899. /**
  42900. * Registers the component in a given scene
  42901. */
  42902. register(): void;
  42903. /**
  42904. * Rebuilds the elements related to this component in case of
  42905. * context lost for instance.
  42906. */
  42907. rebuild(): void;
  42908. /**
  42909. * Disposes the component and the associated ressources
  42910. */
  42911. dispose(): void;
  42912. private _beforeCameraUpdate;
  42913. }
  42914. }
  42915. declare module "babylonjs/Cameras/universalCamera" {
  42916. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  42917. import { Scene } from "babylonjs/scene";
  42918. import { Vector3 } from "babylonjs/Maths/math.vector";
  42919. import "babylonjs/Gamepads/gamepadSceneComponent";
  42920. /**
  42921. * 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,
  42922. * which still works and will still be found in many Playgrounds.
  42923. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42924. */
  42925. export class UniversalCamera extends TouchCamera {
  42926. /**
  42927. * Defines the gamepad rotation sensiblity.
  42928. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42929. */
  42930. get gamepadAngularSensibility(): number;
  42931. set gamepadAngularSensibility(value: number);
  42932. /**
  42933. * Defines the gamepad move sensiblity.
  42934. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42935. */
  42936. get gamepadMoveSensibility(): number;
  42937. set gamepadMoveSensibility(value: number);
  42938. /**
  42939. * 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,
  42940. * which still works and will still be found in many Playgrounds.
  42941. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42942. * @param name Define the name of the camera in the scene
  42943. * @param position Define the start position of the camera in the scene
  42944. * @param scene Define the scene the camera belongs to
  42945. */
  42946. constructor(name: string, position: Vector3, scene: Scene);
  42947. /**
  42948. * Gets the current object class name.
  42949. * @return the class name
  42950. */
  42951. getClassName(): string;
  42952. }
  42953. }
  42954. declare module "babylonjs/Cameras/gamepadCamera" {
  42955. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  42956. import { Scene } from "babylonjs/scene";
  42957. import { Vector3 } from "babylonjs/Maths/math.vector";
  42958. /**
  42959. * This represents a FPS type of camera. This is only here for back compat purpose.
  42960. * Please use the UniversalCamera instead as both are identical.
  42961. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42962. */
  42963. export class GamepadCamera extends UniversalCamera {
  42964. /**
  42965. * Instantiates a new Gamepad Camera
  42966. * This represents a FPS type of camera. This is only here for back compat purpose.
  42967. * Please use the UniversalCamera instead as both are identical.
  42968. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42969. * @param name Define the name of the camera in the scene
  42970. * @param position Define the start position of the camera in the scene
  42971. * @param scene Define the scene the camera belongs to
  42972. */
  42973. constructor(name: string, position: Vector3, scene: Scene);
  42974. /**
  42975. * Gets the current object class name.
  42976. * @return the class name
  42977. */
  42978. getClassName(): string;
  42979. }
  42980. }
  42981. declare module "babylonjs/Shaders/pass.fragment" {
  42982. /** @hidden */
  42983. export var passPixelShader: {
  42984. name: string;
  42985. shader: string;
  42986. };
  42987. }
  42988. declare module "babylonjs/Shaders/passCube.fragment" {
  42989. /** @hidden */
  42990. export var passCubePixelShader: {
  42991. name: string;
  42992. shader: string;
  42993. };
  42994. }
  42995. declare module "babylonjs/PostProcesses/passPostProcess" {
  42996. import { Nullable } from "babylonjs/types";
  42997. import { Camera } from "babylonjs/Cameras/camera";
  42998. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42999. import { Engine } from "babylonjs/Engines/engine";
  43000. import "babylonjs/Shaders/pass.fragment";
  43001. import "babylonjs/Shaders/passCube.fragment";
  43002. /**
  43003. * PassPostProcess which produces an output the same as it's input
  43004. */
  43005. export class PassPostProcess extends PostProcess {
  43006. /**
  43007. * Creates the PassPostProcess
  43008. * @param name The name of the effect.
  43009. * @param options The required width/height ratio to downsize to before computing the render pass.
  43010. * @param camera The camera to apply the render pass to.
  43011. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43012. * @param engine The engine which the post process will be applied. (default: current engine)
  43013. * @param reusable If the post process can be reused on the same frame. (default: false)
  43014. * @param textureType The type of texture to be used when performing the post processing.
  43015. * @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)
  43016. */
  43017. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43018. }
  43019. /**
  43020. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43021. */
  43022. export class PassCubePostProcess extends PostProcess {
  43023. private _face;
  43024. /**
  43025. * Gets or sets the cube face to display.
  43026. * * 0 is +X
  43027. * * 1 is -X
  43028. * * 2 is +Y
  43029. * * 3 is -Y
  43030. * * 4 is +Z
  43031. * * 5 is -Z
  43032. */
  43033. get face(): number;
  43034. set face(value: number);
  43035. /**
  43036. * Creates the PassCubePostProcess
  43037. * @param name The name of the effect.
  43038. * @param options The required width/height ratio to downsize to before computing the render pass.
  43039. * @param camera The camera to apply the render pass to.
  43040. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43041. * @param engine The engine which the post process will be applied. (default: current engine)
  43042. * @param reusable If the post process can be reused on the same frame. (default: false)
  43043. * @param textureType The type of texture to be used when performing the post processing.
  43044. * @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)
  43045. */
  43046. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43047. }
  43048. }
  43049. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43050. /** @hidden */
  43051. export var anaglyphPixelShader: {
  43052. name: string;
  43053. shader: string;
  43054. };
  43055. }
  43056. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43057. import { Engine } from "babylonjs/Engines/engine";
  43058. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43059. import { Camera } from "babylonjs/Cameras/camera";
  43060. import "babylonjs/Shaders/anaglyph.fragment";
  43061. /**
  43062. * Postprocess used to generate anaglyphic rendering
  43063. */
  43064. export class AnaglyphPostProcess extends PostProcess {
  43065. private _passedProcess;
  43066. /**
  43067. * Creates a new AnaglyphPostProcess
  43068. * @param name defines postprocess name
  43069. * @param options defines creation options or target ratio scale
  43070. * @param rigCameras defines cameras using this postprocess
  43071. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43072. * @param engine defines hosting engine
  43073. * @param reusable defines if the postprocess will be reused multiple times per frame
  43074. */
  43075. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43076. }
  43077. }
  43078. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43079. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43080. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43081. import { Scene } from "babylonjs/scene";
  43082. import { Vector3 } from "babylonjs/Maths/math.vector";
  43083. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43084. /**
  43085. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43086. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43087. */
  43088. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43089. /**
  43090. * Creates a new AnaglyphArcRotateCamera
  43091. * @param name defines camera name
  43092. * @param alpha defines alpha angle (in radians)
  43093. * @param beta defines beta angle (in radians)
  43094. * @param radius defines radius
  43095. * @param target defines camera target
  43096. * @param interaxialDistance defines distance between each color axis
  43097. * @param scene defines the hosting scene
  43098. */
  43099. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43100. /**
  43101. * Gets camera class name
  43102. * @returns AnaglyphArcRotateCamera
  43103. */
  43104. getClassName(): string;
  43105. }
  43106. }
  43107. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43108. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43109. import { Scene } from "babylonjs/scene";
  43110. import { Vector3 } from "babylonjs/Maths/math.vector";
  43111. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43112. /**
  43113. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43114. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43115. */
  43116. export class AnaglyphFreeCamera extends FreeCamera {
  43117. /**
  43118. * Creates a new AnaglyphFreeCamera
  43119. * @param name defines camera name
  43120. * @param position defines initial position
  43121. * @param interaxialDistance defines distance between each color axis
  43122. * @param scene defines the hosting scene
  43123. */
  43124. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43125. /**
  43126. * Gets camera class name
  43127. * @returns AnaglyphFreeCamera
  43128. */
  43129. getClassName(): string;
  43130. }
  43131. }
  43132. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43133. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43134. import { Scene } from "babylonjs/scene";
  43135. import { Vector3 } from "babylonjs/Maths/math.vector";
  43136. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43137. /**
  43138. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43139. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43140. */
  43141. export class AnaglyphGamepadCamera extends GamepadCamera {
  43142. /**
  43143. * Creates a new AnaglyphGamepadCamera
  43144. * @param name defines camera name
  43145. * @param position defines initial position
  43146. * @param interaxialDistance defines distance between each color axis
  43147. * @param scene defines the hosting scene
  43148. */
  43149. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43150. /**
  43151. * Gets camera class name
  43152. * @returns AnaglyphGamepadCamera
  43153. */
  43154. getClassName(): string;
  43155. }
  43156. }
  43157. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43158. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43159. import { Scene } from "babylonjs/scene";
  43160. import { Vector3 } from "babylonjs/Maths/math.vector";
  43161. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43162. /**
  43163. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43164. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43165. */
  43166. export class AnaglyphUniversalCamera extends UniversalCamera {
  43167. /**
  43168. * Creates a new AnaglyphUniversalCamera
  43169. * @param name defines camera name
  43170. * @param position defines initial position
  43171. * @param interaxialDistance defines distance between each color axis
  43172. * @param scene defines the hosting scene
  43173. */
  43174. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43175. /**
  43176. * Gets camera class name
  43177. * @returns AnaglyphUniversalCamera
  43178. */
  43179. getClassName(): string;
  43180. }
  43181. }
  43182. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43183. /** @hidden */
  43184. export var stereoscopicInterlacePixelShader: {
  43185. name: string;
  43186. shader: string;
  43187. };
  43188. }
  43189. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43190. import { Camera } from "babylonjs/Cameras/camera";
  43191. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43192. import { Engine } from "babylonjs/Engines/engine";
  43193. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43194. /**
  43195. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43196. */
  43197. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43198. private _stepSize;
  43199. private _passedProcess;
  43200. /**
  43201. * Initializes a StereoscopicInterlacePostProcessI
  43202. * @param name The name of the effect.
  43203. * @param rigCameras The rig cameras to be appled to the post process
  43204. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43205. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43206. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43207. * @param engine The engine which the post process will be applied. (default: current engine)
  43208. * @param reusable If the post process can be reused on the same frame. (default: false)
  43209. */
  43210. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43211. }
  43212. /**
  43213. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43214. */
  43215. export class StereoscopicInterlacePostProcess extends PostProcess {
  43216. private _stepSize;
  43217. private _passedProcess;
  43218. /**
  43219. * Initializes a StereoscopicInterlacePostProcess
  43220. * @param name The name of the effect.
  43221. * @param rigCameras The rig cameras to be appled to the post process
  43222. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43223. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43224. * @param engine The engine which the post process will be applied. (default: current engine)
  43225. * @param reusable If the post process can be reused on the same frame. (default: false)
  43226. */
  43227. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43228. }
  43229. }
  43230. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43231. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43232. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43233. import { Scene } from "babylonjs/scene";
  43234. import { Vector3 } from "babylonjs/Maths/math.vector";
  43235. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43236. /**
  43237. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43238. * @see http://doc.babylonjs.com/features/cameras
  43239. */
  43240. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43241. /**
  43242. * Creates a new StereoscopicArcRotateCamera
  43243. * @param name defines camera name
  43244. * @param alpha defines alpha angle (in radians)
  43245. * @param beta defines beta angle (in radians)
  43246. * @param radius defines radius
  43247. * @param target defines camera target
  43248. * @param interaxialDistance defines distance between each color axis
  43249. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43250. * @param scene defines the hosting scene
  43251. */
  43252. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43253. /**
  43254. * Gets camera class name
  43255. * @returns StereoscopicArcRotateCamera
  43256. */
  43257. getClassName(): string;
  43258. }
  43259. }
  43260. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43261. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43262. import { Scene } from "babylonjs/scene";
  43263. import { Vector3 } from "babylonjs/Maths/math.vector";
  43264. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43265. /**
  43266. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43267. * @see http://doc.babylonjs.com/features/cameras
  43268. */
  43269. export class StereoscopicFreeCamera extends FreeCamera {
  43270. /**
  43271. * Creates a new StereoscopicFreeCamera
  43272. * @param name defines camera name
  43273. * @param position defines initial position
  43274. * @param interaxialDistance defines distance between each color axis
  43275. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43276. * @param scene defines the hosting scene
  43277. */
  43278. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43279. /**
  43280. * Gets camera class name
  43281. * @returns StereoscopicFreeCamera
  43282. */
  43283. getClassName(): string;
  43284. }
  43285. }
  43286. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43287. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43288. import { Scene } from "babylonjs/scene";
  43289. import { Vector3 } from "babylonjs/Maths/math.vector";
  43290. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43291. /**
  43292. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43293. * @see http://doc.babylonjs.com/features/cameras
  43294. */
  43295. export class StereoscopicGamepadCamera extends GamepadCamera {
  43296. /**
  43297. * Creates a new StereoscopicGamepadCamera
  43298. * @param name defines camera name
  43299. * @param position defines initial position
  43300. * @param interaxialDistance defines distance between each color axis
  43301. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43302. * @param scene defines the hosting scene
  43303. */
  43304. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43305. /**
  43306. * Gets camera class name
  43307. * @returns StereoscopicGamepadCamera
  43308. */
  43309. getClassName(): string;
  43310. }
  43311. }
  43312. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43313. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43314. import { Scene } from "babylonjs/scene";
  43315. import { Vector3 } from "babylonjs/Maths/math.vector";
  43316. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43317. /**
  43318. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43319. * @see http://doc.babylonjs.com/features/cameras
  43320. */
  43321. export class StereoscopicUniversalCamera extends UniversalCamera {
  43322. /**
  43323. * Creates a new StereoscopicUniversalCamera
  43324. * @param name defines camera name
  43325. * @param position defines initial position
  43326. * @param interaxialDistance defines distance between each color axis
  43327. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43328. * @param scene defines the hosting scene
  43329. */
  43330. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43331. /**
  43332. * Gets camera class name
  43333. * @returns StereoscopicUniversalCamera
  43334. */
  43335. getClassName(): string;
  43336. }
  43337. }
  43338. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43339. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43340. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43341. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43342. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43343. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43344. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43345. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43346. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43347. }
  43348. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43349. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43350. import { Scene } from "babylonjs/scene";
  43351. import { Vector3 } from "babylonjs/Maths/math.vector";
  43352. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43353. /**
  43354. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43355. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43356. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43357. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43358. */
  43359. export class VirtualJoysticksCamera extends FreeCamera {
  43360. /**
  43361. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43362. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43363. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43364. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43365. * @param name Define the name of the camera in the scene
  43366. * @param position Define the start position of the camera in the scene
  43367. * @param scene Define the scene the camera belongs to
  43368. */
  43369. constructor(name: string, position: Vector3, scene: Scene);
  43370. /**
  43371. * Gets the current object class name.
  43372. * @return the class name
  43373. */
  43374. getClassName(): string;
  43375. }
  43376. }
  43377. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43378. import { Matrix } from "babylonjs/Maths/math.vector";
  43379. /**
  43380. * This represents all the required metrics to create a VR camera.
  43381. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43382. */
  43383. export class VRCameraMetrics {
  43384. /**
  43385. * Define the horizontal resolution off the screen.
  43386. */
  43387. hResolution: number;
  43388. /**
  43389. * Define the vertical resolution off the screen.
  43390. */
  43391. vResolution: number;
  43392. /**
  43393. * Define the horizontal screen size.
  43394. */
  43395. hScreenSize: number;
  43396. /**
  43397. * Define the vertical screen size.
  43398. */
  43399. vScreenSize: number;
  43400. /**
  43401. * Define the vertical screen center position.
  43402. */
  43403. vScreenCenter: number;
  43404. /**
  43405. * Define the distance of the eyes to the screen.
  43406. */
  43407. eyeToScreenDistance: number;
  43408. /**
  43409. * Define the distance between both lenses
  43410. */
  43411. lensSeparationDistance: number;
  43412. /**
  43413. * Define the distance between both viewer's eyes.
  43414. */
  43415. interpupillaryDistance: number;
  43416. /**
  43417. * Define the distortion factor of the VR postprocess.
  43418. * Please, touch with care.
  43419. */
  43420. distortionK: number[];
  43421. /**
  43422. * Define the chromatic aberration correction factors for the VR post process.
  43423. */
  43424. chromaAbCorrection: number[];
  43425. /**
  43426. * Define the scale factor of the post process.
  43427. * The smaller the better but the slower.
  43428. */
  43429. postProcessScaleFactor: number;
  43430. /**
  43431. * Define an offset for the lens center.
  43432. */
  43433. lensCenterOffset: number;
  43434. /**
  43435. * Define if the current vr camera should compensate the distortion of the lense or not.
  43436. */
  43437. compensateDistortion: boolean;
  43438. /**
  43439. * Defines if multiview should be enabled when rendering (Default: false)
  43440. */
  43441. multiviewEnabled: boolean;
  43442. /**
  43443. * Gets the rendering aspect ratio based on the provided resolutions.
  43444. */
  43445. get aspectRatio(): number;
  43446. /**
  43447. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43448. */
  43449. get aspectRatioFov(): number;
  43450. /**
  43451. * @hidden
  43452. */
  43453. get leftHMatrix(): Matrix;
  43454. /**
  43455. * @hidden
  43456. */
  43457. get rightHMatrix(): Matrix;
  43458. /**
  43459. * @hidden
  43460. */
  43461. get leftPreViewMatrix(): Matrix;
  43462. /**
  43463. * @hidden
  43464. */
  43465. get rightPreViewMatrix(): Matrix;
  43466. /**
  43467. * Get the default VRMetrics based on the most generic setup.
  43468. * @returns the default vr metrics
  43469. */
  43470. static GetDefault(): VRCameraMetrics;
  43471. }
  43472. }
  43473. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43474. /** @hidden */
  43475. export var vrDistortionCorrectionPixelShader: {
  43476. name: string;
  43477. shader: string;
  43478. };
  43479. }
  43480. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43481. import { Camera } from "babylonjs/Cameras/camera";
  43482. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43483. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43484. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43485. /**
  43486. * VRDistortionCorrectionPostProcess used for mobile VR
  43487. */
  43488. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43489. private _isRightEye;
  43490. private _distortionFactors;
  43491. private _postProcessScaleFactor;
  43492. private _lensCenterOffset;
  43493. private _scaleIn;
  43494. private _scaleFactor;
  43495. private _lensCenter;
  43496. /**
  43497. * Initializes the VRDistortionCorrectionPostProcess
  43498. * @param name The name of the effect.
  43499. * @param camera The camera to apply the render pass to.
  43500. * @param isRightEye If this is for the right eye distortion
  43501. * @param vrMetrics All the required metrics for the VR camera
  43502. */
  43503. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43504. }
  43505. }
  43506. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43507. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43508. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43509. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43510. import { Scene } from "babylonjs/scene";
  43511. import { Vector3 } from "babylonjs/Maths/math.vector";
  43512. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43513. import "babylonjs/Cameras/RigModes/vrRigMode";
  43514. /**
  43515. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43516. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43517. */
  43518. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43519. /**
  43520. * Creates a new VRDeviceOrientationArcRotateCamera
  43521. * @param name defines camera name
  43522. * @param alpha defines the camera rotation along the logitudinal axis
  43523. * @param beta defines the camera rotation along the latitudinal axis
  43524. * @param radius defines the camera distance from its target
  43525. * @param target defines the camera target
  43526. * @param scene defines the scene the camera belongs to
  43527. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43528. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43529. */
  43530. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43531. /**
  43532. * Gets camera class name
  43533. * @returns VRDeviceOrientationArcRotateCamera
  43534. */
  43535. getClassName(): string;
  43536. }
  43537. }
  43538. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43539. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43540. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43541. import { Scene } from "babylonjs/scene";
  43542. import { Vector3 } from "babylonjs/Maths/math.vector";
  43543. import "babylonjs/Cameras/RigModes/vrRigMode";
  43544. /**
  43545. * Camera used to simulate VR rendering (based on FreeCamera)
  43546. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43547. */
  43548. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43549. /**
  43550. * Creates a new VRDeviceOrientationFreeCamera
  43551. * @param name defines camera name
  43552. * @param position defines the start position of the camera
  43553. * @param scene defines the scene the camera belongs to
  43554. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43555. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43556. */
  43557. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43558. /**
  43559. * Gets camera class name
  43560. * @returns VRDeviceOrientationFreeCamera
  43561. */
  43562. getClassName(): string;
  43563. }
  43564. }
  43565. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43566. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43567. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43568. import { Scene } from "babylonjs/scene";
  43569. import { Vector3 } from "babylonjs/Maths/math.vector";
  43570. import "babylonjs/Gamepads/gamepadSceneComponent";
  43571. /**
  43572. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43573. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43574. */
  43575. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43576. /**
  43577. * Creates a new VRDeviceOrientationGamepadCamera
  43578. * @param name defines camera name
  43579. * @param position defines the start position of the camera
  43580. * @param scene defines the scene the camera belongs to
  43581. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43582. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43583. */
  43584. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43585. /**
  43586. * Gets camera class name
  43587. * @returns VRDeviceOrientationGamepadCamera
  43588. */
  43589. getClassName(): string;
  43590. }
  43591. }
  43592. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43593. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43594. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43595. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  43596. /** @hidden */
  43597. export var imageProcessingPixelShader: {
  43598. name: string;
  43599. shader: string;
  43600. };
  43601. }
  43602. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  43603. import { Nullable } from "babylonjs/types";
  43604. import { Color4 } from "babylonjs/Maths/math.color";
  43605. import { Camera } from "babylonjs/Cameras/camera";
  43606. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  43607. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  43608. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  43609. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43610. import { Engine } from "babylonjs/Engines/engine";
  43611. import "babylonjs/Shaders/imageProcessing.fragment";
  43612. import "babylonjs/Shaders/postprocess.vertex";
  43613. /**
  43614. * ImageProcessingPostProcess
  43615. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  43616. */
  43617. export class ImageProcessingPostProcess extends PostProcess {
  43618. /**
  43619. * Default configuration related to image processing available in the PBR Material.
  43620. */
  43621. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  43622. /**
  43623. * Gets the image processing configuration used either in this material.
  43624. */
  43625. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  43626. /**
  43627. * Sets the Default image processing configuration used either in the this material.
  43628. *
  43629. * If sets to null, the scene one is in use.
  43630. */
  43631. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  43632. /**
  43633. * Keep track of the image processing observer to allow dispose and replace.
  43634. */
  43635. private _imageProcessingObserver;
  43636. /**
  43637. * Attaches a new image processing configuration to the PBR Material.
  43638. * @param configuration
  43639. */
  43640. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  43641. /**
  43642. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43643. */
  43644. get colorCurves(): Nullable<ColorCurves>;
  43645. /**
  43646. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  43647. */
  43648. set colorCurves(value: Nullable<ColorCurves>);
  43649. /**
  43650. * Gets wether the color curves effect is enabled.
  43651. */
  43652. get colorCurvesEnabled(): boolean;
  43653. /**
  43654. * Sets wether the color curves effect is enabled.
  43655. */
  43656. set colorCurvesEnabled(value: boolean);
  43657. /**
  43658. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43659. */
  43660. get colorGradingTexture(): Nullable<BaseTexture>;
  43661. /**
  43662. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  43663. */
  43664. set colorGradingTexture(value: Nullable<BaseTexture>);
  43665. /**
  43666. * Gets wether the color grading effect is enabled.
  43667. */
  43668. get colorGradingEnabled(): boolean;
  43669. /**
  43670. * Gets wether the color grading effect is enabled.
  43671. */
  43672. set colorGradingEnabled(value: boolean);
  43673. /**
  43674. * Gets exposure used in the effect.
  43675. */
  43676. get exposure(): number;
  43677. /**
  43678. * Sets exposure used in the effect.
  43679. */
  43680. set exposure(value: number);
  43681. /**
  43682. * Gets wether tonemapping is enabled or not.
  43683. */
  43684. get toneMappingEnabled(): boolean;
  43685. /**
  43686. * Sets wether tonemapping is enabled or not
  43687. */
  43688. set toneMappingEnabled(value: boolean);
  43689. /**
  43690. * Gets the type of tone mapping effect.
  43691. */
  43692. get toneMappingType(): number;
  43693. /**
  43694. * Sets the type of tone mapping effect.
  43695. */
  43696. set toneMappingType(value: number);
  43697. /**
  43698. * Gets contrast used in the effect.
  43699. */
  43700. get contrast(): number;
  43701. /**
  43702. * Sets contrast used in the effect.
  43703. */
  43704. set contrast(value: number);
  43705. /**
  43706. * Gets Vignette stretch size.
  43707. */
  43708. get vignetteStretch(): number;
  43709. /**
  43710. * Sets Vignette stretch size.
  43711. */
  43712. set vignetteStretch(value: number);
  43713. /**
  43714. * Gets Vignette centre X Offset.
  43715. */
  43716. get vignetteCentreX(): number;
  43717. /**
  43718. * Sets Vignette centre X Offset.
  43719. */
  43720. set vignetteCentreX(value: number);
  43721. /**
  43722. * Gets Vignette centre Y Offset.
  43723. */
  43724. get vignetteCentreY(): number;
  43725. /**
  43726. * Sets Vignette centre Y Offset.
  43727. */
  43728. set vignetteCentreY(value: number);
  43729. /**
  43730. * Gets Vignette weight or intensity of the vignette effect.
  43731. */
  43732. get vignetteWeight(): number;
  43733. /**
  43734. * Sets Vignette weight or intensity of the vignette effect.
  43735. */
  43736. set vignetteWeight(value: number);
  43737. /**
  43738. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43739. * if vignetteEnabled is set to true.
  43740. */
  43741. get vignetteColor(): Color4;
  43742. /**
  43743. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  43744. * if vignetteEnabled is set to true.
  43745. */
  43746. set vignetteColor(value: Color4);
  43747. /**
  43748. * Gets Camera field of view used by the Vignette effect.
  43749. */
  43750. get vignetteCameraFov(): number;
  43751. /**
  43752. * Sets Camera field of view used by the Vignette effect.
  43753. */
  43754. set vignetteCameraFov(value: number);
  43755. /**
  43756. * Gets the vignette blend mode allowing different kind of effect.
  43757. */
  43758. get vignetteBlendMode(): number;
  43759. /**
  43760. * Sets the vignette blend mode allowing different kind of effect.
  43761. */
  43762. set vignetteBlendMode(value: number);
  43763. /**
  43764. * Gets wether the vignette effect is enabled.
  43765. */
  43766. get vignetteEnabled(): boolean;
  43767. /**
  43768. * Sets wether the vignette effect is enabled.
  43769. */
  43770. set vignetteEnabled(value: boolean);
  43771. private _fromLinearSpace;
  43772. /**
  43773. * Gets wether the input of the processing is in Gamma or Linear Space.
  43774. */
  43775. get fromLinearSpace(): boolean;
  43776. /**
  43777. * Sets wether the input of the processing is in Gamma or Linear Space.
  43778. */
  43779. set fromLinearSpace(value: boolean);
  43780. /**
  43781. * Defines cache preventing GC.
  43782. */
  43783. private _defines;
  43784. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  43785. /**
  43786. * "ImageProcessingPostProcess"
  43787. * @returns "ImageProcessingPostProcess"
  43788. */
  43789. getClassName(): string;
  43790. protected _updateParameters(): void;
  43791. dispose(camera?: Camera): void;
  43792. }
  43793. }
  43794. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  43795. import { Scene } from "babylonjs/scene";
  43796. import { Color3 } from "babylonjs/Maths/math.color";
  43797. import { Mesh } from "babylonjs/Meshes/mesh";
  43798. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  43799. import { Nullable } from "babylonjs/types";
  43800. /**
  43801. * Class containing static functions to help procedurally build meshes
  43802. */
  43803. export class GroundBuilder {
  43804. /**
  43805. * Creates a ground mesh
  43806. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  43807. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  43808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43809. * @param name defines the name of the mesh
  43810. * @param options defines the options used to create the mesh
  43811. * @param scene defines the hosting scene
  43812. * @returns the ground mesh
  43813. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  43814. */
  43815. static CreateGround(name: string, options: {
  43816. width?: number;
  43817. height?: number;
  43818. subdivisions?: number;
  43819. subdivisionsX?: number;
  43820. subdivisionsY?: number;
  43821. updatable?: boolean;
  43822. }, scene: any): Mesh;
  43823. /**
  43824. * Creates a tiled ground mesh
  43825. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  43826. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  43827. * * 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
  43828. * * 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
  43829. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43830. * @param name defines the name of the mesh
  43831. * @param options defines the options used to create the mesh
  43832. * @param scene defines the hosting scene
  43833. * @returns the tiled ground mesh
  43834. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  43835. */
  43836. static CreateTiledGround(name: string, options: {
  43837. xmin: number;
  43838. zmin: number;
  43839. xmax: number;
  43840. zmax: number;
  43841. subdivisions?: {
  43842. w: number;
  43843. h: number;
  43844. };
  43845. precision?: {
  43846. w: number;
  43847. h: number;
  43848. };
  43849. updatable?: boolean;
  43850. }, scene?: Nullable<Scene>): Mesh;
  43851. /**
  43852. * Creates a ground mesh from a height map
  43853. * * The parameter `url` sets the URL of the height map image resource.
  43854. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  43855. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  43856. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  43857. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  43858. * * 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.
  43859. * * 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).
  43860. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  43861. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43862. * @param name defines the name of the mesh
  43863. * @param url defines the url to the height map
  43864. * @param options defines the options used to create the mesh
  43865. * @param scene defines the hosting scene
  43866. * @returns the ground mesh
  43867. * @see https://doc.babylonjs.com/babylon101/height_map
  43868. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  43869. */
  43870. static CreateGroundFromHeightMap(name: string, url: string, options: {
  43871. width?: number;
  43872. height?: number;
  43873. subdivisions?: number;
  43874. minHeight?: number;
  43875. maxHeight?: number;
  43876. colorFilter?: Color3;
  43877. alphaFilter?: number;
  43878. updatable?: boolean;
  43879. onReady?: (mesh: GroundMesh) => void;
  43880. }, scene?: Nullable<Scene>): GroundMesh;
  43881. }
  43882. }
  43883. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  43884. import { Vector4 } from "babylonjs/Maths/math.vector";
  43885. import { Mesh } from "babylonjs/Meshes/mesh";
  43886. /**
  43887. * Class containing static functions to help procedurally build meshes
  43888. */
  43889. export class TorusBuilder {
  43890. /**
  43891. * Creates a torus mesh
  43892. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  43893. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  43894. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  43895. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43896. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43898. * @param name defines the name of the mesh
  43899. * @param options defines the options used to create the mesh
  43900. * @param scene defines the hosting scene
  43901. * @returns the torus mesh
  43902. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  43903. */
  43904. static CreateTorus(name: string, options: {
  43905. diameter?: number;
  43906. thickness?: number;
  43907. tessellation?: number;
  43908. updatable?: boolean;
  43909. sideOrientation?: number;
  43910. frontUVs?: Vector4;
  43911. backUVs?: Vector4;
  43912. }, scene: any): Mesh;
  43913. }
  43914. }
  43915. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  43916. import { Vector4 } from "babylonjs/Maths/math.vector";
  43917. import { Color4 } from "babylonjs/Maths/math.color";
  43918. import { Mesh } from "babylonjs/Meshes/mesh";
  43919. /**
  43920. * Class containing static functions to help procedurally build meshes
  43921. */
  43922. export class CylinderBuilder {
  43923. /**
  43924. * Creates a cylinder or a cone mesh
  43925. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  43926. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  43927. * * 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.
  43928. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  43929. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  43930. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  43931. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  43932. * * 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).
  43933. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  43934. * * 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).
  43935. * * 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
  43936. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  43937. * * 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
  43938. * * 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.
  43939. * * If `enclose` is false, a ring surface is one element.
  43940. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  43941. * * 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
  43942. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43943. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  43944. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  43945. * @param name defines the name of the mesh
  43946. * @param options defines the options used to create the mesh
  43947. * @param scene defines the hosting scene
  43948. * @returns the cylinder mesh
  43949. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  43950. */
  43951. static CreateCylinder(name: string, options: {
  43952. height?: number;
  43953. diameterTop?: number;
  43954. diameterBottom?: number;
  43955. diameter?: number;
  43956. tessellation?: number;
  43957. subdivisions?: number;
  43958. arc?: number;
  43959. faceColors?: Color4[];
  43960. faceUV?: Vector4[];
  43961. updatable?: boolean;
  43962. hasRings?: boolean;
  43963. enclose?: boolean;
  43964. cap?: number;
  43965. sideOrientation?: number;
  43966. frontUVs?: Vector4;
  43967. backUVs?: Vector4;
  43968. }, scene: any): Mesh;
  43969. }
  43970. }
  43971. declare module "babylonjs/XR/webXRTypes" {
  43972. import { Nullable } from "babylonjs/types";
  43973. import { IDisposable } from "babylonjs/scene";
  43974. /**
  43975. * States of the webXR experience
  43976. */
  43977. export enum WebXRState {
  43978. /**
  43979. * Transitioning to being in XR mode
  43980. */
  43981. ENTERING_XR = 0,
  43982. /**
  43983. * Transitioning to non XR mode
  43984. */
  43985. EXITING_XR = 1,
  43986. /**
  43987. * In XR mode and presenting
  43988. */
  43989. IN_XR = 2,
  43990. /**
  43991. * Not entered XR mode
  43992. */
  43993. NOT_IN_XR = 3
  43994. }
  43995. /**
  43996. * Abstraction of the XR render target
  43997. */
  43998. export interface WebXRRenderTarget extends IDisposable {
  43999. /**
  44000. * xrpresent context of the canvas which can be used to display/mirror xr content
  44001. */
  44002. canvasContext: WebGLRenderingContext;
  44003. /**
  44004. * xr layer for the canvas
  44005. */
  44006. xrLayer: Nullable<XRWebGLLayer>;
  44007. /**
  44008. * Initializes the xr layer for the session
  44009. * @param xrSession xr session
  44010. * @returns a promise that will resolve once the XR Layer has been created
  44011. */
  44012. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44013. }
  44014. }
  44015. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44016. import { Nullable } from "babylonjs/types";
  44017. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44018. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44019. /**
  44020. * COnfiguration object for WebXR output canvas
  44021. */
  44022. export class WebXRManagedOutputCanvasOptions {
  44023. /**
  44024. * Options for this XR Layer output
  44025. */
  44026. canvasOptions?: XRWebGLLayerOptions;
  44027. /**
  44028. * CSS styling for a newly created canvas (if not provided)
  44029. */
  44030. newCanvasCssStyle?: string;
  44031. /**
  44032. * An optional canvas in case you wish to create it yourself and provide it here.
  44033. * If not provided, a new canvas will be created
  44034. */
  44035. canvasElement?: HTMLCanvasElement;
  44036. /**
  44037. * Get the default values of the configuration object
  44038. * @returns default values of this configuration object
  44039. */
  44040. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44041. }
  44042. /**
  44043. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44044. */
  44045. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44046. private _options;
  44047. private _engine;
  44048. private _canvas;
  44049. /**
  44050. * Rendering context of the canvas which can be used to display/mirror xr content
  44051. */
  44052. canvasContext: WebGLRenderingContext;
  44053. /**
  44054. * xr layer for the canvas
  44055. */
  44056. xrLayer: Nullable<XRWebGLLayer>;
  44057. /**
  44058. * Initializes the xr layer for the session
  44059. * @param xrSession xr session
  44060. * @returns a promise that will resolve once the XR Layer has been created
  44061. */
  44062. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44063. /**
  44064. * Initializes the canvas to be added/removed upon entering/exiting xr
  44065. * @param _xrSessionManager The XR Session manager
  44066. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44067. */
  44068. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44069. /**
  44070. * Disposes of the object
  44071. */
  44072. dispose(): void;
  44073. private _setManagedOutputCanvas;
  44074. private _addCanvas;
  44075. private _removeCanvas;
  44076. }
  44077. }
  44078. declare module "babylonjs/XR/webXRSessionManager" {
  44079. import { Observable } from "babylonjs/Misc/observable";
  44080. import { Nullable } from "babylonjs/types";
  44081. import { IDisposable, Scene } from "babylonjs/scene";
  44082. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44083. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44084. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44085. /**
  44086. * Manages an XRSession to work with Babylon's engine
  44087. * @see https://doc.babylonjs.com/how_to/webxr
  44088. */
  44089. export class WebXRSessionManager implements IDisposable {
  44090. /** The scene which the session should be created for */
  44091. scene: Scene;
  44092. /**
  44093. * Fires every time a new xrFrame arrives which can be used to update the camera
  44094. */
  44095. onXRFrameObservable: Observable<XRFrame>;
  44096. /**
  44097. * Fires when the xr session is ended either by the device or manually done
  44098. */
  44099. onXRSessionEnded: Observable<any>;
  44100. /**
  44101. * Fires when the xr session is ended either by the device or manually done
  44102. */
  44103. onXRSessionInit: Observable<XRSession>;
  44104. /**
  44105. * Fires when the reference space changed
  44106. */
  44107. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44108. /**
  44109. * Underlying xr session
  44110. */
  44111. session: XRSession;
  44112. /**
  44113. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44114. * or get the offset the player is currently at.
  44115. */
  44116. viewerReferenceSpace: XRReferenceSpace;
  44117. private _referenceSpace;
  44118. /**
  44119. * The current reference space used in this session. This reference space can constantly change!
  44120. * It is mainly used to offset the camera's position.
  44121. */
  44122. get referenceSpace(): XRReferenceSpace;
  44123. /**
  44124. * Set a new reference space and triggers the observable
  44125. */
  44126. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44127. /**
  44128. * The base reference space from which the session started. good if you want to reset your
  44129. * reference space
  44130. */
  44131. baseReferenceSpace: XRReferenceSpace;
  44132. /**
  44133. * Used just in case of a failure to initialize an immersive session.
  44134. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44135. */
  44136. defaultHeightCompensation: number;
  44137. /**
  44138. * Current XR frame
  44139. */
  44140. currentFrame: Nullable<XRFrame>;
  44141. /** WebXR timestamp updated every frame */
  44142. currentTimestamp: number;
  44143. private _xrNavigator;
  44144. private baseLayer;
  44145. private _rttProvider;
  44146. private _sessionEnded;
  44147. /**
  44148. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44149. * @param scene The scene which the session should be created for
  44150. */
  44151. constructor(
  44152. /** The scene which the session should be created for */
  44153. scene: Scene);
  44154. /**
  44155. * Initializes the manager
  44156. * After initialization enterXR can be called to start an XR session
  44157. * @returns Promise which resolves after it is initialized
  44158. */
  44159. initializeAsync(): Promise<void>;
  44160. /**
  44161. * Initializes an xr session
  44162. * @param xrSessionMode mode to initialize
  44163. * @param xrSessionInit defines optional and required values to pass to the session builder
  44164. * @returns a promise which will resolve once the session has been initialized
  44165. */
  44166. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44167. /**
  44168. * Sets the reference space on the xr session
  44169. * @param referenceSpaceType space to set
  44170. * @returns a promise that will resolve once the reference space has been set
  44171. */
  44172. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44173. /**
  44174. * Resets the reference space to the one started the session
  44175. */
  44176. resetReferenceSpace(): void;
  44177. /**
  44178. * Updates the render state of the session
  44179. * @param state state to set
  44180. * @returns a promise that resolves once the render state has been updated
  44181. */
  44182. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44183. /**
  44184. * Starts rendering to the xr layer
  44185. */
  44186. runXRRenderLoop(): void;
  44187. /**
  44188. * Gets the correct render target texture to be rendered this frame for this eye
  44189. * @param eye the eye for which to get the render target
  44190. * @returns the render target for the specified eye
  44191. */
  44192. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44193. /**
  44194. * Stops the xrSession and restores the renderloop
  44195. * @returns Promise which resolves after it exits XR
  44196. */
  44197. exitXRAsync(): Promise<void>;
  44198. /**
  44199. * Checks if a session would be supported for the creation options specified
  44200. * @param sessionMode session mode to check if supported eg. immersive-vr
  44201. * @returns A Promise that resolves to true if supported and false if not
  44202. */
  44203. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44204. /**
  44205. * Creates a WebXRRenderTarget object for the XR session
  44206. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44207. * @param options optional options to provide when creating a new render target
  44208. * @returns a WebXR render target to which the session can render
  44209. */
  44210. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44211. /**
  44212. * @hidden
  44213. * Converts the render layer of xrSession to a render target
  44214. * @param session session to create render target for
  44215. * @param scene scene the new render target should be created for
  44216. * @param baseLayer the webgl layer to create the render target for
  44217. */
  44218. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  44219. /**
  44220. * Disposes of the session manager
  44221. */
  44222. dispose(): void;
  44223. /**
  44224. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44225. * @param sessionMode defines the session to test
  44226. * @returns a promise with boolean as final value
  44227. */
  44228. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44229. }
  44230. }
  44231. declare module "babylonjs/XR/webXRCamera" {
  44232. import { Scene } from "babylonjs/scene";
  44233. import { Camera } from "babylonjs/Cameras/camera";
  44234. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44235. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44236. /**
  44237. * WebXR Camera which holds the views for the xrSession
  44238. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44239. */
  44240. export class WebXRCamera extends FreeCamera {
  44241. private _xrSessionManager;
  44242. private _firstFrame;
  44243. private _referenceQuaternion;
  44244. private _referencedPosition;
  44245. private _xrInvPositionCache;
  44246. private _xrInvQuaternionCache;
  44247. /**
  44248. * Should position compensation execute on first frame.
  44249. * This is used when copying the position from a native (non XR) camera
  44250. */
  44251. compensateOnFirstFrame: boolean;
  44252. /**
  44253. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44254. * @param name the name of the camera
  44255. * @param scene the scene to add the camera to
  44256. * @param _xrSessionManager a constructed xr session manager
  44257. */
  44258. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44259. /**
  44260. * Return the user's height, unrelated to the current ground.
  44261. * This will be the y position of this camera, when ground level is 0.
  44262. */
  44263. get realWorldHeight(): number;
  44264. /** @hidden */
  44265. _updateForDualEyeDebugging(): void;
  44266. /**
  44267. * Sets this camera's transformation based on a non-vr camera
  44268. * @param otherCamera the non-vr camera to copy the transformation from
  44269. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44270. */
  44271. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44272. private _updateFromXRSession;
  44273. private _updateNumberOfRigCameras;
  44274. private _updateReferenceSpace;
  44275. private _updateReferenceSpaceOffset;
  44276. }
  44277. }
  44278. declare module "babylonjs/XR/webXRFeaturesManager" {
  44279. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44280. import { IDisposable } from "babylonjs/scene";
  44281. /**
  44282. * Defining the interface required for a (webxr) feature
  44283. */
  44284. export interface IWebXRFeature extends IDisposable {
  44285. /**
  44286. * Is this feature attached
  44287. */
  44288. attached: boolean;
  44289. /**
  44290. * Should auto-attach be disabled?
  44291. */
  44292. disableAutoAttach: boolean;
  44293. /**
  44294. * Attach the feature to the session
  44295. * Will usually be called by the features manager
  44296. *
  44297. * @param force should attachment be forced (even when already attached)
  44298. * @returns true if successful.
  44299. */
  44300. attach(force?: boolean): boolean;
  44301. /**
  44302. * Detach the feature from the session
  44303. * Will usually be called by the features manager
  44304. *
  44305. * @returns true if successful.
  44306. */
  44307. detach(): boolean;
  44308. }
  44309. /**
  44310. * A list of the currently available features without referencing them
  44311. */
  44312. export class WebXRFeatureName {
  44313. /**
  44314. * The name of the hit test feature
  44315. */
  44316. static HIT_TEST: string;
  44317. /**
  44318. * The name of the anchor system feature
  44319. */
  44320. static ANCHOR_SYSTEM: string;
  44321. /**
  44322. * The name of the background remover feature
  44323. */
  44324. static BACKGROUND_REMOVER: string;
  44325. /**
  44326. * The name of the pointer selection feature
  44327. */
  44328. static POINTER_SELECTION: string;
  44329. /**
  44330. * The name of the teleportation feature
  44331. */
  44332. static TELEPORTATION: string;
  44333. /**
  44334. * The name of the plane detection feature
  44335. */
  44336. static PLANE_DETECTION: string;
  44337. /**
  44338. * physics impostors for xr controllers feature
  44339. */
  44340. static PHYSICS_CONTROLLERS: string;
  44341. }
  44342. /**
  44343. * Defining the constructor of a feature. Used to register the modules.
  44344. */
  44345. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44346. /**
  44347. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44348. * It is mainly used in AR sessions.
  44349. *
  44350. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44351. */
  44352. export class WebXRFeaturesManager implements IDisposable {
  44353. private _xrSessionManager;
  44354. private static readonly _AvailableFeatures;
  44355. /**
  44356. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44357. * Mainly used internally.
  44358. *
  44359. * @param featureName the name of the feature to register
  44360. * @param constructorFunction the function used to construct the module
  44361. * @param version the (babylon) version of the module
  44362. * @param stable is that a stable version of this module
  44363. */
  44364. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44365. /**
  44366. * Returns a constructor of a specific feature.
  44367. *
  44368. * @param featureName the name of the feature to construct
  44369. * @param version the version of the feature to load
  44370. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44371. * @param options optional options provided to the module.
  44372. * @returns a function that, when called, will return a new instance of this feature
  44373. */
  44374. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44375. /**
  44376. * Return the latest unstable version of this feature
  44377. * @param featureName the name of the feature to search
  44378. * @returns the version number. if not found will return -1
  44379. */
  44380. static GetLatestVersionOfFeature(featureName: string): number;
  44381. /**
  44382. * Return the latest stable version of this feature
  44383. * @param featureName the name of the feature to search
  44384. * @returns the version number. if not found will return -1
  44385. */
  44386. static GetStableVersionOfFeature(featureName: string): number;
  44387. /**
  44388. * Can be used to return the list of features currently registered
  44389. *
  44390. * @returns an Array of available features
  44391. */
  44392. static GetAvailableFeatures(): string[];
  44393. /**
  44394. * Gets the versions available for a specific feature
  44395. * @param featureName the name of the feature
  44396. * @returns an array with the available versions
  44397. */
  44398. static GetAvailableVersions(featureName: string): string[];
  44399. private _features;
  44400. /**
  44401. * constructs a new features manages.
  44402. *
  44403. * @param _xrSessionManager an instance of WebXRSessionManager
  44404. */
  44405. constructor(_xrSessionManager: WebXRSessionManager);
  44406. /**
  44407. * 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.
  44408. * 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.
  44409. *
  44410. * @param featureName the name of the feature to load or the class of the feature
  44411. * @param version optional version to load. if not provided the latest version will be enabled
  44412. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44413. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44414. * @returns a new constructed feature or throws an error if feature not found.
  44415. */
  44416. enableFeature(featureName: string | {
  44417. Name: string;
  44418. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44419. /**
  44420. * Used to disable an already-enabled feature
  44421. * The feature will be disposed and will be recreated once enabled.
  44422. * @param featureName the feature to disable
  44423. * @returns true if disable was successful
  44424. */
  44425. disableFeature(featureName: string | {
  44426. Name: string;
  44427. }): boolean;
  44428. /**
  44429. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44430. * Can be used during a session to start a feature
  44431. * @param featureName the name of feature to attach
  44432. */
  44433. attachFeature(featureName: string): void;
  44434. /**
  44435. * Can be used inside a session or when the session ends to detach a specific feature
  44436. * @param featureName the name of the feature to detach
  44437. */
  44438. detachFeature(featureName: string): void;
  44439. /**
  44440. * Get the list of enabled features
  44441. * @returns an array of enabled features
  44442. */
  44443. getEnabledFeatures(): string[];
  44444. /**
  44445. * get the implementation of an enabled feature.
  44446. * @param featureName the name of the feature to load
  44447. * @returns the feature class, if found
  44448. */
  44449. getEnabledFeature(featureName: string): IWebXRFeature;
  44450. /**
  44451. * dispose this features manager
  44452. */
  44453. dispose(): void;
  44454. }
  44455. }
  44456. declare module "babylonjs/XR/webXRExperienceHelper" {
  44457. import { Observable } from "babylonjs/Misc/observable";
  44458. import { IDisposable, Scene } from "babylonjs/scene";
  44459. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44460. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44461. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44462. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44463. /**
  44464. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  44465. * @see https://doc.babylonjs.com/how_to/webxr
  44466. */
  44467. export class WebXRExperienceHelper implements IDisposable {
  44468. private scene;
  44469. /**
  44470. * Camera used to render xr content
  44471. */
  44472. camera: WebXRCamera;
  44473. /**
  44474. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44475. */
  44476. state: WebXRState;
  44477. private _setState;
  44478. /**
  44479. * Fires when the state of the experience helper has changed
  44480. */
  44481. onStateChangedObservable: Observable<WebXRState>;
  44482. /**
  44483. * Observers registered here will be triggered after the camera's initial transformation is set
  44484. * This can be used to set a different ground level or an extra rotation.
  44485. *
  44486. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44487. * to the position set after this observable is done executing.
  44488. */
  44489. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44490. /** Session manager used to keep track of xr session */
  44491. sessionManager: WebXRSessionManager;
  44492. /** A features manager for this xr session */
  44493. featuresManager: WebXRFeaturesManager;
  44494. private _nonVRCamera;
  44495. private _originalSceneAutoClear;
  44496. private _supported;
  44497. /**
  44498. * Creates the experience helper
  44499. * @param scene the scene to attach the experience helper to
  44500. * @returns a promise for the experience helper
  44501. */
  44502. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44503. /**
  44504. * Creates a WebXRExperienceHelper
  44505. * @param scene The scene the helper should be created in
  44506. */
  44507. private constructor();
  44508. /**
  44509. * Exits XR mode and returns the scene to its original state
  44510. * @returns promise that resolves after xr mode has exited
  44511. */
  44512. exitXRAsync(): Promise<void>;
  44513. /**
  44514. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44515. * @param sessionMode options for the XR session
  44516. * @param referenceSpaceType frame of reference of the XR session
  44517. * @param renderTarget the output canvas that will be used to enter XR mode
  44518. * @returns promise that resolves after xr mode has entered
  44519. */
  44520. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44521. /**
  44522. * Disposes of the experience helper
  44523. */
  44524. dispose(): void;
  44525. private _nonXRToXRCamera;
  44526. }
  44527. }
  44528. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44529. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44530. import { Observable } from "babylonjs/Misc/observable";
  44531. import { IDisposable } from "babylonjs/scene";
  44532. /**
  44533. * X-Y values for axes in WebXR
  44534. */
  44535. export interface IWebXRMotionControllerAxesValue {
  44536. /**
  44537. * The value of the x axis
  44538. */
  44539. x: number;
  44540. /**
  44541. * The value of the y-axis
  44542. */
  44543. y: number;
  44544. }
  44545. /**
  44546. * changed / previous values for the values of this component
  44547. */
  44548. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44549. /**
  44550. * current (this frame) value
  44551. */
  44552. current: T;
  44553. /**
  44554. * previous (last change) value
  44555. */
  44556. previous: T;
  44557. }
  44558. /**
  44559. * Represents changes in the component between current frame and last values recorded
  44560. */
  44561. export interface IWebXRMotionControllerComponentChanges {
  44562. /**
  44563. * will be populated with previous and current values if touched changed
  44564. */
  44565. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44566. /**
  44567. * will be populated with previous and current values if pressed changed
  44568. */
  44569. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44570. /**
  44571. * will be populated with previous and current values if value changed
  44572. */
  44573. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44574. /**
  44575. * will be populated with previous and current values if axes changed
  44576. */
  44577. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44578. }
  44579. /**
  44580. * This class represents a single component (for example button or thumbstick) of a motion controller
  44581. */
  44582. export class WebXRControllerComponent implements IDisposable {
  44583. /**
  44584. * the id of this component
  44585. */
  44586. id: string;
  44587. /**
  44588. * the type of the component
  44589. */
  44590. type: MotionControllerComponentType;
  44591. private _buttonIndex;
  44592. private _axesIndices;
  44593. /**
  44594. * Thumbstick component type
  44595. */
  44596. static THUMBSTICK_TYPE: MotionControllerComponentType;
  44597. /**
  44598. * Touchpad component type
  44599. */
  44600. static TOUCHPAD_TYPE: MotionControllerComponentType;
  44601. /**
  44602. * trigger component type
  44603. */
  44604. static TRIGGER_TYPE: MotionControllerComponentType;
  44605. /**
  44606. * squeeze component type
  44607. */
  44608. static SQUEEZE_TYPE: MotionControllerComponentType;
  44609. /**
  44610. * button component type
  44611. */
  44612. static BUTTON_TYPE: MotionControllerComponentType;
  44613. /**
  44614. * Observers registered here will be triggered when the state of a button changes
  44615. * State change is either pressed / touched / value
  44616. */
  44617. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  44618. /**
  44619. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  44620. * the axes data changes
  44621. */
  44622. onAxisValueChangedObservable: Observable<{
  44623. x: number;
  44624. y: number;
  44625. }>;
  44626. private _currentValue;
  44627. private _touched;
  44628. private _pressed;
  44629. private _axes;
  44630. private _changes;
  44631. private _hasChanges;
  44632. /**
  44633. * Return whether or not the component changed the last frame
  44634. */
  44635. get hasChanges(): boolean;
  44636. /**
  44637. * Creates a new component for a motion controller.
  44638. * It is created by the motion controller itself
  44639. *
  44640. * @param id the id of this component
  44641. * @param type the type of the component
  44642. * @param _buttonIndex index in the buttons array of the gamepad
  44643. * @param _axesIndices indices of the values in the axes array of the gamepad
  44644. */
  44645. constructor(
  44646. /**
  44647. * the id of this component
  44648. */
  44649. id: string,
  44650. /**
  44651. * the type of the component
  44652. */
  44653. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  44654. /**
  44655. * Get the current value of this component
  44656. */
  44657. get value(): number;
  44658. /**
  44659. * is the button currently pressed
  44660. */
  44661. get pressed(): boolean;
  44662. /**
  44663. * is the button currently touched
  44664. */
  44665. get touched(): boolean;
  44666. /**
  44667. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  44668. */
  44669. get axes(): IWebXRMotionControllerAxesValue;
  44670. /**
  44671. * Get the changes. Elements will be populated only if they changed with their previous and current value
  44672. */
  44673. get changes(): IWebXRMotionControllerComponentChanges;
  44674. /**
  44675. * Is this component a button (hence - pressable)
  44676. * @returns true if can be pressed
  44677. */
  44678. isButton(): boolean;
  44679. /**
  44680. * Are there axes correlating to this component
  44681. * @return true is axes data is available
  44682. */
  44683. isAxes(): boolean;
  44684. /**
  44685. * update this component using the gamepad object it is in. Called on every frame
  44686. * @param nativeController the native gamepad controller object
  44687. */
  44688. update(nativeController: IMinimalMotionControllerObject): void;
  44689. /**
  44690. * Dispose this component
  44691. */
  44692. dispose(): void;
  44693. }
  44694. }
  44695. declare module "babylonjs/Loading/sceneLoader" {
  44696. import { Observable } from "babylonjs/Misc/observable";
  44697. import { Nullable } from "babylonjs/types";
  44698. import { Scene } from "babylonjs/scene";
  44699. import { Engine } from "babylonjs/Engines/engine";
  44700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44701. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  44702. import { AssetContainer } from "babylonjs/assetContainer";
  44703. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  44704. import { Skeleton } from "babylonjs/Bones/skeleton";
  44705. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  44706. import { WebRequest } from "babylonjs/Misc/webRequest";
  44707. /**
  44708. * Class used to represent data loading progression
  44709. */
  44710. export class SceneLoaderProgressEvent {
  44711. /** defines if data length to load can be evaluated */
  44712. readonly lengthComputable: boolean;
  44713. /** defines the loaded data length */
  44714. readonly loaded: number;
  44715. /** defines the data length to load */
  44716. readonly total: number;
  44717. /**
  44718. * Create a new progress event
  44719. * @param lengthComputable defines if data length to load can be evaluated
  44720. * @param loaded defines the loaded data length
  44721. * @param total defines the data length to load
  44722. */
  44723. constructor(
  44724. /** defines if data length to load can be evaluated */
  44725. lengthComputable: boolean,
  44726. /** defines the loaded data length */
  44727. loaded: number,
  44728. /** defines the data length to load */
  44729. total: number);
  44730. /**
  44731. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  44732. * @param event defines the source event
  44733. * @returns a new SceneLoaderProgressEvent
  44734. */
  44735. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  44736. }
  44737. /**
  44738. * Interface used by SceneLoader plugins to define supported file extensions
  44739. */
  44740. export interface ISceneLoaderPluginExtensions {
  44741. /**
  44742. * Defines the list of supported extensions
  44743. */
  44744. [extension: string]: {
  44745. isBinary: boolean;
  44746. };
  44747. }
  44748. /**
  44749. * Interface used by SceneLoader plugin factory
  44750. */
  44751. export interface ISceneLoaderPluginFactory {
  44752. /**
  44753. * Defines the name of the factory
  44754. */
  44755. name: string;
  44756. /**
  44757. * Function called to create a new plugin
  44758. * @return the new plugin
  44759. */
  44760. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  44761. /**
  44762. * The callback that returns true if the data can be directly loaded.
  44763. * @param data string containing the file data
  44764. * @returns if the data can be loaded directly
  44765. */
  44766. canDirectLoad?(data: string): boolean;
  44767. }
  44768. /**
  44769. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  44770. */
  44771. export interface ISceneLoaderPluginBase {
  44772. /**
  44773. * The friendly name of this plugin.
  44774. */
  44775. name: string;
  44776. /**
  44777. * The file extensions supported by this plugin.
  44778. */
  44779. extensions: string | ISceneLoaderPluginExtensions;
  44780. /**
  44781. * The callback called when loading from a url.
  44782. * @param scene scene loading this url
  44783. * @param url url to load
  44784. * @param onSuccess callback called when the file successfully loads
  44785. * @param onProgress callback called while file is loading (if the server supports this mode)
  44786. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  44787. * @param onError callback called when the file fails to load
  44788. * @returns a file request object
  44789. */
  44790. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44791. /**
  44792. * The callback called when loading from a file object.
  44793. * @param scene scene loading this file
  44794. * @param file defines the file to load
  44795. * @param onSuccess defines the callback to call when data is loaded
  44796. * @param onProgress defines the callback to call during loading process
  44797. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  44798. * @param onError defines the callback to call when an error occurs
  44799. * @returns a file request object
  44800. */
  44801. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  44802. /**
  44803. * The callback that returns true if the data can be directly loaded.
  44804. * @param data string containing the file data
  44805. * @returns if the data can be loaded directly
  44806. */
  44807. canDirectLoad?(data: string): boolean;
  44808. /**
  44809. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  44810. * @param scene scene loading this data
  44811. * @param data string containing the data
  44812. * @returns data to pass to the plugin
  44813. */
  44814. directLoad?(scene: Scene, data: string): any;
  44815. /**
  44816. * The callback that allows custom handling of the root url based on the response url.
  44817. * @param rootUrl the original root url
  44818. * @param responseURL the response url if available
  44819. * @returns the new root url
  44820. */
  44821. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  44822. }
  44823. /**
  44824. * Interface used to define a SceneLoader plugin
  44825. */
  44826. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  44827. /**
  44828. * Import meshes into a scene.
  44829. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44830. * @param scene The scene to import into
  44831. * @param data The data to import
  44832. * @param rootUrl The root url for scene and resources
  44833. * @param meshes The meshes array to import into
  44834. * @param particleSystems The particle systems array to import into
  44835. * @param skeletons The skeletons array to import into
  44836. * @param onError The callback when import fails
  44837. * @returns True if successful or false otherwise
  44838. */
  44839. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  44840. /**
  44841. * Load into a scene.
  44842. * @param scene The scene to load into
  44843. * @param data The data to import
  44844. * @param rootUrl The root url for scene and resources
  44845. * @param onError The callback when import fails
  44846. * @returns True if successful or false otherwise
  44847. */
  44848. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  44849. /**
  44850. * Load into an asset container.
  44851. * @param scene The scene to load into
  44852. * @param data The data to import
  44853. * @param rootUrl The root url for scene and resources
  44854. * @param onError The callback when import fails
  44855. * @returns The loaded asset container
  44856. */
  44857. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  44858. }
  44859. /**
  44860. * Interface used to define an async SceneLoader plugin
  44861. */
  44862. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  44863. /**
  44864. * Import meshes into a scene.
  44865. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44866. * @param scene The scene to import into
  44867. * @param data The data to import
  44868. * @param rootUrl The root url for scene and resources
  44869. * @param onProgress The callback when the load progresses
  44870. * @param fileName Defines the name of the file to load
  44871. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  44872. */
  44873. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  44874. meshes: AbstractMesh[];
  44875. particleSystems: IParticleSystem[];
  44876. skeletons: Skeleton[];
  44877. animationGroups: AnimationGroup[];
  44878. }>;
  44879. /**
  44880. * Load into a scene.
  44881. * @param scene The scene to load into
  44882. * @param data The data to import
  44883. * @param rootUrl The root url for scene and resources
  44884. * @param onProgress The callback when the load progresses
  44885. * @param fileName Defines the name of the file to load
  44886. * @returns Nothing
  44887. */
  44888. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  44889. /**
  44890. * Load into an asset container.
  44891. * @param scene The scene to load into
  44892. * @param data The data to import
  44893. * @param rootUrl The root url for scene and resources
  44894. * @param onProgress The callback when the load progresses
  44895. * @param fileName Defines the name of the file to load
  44896. * @returns The loaded asset container
  44897. */
  44898. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  44899. }
  44900. /**
  44901. * Mode that determines how to handle old animation groups before loading new ones.
  44902. */
  44903. export enum SceneLoaderAnimationGroupLoadingMode {
  44904. /**
  44905. * Reset all old animations to initial state then dispose them.
  44906. */
  44907. Clean = 0,
  44908. /**
  44909. * Stop all old animations.
  44910. */
  44911. Stop = 1,
  44912. /**
  44913. * Restart old animations from first frame.
  44914. */
  44915. Sync = 2,
  44916. /**
  44917. * Old animations remains untouched.
  44918. */
  44919. NoSync = 3
  44920. }
  44921. /**
  44922. * Class used to load scene from various file formats using registered plugins
  44923. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  44924. */
  44925. export class SceneLoader {
  44926. /**
  44927. * No logging while loading
  44928. */
  44929. static readonly NO_LOGGING: number;
  44930. /**
  44931. * Minimal logging while loading
  44932. */
  44933. static readonly MINIMAL_LOGGING: number;
  44934. /**
  44935. * Summary logging while loading
  44936. */
  44937. static readonly SUMMARY_LOGGING: number;
  44938. /**
  44939. * Detailled logging while loading
  44940. */
  44941. static readonly DETAILED_LOGGING: number;
  44942. /**
  44943. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  44944. */
  44945. static get ForceFullSceneLoadingForIncremental(): boolean;
  44946. static set ForceFullSceneLoadingForIncremental(value: boolean);
  44947. /**
  44948. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  44949. */
  44950. static get ShowLoadingScreen(): boolean;
  44951. static set ShowLoadingScreen(value: boolean);
  44952. /**
  44953. * Defines the current logging level (while loading the scene)
  44954. * @ignorenaming
  44955. */
  44956. static get loggingLevel(): number;
  44957. static set loggingLevel(value: number);
  44958. /**
  44959. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  44960. */
  44961. static get CleanBoneMatrixWeights(): boolean;
  44962. static set CleanBoneMatrixWeights(value: boolean);
  44963. /**
  44964. * Event raised when a plugin is used to load a scene
  44965. */
  44966. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  44967. private static _registeredPlugins;
  44968. private static _getDefaultPlugin;
  44969. private static _getPluginForExtension;
  44970. private static _getPluginForDirectLoad;
  44971. private static _getPluginForFilename;
  44972. private static _getDirectLoad;
  44973. private static _loadData;
  44974. private static _getFileInfo;
  44975. /**
  44976. * Gets a plugin that can load the given extension
  44977. * @param extension defines the extension to load
  44978. * @returns a plugin or null if none works
  44979. */
  44980. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  44981. /**
  44982. * Gets a boolean indicating that the given extension can be loaded
  44983. * @param extension defines the extension to load
  44984. * @returns true if the extension is supported
  44985. */
  44986. static IsPluginForExtensionAvailable(extension: string): boolean;
  44987. /**
  44988. * Adds a new plugin to the list of registered plugins
  44989. * @param plugin defines the plugin to add
  44990. */
  44991. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  44992. /**
  44993. * Import meshes into a scene
  44994. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  44995. * @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)
  44996. * @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)
  44997. * @param scene the instance of BABYLON.Scene to append to
  44998. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  44999. * @param onProgress a callback with a progress event for each file being loaded
  45000. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45001. * @param pluginExtension the extension used to determine the plugin
  45002. * @returns The loaded plugin
  45003. */
  45004. 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>;
  45005. /**
  45006. * Import meshes into a scene
  45007. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45008. * @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)
  45009. * @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)
  45010. * @param scene the instance of BABYLON.Scene to append to
  45011. * @param onProgress a callback with a progress event for each file being loaded
  45012. * @param pluginExtension the extension used to determine the plugin
  45013. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45014. */
  45015. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45016. meshes: AbstractMesh[];
  45017. particleSystems: IParticleSystem[];
  45018. skeletons: Skeleton[];
  45019. animationGroups: AnimationGroup[];
  45020. }>;
  45021. /**
  45022. * Load a scene
  45023. * @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)
  45024. * @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)
  45025. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45026. * @param onSuccess a callback with the scene when import succeeds
  45027. * @param onProgress a callback with a progress event for each file being loaded
  45028. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45029. * @param pluginExtension the extension used to determine the plugin
  45030. * @returns The loaded plugin
  45031. */
  45032. 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>;
  45033. /**
  45034. * Load a scene
  45035. * @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)
  45036. * @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)
  45037. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45038. * @param onProgress a callback with a progress event for each file being loaded
  45039. * @param pluginExtension the extension used to determine the plugin
  45040. * @returns The loaded scene
  45041. */
  45042. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45043. /**
  45044. * Append a scene
  45045. * @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)
  45046. * @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)
  45047. * @param scene is the instance of BABYLON.Scene to append to
  45048. * @param onSuccess a callback with the scene when import succeeds
  45049. * @param onProgress a callback with a progress event for each file being loaded
  45050. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45051. * @param pluginExtension the extension used to determine the plugin
  45052. * @returns The loaded plugin
  45053. */
  45054. 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>;
  45055. /**
  45056. * Append a scene
  45057. * @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)
  45058. * @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)
  45059. * @param scene is the instance of BABYLON.Scene to append to
  45060. * @param onProgress a callback with a progress event for each file being loaded
  45061. * @param pluginExtension the extension used to determine the plugin
  45062. * @returns The given scene
  45063. */
  45064. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45065. /**
  45066. * Load a scene into an asset container
  45067. * @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)
  45068. * @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)
  45069. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45070. * @param onSuccess a callback with the scene when import succeeds
  45071. * @param onProgress a callback with a progress event for each file being loaded
  45072. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45073. * @param pluginExtension the extension used to determine the plugin
  45074. * @returns The loaded plugin
  45075. */
  45076. 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>;
  45077. /**
  45078. * Load a scene into an asset container
  45079. * @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)
  45080. * @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)
  45081. * @param scene is the instance of Scene to append to
  45082. * @param onProgress a callback with a progress event for each file being loaded
  45083. * @param pluginExtension the extension used to determine the plugin
  45084. * @returns The loaded asset container
  45085. */
  45086. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45087. /**
  45088. * Import animations from a file into 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 scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45092. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45093. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45094. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45095. * @param onSuccess a callback with the scene when import succeeds
  45096. * @param onProgress a callback with a progress event for each file being loaded
  45097. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45098. */
  45099. 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;
  45100. /**
  45101. * Import animations from a file into a scene
  45102. * @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)
  45103. * @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)
  45104. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45105. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45106. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45107. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45108. * @param onSuccess a callback with the scene when import succeeds
  45109. * @param onProgress a callback with a progress event for each file being loaded
  45110. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45111. * @returns the updated scene with imported animations
  45112. */
  45113. 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>;
  45114. }
  45115. }
  45116. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45117. import { IDisposable, Scene } from "babylonjs/scene";
  45118. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45119. import { Observable } from "babylonjs/Misc/observable";
  45120. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45121. import { Nullable } from "babylonjs/types";
  45122. /**
  45123. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45124. */
  45125. export type MotionControllerHandness = "none" | "left" | "right";
  45126. /**
  45127. * The type of components available in motion controllers.
  45128. * This is not the name of the component.
  45129. */
  45130. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45131. /**
  45132. * The state of a controller component
  45133. */
  45134. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45135. /**
  45136. * The schema of motion controller layout.
  45137. * No object will be initialized using this interface
  45138. * This is used just to define the profile.
  45139. */
  45140. export interface IMotionControllerLayout {
  45141. /**
  45142. * Defines the main button component id
  45143. */
  45144. selectComponentId: string;
  45145. /**
  45146. * Available components (unsorted)
  45147. */
  45148. components: {
  45149. /**
  45150. * A map of component Ids
  45151. */
  45152. [componentId: string]: {
  45153. /**
  45154. * The type of input the component outputs
  45155. */
  45156. type: MotionControllerComponentType;
  45157. /**
  45158. * The indices of this component in the gamepad object
  45159. */
  45160. gamepadIndices: {
  45161. /**
  45162. * Index of button
  45163. */
  45164. button?: number;
  45165. /**
  45166. * If available, index of x-axis
  45167. */
  45168. xAxis?: number;
  45169. /**
  45170. * If available, index of y-axis
  45171. */
  45172. yAxis?: number;
  45173. };
  45174. /**
  45175. * The mesh's root node name
  45176. */
  45177. rootNodeName: string;
  45178. /**
  45179. * Animation definitions for this model
  45180. */
  45181. visualResponses: {
  45182. [stateKey: string]: {
  45183. /**
  45184. * What property will be animated
  45185. */
  45186. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45187. /**
  45188. * What states influence this visual reponse
  45189. */
  45190. states: MotionControllerComponentStateType[];
  45191. /**
  45192. * Type of animation - movement or visibility
  45193. */
  45194. valueNodeProperty: "transform" | "visibility";
  45195. /**
  45196. * Base node name to move. Its position will be calculated according to the min and max nodes
  45197. */
  45198. valueNodeName?: string;
  45199. /**
  45200. * Minimum movement node
  45201. */
  45202. minNodeName?: string;
  45203. /**
  45204. * Max movement node
  45205. */
  45206. maxNodeName?: string;
  45207. };
  45208. };
  45209. /**
  45210. * If touch enabled, what is the name of node to display user feedback
  45211. */
  45212. touchPointNodeName?: string;
  45213. };
  45214. };
  45215. /**
  45216. * Is it xr standard mapping or not
  45217. */
  45218. gamepadMapping: "" | "xr-standard";
  45219. /**
  45220. * Base root node of this entire model
  45221. */
  45222. rootNodeName: string;
  45223. /**
  45224. * Path to load the assets. Usually relative to the base path
  45225. */
  45226. assetPath: string;
  45227. }
  45228. /**
  45229. * A definition for the layout map in the input profile
  45230. */
  45231. export interface IMotionControllerLayoutMap {
  45232. /**
  45233. * Layouts with handness type as a key
  45234. */
  45235. [handness: string]: IMotionControllerLayout;
  45236. }
  45237. /**
  45238. * The XR Input profile schema
  45239. * Profiles can be found here:
  45240. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45241. */
  45242. export interface IMotionControllerProfile {
  45243. /**
  45244. * The id of this profile
  45245. * correlates to the profile(s) in the xrInput.profiles array
  45246. */
  45247. profileId: string;
  45248. /**
  45249. * fallback profiles for this profileId
  45250. */
  45251. fallbackProfileIds: string[];
  45252. /**
  45253. * The layout map, with handness as key
  45254. */
  45255. layouts: IMotionControllerLayoutMap;
  45256. }
  45257. /**
  45258. * A helper-interface for the 3 meshes needed for controller button animation
  45259. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45260. */
  45261. export interface IMotionControllerButtonMeshMap {
  45262. /**
  45263. * The mesh that will be changed when value changes
  45264. */
  45265. valueMesh: AbstractMesh;
  45266. /**
  45267. * the mesh that defines the pressed value mesh position.
  45268. * This is used to find the max-position of this button
  45269. */
  45270. pressedMesh: AbstractMesh;
  45271. /**
  45272. * the mesh that defines the unpressed value mesh position.
  45273. * This is used to find the min (or initial) position of this button
  45274. */
  45275. unpressedMesh: AbstractMesh;
  45276. }
  45277. /**
  45278. * A helper-interface for the 3 meshes needed for controller axis animation.
  45279. * This will be expanded when touchpad animations are fully supported
  45280. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45281. */
  45282. export interface IMotionControllerMeshMap {
  45283. /**
  45284. * The mesh that will be changed when axis value changes
  45285. */
  45286. valueMesh: AbstractMesh;
  45287. /**
  45288. * the mesh that defines the minimum value mesh position.
  45289. */
  45290. minMesh?: AbstractMesh;
  45291. /**
  45292. * the mesh that defines the maximum value mesh position.
  45293. */
  45294. maxMesh?: AbstractMesh;
  45295. }
  45296. /**
  45297. * The elements needed for change-detection of the gamepad objects in motion controllers
  45298. */
  45299. export interface IMinimalMotionControllerObject {
  45300. /**
  45301. * An array of available buttons
  45302. */
  45303. buttons: Array<{
  45304. /**
  45305. * Value of the button/trigger
  45306. */
  45307. value: number;
  45308. /**
  45309. * If the button/trigger is currently touched
  45310. */
  45311. touched: boolean;
  45312. /**
  45313. * If the button/trigger is currently pressed
  45314. */
  45315. pressed: boolean;
  45316. }>;
  45317. /**
  45318. * Available axes of this controller
  45319. */
  45320. axes: number[];
  45321. }
  45322. /**
  45323. * An Abstract Motion controller
  45324. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45325. * Each component has an observable to check for changes in value and state
  45326. */
  45327. export abstract class WebXRAbstractMotionController implements IDisposable {
  45328. protected scene: Scene;
  45329. protected layout: IMotionControllerLayout;
  45330. /**
  45331. * The gamepad object correlating to this controller
  45332. */
  45333. gamepadObject: IMinimalMotionControllerObject;
  45334. /**
  45335. * handness (left/right/none) of this controller
  45336. */
  45337. handness: MotionControllerHandness;
  45338. /**
  45339. * The profile id of this motion controller
  45340. */
  45341. abstract profileId: string;
  45342. /**
  45343. * A map of components (WebXRControllerComponent) in this motion controller
  45344. * Components have a ComponentType and can also have both button and axis definitions
  45345. */
  45346. readonly components: {
  45347. [id: string]: WebXRControllerComponent;
  45348. };
  45349. /**
  45350. * Observers registered here will be triggered when the model of this controller is done loading
  45351. */
  45352. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45353. /**
  45354. * The root mesh of the model. It is null if the model was not yet initialized
  45355. */
  45356. rootMesh: Nullable<AbstractMesh>;
  45357. /**
  45358. * Disable the model's animation. Can be set at any time.
  45359. */
  45360. disableAnimation: boolean;
  45361. private _modelReady;
  45362. /**
  45363. * constructs a new abstract motion controller
  45364. * @param scene the scene to which the model of the controller will be added
  45365. * @param layout The profile layout to load
  45366. * @param gamepadObject The gamepad object correlating to this controller
  45367. * @param handness handness (left/right/none) of this controller
  45368. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45369. */
  45370. constructor(scene: Scene, layout: IMotionControllerLayout,
  45371. /**
  45372. * The gamepad object correlating to this controller
  45373. */
  45374. gamepadObject: IMinimalMotionControllerObject,
  45375. /**
  45376. * handness (left/right/none) of this controller
  45377. */
  45378. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45379. private _initComponent;
  45380. /**
  45381. * Update this model using the current XRFrame
  45382. * @param xrFrame the current xr frame to use and update the model
  45383. */
  45384. updateFromXRFrame(xrFrame: XRFrame): void;
  45385. /**
  45386. * Get the list of components available in this motion controller
  45387. * @returns an array of strings correlating to available components
  45388. */
  45389. getComponentIds(): string[];
  45390. /**
  45391. * Get the main (Select) component of this controller as defined in the layout
  45392. * @returns the main component of this controller
  45393. */
  45394. getMainComponent(): WebXRControllerComponent;
  45395. /**
  45396. * get a component based an its component id as defined in layout.components
  45397. * @param id the id of the component
  45398. * @returns the component correlates to the id or undefined if not found
  45399. */
  45400. getComponent(id: string): WebXRControllerComponent;
  45401. /**
  45402. * Get the first component of specific type
  45403. * @param type type of component to find
  45404. * @return a controller component or null if not found
  45405. */
  45406. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45407. /**
  45408. * Returns all components of specific type
  45409. * @param type the type to search for
  45410. * @return an array of components with this type
  45411. */
  45412. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45413. /**
  45414. * Loads the model correlating to this controller
  45415. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45416. * @returns A promise fulfilled with the result of the model loading
  45417. */
  45418. loadModel(): Promise<boolean>;
  45419. /**
  45420. * Update the model itself with the current frame data
  45421. * @param xrFrame the frame to use for updating the model mesh
  45422. */
  45423. protected updateModel(xrFrame: XRFrame): void;
  45424. /**
  45425. * Moves the axis on the controller mesh based on its current state
  45426. * @param axis the index of the axis
  45427. * @param axisValue the value of the axis which determines the meshes new position
  45428. * @hidden
  45429. */
  45430. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45431. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45432. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45433. private _getGenericFilenameAndPath;
  45434. private _getGenericParentMesh;
  45435. /**
  45436. * Get the filename and path for this controller's model
  45437. * @returns a map of filename and path
  45438. */
  45439. protected abstract _getFilenameAndPath(): {
  45440. filename: string;
  45441. path: string;
  45442. };
  45443. /**
  45444. * This function will be called after the model was successfully loaded and can be used
  45445. * for mesh transformations before it is available for the user
  45446. * @param meshes the loaded meshes
  45447. */
  45448. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45449. /**
  45450. * Set the root mesh for this controller. Important for the WebXR controller class
  45451. * @param meshes the loaded meshes
  45452. */
  45453. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45454. /**
  45455. * A function executed each frame that updates the mesh (if needed)
  45456. * @param xrFrame the current xrFrame
  45457. */
  45458. protected abstract _updateModel(xrFrame: XRFrame): void;
  45459. /**
  45460. * This function is called before the mesh is loaded. It checks for loading constraints.
  45461. * For example, this function can check if the GLB loader is available
  45462. * If this function returns false, the generic controller will be loaded instead
  45463. * @returns Is the client ready to load the mesh
  45464. */
  45465. protected abstract _getModelLoadingConstraints(): boolean;
  45466. /**
  45467. * Dispose this controller, the model mesh and all its components
  45468. */
  45469. dispose(): void;
  45470. }
  45471. }
  45472. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45473. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45475. import { Scene } from "babylonjs/scene";
  45476. /**
  45477. * A generic trigger-only motion controller for WebXR
  45478. */
  45479. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45480. /**
  45481. * Static version of the profile id of this controller
  45482. */
  45483. static ProfileId: string;
  45484. profileId: string;
  45485. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45486. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45487. protected _updateModel(): void;
  45488. protected _getFilenameAndPath(): {
  45489. filename: string;
  45490. path: string;
  45491. };
  45492. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45493. protected _getModelLoadingConstraints(): boolean;
  45494. }
  45495. }
  45496. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45497. import { Vector4 } from "babylonjs/Maths/math.vector";
  45498. import { Mesh } from "babylonjs/Meshes/mesh";
  45499. import { Scene } from "babylonjs/scene";
  45500. import { Nullable } from "babylonjs/types";
  45501. /**
  45502. * Class containing static functions to help procedurally build meshes
  45503. */
  45504. export class SphereBuilder {
  45505. /**
  45506. * Creates a sphere mesh
  45507. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45508. * * 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`)
  45509. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45510. * * 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
  45511. * * 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)
  45512. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45513. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45515. * @param name defines the name of the mesh
  45516. * @param options defines the options used to create the mesh
  45517. * @param scene defines the hosting scene
  45518. * @returns the sphere mesh
  45519. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45520. */
  45521. static CreateSphere(name: string, options: {
  45522. segments?: number;
  45523. diameter?: number;
  45524. diameterX?: number;
  45525. diameterY?: number;
  45526. diameterZ?: number;
  45527. arc?: number;
  45528. slice?: number;
  45529. sideOrientation?: number;
  45530. frontUVs?: Vector4;
  45531. backUVs?: Vector4;
  45532. updatable?: boolean;
  45533. }, scene?: Nullable<Scene>): Mesh;
  45534. }
  45535. }
  45536. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45538. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45539. import { Scene } from "babylonjs/scene";
  45540. /**
  45541. * A profiled motion controller has its profile loaded from an online repository.
  45542. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45543. */
  45544. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45545. private _repositoryUrl;
  45546. /**
  45547. * The profile ID of this controller. Will be populated when the controller initializes.
  45548. */
  45549. profileId: string;
  45550. private _buttonMeshMapping;
  45551. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45552. protected _getFilenameAndPath(): {
  45553. filename: string;
  45554. path: string;
  45555. };
  45556. private _touchDots;
  45557. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45558. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45559. protected _updateModel(_xrFrame: XRFrame): void;
  45560. protected _getModelLoadingConstraints(): boolean;
  45561. dispose(): void;
  45562. }
  45563. }
  45564. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45565. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45566. import { Scene } from "babylonjs/scene";
  45567. /**
  45568. * A construction function type to create a new controller based on an xrInput object
  45569. */
  45570. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45571. /**
  45572. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45573. *
  45574. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45575. * it should be replaced with auto-loaded controllers.
  45576. *
  45577. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45578. */
  45579. export class WebXRMotionControllerManager {
  45580. /**
  45581. * The base URL of the online controller repository. Can be changed at any time.
  45582. */
  45583. static BaseRepositoryUrl: string;
  45584. /**
  45585. * Use the online repository, or use only locally-defined controllers
  45586. */
  45587. static UseOnlineRepository: boolean;
  45588. /**
  45589. * Which repository gets priority - local or online
  45590. */
  45591. static PrioritizeOnlineRepository: boolean;
  45592. private static _AvailableControllers;
  45593. private static _Fallbacks;
  45594. /**
  45595. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  45596. *
  45597. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  45598. *
  45599. * @param type the profile type to register
  45600. * @param constructFunction the function to be called when loading this profile
  45601. */
  45602. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  45603. /**
  45604. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  45605. * The order of search:
  45606. *
  45607. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  45608. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  45609. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  45610. * 4) return the generic trigger controller if none were found
  45611. *
  45612. * @param xrInput the xrInput to which a new controller is initialized
  45613. * @param scene the scene to which the model will be added
  45614. * @param forceProfile force a certain profile for this controller
  45615. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  45616. */
  45617. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  45618. private static _LoadProfilesFromAvailableControllers;
  45619. private static _ProfilesList;
  45620. private static _ProfileLoadingPromises;
  45621. private static _LoadProfileFromRepository;
  45622. /**
  45623. * Clear the cache used for profile loading and reload when requested again
  45624. */
  45625. static ClearProfilesCache(): void;
  45626. /**
  45627. * Will update the list of profiles available in the repository
  45628. * @return a promise that resolves to a map of profiles available online
  45629. */
  45630. static UpdateProfilesList(): Promise<{
  45631. [profile: string]: string;
  45632. }>;
  45633. /**
  45634. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  45635. * @param profileId the profile to which a fallback needs to be found
  45636. * @return an array with corresponding fallback profiles
  45637. */
  45638. static FindFallbackWithProfileId(profileId: string): string[];
  45639. /**
  45640. * Register a fallback to a specific profile.
  45641. * @param profileId the profileId that will receive the fallbacks
  45642. * @param fallbacks A list of fallback profiles
  45643. */
  45644. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  45645. /**
  45646. * Register the default fallbacks.
  45647. * This function is called automatically when this file is imported.
  45648. */
  45649. static DefaultFallbacks(): void;
  45650. }
  45651. }
  45652. declare module "babylonjs/XR/webXRInputSource" {
  45653. import { Observable } from "babylonjs/Misc/observable";
  45654. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45655. import { Ray } from "babylonjs/Culling/ray";
  45656. import { Scene } from "babylonjs/scene";
  45657. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45658. /**
  45659. * Configuration options for the WebXR controller creation
  45660. */
  45661. export interface IWebXRControllerOptions {
  45662. /**
  45663. * Force a specific controller type for this controller.
  45664. * This can be used when creating your own profile or when testing different controllers
  45665. */
  45666. forceControllerProfile?: string;
  45667. /**
  45668. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  45669. */
  45670. doNotLoadControllerMesh?: boolean;
  45671. /**
  45672. * Should the controller mesh be animated when a user interacts with it
  45673. * The pressed buttons / thumbstick and touchpad animations will be disabled
  45674. */
  45675. disableMotionControllerAnimation?: boolean;
  45676. }
  45677. /**
  45678. * Represents an XR controller
  45679. */
  45680. export class WebXRInputSource {
  45681. private _scene;
  45682. /** The underlying input source for the controller */
  45683. inputSource: XRInputSource;
  45684. private _options;
  45685. /**
  45686. * 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
  45687. */
  45688. grip?: AbstractMesh;
  45689. /**
  45690. * Pointer which can be used to select objects or attach a visible laser to
  45691. */
  45692. pointer: AbstractMesh;
  45693. /**
  45694. * If available, this is the gamepad object related to this controller.
  45695. * Using this object it is possible to get click events and trackpad changes of the
  45696. * webxr controller that is currently being used.
  45697. */
  45698. motionController?: WebXRAbstractMotionController;
  45699. /**
  45700. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  45701. */
  45702. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  45703. /**
  45704. * Will be triggered when the mesh associated with the motion controller is done loading.
  45705. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  45706. * A shortened version of controller -> motion controller -> on mesh loaded.
  45707. */
  45708. onMeshLoadedObservable: Observable<AbstractMesh>;
  45709. /**
  45710. * Event that fires when the controller is removed/disposed.
  45711. * The object provided as event data is this controller, after associated assets were disposed.
  45712. * uniqueId is still available.
  45713. */
  45714. onDisposeObservable: Observable<WebXRInputSource>;
  45715. private _tmpQuaternion;
  45716. private _tmpVector;
  45717. private _uniqueId;
  45718. /**
  45719. * Creates the controller
  45720. * @see https://doc.babylonjs.com/how_to/webxr
  45721. * @param _scene the scene which the controller should be associated to
  45722. * @param inputSource the underlying input source for the controller
  45723. * @param _options options for this controller creation
  45724. */
  45725. constructor(_scene: Scene,
  45726. /** The underlying input source for the controller */
  45727. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  45728. /**
  45729. * Get this controllers unique id
  45730. */
  45731. get uniqueId(): string;
  45732. /**
  45733. * Updates the controller pose based on the given XRFrame
  45734. * @param xrFrame xr frame to update the pose with
  45735. * @param referenceSpace reference space to use
  45736. */
  45737. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  45738. /**
  45739. * Gets a world space ray coming from the pointer or grip
  45740. * @param result the resulting ray
  45741. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  45742. */
  45743. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  45744. /**
  45745. * Disposes of the object
  45746. */
  45747. dispose(): void;
  45748. }
  45749. }
  45750. declare module "babylonjs/XR/webXRInput" {
  45751. import { Observable } from "babylonjs/Misc/observable";
  45752. import { IDisposable } from "babylonjs/scene";
  45753. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45754. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45755. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  45756. /**
  45757. * The schema for initialization options of the XR Input class
  45758. */
  45759. export interface IWebXRInputOptions {
  45760. /**
  45761. * If set to true no model will be automatically loaded
  45762. */
  45763. doNotLoadControllerMeshes?: boolean;
  45764. /**
  45765. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  45766. * If not found, the xr input profile data will be used.
  45767. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  45768. */
  45769. forceInputProfile?: string;
  45770. /**
  45771. * Do not send a request to the controlle repository to load the profile.
  45772. *
  45773. * Instead, use the controllers available in babylon itself.
  45774. */
  45775. disableOnlineControllerRepository?: boolean;
  45776. /**
  45777. * A custom URL for the controllers repository
  45778. */
  45779. customControllersRepositoryURL?: string;
  45780. /**
  45781. * Should the controller model's components not move according to the user input
  45782. */
  45783. disableControllerAnimation?: boolean;
  45784. }
  45785. /**
  45786. * XR input used to track XR inputs such as controllers/rays
  45787. */
  45788. export class WebXRInput implements IDisposable {
  45789. /**
  45790. * the xr session manager for this session
  45791. */
  45792. xrSessionManager: WebXRSessionManager;
  45793. /**
  45794. * the WebXR camera for this session. Mainly used for teleportation
  45795. */
  45796. xrCamera: WebXRCamera;
  45797. private readonly options;
  45798. /**
  45799. * XR controllers being tracked
  45800. */
  45801. controllers: Array<WebXRInputSource>;
  45802. private _frameObserver;
  45803. private _sessionEndedObserver;
  45804. private _sessionInitObserver;
  45805. /**
  45806. * Event when a controller has been connected/added
  45807. */
  45808. onControllerAddedObservable: Observable<WebXRInputSource>;
  45809. /**
  45810. * Event when a controller has been removed/disconnected
  45811. */
  45812. onControllerRemovedObservable: Observable<WebXRInputSource>;
  45813. /**
  45814. * Initializes the WebXRInput
  45815. * @param xrSessionManager the xr session manager for this session
  45816. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  45817. * @param options = initialization options for this xr input
  45818. */
  45819. constructor(
  45820. /**
  45821. * the xr session manager for this session
  45822. */
  45823. xrSessionManager: WebXRSessionManager,
  45824. /**
  45825. * the WebXR camera for this session. Mainly used for teleportation
  45826. */
  45827. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  45828. private _onInputSourcesChange;
  45829. private _addAndRemoveControllers;
  45830. /**
  45831. * Disposes of the object
  45832. */
  45833. dispose(): void;
  45834. }
  45835. }
  45836. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  45837. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  45838. import { Observable, EventState } from "babylonjs/Misc/observable";
  45839. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45840. /**
  45841. * This is the base class for all WebXR features.
  45842. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  45843. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  45844. */
  45845. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  45846. protected _xrSessionManager: WebXRSessionManager;
  45847. /**
  45848. * Construct a new (abstract) webxr feature
  45849. * @param _xrSessionManager the xr session manager for this feature
  45850. */
  45851. constructor(_xrSessionManager: WebXRSessionManager);
  45852. private _attached;
  45853. private _removeOnDetach;
  45854. /**
  45855. * Is this feature attached
  45856. */
  45857. get attached(): boolean;
  45858. /**
  45859. * Should auto-attach be disabled?
  45860. */
  45861. disableAutoAttach: boolean;
  45862. /**
  45863. * attach this feature
  45864. *
  45865. * @param force should attachment be forced (even when already attached)
  45866. * @returns true if successful, false is failed or already attached
  45867. */
  45868. attach(force?: boolean): boolean;
  45869. /**
  45870. * detach this feature.
  45871. *
  45872. * @returns true if successful, false if failed or already detached
  45873. */
  45874. detach(): boolean;
  45875. /**
  45876. * Dispose this feature and all of the resources attached
  45877. */
  45878. dispose(): void;
  45879. /**
  45880. * Code in this function will be executed on each xrFrame received from the browser.
  45881. * This function will not execute after the feature is detached.
  45882. * @param _xrFrame the current frame
  45883. */
  45884. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  45885. /**
  45886. * This is used to register callbacks that will automatically be removed when detach is called.
  45887. * @param observable the observable to which the observer will be attached
  45888. * @param callback the callback to register
  45889. */
  45890. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  45891. }
  45892. }
  45893. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  45894. import { IDisposable, Scene } from "babylonjs/scene";
  45895. import { Nullable } from "babylonjs/types";
  45896. import { Observable } from "babylonjs/Misc/observable";
  45897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45898. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  45899. import { Camera } from "babylonjs/Cameras/camera";
  45900. /**
  45901. * Renders a layer on top of an existing scene
  45902. */
  45903. export class UtilityLayerRenderer implements IDisposable {
  45904. /** the original scene that will be rendered on top of */
  45905. originalScene: Scene;
  45906. private _pointerCaptures;
  45907. private _lastPointerEvents;
  45908. private static _DefaultUtilityLayer;
  45909. private static _DefaultKeepDepthUtilityLayer;
  45910. private _sharedGizmoLight;
  45911. private _renderCamera;
  45912. /**
  45913. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  45914. * @returns the camera that is used when rendering the utility layer
  45915. */
  45916. getRenderCamera(): Camera;
  45917. /**
  45918. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  45919. * @param cam the camera that should be used when rendering the utility layer
  45920. */
  45921. setRenderCamera(cam: Nullable<Camera>): void;
  45922. /**
  45923. * @hidden
  45924. * Light which used by gizmos to get light shading
  45925. */
  45926. _getSharedGizmoLight(): HemisphericLight;
  45927. /**
  45928. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  45929. */
  45930. pickUtilitySceneFirst: boolean;
  45931. /**
  45932. * 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)
  45933. */
  45934. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  45935. /**
  45936. * 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)
  45937. */
  45938. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  45939. /**
  45940. * The scene that is rendered on top of the original scene
  45941. */
  45942. utilityLayerScene: Scene;
  45943. /**
  45944. * If the utility layer should automatically be rendered on top of existing scene
  45945. */
  45946. shouldRender: boolean;
  45947. /**
  45948. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  45949. */
  45950. onlyCheckPointerDownEvents: boolean;
  45951. /**
  45952. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  45953. */
  45954. processAllEvents: boolean;
  45955. /**
  45956. * Observable raised when the pointer move from the utility layer scene to the main scene
  45957. */
  45958. onPointerOutObservable: Observable<number>;
  45959. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  45960. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  45961. private _afterRenderObserver;
  45962. private _sceneDisposeObserver;
  45963. private _originalPointerObserver;
  45964. /**
  45965. * Instantiates a UtilityLayerRenderer
  45966. * @param originalScene the original scene that will be rendered on top of
  45967. * @param handleEvents boolean indicating if the utility layer should handle events
  45968. */
  45969. constructor(
  45970. /** the original scene that will be rendered on top of */
  45971. originalScene: Scene, handleEvents?: boolean);
  45972. private _notifyObservers;
  45973. /**
  45974. * Renders the utility layers scene on top of the original scene
  45975. */
  45976. render(): void;
  45977. /**
  45978. * Disposes of the renderer
  45979. */
  45980. dispose(): void;
  45981. private _updateCamera;
  45982. }
  45983. }
  45984. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  45985. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  45986. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45987. import { WebXRInput } from "babylonjs/XR/webXRInput";
  45988. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  45989. import { Scene } from "babylonjs/scene";
  45990. import { Nullable } from "babylonjs/types";
  45991. import { Color3 } from "babylonjs/Maths/math.color";
  45992. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  45993. /**
  45994. * Options interface for the pointer selection module
  45995. */
  45996. export interface IWebXRControllerPointerSelectionOptions {
  45997. /**
  45998. * the xr input to use with this pointer selection
  45999. */
  46000. xrInput: WebXRInput;
  46001. /**
  46002. * Different button type to use instead of the main component
  46003. */
  46004. overrideButtonId?: string;
  46005. /**
  46006. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  46007. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46008. * 3000 means 3 seconds between pointing at something and selecting it
  46009. */
  46010. timeToSelect?: number;
  46011. /**
  46012. * 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)
  46013. * If not disabled, the last picked point will be used to execute a pointer up event
  46014. * If disabled, pointer up event will be triggered right after the pointer down event.
  46015. * Used in screen and gaze target ray mode only
  46016. */
  46017. disablePointerUpOnTouchOut: boolean;
  46018. /**
  46019. * For gaze mode (time to select instead of press)
  46020. */
  46021. forceGazeMode: boolean;
  46022. /**
  46023. * 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
  46024. * to start a new countdown to the pointer down event.
  46025. * Defaults to 1.
  46026. */
  46027. gazeModePointerMovedFactor?: number;
  46028. /**
  46029. * Should meshes created here be added to a utility layer or the main scene
  46030. */
  46031. useUtilityLayer?: boolean;
  46032. /**
  46033. * if provided, this scene will be used to render meshes.
  46034. */
  46035. customUtilityLayerScene?: Scene;
  46036. /**
  46037. * use this rendering group id for the meshes (optional)
  46038. */
  46039. renderingGroupId?: number;
  46040. }
  46041. /**
  46042. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46043. */
  46044. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46045. private readonly _options;
  46046. /**
  46047. * The module's name
  46048. */
  46049. static readonly Name: string;
  46050. /**
  46051. * The (Babylon) version of this module.
  46052. * This is an integer representing the implementation version.
  46053. * This number does not correspond to the webxr specs version
  46054. */
  46055. static readonly Version: number;
  46056. /**
  46057. * This color will be set to the laser pointer when selection is triggered
  46058. */
  46059. laserPointerPickedColor: Color3;
  46060. /**
  46061. * This color will be applied to the selection ring when selection is triggered
  46062. */
  46063. selectionMeshPickedColor: Color3;
  46064. /**
  46065. * default color of the selection ring
  46066. */
  46067. selectionMeshDefaultColor: Color3;
  46068. /**
  46069. * Default color of the laser pointer
  46070. */
  46071. lasterPointerDefaultColor: Color3;
  46072. /**
  46073. * Should the laser pointer be displayed
  46074. */
  46075. displayLaserPointer: boolean;
  46076. /**
  46077. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46078. */
  46079. displaySelectionMesh: boolean;
  46080. /**
  46081. * Disable lighting on the laser pointer (so it will always be visible)
  46082. */
  46083. disablePointerLighting: boolean;
  46084. /**
  46085. * Disable lighting on the selection mesh (so it will always be visible)
  46086. */
  46087. disableSelectionMeshLighting: boolean;
  46088. private static _idCounter;
  46089. private _controllers;
  46090. private _scene;
  46091. /**
  46092. * constructs a new background remover module
  46093. * @param _xrSessionManager the session manager for this module
  46094. * @param _options read-only options to be used in this module
  46095. */
  46096. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46097. /**
  46098. * attach this feature
  46099. * Will usually be called by the features manager
  46100. *
  46101. * @returns true if successful.
  46102. */
  46103. attach(): boolean;
  46104. /**
  46105. * detach this feature.
  46106. * Will usually be called by the features manager
  46107. *
  46108. * @returns true if successful.
  46109. */
  46110. detach(): boolean;
  46111. /**
  46112. * Get the xr controller that correlates to the pointer id in the pointer event
  46113. *
  46114. * @param id the pointer id to search for
  46115. * @returns the controller that correlates to this id or null if not found
  46116. */
  46117. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46118. /**
  46119. * Will get the mesh under a specific pointer.
  46120. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46121. * @param controllerId the controllerId to check
  46122. * @returns The mesh under pointer or null if no mesh is under the pointer
  46123. */
  46124. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46125. protected _onXRFrame(_xrFrame: XRFrame): void;
  46126. private _attachController;
  46127. private _attachScreenRayMode;
  46128. private _attachGazeMode;
  46129. private _tmpVectorForPickCompare;
  46130. private _pickingMoved;
  46131. private _attachTrackedPointerRayMode;
  46132. private _detachController;
  46133. private _generateNewMeshPair;
  46134. private _convertNormalToDirectionOfRay;
  46135. private _updatePointerDistance;
  46136. }
  46137. }
  46138. declare module "babylonjs/XR/webXREnterExitUI" {
  46139. import { Nullable } from "babylonjs/types";
  46140. import { Observable } from "babylonjs/Misc/observable";
  46141. import { IDisposable, Scene } from "babylonjs/scene";
  46142. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46143. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46144. /**
  46145. * Button which can be used to enter a different mode of XR
  46146. */
  46147. export class WebXREnterExitUIButton {
  46148. /** button element */
  46149. element: HTMLElement;
  46150. /** XR initialization options for the button */
  46151. sessionMode: XRSessionMode;
  46152. /** Reference space type */
  46153. referenceSpaceType: XRReferenceSpaceType;
  46154. /**
  46155. * Creates a WebXREnterExitUIButton
  46156. * @param element button element
  46157. * @param sessionMode XR initialization session mode
  46158. * @param referenceSpaceType the type of reference space to be used
  46159. */
  46160. constructor(
  46161. /** button element */
  46162. element: HTMLElement,
  46163. /** XR initialization options for the button */
  46164. sessionMode: XRSessionMode,
  46165. /** Reference space type */
  46166. referenceSpaceType: XRReferenceSpaceType);
  46167. /**
  46168. * Overwritable function which can be used to update the button's visuals when the state changes
  46169. * @param activeButton the current active button in the UI
  46170. */
  46171. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46172. }
  46173. /**
  46174. * Options to create the webXR UI
  46175. */
  46176. export class WebXREnterExitUIOptions {
  46177. /**
  46178. * Context to enter xr with
  46179. */
  46180. renderTarget?: Nullable<WebXRRenderTarget>;
  46181. /**
  46182. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46183. */
  46184. customButtons?: Array<WebXREnterExitUIButton>;
  46185. /**
  46186. * A session mode to use when creating the default button.
  46187. * Default is immersive-vr
  46188. */
  46189. sessionMode?: XRSessionMode;
  46190. /**
  46191. * A reference space type to use when creating the default button.
  46192. * Default is local-floor
  46193. */
  46194. referenceSpaceType?: XRReferenceSpaceType;
  46195. }
  46196. /**
  46197. * UI to allow the user to enter/exit XR mode
  46198. */
  46199. export class WebXREnterExitUI implements IDisposable {
  46200. private scene;
  46201. /** version of the options passed to this UI */
  46202. options: WebXREnterExitUIOptions;
  46203. private _overlay;
  46204. private _buttons;
  46205. private _activeButton;
  46206. /**
  46207. * Fired every time the active button is changed.
  46208. *
  46209. * When xr is entered via a button that launches xr that button will be the callback parameter
  46210. *
  46211. * When exiting xr the callback parameter will be null)
  46212. */
  46213. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46214. /**
  46215. * Creates UI to allow the user to enter/exit XR mode
  46216. * @param scene the scene to add the ui to
  46217. * @param helper the xr experience helper to enter/exit xr with
  46218. * @param options options to configure the UI
  46219. * @returns the created ui
  46220. */
  46221. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46222. /**
  46223. *
  46224. * @param scene babylon scene object to use
  46225. * @param options (read-only) version of the options passed to this UI
  46226. */
  46227. private constructor();
  46228. private _updateButtons;
  46229. /**
  46230. * Disposes of the object
  46231. */
  46232. dispose(): void;
  46233. }
  46234. }
  46235. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46236. import { Vector3 } from "babylonjs/Maths/math.vector";
  46237. import { Color4 } from "babylonjs/Maths/math.color";
  46238. import { Nullable } from "babylonjs/types";
  46239. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46240. import { Scene } from "babylonjs/scene";
  46241. /**
  46242. * Class containing static functions to help procedurally build meshes
  46243. */
  46244. export class LinesBuilder {
  46245. /**
  46246. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46247. * * 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
  46248. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46249. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46250. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46251. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46252. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46253. * * 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
  46254. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46255. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46256. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46257. * @param name defines the name of the new line system
  46258. * @param options defines the options used to create the line system
  46259. * @param scene defines the hosting scene
  46260. * @returns a new line system mesh
  46261. */
  46262. static CreateLineSystem(name: string, options: {
  46263. lines: Vector3[][];
  46264. updatable?: boolean;
  46265. instance?: Nullable<LinesMesh>;
  46266. colors?: Nullable<Color4[][]>;
  46267. useVertexAlpha?: boolean;
  46268. }, scene: Nullable<Scene>): LinesMesh;
  46269. /**
  46270. * Creates a line mesh
  46271. * 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
  46272. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46273. * * The parameter `points` is an array successive Vector3
  46274. * * 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
  46275. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46276. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46277. * * When updating an instance, remember that only point positions can change, not the number of points
  46278. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46279. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46280. * @param name defines the name of the new line system
  46281. * @param options defines the options used to create the line system
  46282. * @param scene defines the hosting scene
  46283. * @returns a new line mesh
  46284. */
  46285. static CreateLines(name: string, options: {
  46286. points: Vector3[];
  46287. updatable?: boolean;
  46288. instance?: Nullable<LinesMesh>;
  46289. colors?: Color4[];
  46290. useVertexAlpha?: boolean;
  46291. }, scene?: Nullable<Scene>): LinesMesh;
  46292. /**
  46293. * Creates a dashed line mesh
  46294. * * 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
  46295. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46296. * * The parameter `points` is an array successive Vector3
  46297. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46298. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46299. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46300. * * 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
  46301. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46302. * * When updating an instance, remember that only point positions can change, not the number of points
  46303. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46304. * @param name defines the name of the mesh
  46305. * @param options defines the options used to create the mesh
  46306. * @param scene defines the hosting scene
  46307. * @returns the dashed line mesh
  46308. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46309. */
  46310. static CreateDashedLines(name: string, options: {
  46311. points: Vector3[];
  46312. dashSize?: number;
  46313. gapSize?: number;
  46314. dashNb?: number;
  46315. updatable?: boolean;
  46316. instance?: LinesMesh;
  46317. useVertexAlpha?: boolean;
  46318. }, scene?: Nullable<Scene>): LinesMesh;
  46319. }
  46320. }
  46321. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46322. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46323. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46324. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46325. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46326. import { Vector3 } from "babylonjs/Maths/math.vector";
  46327. import { Material } from "babylonjs/Materials/material";
  46328. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46329. import { Scene } from "babylonjs/scene";
  46330. /**
  46331. * The options container for the teleportation module
  46332. */
  46333. export interface IWebXRTeleportationOptions {
  46334. /**
  46335. * Babylon XR Input class for controller
  46336. */
  46337. xrInput: WebXRInput;
  46338. /**
  46339. * A list of meshes to use as floor meshes.
  46340. * Meshes can be added and removed after initializing the feature using the
  46341. * addFloorMesh and removeFloorMesh functions
  46342. * If empty, rotation will still work
  46343. */
  46344. floorMeshes?: AbstractMesh[];
  46345. /**
  46346. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46347. * If you want to support rotation, make sure your mesh has a direction indicator.
  46348. *
  46349. * When left untouched, the default mesh will be initialized.
  46350. */
  46351. teleportationTargetMesh?: AbstractMesh;
  46352. /**
  46353. * An array of points to which the teleportation will snap to.
  46354. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46355. */
  46356. snapPositions?: Vector3[];
  46357. /**
  46358. * How close should the teleportation ray be in order to snap to position.
  46359. * Default to 0.8 units (meters)
  46360. */
  46361. snapToPositionRadius?: number;
  46362. /**
  46363. * Should teleportation move only to snap points
  46364. */
  46365. snapPointsOnly?: boolean;
  46366. /**
  46367. * Values to configure the default target mesh
  46368. */
  46369. defaultTargetMeshOptions?: {
  46370. /**
  46371. * Fill color of the teleportation area
  46372. */
  46373. teleportationFillColor?: string;
  46374. /**
  46375. * Border color for the teleportation area
  46376. */
  46377. teleportationBorderColor?: string;
  46378. /**
  46379. * Disable the mesh's animation sequence
  46380. */
  46381. disableAnimation?: boolean;
  46382. /**
  46383. * Disable lighting on the material or the ring and arrow
  46384. */
  46385. disableLighting?: boolean;
  46386. /**
  46387. * Override the default material of the torus and arrow
  46388. */
  46389. torusArrowMaterial?: Material;
  46390. };
  46391. /**
  46392. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  46393. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  46394. */
  46395. useMainComponentOnly?: boolean;
  46396. /**
  46397. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  46398. */
  46399. timeToTeleport?: number;
  46400. /**
  46401. * Should meshes created here be added to a utility layer or the main scene
  46402. */
  46403. useUtilityLayer?: boolean;
  46404. /**
  46405. * if provided, this scene will be used to render meshes.
  46406. */
  46407. customUtilityLayerScene?: Scene;
  46408. /**
  46409. * use this rendering group id for the meshes (optional)
  46410. */
  46411. renderingGroupId?: number;
  46412. }
  46413. /**
  46414. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  46415. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46416. * the input of the attached controllers.
  46417. */
  46418. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46419. private _options;
  46420. /**
  46421. * The module's name
  46422. */
  46423. static readonly Name: string;
  46424. /**
  46425. * The (Babylon) version of this module.
  46426. * This is an integer representing the implementation version.
  46427. * This number does not correspond to the webxr specs version
  46428. */
  46429. static readonly Version: number;
  46430. /**
  46431. * Is rotation enabled when moving forward?
  46432. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46433. */
  46434. rotationEnabled: boolean;
  46435. /**
  46436. * Should the module support parabolic ray on top of direct ray
  46437. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46438. * Very helpful when moving between floors / different heights
  46439. */
  46440. parabolicRayEnabled: boolean;
  46441. /**
  46442. * The distance from the user to the inspection point in the direction of the controller
  46443. * A higher number will allow the user to move further
  46444. * defaults to 5 (meters, in xr units)
  46445. */
  46446. parabolicCheckRadius: number;
  46447. /**
  46448. * How much rotation should be applied when rotating right and left
  46449. */
  46450. rotationAngle: number;
  46451. /**
  46452. * Is movement backwards enabled
  46453. */
  46454. backwardsMovementEnabled: boolean;
  46455. /**
  46456. * Distance to travel when moving backwards
  46457. */
  46458. backwardsTeleportationDistance: number;
  46459. /**
  46460. * Add a new mesh to the floor meshes array
  46461. * @param mesh the mesh to use as floor mesh
  46462. */
  46463. addFloorMesh(mesh: AbstractMesh): void;
  46464. /**
  46465. * Remove a mesh from the floor meshes array
  46466. * @param mesh the mesh to remove
  46467. */
  46468. removeFloorMesh(mesh: AbstractMesh): void;
  46469. /**
  46470. * Remove a mesh from the floor meshes array using its name
  46471. * @param name the mesh name to remove
  46472. */
  46473. removeFloorMeshByName(name: string): void;
  46474. private _tmpRay;
  46475. private _tmpVector;
  46476. private _floorMeshes;
  46477. private _snapToPositions;
  46478. private _controllers;
  46479. /**
  46480. * constructs a new anchor system
  46481. * @param _xrSessionManager an instance of WebXRSessionManager
  46482. * @param _options configuration object for this feature
  46483. */
  46484. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46485. private _selectionFeature;
  46486. private _snappedToPoint;
  46487. private _teleportationRingMaterial?;
  46488. /**
  46489. * Get the snapPointsOnly flag
  46490. */
  46491. get snapPointsOnly(): boolean;
  46492. /**
  46493. * Sets the snapPointsOnly flag
  46494. * @param snapToPoints should teleportation be exclusively to snap points
  46495. */
  46496. set snapPointsOnly(snapToPoints: boolean);
  46497. /**
  46498. * Add a new snap-to point to fix teleportation to this position
  46499. * @param newSnapPoint The new Snap-To point
  46500. */
  46501. addSnapPoint(newSnapPoint: Vector3): void;
  46502. /**
  46503. * 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
  46504. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  46505. * @returns was the point found and removed or not
  46506. */
  46507. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  46508. /**
  46509. * This function sets a selection feature that will be disabled when
  46510. * the forward ray is shown and will be reattached when hidden.
  46511. * This is used to remove the selection rays when moving.
  46512. * @param selectionFeature the feature to disable when forward movement is enabled
  46513. */
  46514. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46515. attach(): boolean;
  46516. detach(): boolean;
  46517. dispose(): void;
  46518. protected _onXRFrame(_xrFrame: XRFrame): void;
  46519. private _currentTeleportationControllerId;
  46520. private _attachController;
  46521. private _teleportForward;
  46522. private _detachController;
  46523. private _createDefaultTargetMesh;
  46524. private _setTargetMeshVisibility;
  46525. private _setTargetMeshPosition;
  46526. private _quadraticBezierCurve;
  46527. private _showParabolicPath;
  46528. private _findClosestSnapPointWithRadius;
  46529. }
  46530. }
  46531. declare module "babylonjs/XR/webXRDefaultExperience" {
  46532. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46533. import { Scene } from "babylonjs/scene";
  46534. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46535. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46536. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46537. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46539. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46540. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46541. /**
  46542. * Options for the default xr helper
  46543. */
  46544. export class WebXRDefaultExperienceOptions {
  46545. /**
  46546. * Floor meshes that will be used for teleporting
  46547. */
  46548. floorMeshes?: Array<AbstractMesh>;
  46549. /**
  46550. * Enable or disable default UI to enter XR
  46551. */
  46552. disableDefaultUI?: boolean;
  46553. /**
  46554. * optional configuration for the output canvas
  46555. */
  46556. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46557. /**
  46558. * optional UI options. This can be used among other to change session mode and reference space type
  46559. */
  46560. uiOptions?: WebXREnterExitUIOptions;
  46561. /**
  46562. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46563. */
  46564. inputOptions?: IWebXRInputOptions;
  46565. /**
  46566. * Should teleportation not initialize. defaults to false.
  46567. */
  46568. disableTeleportation?: boolean;
  46569. /**
  46570. * If set to true, the first frame will not be used to reset position
  46571. * The first frame is mainly used when copying transformation from the old camera
  46572. * Mainly used in AR
  46573. */
  46574. ignoreNativeCameraTransformation?: boolean;
  46575. /**
  46576. * When loading teleportation and pointer select, use stable versions instead of latest.
  46577. */
  46578. useStablePlugins?: boolean;
  46579. }
  46580. /**
  46581. * Default experience which provides a similar setup to the previous webVRExperience
  46582. */
  46583. export class WebXRDefaultExperience {
  46584. /**
  46585. * Base experience
  46586. */
  46587. baseExperience: WebXRExperienceHelper;
  46588. /**
  46589. * Input experience extension
  46590. */
  46591. input: WebXRInput;
  46592. /**
  46593. * Enables laser pointer and selection
  46594. */
  46595. pointerSelection: WebXRControllerPointerSelection;
  46596. /**
  46597. * Enables teleportation
  46598. */
  46599. teleportation: WebXRMotionControllerTeleportation;
  46600. /**
  46601. * Enables ui for entering/exiting xr
  46602. */
  46603. enterExitUI: WebXREnterExitUI;
  46604. /**
  46605. * Default target xr should render to
  46606. */
  46607. renderTarget: WebXRRenderTarget;
  46608. /**
  46609. * Creates the default xr experience
  46610. * @param scene scene
  46611. * @param options options for basic configuration
  46612. * @returns resulting WebXRDefaultExperience
  46613. */
  46614. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  46615. private constructor();
  46616. /**
  46617. * DIsposes of the experience helper
  46618. */
  46619. dispose(): void;
  46620. }
  46621. }
  46622. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  46623. import { Observable } from "babylonjs/Misc/observable";
  46624. import { Nullable } from "babylonjs/types";
  46625. import { Camera } from "babylonjs/Cameras/camera";
  46626. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  46627. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  46628. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  46629. import { Scene } from "babylonjs/scene";
  46630. import { Vector3 } from "babylonjs/Maths/math.vector";
  46631. import { Color3 } from "babylonjs/Maths/math.color";
  46632. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46633. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46634. import { Mesh } from "babylonjs/Meshes/mesh";
  46635. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  46636. import { EasingFunction } from "babylonjs/Animations/easing";
  46637. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  46638. import "babylonjs/Meshes/Builders/groundBuilder";
  46639. import "babylonjs/Meshes/Builders/torusBuilder";
  46640. import "babylonjs/Meshes/Builders/cylinderBuilder";
  46641. import "babylonjs/Gamepads/gamepadSceneComponent";
  46642. import "babylonjs/Animations/animatable";
  46643. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  46644. /**
  46645. * Options to modify the vr teleportation behavior.
  46646. */
  46647. export interface VRTeleportationOptions {
  46648. /**
  46649. * The name of the mesh which should be used as the teleportation floor. (default: null)
  46650. */
  46651. floorMeshName?: string;
  46652. /**
  46653. * A list of meshes to be used as the teleportation floor. (default: empty)
  46654. */
  46655. floorMeshes?: Mesh[];
  46656. /**
  46657. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  46658. */
  46659. teleportationMode?: number;
  46660. /**
  46661. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  46662. */
  46663. teleportationTime?: number;
  46664. /**
  46665. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  46666. */
  46667. teleportationSpeed?: number;
  46668. /**
  46669. * The easing function used in the animation or null for Linear. (default CircleEase)
  46670. */
  46671. easingFunction?: EasingFunction;
  46672. }
  46673. /**
  46674. * Options to modify the vr experience helper's behavior.
  46675. */
  46676. export interface VRExperienceHelperOptions extends WebVROptions {
  46677. /**
  46678. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  46679. */
  46680. createDeviceOrientationCamera?: boolean;
  46681. /**
  46682. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  46683. */
  46684. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  46685. /**
  46686. * Uses the main button on the controller to toggle the laser casted. (default: true)
  46687. */
  46688. laserToggle?: boolean;
  46689. /**
  46690. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  46691. */
  46692. floorMeshes?: Mesh[];
  46693. /**
  46694. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  46695. */
  46696. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  46697. /**
  46698. * Defines if WebXR should be used instead of WebVR (if available)
  46699. */
  46700. useXR?: boolean;
  46701. }
  46702. /**
  46703. * Event containing information after VR has been entered
  46704. */
  46705. export class OnAfterEnteringVRObservableEvent {
  46706. /**
  46707. * If entering vr was successful
  46708. */
  46709. success: boolean;
  46710. }
  46711. /**
  46712. * Helps to quickly add VR support to an existing scene.
  46713. * See http://doc.babylonjs.com/how_to/webvr_helper
  46714. */
  46715. export class VRExperienceHelper {
  46716. /** Options to modify the vr experience helper's behavior. */
  46717. webVROptions: VRExperienceHelperOptions;
  46718. private _scene;
  46719. private _position;
  46720. private _btnVR;
  46721. private _btnVRDisplayed;
  46722. private _webVRsupported;
  46723. private _webVRready;
  46724. private _webVRrequesting;
  46725. private _webVRpresenting;
  46726. private _hasEnteredVR;
  46727. private _fullscreenVRpresenting;
  46728. private _inputElement;
  46729. private _webVRCamera;
  46730. private _vrDeviceOrientationCamera;
  46731. private _deviceOrientationCamera;
  46732. private _existingCamera;
  46733. private _onKeyDown;
  46734. private _onVrDisplayPresentChange;
  46735. private _onVRDisplayChanged;
  46736. private _onVRRequestPresentStart;
  46737. private _onVRRequestPresentComplete;
  46738. /**
  46739. * 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)
  46740. */
  46741. enableGazeEvenWhenNoPointerLock: boolean;
  46742. /**
  46743. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  46744. */
  46745. exitVROnDoubleTap: boolean;
  46746. /**
  46747. * Observable raised right before entering VR.
  46748. */
  46749. onEnteringVRObservable: Observable<VRExperienceHelper>;
  46750. /**
  46751. * Observable raised when entering VR has completed.
  46752. */
  46753. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  46754. /**
  46755. * Observable raised when exiting VR.
  46756. */
  46757. onExitingVRObservable: Observable<VRExperienceHelper>;
  46758. /**
  46759. * Observable raised when controller mesh is loaded.
  46760. */
  46761. onControllerMeshLoadedObservable: Observable<WebVRController>;
  46762. /** Return this.onEnteringVRObservable
  46763. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  46764. */
  46765. get onEnteringVR(): Observable<VRExperienceHelper>;
  46766. /** Return this.onExitingVRObservable
  46767. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  46768. */
  46769. get onExitingVR(): Observable<VRExperienceHelper>;
  46770. /** Return this.onControllerMeshLoadedObservable
  46771. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  46772. */
  46773. get onControllerMeshLoaded(): Observable<WebVRController>;
  46774. private _rayLength;
  46775. private _useCustomVRButton;
  46776. private _teleportationRequested;
  46777. private _teleportActive;
  46778. private _floorMeshName;
  46779. private _floorMeshesCollection;
  46780. private _teleportationMode;
  46781. private _teleportationTime;
  46782. private _teleportationSpeed;
  46783. private _teleportationEasing;
  46784. private _rotationAllowed;
  46785. private _teleportBackwardsVector;
  46786. private _teleportationTarget;
  46787. private _isDefaultTeleportationTarget;
  46788. private _postProcessMove;
  46789. private _teleportationFillColor;
  46790. private _teleportationBorderColor;
  46791. private _rotationAngle;
  46792. private _haloCenter;
  46793. private _cameraGazer;
  46794. private _padSensibilityUp;
  46795. private _padSensibilityDown;
  46796. private _leftController;
  46797. private _rightController;
  46798. private _gazeColor;
  46799. private _laserColor;
  46800. private _pickedLaserColor;
  46801. private _pickedGazeColor;
  46802. /**
  46803. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  46804. */
  46805. onNewMeshSelected: Observable<AbstractMesh>;
  46806. /**
  46807. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  46808. * This observable will provide the mesh and the controller used to select the mesh
  46809. */
  46810. onMeshSelectedWithController: Observable<{
  46811. mesh: AbstractMesh;
  46812. controller: WebVRController;
  46813. }>;
  46814. /**
  46815. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  46816. */
  46817. onNewMeshPicked: Observable<PickingInfo>;
  46818. private _circleEase;
  46819. /**
  46820. * Observable raised before camera teleportation
  46821. */
  46822. onBeforeCameraTeleport: Observable<Vector3>;
  46823. /**
  46824. * Observable raised after camera teleportation
  46825. */
  46826. onAfterCameraTeleport: Observable<Vector3>;
  46827. /**
  46828. * Observable raised when current selected mesh gets unselected
  46829. */
  46830. onSelectedMeshUnselected: Observable<AbstractMesh>;
  46831. private _raySelectionPredicate;
  46832. /**
  46833. * To be optionaly changed by user to define custom ray selection
  46834. */
  46835. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46836. /**
  46837. * To be optionaly changed by user to define custom selection logic (after ray selection)
  46838. */
  46839. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  46840. /**
  46841. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  46842. */
  46843. teleportationEnabled: boolean;
  46844. private _defaultHeight;
  46845. private _teleportationInitialized;
  46846. private _interactionsEnabled;
  46847. private _interactionsRequested;
  46848. private _displayGaze;
  46849. private _displayLaserPointer;
  46850. /**
  46851. * The mesh used to display where the user is going to teleport.
  46852. */
  46853. get teleportationTarget(): Mesh;
  46854. /**
  46855. * Sets the mesh to be used to display where the user is going to teleport.
  46856. */
  46857. set teleportationTarget(value: Mesh);
  46858. /**
  46859. * 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
  46860. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  46861. * See http://doc.babylonjs.com/resources/baking_transformations
  46862. */
  46863. get gazeTrackerMesh(): Mesh;
  46864. set gazeTrackerMesh(value: Mesh);
  46865. /**
  46866. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  46867. */
  46868. updateGazeTrackerScale: boolean;
  46869. /**
  46870. * If the gaze trackers color should be updated when selecting meshes
  46871. */
  46872. updateGazeTrackerColor: boolean;
  46873. /**
  46874. * If the controller laser color should be updated when selecting meshes
  46875. */
  46876. updateControllerLaserColor: boolean;
  46877. /**
  46878. * The gaze tracking mesh corresponding to the left controller
  46879. */
  46880. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  46881. /**
  46882. * The gaze tracking mesh corresponding to the right controller
  46883. */
  46884. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  46885. /**
  46886. * If the ray of the gaze should be displayed.
  46887. */
  46888. get displayGaze(): boolean;
  46889. /**
  46890. * Sets if the ray of the gaze should be displayed.
  46891. */
  46892. set displayGaze(value: boolean);
  46893. /**
  46894. * If the ray of the LaserPointer should be displayed.
  46895. */
  46896. get displayLaserPointer(): boolean;
  46897. /**
  46898. * Sets if the ray of the LaserPointer should be displayed.
  46899. */
  46900. set displayLaserPointer(value: boolean);
  46901. /**
  46902. * The deviceOrientationCamera used as the camera when not in VR.
  46903. */
  46904. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  46905. /**
  46906. * Based on the current WebVR support, returns the current VR camera used.
  46907. */
  46908. get currentVRCamera(): Nullable<Camera>;
  46909. /**
  46910. * The webVRCamera which is used when in VR.
  46911. */
  46912. get webVRCamera(): WebVRFreeCamera;
  46913. /**
  46914. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  46915. */
  46916. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  46917. /**
  46918. * The html button that is used to trigger entering into VR.
  46919. */
  46920. get vrButton(): Nullable<HTMLButtonElement>;
  46921. private get _teleportationRequestInitiated();
  46922. /**
  46923. * Defines whether or not Pointer lock should be requested when switching to
  46924. * full screen.
  46925. */
  46926. requestPointerLockOnFullScreen: boolean;
  46927. /**
  46928. * If asking to force XR, this will be populated with the default xr experience
  46929. */
  46930. xr: WebXRDefaultExperience;
  46931. /**
  46932. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  46933. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  46934. */
  46935. xrTestDone: boolean;
  46936. /**
  46937. * Instantiates a VRExperienceHelper.
  46938. * Helps to quickly add VR support to an existing scene.
  46939. * @param scene The scene the VRExperienceHelper belongs to.
  46940. * @param webVROptions Options to modify the vr experience helper's behavior.
  46941. */
  46942. constructor(scene: Scene,
  46943. /** Options to modify the vr experience helper's behavior. */
  46944. webVROptions?: VRExperienceHelperOptions);
  46945. private completeVRInit;
  46946. private _onDefaultMeshLoaded;
  46947. private _onResize;
  46948. private _onFullscreenChange;
  46949. /**
  46950. * Gets a value indicating if we are currently in VR mode.
  46951. */
  46952. get isInVRMode(): boolean;
  46953. private onVrDisplayPresentChange;
  46954. private onVRDisplayChanged;
  46955. private moveButtonToBottomRight;
  46956. private displayVRButton;
  46957. private updateButtonVisibility;
  46958. private _cachedAngularSensibility;
  46959. /**
  46960. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  46961. * Otherwise, will use the fullscreen API.
  46962. */
  46963. enterVR(): void;
  46964. /**
  46965. * Attempt to exit VR, or fullscreen.
  46966. */
  46967. exitVR(): void;
  46968. /**
  46969. * The position of the vr experience helper.
  46970. */
  46971. get position(): Vector3;
  46972. /**
  46973. * Sets the position of the vr experience helper.
  46974. */
  46975. set position(value: Vector3);
  46976. /**
  46977. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  46978. */
  46979. enableInteractions(): void;
  46980. private get _noControllerIsActive();
  46981. private beforeRender;
  46982. private _isTeleportationFloor;
  46983. /**
  46984. * Adds a floor mesh to be used for teleportation.
  46985. * @param floorMesh the mesh to be used for teleportation.
  46986. */
  46987. addFloorMesh(floorMesh: Mesh): void;
  46988. /**
  46989. * Removes a floor mesh from being used for teleportation.
  46990. * @param floorMesh the mesh to be removed.
  46991. */
  46992. removeFloorMesh(floorMesh: Mesh): void;
  46993. /**
  46994. * Enables interactions and teleportation using the VR controllers and gaze.
  46995. * @param vrTeleportationOptions options to modify teleportation behavior.
  46996. */
  46997. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  46998. private _onNewGamepadConnected;
  46999. private _tryEnableInteractionOnController;
  47000. private _onNewGamepadDisconnected;
  47001. private _enableInteractionOnController;
  47002. private _checkTeleportWithRay;
  47003. private _checkRotate;
  47004. private _checkTeleportBackwards;
  47005. private _enableTeleportationOnController;
  47006. private _createTeleportationCircles;
  47007. private _displayTeleportationTarget;
  47008. private _hideTeleportationTarget;
  47009. private _rotateCamera;
  47010. private _moveTeleportationSelectorTo;
  47011. private _workingVector;
  47012. private _workingQuaternion;
  47013. private _workingMatrix;
  47014. /**
  47015. * Time Constant Teleportation Mode
  47016. */
  47017. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47018. /**
  47019. * Speed Constant Teleportation Mode
  47020. */
  47021. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47022. /**
  47023. * Teleports the users feet to the desired location
  47024. * @param location The location where the user's feet should be placed
  47025. */
  47026. teleportCamera(location: Vector3): void;
  47027. private _convertNormalToDirectionOfRay;
  47028. private _castRayAndSelectObject;
  47029. private _notifySelectedMeshUnselected;
  47030. /**
  47031. * Permanently set new colors for the laser pointer
  47032. * @param color the new laser color
  47033. * @param pickedColor the new laser color when picked mesh detected
  47034. */
  47035. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47036. /**
  47037. * Set lighting enabled / disabled on the laser pointer of both controllers
  47038. * @param enabled should the lighting be enabled on the laser pointer
  47039. */
  47040. setLaserLightingState(enabled?: boolean): void;
  47041. /**
  47042. * Permanently set new colors for the gaze pointer
  47043. * @param color the new gaze color
  47044. * @param pickedColor the new gaze color when picked mesh detected
  47045. */
  47046. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47047. /**
  47048. * Sets the color of the laser ray from the vr controllers.
  47049. * @param color new color for the ray.
  47050. */
  47051. changeLaserColor(color: Color3): void;
  47052. /**
  47053. * Sets the color of the ray from the vr headsets gaze.
  47054. * @param color new color for the ray.
  47055. */
  47056. changeGazeColor(color: Color3): void;
  47057. /**
  47058. * Exits VR and disposes of the vr experience helper
  47059. */
  47060. dispose(): void;
  47061. /**
  47062. * Gets the name of the VRExperienceHelper class
  47063. * @returns "VRExperienceHelper"
  47064. */
  47065. getClassName(): string;
  47066. }
  47067. }
  47068. declare module "babylonjs/Cameras/VR/index" {
  47069. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47070. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47071. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47072. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47073. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47074. export * from "babylonjs/Cameras/VR/webVRCamera";
  47075. }
  47076. declare module "babylonjs/Cameras/RigModes/index" {
  47077. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47078. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47079. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47080. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47081. }
  47082. declare module "babylonjs/Cameras/index" {
  47083. export * from "babylonjs/Cameras/Inputs/index";
  47084. export * from "babylonjs/Cameras/cameraInputsManager";
  47085. export * from "babylonjs/Cameras/camera";
  47086. export * from "babylonjs/Cameras/targetCamera";
  47087. export * from "babylonjs/Cameras/freeCamera";
  47088. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47089. export * from "babylonjs/Cameras/touchCamera";
  47090. export * from "babylonjs/Cameras/arcRotateCamera";
  47091. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47092. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47093. export * from "babylonjs/Cameras/flyCamera";
  47094. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47095. export * from "babylonjs/Cameras/followCamera";
  47096. export * from "babylonjs/Cameras/followCameraInputsManager";
  47097. export * from "babylonjs/Cameras/gamepadCamera";
  47098. export * from "babylonjs/Cameras/Stereoscopic/index";
  47099. export * from "babylonjs/Cameras/universalCamera";
  47100. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47101. export * from "babylonjs/Cameras/VR/index";
  47102. export * from "babylonjs/Cameras/RigModes/index";
  47103. }
  47104. declare module "babylonjs/Collisions/index" {
  47105. export * from "babylonjs/Collisions/collider";
  47106. export * from "babylonjs/Collisions/collisionCoordinator";
  47107. export * from "babylonjs/Collisions/pickingInfo";
  47108. export * from "babylonjs/Collisions/intersectionInfo";
  47109. export * from "babylonjs/Collisions/meshCollisionData";
  47110. }
  47111. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47112. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47113. import { Vector3 } from "babylonjs/Maths/math.vector";
  47114. import { Ray } from "babylonjs/Culling/ray";
  47115. import { Plane } from "babylonjs/Maths/math.plane";
  47116. /**
  47117. * Contains an array of blocks representing the octree
  47118. */
  47119. export interface IOctreeContainer<T> {
  47120. /**
  47121. * Blocks within the octree
  47122. */
  47123. blocks: Array<OctreeBlock<T>>;
  47124. }
  47125. /**
  47126. * Class used to store a cell in an octree
  47127. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47128. */
  47129. export class OctreeBlock<T> {
  47130. /**
  47131. * Gets the content of the current block
  47132. */
  47133. entries: T[];
  47134. /**
  47135. * Gets the list of block children
  47136. */
  47137. blocks: Array<OctreeBlock<T>>;
  47138. private _depth;
  47139. private _maxDepth;
  47140. private _capacity;
  47141. private _minPoint;
  47142. private _maxPoint;
  47143. private _boundingVectors;
  47144. private _creationFunc;
  47145. /**
  47146. * Creates a new block
  47147. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47148. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47149. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47150. * @param depth defines the current depth of this block in the octree
  47151. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47152. * @param creationFunc defines a callback to call when an element is added to the block
  47153. */
  47154. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47155. /**
  47156. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47157. */
  47158. get capacity(): number;
  47159. /**
  47160. * Gets the minimum vector (in world space) of the block's bounding box
  47161. */
  47162. get minPoint(): Vector3;
  47163. /**
  47164. * Gets the maximum vector (in world space) of the block's bounding box
  47165. */
  47166. get maxPoint(): Vector3;
  47167. /**
  47168. * Add a new element to this block
  47169. * @param entry defines the element to add
  47170. */
  47171. addEntry(entry: T): void;
  47172. /**
  47173. * Remove an element from this block
  47174. * @param entry defines the element to remove
  47175. */
  47176. removeEntry(entry: T): void;
  47177. /**
  47178. * Add an array of elements to this block
  47179. * @param entries defines the array of elements to add
  47180. */
  47181. addEntries(entries: T[]): void;
  47182. /**
  47183. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47184. * @param frustumPlanes defines the frustum planes to test
  47185. * @param selection defines the array to store current content if selection is positive
  47186. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47187. */
  47188. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47189. /**
  47190. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47191. * @param sphereCenter defines the bounding sphere center
  47192. * @param sphereRadius defines the bounding sphere radius
  47193. * @param selection defines the array to store current content if selection is positive
  47194. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47195. */
  47196. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47197. /**
  47198. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47199. * @param ray defines the ray to test with
  47200. * @param selection defines the array to store current content if selection is positive
  47201. */
  47202. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47203. /**
  47204. * Subdivide the content into child blocks (this block will then be empty)
  47205. */
  47206. createInnerBlocks(): void;
  47207. /**
  47208. * @hidden
  47209. */
  47210. 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;
  47211. }
  47212. }
  47213. declare module "babylonjs/Culling/Octrees/octree" {
  47214. import { SmartArray } from "babylonjs/Misc/smartArray";
  47215. import { Vector3 } from "babylonjs/Maths/math.vector";
  47216. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47218. import { Ray } from "babylonjs/Culling/ray";
  47219. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47220. import { Plane } from "babylonjs/Maths/math.plane";
  47221. /**
  47222. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47223. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47224. */
  47225. export class Octree<T> {
  47226. /** 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.) */
  47227. maxDepth: number;
  47228. /**
  47229. * Blocks within the octree containing objects
  47230. */
  47231. blocks: Array<OctreeBlock<T>>;
  47232. /**
  47233. * Content stored in the octree
  47234. */
  47235. dynamicContent: T[];
  47236. private _maxBlockCapacity;
  47237. private _selectionContent;
  47238. private _creationFunc;
  47239. /**
  47240. * Creates a octree
  47241. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47242. * @param creationFunc function to be used to instatiate the octree
  47243. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47244. * @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.)
  47245. */
  47246. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47247. /** 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.) */
  47248. maxDepth?: number);
  47249. /**
  47250. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47251. * @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);
  47252. * @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);
  47253. * @param entries meshes to be added to the octree blocks
  47254. */
  47255. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47256. /**
  47257. * Adds a mesh to the octree
  47258. * @param entry Mesh to add to the octree
  47259. */
  47260. addMesh(entry: T): void;
  47261. /**
  47262. * Remove an element from the octree
  47263. * @param entry defines the element to remove
  47264. */
  47265. removeMesh(entry: T): void;
  47266. /**
  47267. * Selects an array of meshes within the frustum
  47268. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47269. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47270. * @returns array of meshes within the frustum
  47271. */
  47272. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47273. /**
  47274. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47275. * @param sphereCenter defines the bounding sphere center
  47276. * @param sphereRadius defines the bounding sphere radius
  47277. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47278. * @returns an array of objects that intersect the sphere
  47279. */
  47280. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47281. /**
  47282. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47283. * @param ray defines the ray to test with
  47284. * @returns array of intersected objects
  47285. */
  47286. intersectsRay(ray: Ray): SmartArray<T>;
  47287. /**
  47288. * Adds a mesh into the octree block if it intersects the block
  47289. */
  47290. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47291. /**
  47292. * Adds a submesh into the octree block if it intersects the block
  47293. */
  47294. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47295. }
  47296. }
  47297. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47298. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47299. import { Scene } from "babylonjs/scene";
  47300. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47301. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47302. import { Ray } from "babylonjs/Culling/ray";
  47303. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47304. import { Collider } from "babylonjs/Collisions/collider";
  47305. module "babylonjs/scene" {
  47306. interface Scene {
  47307. /**
  47308. * @hidden
  47309. * Backing Filed
  47310. */
  47311. _selectionOctree: Octree<AbstractMesh>;
  47312. /**
  47313. * Gets the octree used to boost mesh selection (picking)
  47314. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47315. */
  47316. selectionOctree: Octree<AbstractMesh>;
  47317. /**
  47318. * Creates or updates the octree used to boost selection (picking)
  47319. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47320. * @param maxCapacity defines the maximum capacity per leaf
  47321. * @param maxDepth defines the maximum depth of the octree
  47322. * @returns an octree of AbstractMesh
  47323. */
  47324. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47325. }
  47326. }
  47327. module "babylonjs/Meshes/abstractMesh" {
  47328. interface AbstractMesh {
  47329. /**
  47330. * @hidden
  47331. * Backing Field
  47332. */
  47333. _submeshesOctree: Octree<SubMesh>;
  47334. /**
  47335. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47336. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47337. * @param maxCapacity defines the maximum size of each block (64 by default)
  47338. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47339. * @returns the new octree
  47340. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47341. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47342. */
  47343. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47344. }
  47345. }
  47346. /**
  47347. * Defines the octree scene component responsible to manage any octrees
  47348. * in a given scene.
  47349. */
  47350. export class OctreeSceneComponent {
  47351. /**
  47352. * The component name help to identify the component in the list of scene components.
  47353. */
  47354. readonly name: string;
  47355. /**
  47356. * The scene the component belongs to.
  47357. */
  47358. scene: Scene;
  47359. /**
  47360. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47361. */
  47362. readonly checksIsEnabled: boolean;
  47363. /**
  47364. * Creates a new instance of the component for the given scene
  47365. * @param scene Defines the scene to register the component in
  47366. */
  47367. constructor(scene: Scene);
  47368. /**
  47369. * Registers the component in a given scene
  47370. */
  47371. register(): void;
  47372. /**
  47373. * Return the list of active meshes
  47374. * @returns the list of active meshes
  47375. */
  47376. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47377. /**
  47378. * Return the list of active sub meshes
  47379. * @param mesh The mesh to get the candidates sub meshes from
  47380. * @returns the list of active sub meshes
  47381. */
  47382. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47383. private _tempRay;
  47384. /**
  47385. * Return the list of sub meshes intersecting with a given local ray
  47386. * @param mesh defines the mesh to find the submesh for
  47387. * @param localRay defines the ray in local space
  47388. * @returns the list of intersecting sub meshes
  47389. */
  47390. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47391. /**
  47392. * Return the list of sub meshes colliding with a collider
  47393. * @param mesh defines the mesh to find the submesh for
  47394. * @param collider defines the collider to evaluate the collision against
  47395. * @returns the list of colliding sub meshes
  47396. */
  47397. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47398. /**
  47399. * Rebuilds the elements related to this component in case of
  47400. * context lost for instance.
  47401. */
  47402. rebuild(): void;
  47403. /**
  47404. * Disposes the component and the associated ressources.
  47405. */
  47406. dispose(): void;
  47407. }
  47408. }
  47409. declare module "babylonjs/Culling/Octrees/index" {
  47410. export * from "babylonjs/Culling/Octrees/octree";
  47411. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47412. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47413. }
  47414. declare module "babylonjs/Culling/index" {
  47415. export * from "babylonjs/Culling/boundingBox";
  47416. export * from "babylonjs/Culling/boundingInfo";
  47417. export * from "babylonjs/Culling/boundingSphere";
  47418. export * from "babylonjs/Culling/Octrees/index";
  47419. export * from "babylonjs/Culling/ray";
  47420. }
  47421. declare module "babylonjs/Gizmos/gizmo" {
  47422. import { Nullable } from "babylonjs/types";
  47423. import { IDisposable } from "babylonjs/scene";
  47424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47425. import { Mesh } from "babylonjs/Meshes/mesh";
  47426. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47427. /**
  47428. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47429. */
  47430. export class Gizmo implements IDisposable {
  47431. /** The utility layer the gizmo will be added to */
  47432. gizmoLayer: UtilityLayerRenderer;
  47433. /**
  47434. * The root mesh of the gizmo
  47435. */
  47436. _rootMesh: Mesh;
  47437. private _attachedMesh;
  47438. /**
  47439. * Ratio for the scale of the gizmo (Default: 1)
  47440. */
  47441. scaleRatio: number;
  47442. /**
  47443. * If a custom mesh has been set (Default: false)
  47444. */
  47445. protected _customMeshSet: boolean;
  47446. /**
  47447. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47448. * * When set, interactions will be enabled
  47449. */
  47450. get attachedMesh(): Nullable<AbstractMesh>;
  47451. set attachedMesh(value: Nullable<AbstractMesh>);
  47452. /**
  47453. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47454. * @param mesh The mesh to replace the default mesh of the gizmo
  47455. */
  47456. setCustomMesh(mesh: Mesh): void;
  47457. /**
  47458. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47459. */
  47460. updateGizmoRotationToMatchAttachedMesh: boolean;
  47461. /**
  47462. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47463. */
  47464. updateGizmoPositionToMatchAttachedMesh: boolean;
  47465. /**
  47466. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47467. */
  47468. updateScale: boolean;
  47469. protected _interactionsEnabled: boolean;
  47470. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47471. private _beforeRenderObserver;
  47472. private _tempVector;
  47473. /**
  47474. * Creates a gizmo
  47475. * @param gizmoLayer The utility layer the gizmo will be added to
  47476. */
  47477. constructor(
  47478. /** The utility layer the gizmo will be added to */
  47479. gizmoLayer?: UtilityLayerRenderer);
  47480. /**
  47481. * Updates the gizmo to match the attached mesh's position/rotation
  47482. */
  47483. protected _update(): void;
  47484. /**
  47485. * Disposes of the gizmo
  47486. */
  47487. dispose(): void;
  47488. }
  47489. }
  47490. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47491. import { Observable } from "babylonjs/Misc/observable";
  47492. import { Nullable } from "babylonjs/types";
  47493. import { Vector3 } from "babylonjs/Maths/math.vector";
  47494. import { Color3 } from "babylonjs/Maths/math.color";
  47495. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47496. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47497. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47498. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47499. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47500. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47501. import { Scene } from "babylonjs/scene";
  47502. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47503. /**
  47504. * Single plane drag gizmo
  47505. */
  47506. export class PlaneDragGizmo extends Gizmo {
  47507. /**
  47508. * Drag behavior responsible for the gizmos dragging interactions
  47509. */
  47510. dragBehavior: PointerDragBehavior;
  47511. private _pointerObserver;
  47512. /**
  47513. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47514. */
  47515. snapDistance: number;
  47516. /**
  47517. * Event that fires each time the gizmo snaps to a new location.
  47518. * * snapDistance is the the change in distance
  47519. */
  47520. onSnapObservable: Observable<{
  47521. snapDistance: number;
  47522. }>;
  47523. private _plane;
  47524. private _coloredMaterial;
  47525. private _hoverMaterial;
  47526. private _isEnabled;
  47527. private _parent;
  47528. /** @hidden */
  47529. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47530. /** @hidden */
  47531. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47532. /**
  47533. * Creates a PlaneDragGizmo
  47534. * @param gizmoLayer The utility layer the gizmo will be added to
  47535. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47536. * @param color The color of the gizmo
  47537. */
  47538. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47539. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47540. /**
  47541. * If the gizmo is enabled
  47542. */
  47543. set isEnabled(value: boolean);
  47544. get isEnabled(): boolean;
  47545. /**
  47546. * Disposes of the gizmo
  47547. */
  47548. dispose(): void;
  47549. }
  47550. }
  47551. declare module "babylonjs/Gizmos/positionGizmo" {
  47552. import { Observable } from "babylonjs/Misc/observable";
  47553. import { Nullable } from "babylonjs/types";
  47554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47555. import { Mesh } from "babylonjs/Meshes/mesh";
  47556. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47557. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47558. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47559. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47560. /**
  47561. * Gizmo that enables dragging a mesh along 3 axis
  47562. */
  47563. export class PositionGizmo extends Gizmo {
  47564. /**
  47565. * Internal gizmo used for interactions on the x axis
  47566. */
  47567. xGizmo: AxisDragGizmo;
  47568. /**
  47569. * Internal gizmo used for interactions on the y axis
  47570. */
  47571. yGizmo: AxisDragGizmo;
  47572. /**
  47573. * Internal gizmo used for interactions on the z axis
  47574. */
  47575. zGizmo: AxisDragGizmo;
  47576. /**
  47577. * Internal gizmo used for interactions on the yz plane
  47578. */
  47579. xPlaneGizmo: PlaneDragGizmo;
  47580. /**
  47581. * Internal gizmo used for interactions on the xz plane
  47582. */
  47583. yPlaneGizmo: PlaneDragGizmo;
  47584. /**
  47585. * Internal gizmo used for interactions on the xy plane
  47586. */
  47587. zPlaneGizmo: PlaneDragGizmo;
  47588. /**
  47589. * private variables
  47590. */
  47591. private _meshAttached;
  47592. private _updateGizmoRotationToMatchAttachedMesh;
  47593. private _snapDistance;
  47594. private _scaleRatio;
  47595. /** Fires an event when any of it's sub gizmos are dragged */
  47596. onDragStartObservable: Observable<unknown>;
  47597. /** Fires an event when any of it's sub gizmos are released from dragging */
  47598. onDragEndObservable: Observable<unknown>;
  47599. /**
  47600. * If set to true, planar drag is enabled
  47601. */
  47602. private _planarGizmoEnabled;
  47603. get attachedMesh(): Nullable<AbstractMesh>;
  47604. set attachedMesh(mesh: Nullable<AbstractMesh>);
  47605. /**
  47606. * Creates a PositionGizmo
  47607. * @param gizmoLayer The utility layer the gizmo will be added to
  47608. */
  47609. constructor(gizmoLayer?: UtilityLayerRenderer);
  47610. /**
  47611. * If the planar drag gizmo is enabled
  47612. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  47613. */
  47614. set planarGizmoEnabled(value: boolean);
  47615. get planarGizmoEnabled(): boolean;
  47616. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  47617. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  47618. /**
  47619. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47620. */
  47621. set snapDistance(value: number);
  47622. get snapDistance(): number;
  47623. /**
  47624. * Ratio for the scale of the gizmo (Default: 1)
  47625. */
  47626. set scaleRatio(value: number);
  47627. get scaleRatio(): number;
  47628. /**
  47629. * Disposes of the gizmo
  47630. */
  47631. dispose(): void;
  47632. /**
  47633. * CustomMeshes are not supported by this gizmo
  47634. * @param mesh The mesh to replace the default mesh of the gizmo
  47635. */
  47636. setCustomMesh(mesh: Mesh): void;
  47637. }
  47638. }
  47639. declare module "babylonjs/Gizmos/axisDragGizmo" {
  47640. import { Observable } from "babylonjs/Misc/observable";
  47641. import { Nullable } from "babylonjs/types";
  47642. import { Vector3 } from "babylonjs/Maths/math.vector";
  47643. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47645. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47646. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47647. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47648. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47649. import { Scene } from "babylonjs/scene";
  47650. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47651. import { Color3 } from "babylonjs/Maths/math.color";
  47652. /**
  47653. * Single axis drag gizmo
  47654. */
  47655. export class AxisDragGizmo extends Gizmo {
  47656. /**
  47657. * Drag behavior responsible for the gizmos dragging interactions
  47658. */
  47659. dragBehavior: PointerDragBehavior;
  47660. private _pointerObserver;
  47661. /**
  47662. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47663. */
  47664. snapDistance: number;
  47665. /**
  47666. * Event that fires each time the gizmo snaps to a new location.
  47667. * * snapDistance is the the change in distance
  47668. */
  47669. onSnapObservable: Observable<{
  47670. snapDistance: number;
  47671. }>;
  47672. private _isEnabled;
  47673. private _parent;
  47674. private _arrow;
  47675. private _coloredMaterial;
  47676. private _hoverMaterial;
  47677. /** @hidden */
  47678. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  47679. /** @hidden */
  47680. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47681. /**
  47682. * Creates an AxisDragGizmo
  47683. * @param gizmoLayer The utility layer the gizmo will be added to
  47684. * @param dragAxis The axis which the gizmo will be able to drag on
  47685. * @param color The color of the gizmo
  47686. */
  47687. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47688. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47689. /**
  47690. * If the gizmo is enabled
  47691. */
  47692. set isEnabled(value: boolean);
  47693. get isEnabled(): boolean;
  47694. /**
  47695. * Disposes of the gizmo
  47696. */
  47697. dispose(): void;
  47698. }
  47699. }
  47700. declare module "babylonjs/Debug/axesViewer" {
  47701. import { Vector3 } from "babylonjs/Maths/math.vector";
  47702. import { Nullable } from "babylonjs/types";
  47703. import { Scene } from "babylonjs/scene";
  47704. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47705. /**
  47706. * The Axes viewer will show 3 axes in a specific point in space
  47707. */
  47708. export class AxesViewer {
  47709. private _xAxis;
  47710. private _yAxis;
  47711. private _zAxis;
  47712. private _scaleLinesFactor;
  47713. private _instanced;
  47714. /**
  47715. * Gets the hosting scene
  47716. */
  47717. scene: Scene;
  47718. /**
  47719. * Gets or sets a number used to scale line length
  47720. */
  47721. scaleLines: number;
  47722. /** Gets the node hierarchy used to render x-axis */
  47723. get xAxis(): TransformNode;
  47724. /** Gets the node hierarchy used to render y-axis */
  47725. get yAxis(): TransformNode;
  47726. /** Gets the node hierarchy used to render z-axis */
  47727. get zAxis(): TransformNode;
  47728. /**
  47729. * Creates a new AxesViewer
  47730. * @param scene defines the hosting scene
  47731. * @param scaleLines defines a number used to scale line length (1 by default)
  47732. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  47733. * @param xAxis defines the node hierarchy used to render the x-axis
  47734. * @param yAxis defines the node hierarchy used to render the y-axis
  47735. * @param zAxis defines the node hierarchy used to render the z-axis
  47736. */
  47737. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  47738. /**
  47739. * Force the viewer to update
  47740. * @param position defines the position of the viewer
  47741. * @param xaxis defines the x axis of the viewer
  47742. * @param yaxis defines the y axis of the viewer
  47743. * @param zaxis defines the z axis of the viewer
  47744. */
  47745. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  47746. /**
  47747. * Creates an instance of this axes viewer.
  47748. * @returns a new axes viewer with instanced meshes
  47749. */
  47750. createInstance(): AxesViewer;
  47751. /** Releases resources */
  47752. dispose(): void;
  47753. private static _SetRenderingGroupId;
  47754. }
  47755. }
  47756. declare module "babylonjs/Debug/boneAxesViewer" {
  47757. import { Nullable } from "babylonjs/types";
  47758. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  47759. import { Vector3 } from "babylonjs/Maths/math.vector";
  47760. import { Mesh } from "babylonjs/Meshes/mesh";
  47761. import { Bone } from "babylonjs/Bones/bone";
  47762. import { Scene } from "babylonjs/scene";
  47763. /**
  47764. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  47765. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  47766. */
  47767. export class BoneAxesViewer extends AxesViewer {
  47768. /**
  47769. * Gets or sets the target mesh where to display the axes viewer
  47770. */
  47771. mesh: Nullable<Mesh>;
  47772. /**
  47773. * Gets or sets the target bone where to display the axes viewer
  47774. */
  47775. bone: Nullable<Bone>;
  47776. /** Gets current position */
  47777. pos: Vector3;
  47778. /** Gets direction of X axis */
  47779. xaxis: Vector3;
  47780. /** Gets direction of Y axis */
  47781. yaxis: Vector3;
  47782. /** Gets direction of Z axis */
  47783. zaxis: Vector3;
  47784. /**
  47785. * Creates a new BoneAxesViewer
  47786. * @param scene defines the hosting scene
  47787. * @param bone defines the target bone
  47788. * @param mesh defines the target mesh
  47789. * @param scaleLines defines a scaling factor for line length (1 by default)
  47790. */
  47791. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  47792. /**
  47793. * Force the viewer to update
  47794. */
  47795. update(): void;
  47796. /** Releases resources */
  47797. dispose(): void;
  47798. }
  47799. }
  47800. declare module "babylonjs/Debug/debugLayer" {
  47801. import { Scene } from "babylonjs/scene";
  47802. /**
  47803. * Interface used to define scene explorer extensibility option
  47804. */
  47805. export interface IExplorerExtensibilityOption {
  47806. /**
  47807. * Define the option label
  47808. */
  47809. label: string;
  47810. /**
  47811. * Defines the action to execute on click
  47812. */
  47813. action: (entity: any) => void;
  47814. }
  47815. /**
  47816. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  47817. */
  47818. export interface IExplorerExtensibilityGroup {
  47819. /**
  47820. * Defines a predicate to test if a given type mut be extended
  47821. */
  47822. predicate: (entity: any) => boolean;
  47823. /**
  47824. * Gets the list of options added to a type
  47825. */
  47826. entries: IExplorerExtensibilityOption[];
  47827. }
  47828. /**
  47829. * Interface used to define the options to use to create the Inspector
  47830. */
  47831. export interface IInspectorOptions {
  47832. /**
  47833. * Display in overlay mode (default: false)
  47834. */
  47835. overlay?: boolean;
  47836. /**
  47837. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  47838. */
  47839. globalRoot?: HTMLElement;
  47840. /**
  47841. * Display the Scene explorer
  47842. */
  47843. showExplorer?: boolean;
  47844. /**
  47845. * Display the property inspector
  47846. */
  47847. showInspector?: boolean;
  47848. /**
  47849. * Display in embed mode (both panes on the right)
  47850. */
  47851. embedMode?: boolean;
  47852. /**
  47853. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  47854. */
  47855. handleResize?: boolean;
  47856. /**
  47857. * Allow the panes to popup (default: true)
  47858. */
  47859. enablePopup?: boolean;
  47860. /**
  47861. * Allow the panes to be closed by users (default: true)
  47862. */
  47863. enableClose?: boolean;
  47864. /**
  47865. * Optional list of extensibility entries
  47866. */
  47867. explorerExtensibility?: IExplorerExtensibilityGroup[];
  47868. /**
  47869. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  47870. */
  47871. inspectorURL?: string;
  47872. /**
  47873. * Optional initial tab (default to DebugLayerTab.Properties)
  47874. */
  47875. initialTab?: DebugLayerTab;
  47876. }
  47877. module "babylonjs/scene" {
  47878. interface Scene {
  47879. /**
  47880. * @hidden
  47881. * Backing field
  47882. */
  47883. _debugLayer: DebugLayer;
  47884. /**
  47885. * Gets the debug layer (aka Inspector) associated with the scene
  47886. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47887. */
  47888. debugLayer: DebugLayer;
  47889. }
  47890. }
  47891. /**
  47892. * Enum of inspector action tab
  47893. */
  47894. export enum DebugLayerTab {
  47895. /**
  47896. * Properties tag (default)
  47897. */
  47898. Properties = 0,
  47899. /**
  47900. * Debug tab
  47901. */
  47902. Debug = 1,
  47903. /**
  47904. * Statistics tab
  47905. */
  47906. Statistics = 2,
  47907. /**
  47908. * Tools tab
  47909. */
  47910. Tools = 3,
  47911. /**
  47912. * Settings tab
  47913. */
  47914. Settings = 4
  47915. }
  47916. /**
  47917. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47918. * what is happening in your scene
  47919. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47920. */
  47921. export class DebugLayer {
  47922. /**
  47923. * Define the url to get the inspector script from.
  47924. * By default it uses the babylonjs CDN.
  47925. * @ignoreNaming
  47926. */
  47927. static InspectorURL: string;
  47928. private _scene;
  47929. private BJSINSPECTOR;
  47930. private _onPropertyChangedObservable?;
  47931. /**
  47932. * Observable triggered when a property is changed through the inspector.
  47933. */
  47934. get onPropertyChangedObservable(): any;
  47935. /**
  47936. * Instantiates a new debug layer.
  47937. * The debug layer (aka Inspector) is the go to tool in order to better understand
  47938. * what is happening in your scene
  47939. * @see http://doc.babylonjs.com/features/playground_debuglayer
  47940. * @param scene Defines the scene to inspect
  47941. */
  47942. constructor(scene: Scene);
  47943. /** Creates the inspector window. */
  47944. private _createInspector;
  47945. /**
  47946. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  47947. * @param entity defines the entity to select
  47948. * @param lineContainerTitle defines the specific block to highlight
  47949. */
  47950. select(entity: any, lineContainerTitle?: string): void;
  47951. /** Get the inspector from bundle or global */
  47952. private _getGlobalInspector;
  47953. /**
  47954. * Get if the inspector is visible or not.
  47955. * @returns true if visible otherwise, false
  47956. */
  47957. isVisible(): boolean;
  47958. /**
  47959. * Hide the inspector and close its window.
  47960. */
  47961. hide(): void;
  47962. /**
  47963. * Launch the debugLayer.
  47964. * @param config Define the configuration of the inspector
  47965. * @return a promise fulfilled when the debug layer is visible
  47966. */
  47967. show(config?: IInspectorOptions): Promise<DebugLayer>;
  47968. }
  47969. }
  47970. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  47971. import { Nullable } from "babylonjs/types";
  47972. import { Scene } from "babylonjs/scene";
  47973. import { Vector4 } from "babylonjs/Maths/math.vector";
  47974. import { Color4 } from "babylonjs/Maths/math.color";
  47975. import { Mesh } from "babylonjs/Meshes/mesh";
  47976. /**
  47977. * Class containing static functions to help procedurally build meshes
  47978. */
  47979. export class BoxBuilder {
  47980. /**
  47981. * Creates a box mesh
  47982. * * The parameter `size` sets the size (float) of each box side (default 1)
  47983. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  47984. * * 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)
  47985. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  47986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  47987. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  47988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  47989. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  47990. * @param name defines the name of the mesh
  47991. * @param options defines the options used to create the mesh
  47992. * @param scene defines the hosting scene
  47993. * @returns the box mesh
  47994. */
  47995. static CreateBox(name: string, options: {
  47996. size?: number;
  47997. width?: number;
  47998. height?: number;
  47999. depth?: number;
  48000. faceUV?: Vector4[];
  48001. faceColors?: Color4[];
  48002. sideOrientation?: number;
  48003. frontUVs?: Vector4;
  48004. backUVs?: Vector4;
  48005. wrap?: boolean;
  48006. topBaseAt?: number;
  48007. bottomBaseAt?: number;
  48008. updatable?: boolean;
  48009. }, scene?: Nullable<Scene>): Mesh;
  48010. }
  48011. }
  48012. declare module "babylonjs/Debug/physicsViewer" {
  48013. import { Nullable } from "babylonjs/types";
  48014. import { Scene } from "babylonjs/scene";
  48015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48016. import { Mesh } from "babylonjs/Meshes/mesh";
  48017. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48018. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48019. /**
  48020. * Used to show the physics impostor around the specific mesh
  48021. */
  48022. export class PhysicsViewer {
  48023. /** @hidden */
  48024. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48025. /** @hidden */
  48026. protected _meshes: Array<Nullable<AbstractMesh>>;
  48027. /** @hidden */
  48028. protected _scene: Nullable<Scene>;
  48029. /** @hidden */
  48030. protected _numMeshes: number;
  48031. /** @hidden */
  48032. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48033. private _renderFunction;
  48034. private _utilityLayer;
  48035. private _debugBoxMesh;
  48036. private _debugSphereMesh;
  48037. private _debugCylinderMesh;
  48038. private _debugMaterial;
  48039. private _debugMeshMeshes;
  48040. /**
  48041. * Creates a new PhysicsViewer
  48042. * @param scene defines the hosting scene
  48043. */
  48044. constructor(scene: Scene);
  48045. /** @hidden */
  48046. protected _updateDebugMeshes(): void;
  48047. /**
  48048. * Renders a specified physic impostor
  48049. * @param impostor defines the impostor to render
  48050. * @param targetMesh defines the mesh represented by the impostor
  48051. * @returns the new debug mesh used to render the impostor
  48052. */
  48053. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48054. /**
  48055. * Hides a specified physic impostor
  48056. * @param impostor defines the impostor to hide
  48057. */
  48058. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48059. private _getDebugMaterial;
  48060. private _getDebugBoxMesh;
  48061. private _getDebugSphereMesh;
  48062. private _getDebugCylinderMesh;
  48063. private _getDebugMeshMesh;
  48064. private _getDebugMesh;
  48065. /** Releases all resources */
  48066. dispose(): void;
  48067. }
  48068. }
  48069. declare module "babylonjs/Debug/rayHelper" {
  48070. import { Nullable } from "babylonjs/types";
  48071. import { Ray } from "babylonjs/Culling/ray";
  48072. import { Vector3 } from "babylonjs/Maths/math.vector";
  48073. import { Color3 } from "babylonjs/Maths/math.color";
  48074. import { Scene } from "babylonjs/scene";
  48075. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48076. import "babylonjs/Meshes/Builders/linesBuilder";
  48077. /**
  48078. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48079. * in order to better appreciate the issue one might have.
  48080. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48081. */
  48082. export class RayHelper {
  48083. /**
  48084. * Defines the ray we are currently tryin to visualize.
  48085. */
  48086. ray: Nullable<Ray>;
  48087. private _renderPoints;
  48088. private _renderLine;
  48089. private _renderFunction;
  48090. private _scene;
  48091. private _updateToMeshFunction;
  48092. private _attachedToMesh;
  48093. private _meshSpaceDirection;
  48094. private _meshSpaceOrigin;
  48095. /**
  48096. * Helper function to create a colored helper in a scene in one line.
  48097. * @param ray Defines the ray we are currently tryin to visualize
  48098. * @param scene Defines the scene the ray is used in
  48099. * @param color Defines the color we want to see the ray in
  48100. * @returns The newly created ray helper.
  48101. */
  48102. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48103. /**
  48104. * Instantiate a new ray helper.
  48105. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48106. * in order to better appreciate the issue one might have.
  48107. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48108. * @param ray Defines the ray we are currently tryin to visualize
  48109. */
  48110. constructor(ray: Ray);
  48111. /**
  48112. * Shows the ray we are willing to debug.
  48113. * @param scene Defines the scene the ray needs to be rendered in
  48114. * @param color Defines the color the ray needs to be rendered in
  48115. */
  48116. show(scene: Scene, color?: Color3): void;
  48117. /**
  48118. * Hides the ray we are debugging.
  48119. */
  48120. hide(): void;
  48121. private _render;
  48122. /**
  48123. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48124. * @param mesh Defines the mesh we want the helper attached to
  48125. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48126. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48127. * @param length Defines the length of the ray
  48128. */
  48129. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48130. /**
  48131. * Detach the ray helper from the mesh it has previously been attached to.
  48132. */
  48133. detachFromMesh(): void;
  48134. private _updateToMesh;
  48135. /**
  48136. * Dispose the helper and release its associated resources.
  48137. */
  48138. dispose(): void;
  48139. }
  48140. }
  48141. declare module "babylonjs/Debug/skeletonViewer" {
  48142. import { Color3 } from "babylonjs/Maths/math.color";
  48143. import { Scene } from "babylonjs/scene";
  48144. import { Nullable } from "babylonjs/types";
  48145. import { Skeleton } from "babylonjs/Bones/skeleton";
  48146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48147. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48148. /**
  48149. * Class used to render a debug view of a given skeleton
  48150. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48151. */
  48152. export class SkeletonViewer {
  48153. /** defines the skeleton to render */
  48154. skeleton: Skeleton;
  48155. /** defines the mesh attached to the skeleton */
  48156. mesh: AbstractMesh;
  48157. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48158. autoUpdateBonesMatrices: boolean;
  48159. /** defines the rendering group id to use with the viewer */
  48160. renderingGroupId: number;
  48161. /** Gets or sets the color used to render the skeleton */
  48162. color: Color3;
  48163. private _scene;
  48164. private _debugLines;
  48165. private _debugMesh;
  48166. private _isEnabled;
  48167. private _renderFunction;
  48168. private _utilityLayer;
  48169. /**
  48170. * Returns the mesh used to render the bones
  48171. */
  48172. get debugMesh(): Nullable<LinesMesh>;
  48173. /**
  48174. * Creates a new SkeletonViewer
  48175. * @param skeleton defines the skeleton to render
  48176. * @param mesh defines the mesh attached to the skeleton
  48177. * @param scene defines the hosting scene
  48178. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48179. * @param renderingGroupId defines the rendering group id to use with the viewer
  48180. */
  48181. constructor(
  48182. /** defines the skeleton to render */
  48183. skeleton: Skeleton,
  48184. /** defines the mesh attached to the skeleton */
  48185. mesh: AbstractMesh, scene: Scene,
  48186. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48187. autoUpdateBonesMatrices?: boolean,
  48188. /** defines the rendering group id to use with the viewer */
  48189. renderingGroupId?: number);
  48190. /** Gets or sets a boolean indicating if the viewer is enabled */
  48191. set isEnabled(value: boolean);
  48192. get isEnabled(): boolean;
  48193. private _getBonePosition;
  48194. private _getLinesForBonesWithLength;
  48195. private _getLinesForBonesNoLength;
  48196. /** Update the viewer to sync with current skeleton state */
  48197. update(): void;
  48198. /** Release associated resources */
  48199. dispose(): void;
  48200. }
  48201. }
  48202. declare module "babylonjs/Debug/index" {
  48203. export * from "babylonjs/Debug/axesViewer";
  48204. export * from "babylonjs/Debug/boneAxesViewer";
  48205. export * from "babylonjs/Debug/debugLayer";
  48206. export * from "babylonjs/Debug/physicsViewer";
  48207. export * from "babylonjs/Debug/rayHelper";
  48208. export * from "babylonjs/Debug/skeletonViewer";
  48209. }
  48210. declare module "babylonjs/Engines/nullEngine" {
  48211. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48212. import { Scene } from "babylonjs/scene";
  48213. import { Engine } from "babylonjs/Engines/engine";
  48214. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48215. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48216. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48217. import { Effect } from "babylonjs/Materials/effect";
  48218. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48219. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48220. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48221. /**
  48222. * Options to create the null engine
  48223. */
  48224. export class NullEngineOptions {
  48225. /**
  48226. * Render width (Default: 512)
  48227. */
  48228. renderWidth: number;
  48229. /**
  48230. * Render height (Default: 256)
  48231. */
  48232. renderHeight: number;
  48233. /**
  48234. * Texture size (Default: 512)
  48235. */
  48236. textureSize: number;
  48237. /**
  48238. * If delta time between frames should be constant
  48239. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48240. */
  48241. deterministicLockstep: boolean;
  48242. /**
  48243. * Maximum about of steps between frames (Default: 4)
  48244. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48245. */
  48246. lockstepMaxSteps: number;
  48247. }
  48248. /**
  48249. * The null engine class provides support for headless version of babylon.js.
  48250. * This can be used in server side scenario or for testing purposes
  48251. */
  48252. export class NullEngine extends Engine {
  48253. private _options;
  48254. /**
  48255. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48256. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48257. * @returns true if engine is in deterministic lock step mode
  48258. */
  48259. isDeterministicLockStep(): boolean;
  48260. /**
  48261. * Gets the max steps when engine is running in deterministic lock step
  48262. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48263. * @returns the max steps
  48264. */
  48265. getLockstepMaxSteps(): number;
  48266. /**
  48267. * Gets the current hardware scaling level.
  48268. * By default the hardware scaling level is computed from the window device ratio.
  48269. * 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.
  48270. * @returns a number indicating the current hardware scaling level
  48271. */
  48272. getHardwareScalingLevel(): number;
  48273. constructor(options?: NullEngineOptions);
  48274. /**
  48275. * Creates a vertex buffer
  48276. * @param vertices the data for the vertex buffer
  48277. * @returns the new WebGL static buffer
  48278. */
  48279. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48280. /**
  48281. * Creates a new index buffer
  48282. * @param indices defines the content of the index buffer
  48283. * @param updatable defines if the index buffer must be updatable
  48284. * @returns a new webGL buffer
  48285. */
  48286. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48287. /**
  48288. * Clear the current render buffer or the current render target (if any is set up)
  48289. * @param color defines the color to use
  48290. * @param backBuffer defines if the back buffer must be cleared
  48291. * @param depth defines if the depth buffer must be cleared
  48292. * @param stencil defines if the stencil buffer must be cleared
  48293. */
  48294. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48295. /**
  48296. * Gets the current render width
  48297. * @param useScreen defines if screen size must be used (or the current render target if any)
  48298. * @returns a number defining the current render width
  48299. */
  48300. getRenderWidth(useScreen?: boolean): number;
  48301. /**
  48302. * Gets the current render height
  48303. * @param useScreen defines if screen size must be used (or the current render target if any)
  48304. * @returns a number defining the current render height
  48305. */
  48306. getRenderHeight(useScreen?: boolean): number;
  48307. /**
  48308. * Set the WebGL's viewport
  48309. * @param viewport defines the viewport element to be used
  48310. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48311. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48312. */
  48313. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48314. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48315. /**
  48316. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48317. * @param pipelineContext defines the pipeline context to use
  48318. * @param uniformsNames defines the list of uniform names
  48319. * @returns an array of webGL uniform locations
  48320. */
  48321. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48322. /**
  48323. * Gets the lsit of active attributes for a given webGL program
  48324. * @param pipelineContext defines the pipeline context to use
  48325. * @param attributesNames defines the list of attribute names to get
  48326. * @returns an array of indices indicating the offset of each attribute
  48327. */
  48328. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48329. /**
  48330. * Binds an effect to the webGL context
  48331. * @param effect defines the effect to bind
  48332. */
  48333. bindSamplers(effect: Effect): void;
  48334. /**
  48335. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48336. * @param effect defines the effect to activate
  48337. */
  48338. enableEffect(effect: Effect): void;
  48339. /**
  48340. * Set various states to the webGL context
  48341. * @param culling defines backface culling state
  48342. * @param zOffset defines the value to apply to zOffset (0 by default)
  48343. * @param force defines if states must be applied even if cache is up to date
  48344. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48345. */
  48346. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48347. /**
  48348. * Set the value of an uniform to an array of int32
  48349. * @param uniform defines the webGL uniform location where to store the value
  48350. * @param array defines the array of int32 to store
  48351. */
  48352. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48353. /**
  48354. * Set the value of an uniform to an array of int32 (stored as vec2)
  48355. * @param uniform defines the webGL uniform location where to store the value
  48356. * @param array defines the array of int32 to store
  48357. */
  48358. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48359. /**
  48360. * Set the value of an uniform to an array of int32 (stored as vec3)
  48361. * @param uniform defines the webGL uniform location where to store the value
  48362. * @param array defines the array of int32 to store
  48363. */
  48364. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48365. /**
  48366. * Set the value of an uniform to an array of int32 (stored as vec4)
  48367. * @param uniform defines the webGL uniform location where to store the value
  48368. * @param array defines the array of int32 to store
  48369. */
  48370. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48371. /**
  48372. * Set the value of an uniform to an array of float32
  48373. * @param uniform defines the webGL uniform location where to store the value
  48374. * @param array defines the array of float32 to store
  48375. */
  48376. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48377. /**
  48378. * Set the value of an uniform to an array of float32 (stored as vec2)
  48379. * @param uniform defines the webGL uniform location where to store the value
  48380. * @param array defines the array of float32 to store
  48381. */
  48382. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48383. /**
  48384. * Set the value of an uniform to an array of float32 (stored as vec3)
  48385. * @param uniform defines the webGL uniform location where to store the value
  48386. * @param array defines the array of float32 to store
  48387. */
  48388. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48389. /**
  48390. * Set the value of an uniform to an array of float32 (stored as vec4)
  48391. * @param uniform defines the webGL uniform location where to store the value
  48392. * @param array defines the array of float32 to store
  48393. */
  48394. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48395. /**
  48396. * Set the value of an uniform to an array of number
  48397. * @param uniform defines the webGL uniform location where to store the value
  48398. * @param array defines the array of number to store
  48399. */
  48400. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48401. /**
  48402. * Set the value of an uniform to an array of number (stored as vec2)
  48403. * @param uniform defines the webGL uniform location where to store the value
  48404. * @param array defines the array of number to store
  48405. */
  48406. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48407. /**
  48408. * Set the value of an uniform to an array of number (stored as vec3)
  48409. * @param uniform defines the webGL uniform location where to store the value
  48410. * @param array defines the array of number to store
  48411. */
  48412. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48413. /**
  48414. * Set the value of an uniform to an array of number (stored as vec4)
  48415. * @param uniform defines the webGL uniform location where to store the value
  48416. * @param array defines the array of number to store
  48417. */
  48418. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48419. /**
  48420. * Set the value of an uniform to an array of float32 (stored as matrices)
  48421. * @param uniform defines the webGL uniform location where to store the value
  48422. * @param matrices defines the array of float32 to store
  48423. */
  48424. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48425. /**
  48426. * Set the value of an uniform to a matrix (3x3)
  48427. * @param uniform defines the webGL uniform location where to store the value
  48428. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48429. */
  48430. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48431. /**
  48432. * Set the value of an uniform to a matrix (2x2)
  48433. * @param uniform defines the webGL uniform location where to store the value
  48434. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48435. */
  48436. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48437. /**
  48438. * Set the value of an uniform to a number (float)
  48439. * @param uniform defines the webGL uniform location where to store the value
  48440. * @param value defines the float number to store
  48441. */
  48442. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48443. /**
  48444. * Set the value of an uniform to a vec2
  48445. * @param uniform defines the webGL uniform location where to store the value
  48446. * @param x defines the 1st component of the value
  48447. * @param y defines the 2nd component of the value
  48448. */
  48449. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48450. /**
  48451. * Set the value of an uniform to a vec3
  48452. * @param uniform defines the webGL uniform location where to store the value
  48453. * @param x defines the 1st component of the value
  48454. * @param y defines the 2nd component of the value
  48455. * @param z defines the 3rd component of the value
  48456. */
  48457. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48458. /**
  48459. * Set the value of an uniform to a boolean
  48460. * @param uniform defines the webGL uniform location where to store the value
  48461. * @param bool defines the boolean to store
  48462. */
  48463. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48464. /**
  48465. * Set the value of an uniform to a vec4
  48466. * @param uniform defines the webGL uniform location where to store the value
  48467. * @param x defines the 1st component of the value
  48468. * @param y defines the 2nd component of the value
  48469. * @param z defines the 3rd component of the value
  48470. * @param w defines the 4th component of the value
  48471. */
  48472. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48473. /**
  48474. * Sets the current alpha mode
  48475. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48476. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48477. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48478. */
  48479. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48480. /**
  48481. * Bind webGl buffers directly to the webGL context
  48482. * @param vertexBuffers defines the vertex buffer to bind
  48483. * @param indexBuffer defines the index buffer to bind
  48484. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48485. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48486. * @param effect defines the effect associated with the vertex buffer
  48487. */
  48488. bindBuffers(vertexBuffers: {
  48489. [key: string]: VertexBuffer;
  48490. }, indexBuffer: DataBuffer, effect: Effect): void;
  48491. /**
  48492. * Force the entire cache to be cleared
  48493. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48494. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48495. */
  48496. wipeCaches(bruteForce?: boolean): void;
  48497. /**
  48498. * Send a draw order
  48499. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48500. * @param indexStart defines the starting index
  48501. * @param indexCount defines the number of index to draw
  48502. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48503. */
  48504. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48505. /**
  48506. * Draw a list of indexed primitives
  48507. * @param fillMode defines the primitive to use
  48508. * @param indexStart defines the starting index
  48509. * @param indexCount defines the number of index to draw
  48510. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48511. */
  48512. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48513. /**
  48514. * Draw a list of unindexed primitives
  48515. * @param fillMode defines the primitive to use
  48516. * @param verticesStart defines the index of first vertex to draw
  48517. * @param verticesCount defines the count of vertices to draw
  48518. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48519. */
  48520. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48521. /** @hidden */
  48522. _createTexture(): WebGLTexture;
  48523. /** @hidden */
  48524. _releaseTexture(texture: InternalTexture): void;
  48525. /**
  48526. * Usually called from Texture.ts.
  48527. * Passed information to create a WebGLTexture
  48528. * @param urlArg defines a value which contains one of the following:
  48529. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48530. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48531. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48532. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48533. * @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)
  48534. * @param scene needed for loading to the correct scene
  48535. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48536. * @param onLoad optional callback to be called upon successful completion
  48537. * @param onError optional callback to be called upon failure
  48538. * @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
  48539. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48540. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48541. * @param forcedExtension defines the extension to use to pick the right loader
  48542. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  48543. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48544. */
  48545. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  48546. /**
  48547. * Creates a new render target texture
  48548. * @param size defines the size of the texture
  48549. * @param options defines the options used to create the texture
  48550. * @returns a new render target texture stored in an InternalTexture
  48551. */
  48552. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48553. /**
  48554. * Update the sampling mode of a given texture
  48555. * @param samplingMode defines the required sampling mode
  48556. * @param texture defines the texture to update
  48557. */
  48558. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48559. /**
  48560. * Binds the frame buffer to the specified texture.
  48561. * @param texture The texture to render to or null for the default canvas
  48562. * @param faceIndex The face of the texture to render to in case of cube texture
  48563. * @param requiredWidth The width of the target to render to
  48564. * @param requiredHeight The height of the target to render to
  48565. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48566. * @param lodLevel defines le lod level to bind to the frame buffer
  48567. */
  48568. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48569. /**
  48570. * Unbind the current render target texture from the webGL context
  48571. * @param texture defines the render target texture to unbind
  48572. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48573. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48574. */
  48575. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48576. /**
  48577. * Creates a dynamic vertex buffer
  48578. * @param vertices the data for the dynamic vertex buffer
  48579. * @returns the new WebGL dynamic buffer
  48580. */
  48581. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48582. /**
  48583. * Update the content of a dynamic texture
  48584. * @param texture defines the texture to update
  48585. * @param canvas defines the canvas containing the source
  48586. * @param invertY defines if data must be stored with Y axis inverted
  48587. * @param premulAlpha defines if alpha is stored as premultiplied
  48588. * @param format defines the format of the data
  48589. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48590. */
  48591. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  48592. /**
  48593. * Gets a boolean indicating if all created effects are ready
  48594. * @returns true if all effects are ready
  48595. */
  48596. areAllEffectsReady(): boolean;
  48597. /**
  48598. * @hidden
  48599. * Get the current error code of the webGL context
  48600. * @returns the error code
  48601. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  48602. */
  48603. getError(): number;
  48604. /** @hidden */
  48605. _getUnpackAlignement(): number;
  48606. /** @hidden */
  48607. _unpackFlipY(value: boolean): void;
  48608. /**
  48609. * Update a dynamic index buffer
  48610. * @param indexBuffer defines the target index buffer
  48611. * @param indices defines the data to update
  48612. * @param offset defines the offset in the target index buffer where update should start
  48613. */
  48614. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  48615. /**
  48616. * Updates a dynamic vertex buffer.
  48617. * @param vertexBuffer the vertex buffer to update
  48618. * @param vertices the data used to update the vertex buffer
  48619. * @param byteOffset the byte offset of the data (optional)
  48620. * @param byteLength the byte length of the data (optional)
  48621. */
  48622. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  48623. /** @hidden */
  48624. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  48625. /** @hidden */
  48626. _bindTexture(channel: number, texture: InternalTexture): void;
  48627. protected _deleteBuffer(buffer: WebGLBuffer): void;
  48628. /**
  48629. * 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
  48630. */
  48631. releaseEffects(): void;
  48632. displayLoadingUI(): void;
  48633. hideLoadingUI(): void;
  48634. /** @hidden */
  48635. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48636. /** @hidden */
  48637. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48638. /** @hidden */
  48639. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  48640. /** @hidden */
  48641. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  48642. }
  48643. }
  48644. declare module "babylonjs/Instrumentation/timeToken" {
  48645. import { Nullable } from "babylonjs/types";
  48646. /**
  48647. * @hidden
  48648. **/
  48649. export class _TimeToken {
  48650. _startTimeQuery: Nullable<WebGLQuery>;
  48651. _endTimeQuery: Nullable<WebGLQuery>;
  48652. _timeElapsedQuery: Nullable<WebGLQuery>;
  48653. _timeElapsedQueryEnded: boolean;
  48654. }
  48655. }
  48656. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  48657. import { Nullable, int } from "babylonjs/types";
  48658. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  48659. /** @hidden */
  48660. export class _OcclusionDataStorage {
  48661. /** @hidden */
  48662. occlusionInternalRetryCounter: number;
  48663. /** @hidden */
  48664. isOcclusionQueryInProgress: boolean;
  48665. /** @hidden */
  48666. isOccluded: boolean;
  48667. /** @hidden */
  48668. occlusionRetryCount: number;
  48669. /** @hidden */
  48670. occlusionType: number;
  48671. /** @hidden */
  48672. occlusionQueryAlgorithmType: number;
  48673. }
  48674. module "babylonjs/Engines/engine" {
  48675. interface Engine {
  48676. /**
  48677. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  48678. * @return the new query
  48679. */
  48680. createQuery(): WebGLQuery;
  48681. /**
  48682. * Delete and release a webGL query
  48683. * @param query defines the query to delete
  48684. * @return the current engine
  48685. */
  48686. deleteQuery(query: WebGLQuery): Engine;
  48687. /**
  48688. * Check if a given query has resolved and got its value
  48689. * @param query defines the query to check
  48690. * @returns true if the query got its value
  48691. */
  48692. isQueryResultAvailable(query: WebGLQuery): boolean;
  48693. /**
  48694. * Gets the value of a given query
  48695. * @param query defines the query to check
  48696. * @returns the value of the query
  48697. */
  48698. getQueryResult(query: WebGLQuery): number;
  48699. /**
  48700. * Initiates an occlusion query
  48701. * @param algorithmType defines the algorithm to use
  48702. * @param query defines the query to use
  48703. * @returns the current engine
  48704. * @see http://doc.babylonjs.com/features/occlusionquery
  48705. */
  48706. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  48707. /**
  48708. * Ends an occlusion query
  48709. * @see http://doc.babylonjs.com/features/occlusionquery
  48710. * @param algorithmType defines the algorithm to use
  48711. * @returns the current engine
  48712. */
  48713. endOcclusionQuery(algorithmType: number): Engine;
  48714. /**
  48715. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  48716. * Please note that only one query can be issued at a time
  48717. * @returns a time token used to track the time span
  48718. */
  48719. startTimeQuery(): Nullable<_TimeToken>;
  48720. /**
  48721. * Ends a time query
  48722. * @param token defines the token used to measure the time span
  48723. * @returns the time spent (in ns)
  48724. */
  48725. endTimeQuery(token: _TimeToken): int;
  48726. /** @hidden */
  48727. _currentNonTimestampToken: Nullable<_TimeToken>;
  48728. /** @hidden */
  48729. _createTimeQuery(): WebGLQuery;
  48730. /** @hidden */
  48731. _deleteTimeQuery(query: WebGLQuery): void;
  48732. /** @hidden */
  48733. _getGlAlgorithmType(algorithmType: number): number;
  48734. /** @hidden */
  48735. _getTimeQueryResult(query: WebGLQuery): any;
  48736. /** @hidden */
  48737. _getTimeQueryAvailability(query: WebGLQuery): any;
  48738. }
  48739. }
  48740. module "babylonjs/Meshes/abstractMesh" {
  48741. interface AbstractMesh {
  48742. /**
  48743. * Backing filed
  48744. * @hidden
  48745. */
  48746. __occlusionDataStorage: _OcclusionDataStorage;
  48747. /**
  48748. * Access property
  48749. * @hidden
  48750. */
  48751. _occlusionDataStorage: _OcclusionDataStorage;
  48752. /**
  48753. * 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.
  48754. * The default value is -1 which means don't break the query and wait till the result
  48755. * @see http://doc.babylonjs.com/features/occlusionquery
  48756. */
  48757. occlusionRetryCount: number;
  48758. /**
  48759. * 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:
  48760. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  48761. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  48762. * * 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.
  48763. * @see http://doc.babylonjs.com/features/occlusionquery
  48764. */
  48765. occlusionType: number;
  48766. /**
  48767. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  48768. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  48769. * * 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.
  48770. * @see http://doc.babylonjs.com/features/occlusionquery
  48771. */
  48772. occlusionQueryAlgorithmType: number;
  48773. /**
  48774. * 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
  48775. * @see http://doc.babylonjs.com/features/occlusionquery
  48776. */
  48777. isOccluded: boolean;
  48778. /**
  48779. * Flag to check the progress status of the query
  48780. * @see http://doc.babylonjs.com/features/occlusionquery
  48781. */
  48782. isOcclusionQueryInProgress: boolean;
  48783. }
  48784. }
  48785. }
  48786. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  48787. import { Nullable } from "babylonjs/types";
  48788. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48789. /** @hidden */
  48790. export var _forceTransformFeedbackToBundle: boolean;
  48791. module "babylonjs/Engines/engine" {
  48792. interface Engine {
  48793. /**
  48794. * Creates a webGL transform feedback object
  48795. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  48796. * @returns the webGL transform feedback object
  48797. */
  48798. createTransformFeedback(): WebGLTransformFeedback;
  48799. /**
  48800. * Delete a webGL transform feedback object
  48801. * @param value defines the webGL transform feedback object to delete
  48802. */
  48803. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  48804. /**
  48805. * Bind a webGL transform feedback object to the webgl context
  48806. * @param value defines the webGL transform feedback object to bind
  48807. */
  48808. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  48809. /**
  48810. * Begins a transform feedback operation
  48811. * @param usePoints defines if points or triangles must be used
  48812. */
  48813. beginTransformFeedback(usePoints: boolean): void;
  48814. /**
  48815. * Ends a transform feedback operation
  48816. */
  48817. endTransformFeedback(): void;
  48818. /**
  48819. * Specify the varyings to use with transform feedback
  48820. * @param program defines the associated webGL program
  48821. * @param value defines the list of strings representing the varying names
  48822. */
  48823. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  48824. /**
  48825. * Bind a webGL buffer for a transform feedback operation
  48826. * @param value defines the webGL buffer to bind
  48827. */
  48828. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  48829. }
  48830. }
  48831. }
  48832. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  48833. import { Scene } from "babylonjs/scene";
  48834. import { Engine } from "babylonjs/Engines/engine";
  48835. import { Texture } from "babylonjs/Materials/Textures/texture";
  48836. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48837. import "babylonjs/Engines/Extensions/engine.multiRender";
  48838. /**
  48839. * Creation options of the multi render target texture.
  48840. */
  48841. export interface IMultiRenderTargetOptions {
  48842. /**
  48843. * Define if the texture needs to create mip maps after render.
  48844. */
  48845. generateMipMaps?: boolean;
  48846. /**
  48847. * Define the types of all the draw buffers we want to create
  48848. */
  48849. types?: number[];
  48850. /**
  48851. * Define the sampling modes of all the draw buffers we want to create
  48852. */
  48853. samplingModes?: number[];
  48854. /**
  48855. * Define if a depth buffer is required
  48856. */
  48857. generateDepthBuffer?: boolean;
  48858. /**
  48859. * Define if a stencil buffer is required
  48860. */
  48861. generateStencilBuffer?: boolean;
  48862. /**
  48863. * Define if a depth texture is required instead of a depth buffer
  48864. */
  48865. generateDepthTexture?: boolean;
  48866. /**
  48867. * Define the number of desired draw buffers
  48868. */
  48869. textureCount?: number;
  48870. /**
  48871. * Define if aspect ratio should be adapted to the texture or stay the scene one
  48872. */
  48873. doNotChangeAspectRatio?: boolean;
  48874. /**
  48875. * Define the default type of the buffers we are creating
  48876. */
  48877. defaultType?: number;
  48878. }
  48879. /**
  48880. * A multi render target, like a render target provides the ability to render to a texture.
  48881. * Unlike the render target, it can render to several draw buffers in one draw.
  48882. * This is specially interesting in deferred rendering or for any effects requiring more than
  48883. * just one color from a single pass.
  48884. */
  48885. export class MultiRenderTarget extends RenderTargetTexture {
  48886. private _internalTextures;
  48887. private _textures;
  48888. private _multiRenderTargetOptions;
  48889. /**
  48890. * Get if draw buffers are currently supported by the used hardware and browser.
  48891. */
  48892. get isSupported(): boolean;
  48893. /**
  48894. * Get the list of textures generated by the multi render target.
  48895. */
  48896. get textures(): Texture[];
  48897. /**
  48898. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  48899. */
  48900. get depthTexture(): Texture;
  48901. /**
  48902. * Set the wrapping mode on U of all the textures we are rendering to.
  48903. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48904. */
  48905. set wrapU(wrap: number);
  48906. /**
  48907. * Set the wrapping mode on V of all the textures we are rendering to.
  48908. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  48909. */
  48910. set wrapV(wrap: number);
  48911. /**
  48912. * Instantiate a new multi render target texture.
  48913. * A multi render target, like a render target provides the ability to render to a texture.
  48914. * Unlike the render target, it can render to several draw buffers in one draw.
  48915. * This is specially interesting in deferred rendering or for any effects requiring more than
  48916. * just one color from a single pass.
  48917. * @param name Define the name of the texture
  48918. * @param size Define the size of the buffers to render to
  48919. * @param count Define the number of target we are rendering into
  48920. * @param scene Define the scene the texture belongs to
  48921. * @param options Define the options used to create the multi render target
  48922. */
  48923. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  48924. /** @hidden */
  48925. _rebuild(): void;
  48926. private _createInternalTextures;
  48927. private _createTextures;
  48928. /**
  48929. * Define the number of samples used if MSAA is enabled.
  48930. */
  48931. get samples(): number;
  48932. set samples(value: number);
  48933. /**
  48934. * Resize all the textures in the multi render target.
  48935. * Be carrefull as it will recreate all the data in the new texture.
  48936. * @param size Define the new size
  48937. */
  48938. resize(size: any): void;
  48939. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  48940. /**
  48941. * Dispose the render targets and their associated resources
  48942. */
  48943. dispose(): void;
  48944. /**
  48945. * Release all the underlying texture used as draw buffers.
  48946. */
  48947. releaseInternalTextures(): void;
  48948. }
  48949. }
  48950. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  48951. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48952. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  48953. import { Nullable } from "babylonjs/types";
  48954. module "babylonjs/Engines/thinEngine" {
  48955. interface ThinEngine {
  48956. /**
  48957. * Unbind a list of render target textures from the webGL context
  48958. * This is used only when drawBuffer extension or webGL2 are active
  48959. * @param textures defines the render target textures to unbind
  48960. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48961. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48962. */
  48963. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  48964. /**
  48965. * Create a multi render target texture
  48966. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  48967. * @param size defines the size of the texture
  48968. * @param options defines the creation options
  48969. * @returns the cube texture as an InternalTexture
  48970. */
  48971. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  48972. /**
  48973. * Update the sample count for a given multiple render target texture
  48974. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  48975. * @param textures defines the textures to update
  48976. * @param samples defines the sample count to set
  48977. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  48978. */
  48979. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  48980. }
  48981. }
  48982. }
  48983. declare module "babylonjs/Engines/Extensions/engine.views" {
  48984. import { Camera } from "babylonjs/Cameras/camera";
  48985. import { Nullable } from "babylonjs/types";
  48986. /**
  48987. * Class used to define an additional view for the engine
  48988. * @see https://doc.babylonjs.com/how_to/multi_canvases
  48989. */
  48990. export class EngineView {
  48991. /** Defines the canvas where to render the view */
  48992. target: HTMLCanvasElement;
  48993. /** Defines an optional camera used to render the view (will use active camera else) */
  48994. camera?: Camera;
  48995. }
  48996. module "babylonjs/Engines/engine" {
  48997. interface Engine {
  48998. /**
  48999. * Gets or sets the HTML element to use for attaching events
  49000. */
  49001. inputElement: Nullable<HTMLElement>;
  49002. /**
  49003. * Gets the current engine view
  49004. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49005. */
  49006. activeView: Nullable<EngineView>;
  49007. /** Gets or sets the list of views */
  49008. views: EngineView[];
  49009. /**
  49010. * Register a new child canvas
  49011. * @param canvas defines the canvas to register
  49012. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49013. * @returns the associated view
  49014. */
  49015. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49016. /**
  49017. * Remove a registered child canvas
  49018. * @param canvas defines the canvas to remove
  49019. * @returns the current engine
  49020. */
  49021. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49022. }
  49023. }
  49024. }
  49025. declare module "babylonjs/Engines/Extensions/index" {
  49026. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49027. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49028. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49029. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49030. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49031. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49032. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49033. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49034. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49035. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49036. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49037. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49038. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49039. export * from "babylonjs/Engines/Extensions/engine.views";
  49040. }
  49041. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49042. import { Nullable } from "babylonjs/types";
  49043. /**
  49044. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49045. */
  49046. export interface CubeMapInfo {
  49047. /**
  49048. * The pixel array for the front face.
  49049. * This is stored in format, left to right, up to down format.
  49050. */
  49051. front: Nullable<ArrayBufferView>;
  49052. /**
  49053. * The pixel array for the back face.
  49054. * This is stored in format, left to right, up to down format.
  49055. */
  49056. back: Nullable<ArrayBufferView>;
  49057. /**
  49058. * The pixel array for the left face.
  49059. * This is stored in format, left to right, up to down format.
  49060. */
  49061. left: Nullable<ArrayBufferView>;
  49062. /**
  49063. * The pixel array for the right face.
  49064. * This is stored in format, left to right, up to down format.
  49065. */
  49066. right: Nullable<ArrayBufferView>;
  49067. /**
  49068. * The pixel array for the up face.
  49069. * This is stored in format, left to right, up to down format.
  49070. */
  49071. up: Nullable<ArrayBufferView>;
  49072. /**
  49073. * The pixel array for the down face.
  49074. * This is stored in format, left to right, up to down format.
  49075. */
  49076. down: Nullable<ArrayBufferView>;
  49077. /**
  49078. * The size of the cubemap stored.
  49079. *
  49080. * Each faces will be size * size pixels.
  49081. */
  49082. size: number;
  49083. /**
  49084. * The format of the texture.
  49085. *
  49086. * RGBA, RGB.
  49087. */
  49088. format: number;
  49089. /**
  49090. * The type of the texture data.
  49091. *
  49092. * UNSIGNED_INT, FLOAT.
  49093. */
  49094. type: number;
  49095. /**
  49096. * Specifies whether the texture is in gamma space.
  49097. */
  49098. gammaSpace: boolean;
  49099. }
  49100. /**
  49101. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49102. */
  49103. export class PanoramaToCubeMapTools {
  49104. private static FACE_FRONT;
  49105. private static FACE_BACK;
  49106. private static FACE_RIGHT;
  49107. private static FACE_LEFT;
  49108. private static FACE_DOWN;
  49109. private static FACE_UP;
  49110. /**
  49111. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49112. *
  49113. * @param float32Array The source data.
  49114. * @param inputWidth The width of the input panorama.
  49115. * @param inputHeight The height of the input panorama.
  49116. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49117. * @return The cubemap data
  49118. */
  49119. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49120. private static CreateCubemapTexture;
  49121. private static CalcProjectionSpherical;
  49122. }
  49123. }
  49124. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49125. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49126. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49127. import { Nullable } from "babylonjs/types";
  49128. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49129. /**
  49130. * Helper class dealing with the extraction of spherical polynomial dataArray
  49131. * from a cube map.
  49132. */
  49133. export class CubeMapToSphericalPolynomialTools {
  49134. private static FileFaces;
  49135. /**
  49136. * Converts a texture to the according Spherical Polynomial data.
  49137. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49138. *
  49139. * @param texture The texture to extract the information from.
  49140. * @return The Spherical Polynomial data.
  49141. */
  49142. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49143. /**
  49144. * Converts a cubemap to the according Spherical Polynomial data.
  49145. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49146. *
  49147. * @param cubeInfo The Cube map to extract the information from.
  49148. * @return The Spherical Polynomial data.
  49149. */
  49150. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49151. }
  49152. }
  49153. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49154. import { Nullable } from "babylonjs/types";
  49155. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49156. module "babylonjs/Materials/Textures/baseTexture" {
  49157. interface BaseTexture {
  49158. /**
  49159. * Get the polynomial representation of the texture data.
  49160. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49161. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49162. */
  49163. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49164. }
  49165. }
  49166. }
  49167. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49168. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49169. /** @hidden */
  49170. export var rgbdEncodePixelShader: {
  49171. name: string;
  49172. shader: string;
  49173. };
  49174. }
  49175. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49176. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49177. /** @hidden */
  49178. export var rgbdDecodePixelShader: {
  49179. name: string;
  49180. shader: string;
  49181. };
  49182. }
  49183. declare module "babylonjs/Misc/environmentTextureTools" {
  49184. import { Nullable } from "babylonjs/types";
  49185. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49186. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49187. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49188. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49189. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49190. import "babylonjs/Shaders/rgbdEncode.fragment";
  49191. import "babylonjs/Shaders/rgbdDecode.fragment";
  49192. /**
  49193. * Raw texture data and descriptor sufficient for WebGL texture upload
  49194. */
  49195. export interface EnvironmentTextureInfo {
  49196. /**
  49197. * Version of the environment map
  49198. */
  49199. version: number;
  49200. /**
  49201. * Width of image
  49202. */
  49203. width: number;
  49204. /**
  49205. * Irradiance information stored in the file.
  49206. */
  49207. irradiance: any;
  49208. /**
  49209. * Specular information stored in the file.
  49210. */
  49211. specular: any;
  49212. }
  49213. /**
  49214. * Defines One Image in the file. It requires only the position in the file
  49215. * as well as the length.
  49216. */
  49217. interface BufferImageData {
  49218. /**
  49219. * Length of the image data.
  49220. */
  49221. length: number;
  49222. /**
  49223. * Position of the data from the null terminator delimiting the end of the JSON.
  49224. */
  49225. position: number;
  49226. }
  49227. /**
  49228. * Defines the specular data enclosed in the file.
  49229. * This corresponds to the version 1 of the data.
  49230. */
  49231. export interface EnvironmentTextureSpecularInfoV1 {
  49232. /**
  49233. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49234. */
  49235. specularDataPosition?: number;
  49236. /**
  49237. * This contains all the images data needed to reconstruct the cubemap.
  49238. */
  49239. mipmaps: Array<BufferImageData>;
  49240. /**
  49241. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49242. */
  49243. lodGenerationScale: number;
  49244. }
  49245. /**
  49246. * Sets of helpers addressing the serialization and deserialization of environment texture
  49247. * stored in a BabylonJS env file.
  49248. * Those files are usually stored as .env files.
  49249. */
  49250. export class EnvironmentTextureTools {
  49251. /**
  49252. * Magic number identifying the env file.
  49253. */
  49254. private static _MagicBytes;
  49255. /**
  49256. * Gets the environment info from an env file.
  49257. * @param data The array buffer containing the .env bytes.
  49258. * @returns the environment file info (the json header) if successfully parsed.
  49259. */
  49260. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49261. /**
  49262. * Creates an environment texture from a loaded cube texture.
  49263. * @param texture defines the cube texture to convert in env file
  49264. * @return a promise containing the environment data if succesfull.
  49265. */
  49266. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49267. /**
  49268. * Creates a JSON representation of the spherical data.
  49269. * @param texture defines the texture containing the polynomials
  49270. * @return the JSON representation of the spherical info
  49271. */
  49272. private static _CreateEnvTextureIrradiance;
  49273. /**
  49274. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49275. * @param data the image data
  49276. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49277. * @return the views described by info providing access to the underlying buffer
  49278. */
  49279. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49280. /**
  49281. * Uploads the texture info contained in the env file to the GPU.
  49282. * @param texture defines the internal texture to upload to
  49283. * @param data defines the data to load
  49284. * @param info defines the texture info retrieved through the GetEnvInfo method
  49285. * @returns a promise
  49286. */
  49287. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49288. private static _OnImageReadyAsync;
  49289. /**
  49290. * Uploads the levels of image data to the GPU.
  49291. * @param texture defines the internal texture to upload to
  49292. * @param imageData defines the array buffer views of image data [mipmap][face]
  49293. * @returns a promise
  49294. */
  49295. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49296. /**
  49297. * Uploads spherical polynomials information to the texture.
  49298. * @param texture defines the texture we are trying to upload the information to
  49299. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49300. */
  49301. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49302. /** @hidden */
  49303. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49304. }
  49305. }
  49306. declare module "babylonjs/Maths/math.vertexFormat" {
  49307. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49308. /**
  49309. * Contains position and normal vectors for a vertex
  49310. */
  49311. export class PositionNormalVertex {
  49312. /** the position of the vertex (defaut: 0,0,0) */
  49313. position: Vector3;
  49314. /** the normal of the vertex (defaut: 0,1,0) */
  49315. normal: Vector3;
  49316. /**
  49317. * Creates a PositionNormalVertex
  49318. * @param position the position of the vertex (defaut: 0,0,0)
  49319. * @param normal the normal of the vertex (defaut: 0,1,0)
  49320. */
  49321. constructor(
  49322. /** the position of the vertex (defaut: 0,0,0) */
  49323. position?: Vector3,
  49324. /** the normal of the vertex (defaut: 0,1,0) */
  49325. normal?: Vector3);
  49326. /**
  49327. * Clones the PositionNormalVertex
  49328. * @returns the cloned PositionNormalVertex
  49329. */
  49330. clone(): PositionNormalVertex;
  49331. }
  49332. /**
  49333. * Contains position, normal and uv vectors for a vertex
  49334. */
  49335. export class PositionNormalTextureVertex {
  49336. /** the position of the vertex (defaut: 0,0,0) */
  49337. position: Vector3;
  49338. /** the normal of the vertex (defaut: 0,1,0) */
  49339. normal: Vector3;
  49340. /** the uv of the vertex (default: 0,0) */
  49341. uv: Vector2;
  49342. /**
  49343. * Creates a PositionNormalTextureVertex
  49344. * @param position the position of the vertex (defaut: 0,0,0)
  49345. * @param normal the normal of the vertex (defaut: 0,1,0)
  49346. * @param uv the uv of the vertex (default: 0,0)
  49347. */
  49348. constructor(
  49349. /** the position of the vertex (defaut: 0,0,0) */
  49350. position?: Vector3,
  49351. /** the normal of the vertex (defaut: 0,1,0) */
  49352. normal?: Vector3,
  49353. /** the uv of the vertex (default: 0,0) */
  49354. uv?: Vector2);
  49355. /**
  49356. * Clones the PositionNormalTextureVertex
  49357. * @returns the cloned PositionNormalTextureVertex
  49358. */
  49359. clone(): PositionNormalTextureVertex;
  49360. }
  49361. }
  49362. declare module "babylonjs/Maths/math" {
  49363. export * from "babylonjs/Maths/math.axis";
  49364. export * from "babylonjs/Maths/math.color";
  49365. export * from "babylonjs/Maths/math.constants";
  49366. export * from "babylonjs/Maths/math.frustum";
  49367. export * from "babylonjs/Maths/math.path";
  49368. export * from "babylonjs/Maths/math.plane";
  49369. export * from "babylonjs/Maths/math.size";
  49370. export * from "babylonjs/Maths/math.vector";
  49371. export * from "babylonjs/Maths/math.vertexFormat";
  49372. export * from "babylonjs/Maths/math.viewport";
  49373. }
  49374. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49375. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49376. /** @hidden */
  49377. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49378. private _genericAttributeLocation;
  49379. private _varyingLocationCount;
  49380. private _varyingLocationMap;
  49381. private _replacements;
  49382. private _textureCount;
  49383. private _uniforms;
  49384. lineProcessor(line: string): string;
  49385. attributeProcessor(attribute: string): string;
  49386. varyingProcessor(varying: string, isFragment: boolean): string;
  49387. uniformProcessor(uniform: string): string;
  49388. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49389. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49390. }
  49391. }
  49392. declare module "babylonjs/Engines/nativeEngine" {
  49393. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49394. import { Engine } from "babylonjs/Engines/engine";
  49395. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49396. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49397. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49398. import { Effect } from "babylonjs/Materials/effect";
  49399. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49400. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49401. import { IColor4Like } from "babylonjs/Maths/math.like";
  49402. import { Scene } from "babylonjs/scene";
  49403. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49404. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49405. /**
  49406. * Container for accessors for natively-stored mesh data buffers.
  49407. */
  49408. class NativeDataBuffer extends DataBuffer {
  49409. /**
  49410. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49411. */
  49412. nativeIndexBuffer?: any;
  49413. /**
  49414. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49415. */
  49416. nativeVertexBuffer?: any;
  49417. }
  49418. /** @hidden */
  49419. class NativeTexture extends InternalTexture {
  49420. getInternalTexture(): InternalTexture;
  49421. getViewCount(): number;
  49422. }
  49423. /** @hidden */
  49424. export class NativeEngine extends Engine {
  49425. private readonly _native;
  49426. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49427. private readonly INVALID_HANDLE;
  49428. getHardwareScalingLevel(): number;
  49429. constructor();
  49430. /**
  49431. * Can be used to override the current requestAnimationFrame requester.
  49432. * @hidden
  49433. */
  49434. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49435. /**
  49436. * Override default engine behavior.
  49437. * @param color
  49438. * @param backBuffer
  49439. * @param depth
  49440. * @param stencil
  49441. */
  49442. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49443. /**
  49444. * Gets host document
  49445. * @returns the host document object
  49446. */
  49447. getHostDocument(): Nullable<Document>;
  49448. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49449. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49450. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49451. recordVertexArrayObject(vertexBuffers: {
  49452. [key: string]: VertexBuffer;
  49453. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49454. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49455. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49456. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49457. /**
  49458. * Draw a list of indexed primitives
  49459. * @param fillMode defines the primitive to use
  49460. * @param indexStart defines the starting index
  49461. * @param indexCount defines the number of index to draw
  49462. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49463. */
  49464. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49465. /**
  49466. * Draw a list of unindexed primitives
  49467. * @param fillMode defines the primitive to use
  49468. * @param verticesStart defines the index of first vertex to draw
  49469. * @param verticesCount defines the count of vertices to draw
  49470. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49471. */
  49472. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49473. createPipelineContext(): IPipelineContext;
  49474. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49475. /** @hidden */
  49476. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49477. /** @hidden */
  49478. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49479. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49480. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49481. protected _setProgram(program: WebGLProgram): void;
  49482. _releaseEffect(effect: Effect): void;
  49483. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49484. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49485. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49486. bindSamplers(effect: Effect): void;
  49487. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49488. getRenderWidth(useScreen?: boolean): number;
  49489. getRenderHeight(useScreen?: boolean): number;
  49490. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49491. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49492. /**
  49493. * Set the z offset to apply to current rendering
  49494. * @param value defines the offset to apply
  49495. */
  49496. setZOffset(value: number): void;
  49497. /**
  49498. * Gets the current value of the zOffset
  49499. * @returns the current zOffset state
  49500. */
  49501. getZOffset(): number;
  49502. /**
  49503. * Enable or disable depth buffering
  49504. * @param enable defines the state to set
  49505. */
  49506. setDepthBuffer(enable: boolean): void;
  49507. /**
  49508. * Gets a boolean indicating if depth writing is enabled
  49509. * @returns the current depth writing state
  49510. */
  49511. getDepthWrite(): boolean;
  49512. /**
  49513. * Enable or disable depth writing
  49514. * @param enable defines the state to set
  49515. */
  49516. setDepthWrite(enable: boolean): void;
  49517. /**
  49518. * Enable or disable color writing
  49519. * @param enable defines the state to set
  49520. */
  49521. setColorWrite(enable: boolean): void;
  49522. /**
  49523. * Gets a boolean indicating if color writing is enabled
  49524. * @returns the current color writing state
  49525. */
  49526. getColorWrite(): boolean;
  49527. /**
  49528. * Sets alpha constants used by some alpha blending modes
  49529. * @param r defines the red component
  49530. * @param g defines the green component
  49531. * @param b defines the blue component
  49532. * @param a defines the alpha component
  49533. */
  49534. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49535. /**
  49536. * Sets the current alpha mode
  49537. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49538. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49539. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49540. */
  49541. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  49542. /**
  49543. * Gets the current alpha mode
  49544. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49545. * @returns the current alpha mode
  49546. */
  49547. getAlphaMode(): number;
  49548. setInt(uniform: WebGLUniformLocation, int: number): void;
  49549. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  49550. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  49551. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  49552. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  49553. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  49554. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  49555. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  49556. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  49557. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  49558. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  49559. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  49560. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  49561. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  49562. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49563. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  49564. setFloat(uniform: WebGLUniformLocation, value: number): void;
  49565. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  49566. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  49567. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  49568. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  49569. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  49570. wipeCaches(bruteForce?: boolean): void;
  49571. _createTexture(): WebGLTexture;
  49572. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  49573. /**
  49574. * Usually called from BABYLON.Texture.ts.
  49575. * Passed information to create a WebGLTexture
  49576. * @param urlArg defines a value which contains one of the following:
  49577. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  49578. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  49579. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  49580. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  49581. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  49582. * @param scene needed for loading to the correct scene
  49583. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  49584. * @param onLoad optional callback to be called upon successful completion
  49585. * @param onError optional callback to be called upon failure
  49586. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  49587. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  49588. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  49589. * @param forcedExtension defines the extension to use to pick the right loader
  49590. * @returns a InternalTexture for assignment back into BABYLON.Texture
  49591. */
  49592. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  49593. /**
  49594. * Creates a cube texture
  49595. * @param rootUrl defines the url where the files to load is located
  49596. * @param scene defines the current scene
  49597. * @param files defines the list of files to load (1 per face)
  49598. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  49599. * @param onLoad defines an optional callback raised when the texture is loaded
  49600. * @param onError defines an optional callback raised if there is an issue to load the texture
  49601. * @param format defines the format of the data
  49602. * @param forcedExtension defines the extension to use to pick the right loader
  49603. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  49604. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  49605. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  49606. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  49607. * @returns the cube texture as an InternalTexture
  49608. */
  49609. 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;
  49610. private _getSamplingFilter;
  49611. private static _GetNativeTextureFormat;
  49612. createRenderTargetTexture(size: number | {
  49613. width: number;
  49614. height: number;
  49615. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  49616. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  49617. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  49618. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  49619. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  49620. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  49621. /**
  49622. * Updates a dynamic vertex buffer.
  49623. * @param vertexBuffer the vertex buffer to update
  49624. * @param data the data used to update the vertex buffer
  49625. * @param byteOffset the byte offset of the data (optional)
  49626. * @param byteLength the byte length of the data (optional)
  49627. */
  49628. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  49629. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  49630. private _updateAnisotropicLevel;
  49631. private _getAddressMode;
  49632. /** @hidden */
  49633. _bindTexture(channel: number, texture: InternalTexture): void;
  49634. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  49635. releaseEffects(): void;
  49636. /** @hidden */
  49637. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49638. /** @hidden */
  49639. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49640. /** @hidden */
  49641. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49642. /** @hidden */
  49643. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49644. }
  49645. }
  49646. declare module "babylonjs/Engines/index" {
  49647. export * from "babylonjs/Engines/constants";
  49648. export * from "babylonjs/Engines/engineCapabilities";
  49649. export * from "babylonjs/Engines/instancingAttributeInfo";
  49650. export * from "babylonjs/Engines/thinEngine";
  49651. export * from "babylonjs/Engines/engine";
  49652. export * from "babylonjs/Engines/engineStore";
  49653. export * from "babylonjs/Engines/nullEngine";
  49654. export * from "babylonjs/Engines/Extensions/index";
  49655. export * from "babylonjs/Engines/IPipelineContext";
  49656. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  49657. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49658. export * from "babylonjs/Engines/nativeEngine";
  49659. }
  49660. declare module "babylonjs/Events/clipboardEvents" {
  49661. /**
  49662. * Gather the list of clipboard event types as constants.
  49663. */
  49664. export class ClipboardEventTypes {
  49665. /**
  49666. * The clipboard event is fired when a copy command is active (pressed).
  49667. */
  49668. static readonly COPY: number;
  49669. /**
  49670. * The clipboard event is fired when a cut command is active (pressed).
  49671. */
  49672. static readonly CUT: number;
  49673. /**
  49674. * The clipboard event is fired when a paste command is active (pressed).
  49675. */
  49676. static readonly PASTE: number;
  49677. }
  49678. /**
  49679. * This class is used to store clipboard related info for the onClipboardObservable event.
  49680. */
  49681. export class ClipboardInfo {
  49682. /**
  49683. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49684. */
  49685. type: number;
  49686. /**
  49687. * Defines the related dom event
  49688. */
  49689. event: ClipboardEvent;
  49690. /**
  49691. *Creates an instance of ClipboardInfo.
  49692. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  49693. * @param event Defines the related dom event
  49694. */
  49695. constructor(
  49696. /**
  49697. * Defines the type of event (BABYLON.ClipboardEventTypes)
  49698. */
  49699. type: number,
  49700. /**
  49701. * Defines the related dom event
  49702. */
  49703. event: ClipboardEvent);
  49704. /**
  49705. * Get the clipboard event's type from the keycode.
  49706. * @param keyCode Defines the keyCode for the current keyboard event.
  49707. * @return {number}
  49708. */
  49709. static GetTypeFromCharacter(keyCode: number): number;
  49710. }
  49711. }
  49712. declare module "babylonjs/Events/index" {
  49713. export * from "babylonjs/Events/keyboardEvents";
  49714. export * from "babylonjs/Events/pointerEvents";
  49715. export * from "babylonjs/Events/clipboardEvents";
  49716. }
  49717. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  49718. import { Scene } from "babylonjs/scene";
  49719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49720. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49721. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49722. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49723. /**
  49724. * Google Daydream controller
  49725. */
  49726. export class DaydreamController extends WebVRController {
  49727. /**
  49728. * Base Url for the controller model.
  49729. */
  49730. static MODEL_BASE_URL: string;
  49731. /**
  49732. * File name for the controller model.
  49733. */
  49734. static MODEL_FILENAME: string;
  49735. /**
  49736. * Gamepad Id prefix used to identify Daydream Controller.
  49737. */
  49738. static readonly GAMEPAD_ID_PREFIX: string;
  49739. /**
  49740. * Creates a new DaydreamController from a gamepad
  49741. * @param vrGamepad the gamepad that the controller should be created from
  49742. */
  49743. constructor(vrGamepad: any);
  49744. /**
  49745. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49746. * @param scene scene in which to add meshes
  49747. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49748. */
  49749. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49750. /**
  49751. * Called once for each button that changed state since the last frame
  49752. * @param buttonIdx Which button index changed
  49753. * @param state New state of the button
  49754. * @param changes Which properties on the state changed since last frame
  49755. */
  49756. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49757. }
  49758. }
  49759. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  49760. import { Scene } from "babylonjs/scene";
  49761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49762. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49763. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49764. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49765. /**
  49766. * Gear VR Controller
  49767. */
  49768. export class GearVRController extends WebVRController {
  49769. /**
  49770. * Base Url for the controller model.
  49771. */
  49772. static MODEL_BASE_URL: string;
  49773. /**
  49774. * File name for the controller model.
  49775. */
  49776. static MODEL_FILENAME: string;
  49777. /**
  49778. * Gamepad Id prefix used to identify this controller.
  49779. */
  49780. static readonly GAMEPAD_ID_PREFIX: string;
  49781. private readonly _buttonIndexToObservableNameMap;
  49782. /**
  49783. * Creates a new GearVRController from a gamepad
  49784. * @param vrGamepad the gamepad that the controller should be created from
  49785. */
  49786. constructor(vrGamepad: any);
  49787. /**
  49788. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49789. * @param scene scene in which to add meshes
  49790. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49791. */
  49792. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49793. /**
  49794. * Called once for each button that changed state since the last frame
  49795. * @param buttonIdx Which button index changed
  49796. * @param state New state of the button
  49797. * @param changes Which properties on the state changed since last frame
  49798. */
  49799. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49800. }
  49801. }
  49802. declare module "babylonjs/Gamepads/Controllers/genericController" {
  49803. import { Scene } from "babylonjs/scene";
  49804. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49805. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49806. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49807. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49808. /**
  49809. * Generic Controller
  49810. */
  49811. export class GenericController extends WebVRController {
  49812. /**
  49813. * Base Url for the controller model.
  49814. */
  49815. static readonly MODEL_BASE_URL: string;
  49816. /**
  49817. * File name for the controller model.
  49818. */
  49819. static readonly MODEL_FILENAME: string;
  49820. /**
  49821. * Creates a new GenericController from a gamepad
  49822. * @param vrGamepad the gamepad that the controller should be created from
  49823. */
  49824. constructor(vrGamepad: any);
  49825. /**
  49826. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49827. * @param scene scene in which to add meshes
  49828. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49829. */
  49830. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49831. /**
  49832. * Called once for each button that changed state since the last frame
  49833. * @param buttonIdx Which button index changed
  49834. * @param state New state of the button
  49835. * @param changes Which properties on the state changed since last frame
  49836. */
  49837. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49838. }
  49839. }
  49840. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  49841. import { Observable } from "babylonjs/Misc/observable";
  49842. import { Scene } from "babylonjs/scene";
  49843. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49844. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49845. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49846. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49847. /**
  49848. * Oculus Touch Controller
  49849. */
  49850. export class OculusTouchController extends WebVRController {
  49851. /**
  49852. * Base Url for the controller model.
  49853. */
  49854. static MODEL_BASE_URL: string;
  49855. /**
  49856. * File name for the left controller model.
  49857. */
  49858. static MODEL_LEFT_FILENAME: string;
  49859. /**
  49860. * File name for the right controller model.
  49861. */
  49862. static MODEL_RIGHT_FILENAME: string;
  49863. /**
  49864. * Base Url for the Quest controller model.
  49865. */
  49866. static QUEST_MODEL_BASE_URL: string;
  49867. /**
  49868. * @hidden
  49869. * If the controllers are running on a device that needs the updated Quest controller models
  49870. */
  49871. static _IsQuest: boolean;
  49872. /**
  49873. * Fired when the secondary trigger on this controller is modified
  49874. */
  49875. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  49876. /**
  49877. * Fired when the thumb rest on this controller is modified
  49878. */
  49879. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  49880. /**
  49881. * Creates a new OculusTouchController from a gamepad
  49882. * @param vrGamepad the gamepad that the controller should be created from
  49883. */
  49884. constructor(vrGamepad: any);
  49885. /**
  49886. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49887. * @param scene scene in which to add meshes
  49888. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49889. */
  49890. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49891. /**
  49892. * Fired when the A button on this controller is modified
  49893. */
  49894. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49895. /**
  49896. * Fired when the B button on this controller is modified
  49897. */
  49898. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49899. /**
  49900. * Fired when the X button on this controller is modified
  49901. */
  49902. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49903. /**
  49904. * Fired when the Y button on this controller is modified
  49905. */
  49906. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49907. /**
  49908. * Called once for each button that changed state since the last frame
  49909. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  49910. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  49911. * 2) secondary trigger (same)
  49912. * 3) A (right) X (left), touch, pressed = value
  49913. * 4) B / Y
  49914. * 5) thumb rest
  49915. * @param buttonIdx Which button index changed
  49916. * @param state New state of the button
  49917. * @param changes Which properties on the state changed since last frame
  49918. */
  49919. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49920. }
  49921. }
  49922. declare module "babylonjs/Gamepads/Controllers/viveController" {
  49923. import { Scene } from "babylonjs/scene";
  49924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49925. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49926. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49927. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49928. import { Observable } from "babylonjs/Misc/observable";
  49929. /**
  49930. * Vive Controller
  49931. */
  49932. export class ViveController extends WebVRController {
  49933. /**
  49934. * Base Url for the controller model.
  49935. */
  49936. static MODEL_BASE_URL: string;
  49937. /**
  49938. * File name for the controller model.
  49939. */
  49940. static MODEL_FILENAME: string;
  49941. /**
  49942. * Creates a new ViveController from a gamepad
  49943. * @param vrGamepad the gamepad that the controller should be created from
  49944. */
  49945. constructor(vrGamepad: any);
  49946. /**
  49947. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  49948. * @param scene scene in which to add meshes
  49949. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  49950. */
  49951. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  49952. /**
  49953. * Fired when the left button on this controller is modified
  49954. */
  49955. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49956. /**
  49957. * Fired when the right button on this controller is modified
  49958. */
  49959. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49960. /**
  49961. * Fired when the menu button on this controller is modified
  49962. */
  49963. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  49964. /**
  49965. * Called once for each button that changed state since the last frame
  49966. * Vive mapping:
  49967. * 0: touchpad
  49968. * 1: trigger
  49969. * 2: left AND right buttons
  49970. * 3: menu button
  49971. * @param buttonIdx Which button index changed
  49972. * @param state New state of the button
  49973. * @param changes Which properties on the state changed since last frame
  49974. */
  49975. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  49976. }
  49977. }
  49978. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  49979. import { Observable } from "babylonjs/Misc/observable";
  49980. import { Scene } from "babylonjs/scene";
  49981. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49982. import { Ray } from "babylonjs/Culling/ray";
  49983. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  49984. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  49985. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  49986. /**
  49987. * Defines the WindowsMotionController object that the state of the windows motion controller
  49988. */
  49989. export class WindowsMotionController extends WebVRController {
  49990. /**
  49991. * The base url used to load the left and right controller models
  49992. */
  49993. static MODEL_BASE_URL: string;
  49994. /**
  49995. * The name of the left controller model file
  49996. */
  49997. static MODEL_LEFT_FILENAME: string;
  49998. /**
  49999. * The name of the right controller model file
  50000. */
  50001. static MODEL_RIGHT_FILENAME: string;
  50002. /**
  50003. * The controller name prefix for this controller type
  50004. */
  50005. static readonly GAMEPAD_ID_PREFIX: string;
  50006. /**
  50007. * The controller id pattern for this controller type
  50008. */
  50009. private static readonly GAMEPAD_ID_PATTERN;
  50010. private _loadedMeshInfo;
  50011. protected readonly _mapping: {
  50012. buttons: string[];
  50013. buttonMeshNames: {
  50014. 'trigger': string;
  50015. 'menu': string;
  50016. 'grip': string;
  50017. 'thumbstick': string;
  50018. 'trackpad': string;
  50019. };
  50020. buttonObservableNames: {
  50021. 'trigger': string;
  50022. 'menu': string;
  50023. 'grip': string;
  50024. 'thumbstick': string;
  50025. 'trackpad': string;
  50026. };
  50027. axisMeshNames: string[];
  50028. pointingPoseMeshName: string;
  50029. };
  50030. /**
  50031. * Fired when the trackpad on this controller is clicked
  50032. */
  50033. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50034. /**
  50035. * Fired when the trackpad on this controller is modified
  50036. */
  50037. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50038. /**
  50039. * The current x and y values of this controller's trackpad
  50040. */
  50041. trackpad: StickValues;
  50042. /**
  50043. * Creates a new WindowsMotionController from a gamepad
  50044. * @param vrGamepad the gamepad that the controller should be created from
  50045. */
  50046. constructor(vrGamepad: any);
  50047. /**
  50048. * Fired when the trigger on this controller is modified
  50049. */
  50050. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50051. /**
  50052. * Fired when the menu button on this controller is modified
  50053. */
  50054. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50055. /**
  50056. * Fired when the grip button on this controller is modified
  50057. */
  50058. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50059. /**
  50060. * Fired when the thumbstick button on this controller is modified
  50061. */
  50062. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50063. /**
  50064. * Fired when the touchpad button on this controller is modified
  50065. */
  50066. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50067. /**
  50068. * Fired when the touchpad values on this controller are modified
  50069. */
  50070. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50071. protected _updateTrackpad(): void;
  50072. /**
  50073. * Called once per frame by the engine.
  50074. */
  50075. update(): void;
  50076. /**
  50077. * Called once for each button that changed state since the last frame
  50078. * @param buttonIdx Which button index changed
  50079. * @param state New state of the button
  50080. * @param changes Which properties on the state changed since last frame
  50081. */
  50082. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50083. /**
  50084. * Moves the buttons on the controller mesh based on their current state
  50085. * @param buttonName the name of the button to move
  50086. * @param buttonValue the value of the button which determines the buttons new position
  50087. */
  50088. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50089. /**
  50090. * Moves the axis on the controller mesh based on its current state
  50091. * @param axis the index of the axis
  50092. * @param axisValue the value of the axis which determines the meshes new position
  50093. * @hidden
  50094. */
  50095. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50096. /**
  50097. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50098. * @param scene scene in which to add meshes
  50099. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50100. */
  50101. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50102. /**
  50103. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50104. * can be transformed by button presses and axes values, based on this._mapping.
  50105. *
  50106. * @param scene scene in which the meshes exist
  50107. * @param meshes list of meshes that make up the controller model to process
  50108. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50109. */
  50110. private processModel;
  50111. private createMeshInfo;
  50112. /**
  50113. * Gets the ray of the controller in the direction the controller is pointing
  50114. * @param length the length the resulting ray should be
  50115. * @returns a ray in the direction the controller is pointing
  50116. */
  50117. getForwardRay(length?: number): Ray;
  50118. /**
  50119. * Disposes of the controller
  50120. */
  50121. dispose(): void;
  50122. }
  50123. /**
  50124. * This class represents a new windows motion controller in XR.
  50125. */
  50126. export class XRWindowsMotionController extends WindowsMotionController {
  50127. /**
  50128. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50129. */
  50130. protected readonly _mapping: {
  50131. buttons: string[];
  50132. buttonMeshNames: {
  50133. 'trigger': string;
  50134. 'menu': string;
  50135. 'grip': string;
  50136. 'thumbstick': string;
  50137. 'trackpad': string;
  50138. };
  50139. buttonObservableNames: {
  50140. 'trigger': string;
  50141. 'menu': string;
  50142. 'grip': string;
  50143. 'thumbstick': string;
  50144. 'trackpad': string;
  50145. };
  50146. axisMeshNames: string[];
  50147. pointingPoseMeshName: string;
  50148. };
  50149. /**
  50150. * Construct a new XR-Based windows motion controller
  50151. *
  50152. * @param gamepadInfo the gamepad object from the browser
  50153. */
  50154. constructor(gamepadInfo: any);
  50155. /**
  50156. * holds the thumbstick values (X,Y)
  50157. */
  50158. thumbstickValues: StickValues;
  50159. /**
  50160. * Fired when the thumbstick on this controller is clicked
  50161. */
  50162. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50163. /**
  50164. * Fired when the thumbstick on this controller is modified
  50165. */
  50166. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50167. /**
  50168. * Fired when the touchpad button on this controller is modified
  50169. */
  50170. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50171. /**
  50172. * Fired when the touchpad values on this controller are modified
  50173. */
  50174. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50175. /**
  50176. * Fired when the thumbstick button on this controller is modified
  50177. * here to prevent breaking changes
  50178. */
  50179. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50180. /**
  50181. * updating the thumbstick(!) and not the trackpad.
  50182. * This is named this way due to the difference between WebVR and XR and to avoid
  50183. * changing the parent class.
  50184. */
  50185. protected _updateTrackpad(): void;
  50186. /**
  50187. * Disposes the class with joy
  50188. */
  50189. dispose(): void;
  50190. }
  50191. }
  50192. declare module "babylonjs/Gamepads/Controllers/index" {
  50193. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50194. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50195. export * from "babylonjs/Gamepads/Controllers/genericController";
  50196. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50197. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50198. export * from "babylonjs/Gamepads/Controllers/viveController";
  50199. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50200. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50201. }
  50202. declare module "babylonjs/Gamepads/index" {
  50203. export * from "babylonjs/Gamepads/Controllers/index";
  50204. export * from "babylonjs/Gamepads/gamepad";
  50205. export * from "babylonjs/Gamepads/gamepadManager";
  50206. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50207. export * from "babylonjs/Gamepads/xboxGamepad";
  50208. export * from "babylonjs/Gamepads/dualShockGamepad";
  50209. }
  50210. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50211. import { Scene } from "babylonjs/scene";
  50212. import { Vector4 } from "babylonjs/Maths/math.vector";
  50213. import { Color4 } from "babylonjs/Maths/math.color";
  50214. import { Mesh } from "babylonjs/Meshes/mesh";
  50215. import { Nullable } from "babylonjs/types";
  50216. /**
  50217. * Class containing static functions to help procedurally build meshes
  50218. */
  50219. export class PolyhedronBuilder {
  50220. /**
  50221. * Creates a polyhedron mesh
  50222. * * 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
  50223. * * The parameter `size` (positive float, default 1) sets the polygon size
  50224. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50225. * * 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`
  50226. * * 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
  50227. * * 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)`)
  50228. * * 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
  50229. * * 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
  50230. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50231. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50232. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50233. * @param name defines the name of the mesh
  50234. * @param options defines the options used to create the mesh
  50235. * @param scene defines the hosting scene
  50236. * @returns the polyhedron mesh
  50237. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50238. */
  50239. static CreatePolyhedron(name: string, options: {
  50240. type?: number;
  50241. size?: number;
  50242. sizeX?: number;
  50243. sizeY?: number;
  50244. sizeZ?: number;
  50245. custom?: any;
  50246. faceUV?: Vector4[];
  50247. faceColors?: Color4[];
  50248. flat?: boolean;
  50249. updatable?: boolean;
  50250. sideOrientation?: number;
  50251. frontUVs?: Vector4;
  50252. backUVs?: Vector4;
  50253. }, scene?: Nullable<Scene>): Mesh;
  50254. }
  50255. }
  50256. declare module "babylonjs/Gizmos/scaleGizmo" {
  50257. import { Observable } from "babylonjs/Misc/observable";
  50258. import { Nullable } from "babylonjs/types";
  50259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50260. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50261. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50262. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50263. /**
  50264. * Gizmo that enables scaling a mesh along 3 axis
  50265. */
  50266. export class ScaleGizmo extends Gizmo {
  50267. /**
  50268. * Internal gizmo used for interactions on the x axis
  50269. */
  50270. xGizmo: AxisScaleGizmo;
  50271. /**
  50272. * Internal gizmo used for interactions on the y axis
  50273. */
  50274. yGizmo: AxisScaleGizmo;
  50275. /**
  50276. * Internal gizmo used for interactions on the z axis
  50277. */
  50278. zGizmo: AxisScaleGizmo;
  50279. /**
  50280. * Internal gizmo used to scale all axis equally
  50281. */
  50282. uniformScaleGizmo: AxisScaleGizmo;
  50283. private _meshAttached;
  50284. private _updateGizmoRotationToMatchAttachedMesh;
  50285. private _snapDistance;
  50286. private _scaleRatio;
  50287. private _uniformScalingMesh;
  50288. private _octahedron;
  50289. private _sensitivity;
  50290. /** Fires an event when any of it's sub gizmos are dragged */
  50291. onDragStartObservable: Observable<unknown>;
  50292. /** Fires an event when any of it's sub gizmos are released from dragging */
  50293. onDragEndObservable: Observable<unknown>;
  50294. get attachedMesh(): Nullable<AbstractMesh>;
  50295. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50296. /**
  50297. * Creates a ScaleGizmo
  50298. * @param gizmoLayer The utility layer the gizmo will be added to
  50299. */
  50300. constructor(gizmoLayer?: UtilityLayerRenderer);
  50301. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50302. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50303. /**
  50304. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50305. */
  50306. set snapDistance(value: number);
  50307. get snapDistance(): number;
  50308. /**
  50309. * Ratio for the scale of the gizmo (Default: 1)
  50310. */
  50311. set scaleRatio(value: number);
  50312. get scaleRatio(): number;
  50313. /**
  50314. * Sensitivity factor for dragging (Default: 1)
  50315. */
  50316. set sensitivity(value: number);
  50317. get sensitivity(): number;
  50318. /**
  50319. * Disposes of the gizmo
  50320. */
  50321. dispose(): void;
  50322. }
  50323. }
  50324. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50325. import { Observable } from "babylonjs/Misc/observable";
  50326. import { Nullable } from "babylonjs/types";
  50327. import { Vector3 } from "babylonjs/Maths/math.vector";
  50328. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50329. import { Mesh } from "babylonjs/Meshes/mesh";
  50330. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50331. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50332. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50333. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50334. import { Color3 } from "babylonjs/Maths/math.color";
  50335. /**
  50336. * Single axis scale gizmo
  50337. */
  50338. export class AxisScaleGizmo extends Gizmo {
  50339. /**
  50340. * Drag behavior responsible for the gizmos dragging interactions
  50341. */
  50342. dragBehavior: PointerDragBehavior;
  50343. private _pointerObserver;
  50344. /**
  50345. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50346. */
  50347. snapDistance: number;
  50348. /**
  50349. * Event that fires each time the gizmo snaps to a new location.
  50350. * * snapDistance is the the change in distance
  50351. */
  50352. onSnapObservable: Observable<{
  50353. snapDistance: number;
  50354. }>;
  50355. /**
  50356. * If the scaling operation should be done on all axis (default: false)
  50357. */
  50358. uniformScaling: boolean;
  50359. /**
  50360. * Custom sensitivity value for the drag strength
  50361. */
  50362. sensitivity: number;
  50363. private _isEnabled;
  50364. private _parent;
  50365. private _arrow;
  50366. private _coloredMaterial;
  50367. private _hoverMaterial;
  50368. /**
  50369. * Creates an AxisScaleGizmo
  50370. * @param gizmoLayer The utility layer the gizmo will be added to
  50371. * @param dragAxis The axis which the gizmo will be able to scale on
  50372. * @param color The color of the gizmo
  50373. */
  50374. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50375. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50376. /**
  50377. * If the gizmo is enabled
  50378. */
  50379. set isEnabled(value: boolean);
  50380. get isEnabled(): boolean;
  50381. /**
  50382. * Disposes of the gizmo
  50383. */
  50384. dispose(): void;
  50385. /**
  50386. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50387. * @param mesh The mesh to replace the default mesh of the gizmo
  50388. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50389. */
  50390. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50391. }
  50392. }
  50393. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50394. import { Observable } from "babylonjs/Misc/observable";
  50395. import { Nullable } from "babylonjs/types";
  50396. import { Vector3 } from "babylonjs/Maths/math.vector";
  50397. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50398. import { Mesh } from "babylonjs/Meshes/mesh";
  50399. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50400. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50401. import { Color3 } from "babylonjs/Maths/math.color";
  50402. import "babylonjs/Meshes/Builders/boxBuilder";
  50403. /**
  50404. * Bounding box gizmo
  50405. */
  50406. export class BoundingBoxGizmo extends Gizmo {
  50407. private _lineBoundingBox;
  50408. private _rotateSpheresParent;
  50409. private _scaleBoxesParent;
  50410. private _boundingDimensions;
  50411. private _renderObserver;
  50412. private _pointerObserver;
  50413. private _scaleDragSpeed;
  50414. private _tmpQuaternion;
  50415. private _tmpVector;
  50416. private _tmpRotationMatrix;
  50417. /**
  50418. * 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)
  50419. */
  50420. ignoreChildren: boolean;
  50421. /**
  50422. * 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)
  50423. */
  50424. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50425. /**
  50426. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50427. */
  50428. rotationSphereSize: number;
  50429. /**
  50430. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50431. */
  50432. scaleBoxSize: number;
  50433. /**
  50434. * 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)
  50435. */
  50436. fixedDragMeshScreenSize: boolean;
  50437. /**
  50438. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50439. */
  50440. fixedDragMeshScreenSizeDistanceFactor: number;
  50441. /**
  50442. * Fired when a rotation sphere or scale box is dragged
  50443. */
  50444. onDragStartObservable: Observable<{}>;
  50445. /**
  50446. * Fired when a scale box is dragged
  50447. */
  50448. onScaleBoxDragObservable: Observable<{}>;
  50449. /**
  50450. * Fired when a scale box drag is ended
  50451. */
  50452. onScaleBoxDragEndObservable: Observable<{}>;
  50453. /**
  50454. * Fired when a rotation sphere is dragged
  50455. */
  50456. onRotationSphereDragObservable: Observable<{}>;
  50457. /**
  50458. * Fired when a rotation sphere drag is ended
  50459. */
  50460. onRotationSphereDragEndObservable: Observable<{}>;
  50461. /**
  50462. * 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)
  50463. */
  50464. scalePivot: Nullable<Vector3>;
  50465. /**
  50466. * Mesh used as a pivot to rotate the attached mesh
  50467. */
  50468. private _anchorMesh;
  50469. private _existingMeshScale;
  50470. private _dragMesh;
  50471. private pointerDragBehavior;
  50472. private coloredMaterial;
  50473. private hoverColoredMaterial;
  50474. /**
  50475. * Sets the color of the bounding box gizmo
  50476. * @param color the color to set
  50477. */
  50478. setColor(color: Color3): void;
  50479. /**
  50480. * Creates an BoundingBoxGizmo
  50481. * @param gizmoLayer The utility layer the gizmo will be added to
  50482. * @param color The color of the gizmo
  50483. */
  50484. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50485. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50486. private _selectNode;
  50487. /**
  50488. * Updates the bounding box information for the Gizmo
  50489. */
  50490. updateBoundingBox(): void;
  50491. private _updateRotationSpheres;
  50492. private _updateScaleBoxes;
  50493. /**
  50494. * Enables rotation on the specified axis and disables rotation on the others
  50495. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50496. */
  50497. setEnabledRotationAxis(axis: string): void;
  50498. /**
  50499. * Enables/disables scaling
  50500. * @param enable if scaling should be enabled
  50501. */
  50502. setEnabledScaling(enable: boolean): void;
  50503. private _updateDummy;
  50504. /**
  50505. * Enables a pointer drag behavior on the bounding box of the gizmo
  50506. */
  50507. enableDragBehavior(): void;
  50508. /**
  50509. * Disposes of the gizmo
  50510. */
  50511. dispose(): void;
  50512. /**
  50513. * 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)
  50514. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50515. * @returns the bounding box mesh with the passed in mesh as a child
  50516. */
  50517. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50518. /**
  50519. * CustomMeshes are not supported by this gizmo
  50520. * @param mesh The mesh to replace the default mesh of the gizmo
  50521. */
  50522. setCustomMesh(mesh: Mesh): void;
  50523. }
  50524. }
  50525. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50526. import { Observable } from "babylonjs/Misc/observable";
  50527. import { Nullable } from "babylonjs/types";
  50528. import { Vector3 } from "babylonjs/Maths/math.vector";
  50529. import { Color3 } from "babylonjs/Maths/math.color";
  50530. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50531. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50532. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50533. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50534. import "babylonjs/Meshes/Builders/linesBuilder";
  50535. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50536. /**
  50537. * Single plane rotation gizmo
  50538. */
  50539. export class PlaneRotationGizmo extends Gizmo {
  50540. /**
  50541. * Drag behavior responsible for the gizmos dragging interactions
  50542. */
  50543. dragBehavior: PointerDragBehavior;
  50544. private _pointerObserver;
  50545. /**
  50546. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  50547. */
  50548. snapDistance: number;
  50549. /**
  50550. * Event that fires each time the gizmo snaps to a new location.
  50551. * * snapDistance is the the change in distance
  50552. */
  50553. onSnapObservable: Observable<{
  50554. snapDistance: number;
  50555. }>;
  50556. private _isEnabled;
  50557. private _parent;
  50558. /**
  50559. * Creates a PlaneRotationGizmo
  50560. * @param gizmoLayer The utility layer the gizmo will be added to
  50561. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  50562. * @param color The color of the gizmo
  50563. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50564. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50565. */
  50566. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  50567. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50568. /**
  50569. * If the gizmo is enabled
  50570. */
  50571. set isEnabled(value: boolean);
  50572. get isEnabled(): boolean;
  50573. /**
  50574. * Disposes of the gizmo
  50575. */
  50576. dispose(): void;
  50577. }
  50578. }
  50579. declare module "babylonjs/Gizmos/rotationGizmo" {
  50580. import { Observable } from "babylonjs/Misc/observable";
  50581. import { Nullable } from "babylonjs/types";
  50582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50583. import { Mesh } from "babylonjs/Meshes/mesh";
  50584. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50585. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  50586. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50587. /**
  50588. * Gizmo that enables rotating a mesh along 3 axis
  50589. */
  50590. export class RotationGizmo extends Gizmo {
  50591. /**
  50592. * Internal gizmo used for interactions on the x axis
  50593. */
  50594. xGizmo: PlaneRotationGizmo;
  50595. /**
  50596. * Internal gizmo used for interactions on the y axis
  50597. */
  50598. yGizmo: PlaneRotationGizmo;
  50599. /**
  50600. * Internal gizmo used for interactions on the z axis
  50601. */
  50602. zGizmo: PlaneRotationGizmo;
  50603. /** Fires an event when any of it's sub gizmos are dragged */
  50604. onDragStartObservable: Observable<unknown>;
  50605. /** Fires an event when any of it's sub gizmos are released from dragging */
  50606. onDragEndObservable: Observable<unknown>;
  50607. private _meshAttached;
  50608. get attachedMesh(): Nullable<AbstractMesh>;
  50609. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50610. /**
  50611. * Creates a RotationGizmo
  50612. * @param gizmoLayer The utility layer the gizmo will be added to
  50613. * @param tessellation Amount of tessellation to be used when creating rotation circles
  50614. * @param useEulerRotation Use and update Euler angle instead of quaternion
  50615. */
  50616. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  50617. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50618. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50619. /**
  50620. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50621. */
  50622. set snapDistance(value: number);
  50623. get snapDistance(): number;
  50624. /**
  50625. * Ratio for the scale of the gizmo (Default: 1)
  50626. */
  50627. set scaleRatio(value: number);
  50628. get scaleRatio(): number;
  50629. /**
  50630. * Disposes of the gizmo
  50631. */
  50632. dispose(): void;
  50633. /**
  50634. * CustomMeshes are not supported by this gizmo
  50635. * @param mesh The mesh to replace the default mesh of the gizmo
  50636. */
  50637. setCustomMesh(mesh: Mesh): void;
  50638. }
  50639. }
  50640. declare module "babylonjs/Gizmos/gizmoManager" {
  50641. import { Observable } from "babylonjs/Misc/observable";
  50642. import { Nullable } from "babylonjs/types";
  50643. import { Scene, IDisposable } from "babylonjs/scene";
  50644. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50645. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50646. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  50647. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50648. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  50649. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50650. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  50651. /**
  50652. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  50653. */
  50654. export class GizmoManager implements IDisposable {
  50655. private scene;
  50656. /**
  50657. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  50658. */
  50659. gizmos: {
  50660. positionGizmo: Nullable<PositionGizmo>;
  50661. rotationGizmo: Nullable<RotationGizmo>;
  50662. scaleGizmo: Nullable<ScaleGizmo>;
  50663. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  50664. };
  50665. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  50666. clearGizmoOnEmptyPointerEvent: boolean;
  50667. /** Fires an event when the manager is attached to a mesh */
  50668. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  50669. private _gizmosEnabled;
  50670. private _pointerObserver;
  50671. private _attachedMesh;
  50672. private _boundingBoxColor;
  50673. private _defaultUtilityLayer;
  50674. private _defaultKeepDepthUtilityLayer;
  50675. /**
  50676. * When bounding box gizmo is enabled, this can be used to track drag/end events
  50677. */
  50678. boundingBoxDragBehavior: SixDofDragBehavior;
  50679. /**
  50680. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  50681. */
  50682. attachableMeshes: Nullable<Array<AbstractMesh>>;
  50683. /**
  50684. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  50685. */
  50686. usePointerToAttachGizmos: boolean;
  50687. /**
  50688. * Utility layer that the bounding box gizmo belongs to
  50689. */
  50690. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  50691. /**
  50692. * Utility layer that all gizmos besides bounding box belong to
  50693. */
  50694. get utilityLayer(): UtilityLayerRenderer;
  50695. /**
  50696. * Instatiates a gizmo manager
  50697. * @param scene the scene to overlay the gizmos on top of
  50698. */
  50699. constructor(scene: Scene);
  50700. /**
  50701. * Attaches a set of gizmos to the specified mesh
  50702. * @param mesh The mesh the gizmo's should be attached to
  50703. */
  50704. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50705. /**
  50706. * If the position gizmo is enabled
  50707. */
  50708. set positionGizmoEnabled(value: boolean);
  50709. get positionGizmoEnabled(): boolean;
  50710. /**
  50711. * If the rotation gizmo is enabled
  50712. */
  50713. set rotationGizmoEnabled(value: boolean);
  50714. get rotationGizmoEnabled(): boolean;
  50715. /**
  50716. * If the scale gizmo is enabled
  50717. */
  50718. set scaleGizmoEnabled(value: boolean);
  50719. get scaleGizmoEnabled(): boolean;
  50720. /**
  50721. * If the boundingBox gizmo is enabled
  50722. */
  50723. set boundingBoxGizmoEnabled(value: boolean);
  50724. get boundingBoxGizmoEnabled(): boolean;
  50725. /**
  50726. * Disposes of the gizmo manager
  50727. */
  50728. dispose(): void;
  50729. }
  50730. }
  50731. declare module "babylonjs/Lights/directionalLight" {
  50732. import { Camera } from "babylonjs/Cameras/camera";
  50733. import { Scene } from "babylonjs/scene";
  50734. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50736. import { Light } from "babylonjs/Lights/light";
  50737. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50738. import { Effect } from "babylonjs/Materials/effect";
  50739. /**
  50740. * A directional light is defined by a direction (what a surprise!).
  50741. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  50742. * 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.
  50743. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50744. */
  50745. export class DirectionalLight extends ShadowLight {
  50746. private _shadowFrustumSize;
  50747. /**
  50748. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  50749. */
  50750. get shadowFrustumSize(): number;
  50751. /**
  50752. * Specifies a fix frustum size for the shadow generation.
  50753. */
  50754. set shadowFrustumSize(value: number);
  50755. private _shadowOrthoScale;
  50756. /**
  50757. * Gets the shadow projection scale against the optimal computed one.
  50758. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50759. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50760. */
  50761. get shadowOrthoScale(): number;
  50762. /**
  50763. * Sets the shadow projection scale against the optimal computed one.
  50764. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  50765. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  50766. */
  50767. set shadowOrthoScale(value: number);
  50768. /**
  50769. * Automatically compute the projection matrix to best fit (including all the casters)
  50770. * on each frame.
  50771. */
  50772. autoUpdateExtends: boolean;
  50773. /**
  50774. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  50775. * on each frame. autoUpdateExtends must be set to true for this to work
  50776. */
  50777. autoCalcShadowZBounds: boolean;
  50778. private _orthoLeft;
  50779. private _orthoRight;
  50780. private _orthoTop;
  50781. private _orthoBottom;
  50782. /**
  50783. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  50784. * The directional light is emitted from everywhere in the given direction.
  50785. * It can cast shadows.
  50786. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50787. * @param name The friendly name of the light
  50788. * @param direction The direction of the light
  50789. * @param scene The scene the light belongs to
  50790. */
  50791. constructor(name: string, direction: Vector3, scene: Scene);
  50792. /**
  50793. * Returns the string "DirectionalLight".
  50794. * @return The class name
  50795. */
  50796. getClassName(): string;
  50797. /**
  50798. * Returns the integer 1.
  50799. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50800. */
  50801. getTypeID(): number;
  50802. /**
  50803. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  50804. * Returns the DirectionalLight Shadow projection matrix.
  50805. */
  50806. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50807. /**
  50808. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  50809. * Returns the DirectionalLight Shadow projection matrix.
  50810. */
  50811. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  50812. /**
  50813. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  50814. * Returns the DirectionalLight Shadow projection matrix.
  50815. */
  50816. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50817. protected _buildUniformLayout(): void;
  50818. /**
  50819. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  50820. * @param effect The effect to update
  50821. * @param lightIndex The index of the light in the effect to update
  50822. * @returns The directional light
  50823. */
  50824. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  50825. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  50826. /**
  50827. * Gets the minZ used for shadow according to both the scene and the light.
  50828. *
  50829. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50830. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50831. * @param activeCamera The camera we are returning the min for
  50832. * @returns the depth min z
  50833. */
  50834. getDepthMinZ(activeCamera: Camera): number;
  50835. /**
  50836. * Gets the maxZ used for shadow according to both the scene and the light.
  50837. *
  50838. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  50839. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  50840. * @param activeCamera The camera we are returning the max for
  50841. * @returns the depth max z
  50842. */
  50843. getDepthMaxZ(activeCamera: Camera): number;
  50844. /**
  50845. * Prepares the list of defines specific to the light type.
  50846. * @param defines the list of defines
  50847. * @param lightIndex defines the index of the light for the effect
  50848. */
  50849. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50850. }
  50851. }
  50852. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  50853. import { Mesh } from "babylonjs/Meshes/mesh";
  50854. /**
  50855. * Class containing static functions to help procedurally build meshes
  50856. */
  50857. export class HemisphereBuilder {
  50858. /**
  50859. * Creates a hemisphere mesh
  50860. * @param name defines the name of the mesh
  50861. * @param options defines the options used to create the mesh
  50862. * @param scene defines the hosting scene
  50863. * @returns the hemisphere mesh
  50864. */
  50865. static CreateHemisphere(name: string, options: {
  50866. segments?: number;
  50867. diameter?: number;
  50868. sideOrientation?: number;
  50869. }, scene: any): Mesh;
  50870. }
  50871. }
  50872. declare module "babylonjs/Lights/spotLight" {
  50873. import { Nullable } from "babylonjs/types";
  50874. import { Scene } from "babylonjs/scene";
  50875. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  50876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50877. import { Effect } from "babylonjs/Materials/effect";
  50878. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50879. import { Light } from "babylonjs/Lights/light";
  50880. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50881. /**
  50882. * A spot light is defined by a position, a direction, an angle, and an exponent.
  50883. * These values define a cone of light starting from the position, emitting toward the direction.
  50884. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  50885. * and the exponent defines the speed of the decay of the light with distance (reach).
  50886. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50887. */
  50888. export class SpotLight extends ShadowLight {
  50889. private _angle;
  50890. private _innerAngle;
  50891. private _cosHalfAngle;
  50892. private _lightAngleScale;
  50893. private _lightAngleOffset;
  50894. /**
  50895. * Gets the cone angle of the spot light in Radians.
  50896. */
  50897. get angle(): number;
  50898. /**
  50899. * Sets the cone angle of the spot light in Radians.
  50900. */
  50901. set angle(value: number);
  50902. /**
  50903. * Only used in gltf falloff mode, this defines the angle where
  50904. * the directional falloff will start before cutting at angle which could be seen
  50905. * as outer angle.
  50906. */
  50907. get innerAngle(): number;
  50908. /**
  50909. * Only used in gltf falloff mode, this defines the angle where
  50910. * the directional falloff will start before cutting at angle which could be seen
  50911. * as outer angle.
  50912. */
  50913. set innerAngle(value: number);
  50914. private _shadowAngleScale;
  50915. /**
  50916. * Allows scaling the angle of the light for shadow generation only.
  50917. */
  50918. get shadowAngleScale(): number;
  50919. /**
  50920. * Allows scaling the angle of the light for shadow generation only.
  50921. */
  50922. set shadowAngleScale(value: number);
  50923. /**
  50924. * The light decay speed with the distance from the emission spot.
  50925. */
  50926. exponent: number;
  50927. private _projectionTextureMatrix;
  50928. /**
  50929. * Allows reading the projecton texture
  50930. */
  50931. get projectionTextureMatrix(): Matrix;
  50932. protected _projectionTextureLightNear: number;
  50933. /**
  50934. * Gets the near clip of the Spotlight for texture projection.
  50935. */
  50936. get projectionTextureLightNear(): number;
  50937. /**
  50938. * Sets the near clip of the Spotlight for texture projection.
  50939. */
  50940. set projectionTextureLightNear(value: number);
  50941. protected _projectionTextureLightFar: number;
  50942. /**
  50943. * Gets the far clip of the Spotlight for texture projection.
  50944. */
  50945. get projectionTextureLightFar(): number;
  50946. /**
  50947. * Sets the far clip of the Spotlight for texture projection.
  50948. */
  50949. set projectionTextureLightFar(value: number);
  50950. protected _projectionTextureUpDirection: Vector3;
  50951. /**
  50952. * Gets the Up vector of the Spotlight for texture projection.
  50953. */
  50954. get projectionTextureUpDirection(): Vector3;
  50955. /**
  50956. * Sets the Up vector of the Spotlight for texture projection.
  50957. */
  50958. set projectionTextureUpDirection(value: Vector3);
  50959. private _projectionTexture;
  50960. /**
  50961. * Gets the projection texture of the light.
  50962. */
  50963. get projectionTexture(): Nullable<BaseTexture>;
  50964. /**
  50965. * Sets the projection texture of the light.
  50966. */
  50967. set projectionTexture(value: Nullable<BaseTexture>);
  50968. private _projectionTextureViewLightDirty;
  50969. private _projectionTextureProjectionLightDirty;
  50970. private _projectionTextureDirty;
  50971. private _projectionTextureViewTargetVector;
  50972. private _projectionTextureViewLightMatrix;
  50973. private _projectionTextureProjectionLightMatrix;
  50974. private _projectionTextureScalingMatrix;
  50975. /**
  50976. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  50977. * It can cast shadows.
  50978. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50979. * @param name The light friendly name
  50980. * @param position The position of the spot light in the scene
  50981. * @param direction The direction of the light in the scene
  50982. * @param angle The cone angle of the light in Radians
  50983. * @param exponent The light decay speed with the distance from the emission spot
  50984. * @param scene The scene the lights belongs to
  50985. */
  50986. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  50987. /**
  50988. * Returns the string "SpotLight".
  50989. * @returns the class name
  50990. */
  50991. getClassName(): string;
  50992. /**
  50993. * Returns the integer 2.
  50994. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50995. */
  50996. getTypeID(): number;
  50997. /**
  50998. * Overrides the direction setter to recompute the projection texture view light Matrix.
  50999. */
  51000. protected _setDirection(value: Vector3): void;
  51001. /**
  51002. * Overrides the position setter to recompute the projection texture view light Matrix.
  51003. */
  51004. protected _setPosition(value: Vector3): void;
  51005. /**
  51006. * 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.
  51007. * Returns the SpotLight.
  51008. */
  51009. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51010. protected _computeProjectionTextureViewLightMatrix(): void;
  51011. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51012. /**
  51013. * Main function for light texture projection matrix computing.
  51014. */
  51015. protected _computeProjectionTextureMatrix(): void;
  51016. protected _buildUniformLayout(): void;
  51017. private _computeAngleValues;
  51018. /**
  51019. * Sets the passed Effect "effect" with the Light textures.
  51020. * @param effect The effect to update
  51021. * @param lightIndex The index of the light in the effect to update
  51022. * @returns The light
  51023. */
  51024. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51025. /**
  51026. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51027. * @param effect The effect to update
  51028. * @param lightIndex The index of the light in the effect to update
  51029. * @returns The spot light
  51030. */
  51031. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51032. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51033. /**
  51034. * Disposes the light and the associated resources.
  51035. */
  51036. dispose(): void;
  51037. /**
  51038. * Prepares the list of defines specific to the light type.
  51039. * @param defines the list of defines
  51040. * @param lightIndex defines the index of the light for the effect
  51041. */
  51042. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51043. }
  51044. }
  51045. declare module "babylonjs/Gizmos/lightGizmo" {
  51046. import { Nullable } from "babylonjs/types";
  51047. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51048. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51049. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51050. import { Light } from "babylonjs/Lights/light";
  51051. /**
  51052. * Gizmo that enables viewing a light
  51053. */
  51054. export class LightGizmo extends Gizmo {
  51055. private _lightMesh;
  51056. private _material;
  51057. private _cachedPosition;
  51058. private _cachedForward;
  51059. private _attachedMeshParent;
  51060. /**
  51061. * Creates a LightGizmo
  51062. * @param gizmoLayer The utility layer the gizmo will be added to
  51063. */
  51064. constructor(gizmoLayer?: UtilityLayerRenderer);
  51065. private _light;
  51066. /**
  51067. * The light that the gizmo is attached to
  51068. */
  51069. set light(light: Nullable<Light>);
  51070. get light(): Nullable<Light>;
  51071. /**
  51072. * Gets the material used to render the light gizmo
  51073. */
  51074. get material(): StandardMaterial;
  51075. /**
  51076. * @hidden
  51077. * Updates the gizmo to match the attached mesh's position/rotation
  51078. */
  51079. protected _update(): void;
  51080. private static _Scale;
  51081. /**
  51082. * Creates the lines for a light mesh
  51083. */
  51084. private static _CreateLightLines;
  51085. /**
  51086. * Disposes of the light gizmo
  51087. */
  51088. dispose(): void;
  51089. private static _CreateHemisphericLightMesh;
  51090. private static _CreatePointLightMesh;
  51091. private static _CreateSpotLightMesh;
  51092. private static _CreateDirectionalLightMesh;
  51093. }
  51094. }
  51095. declare module "babylonjs/Gizmos/index" {
  51096. export * from "babylonjs/Gizmos/axisDragGizmo";
  51097. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51098. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51099. export * from "babylonjs/Gizmos/gizmo";
  51100. export * from "babylonjs/Gizmos/gizmoManager";
  51101. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51102. export * from "babylonjs/Gizmos/positionGizmo";
  51103. export * from "babylonjs/Gizmos/rotationGizmo";
  51104. export * from "babylonjs/Gizmos/scaleGizmo";
  51105. export * from "babylonjs/Gizmos/lightGizmo";
  51106. export * from "babylonjs/Gizmos/planeDragGizmo";
  51107. }
  51108. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51109. /** @hidden */
  51110. export var backgroundFragmentDeclaration: {
  51111. name: string;
  51112. shader: string;
  51113. };
  51114. }
  51115. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51116. /** @hidden */
  51117. export var backgroundUboDeclaration: {
  51118. name: string;
  51119. shader: string;
  51120. };
  51121. }
  51122. declare module "babylonjs/Shaders/background.fragment" {
  51123. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51124. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51125. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51126. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51127. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51128. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51129. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51130. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51131. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51132. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51133. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51134. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51135. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51136. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51137. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51138. /** @hidden */
  51139. export var backgroundPixelShader: {
  51140. name: string;
  51141. shader: string;
  51142. };
  51143. }
  51144. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51145. /** @hidden */
  51146. export var backgroundVertexDeclaration: {
  51147. name: string;
  51148. shader: string;
  51149. };
  51150. }
  51151. declare module "babylonjs/Shaders/background.vertex" {
  51152. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51153. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51154. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51155. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51156. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51157. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51158. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51159. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51160. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51161. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51162. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51163. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51164. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51165. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51166. /** @hidden */
  51167. export var backgroundVertexShader: {
  51168. name: string;
  51169. shader: string;
  51170. };
  51171. }
  51172. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51173. import { Nullable, int, float } from "babylonjs/types";
  51174. import { Scene } from "babylonjs/scene";
  51175. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51176. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51178. import { Mesh } from "babylonjs/Meshes/mesh";
  51179. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51180. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51181. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51182. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51183. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51184. import { Color3 } from "babylonjs/Maths/math.color";
  51185. import "babylonjs/Shaders/background.fragment";
  51186. import "babylonjs/Shaders/background.vertex";
  51187. /**
  51188. * Background material used to create an efficient environement around your scene.
  51189. */
  51190. export class BackgroundMaterial extends PushMaterial {
  51191. /**
  51192. * Standard reflectance value at parallel view angle.
  51193. */
  51194. static StandardReflectance0: number;
  51195. /**
  51196. * Standard reflectance value at grazing angle.
  51197. */
  51198. static StandardReflectance90: number;
  51199. protected _primaryColor: Color3;
  51200. /**
  51201. * Key light Color (multiply against the environement texture)
  51202. */
  51203. primaryColor: Color3;
  51204. protected __perceptualColor: Nullable<Color3>;
  51205. /**
  51206. * Experimental Internal Use Only.
  51207. *
  51208. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51209. * This acts as a helper to set the primary color to a more "human friendly" value.
  51210. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51211. * output color as close as possible from the chosen value.
  51212. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51213. * part of lighting setup.)
  51214. */
  51215. get _perceptualColor(): Nullable<Color3>;
  51216. set _perceptualColor(value: Nullable<Color3>);
  51217. protected _primaryColorShadowLevel: float;
  51218. /**
  51219. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51220. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51221. */
  51222. get primaryColorShadowLevel(): float;
  51223. set primaryColorShadowLevel(value: float);
  51224. protected _primaryColorHighlightLevel: float;
  51225. /**
  51226. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51227. * The primary color is used at the level chosen to define what the white area would look.
  51228. */
  51229. get primaryColorHighlightLevel(): float;
  51230. set primaryColorHighlightLevel(value: float);
  51231. protected _reflectionTexture: Nullable<BaseTexture>;
  51232. /**
  51233. * Reflection Texture used in the material.
  51234. * Should be author in a specific way for the best result (refer to the documentation).
  51235. */
  51236. reflectionTexture: Nullable<BaseTexture>;
  51237. protected _reflectionBlur: float;
  51238. /**
  51239. * Reflection Texture level of blur.
  51240. *
  51241. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51242. * texture twice.
  51243. */
  51244. reflectionBlur: float;
  51245. protected _diffuseTexture: Nullable<BaseTexture>;
  51246. /**
  51247. * Diffuse Texture used in the material.
  51248. * Should be author in a specific way for the best result (refer to the documentation).
  51249. */
  51250. diffuseTexture: Nullable<BaseTexture>;
  51251. protected _shadowLights: Nullable<IShadowLight[]>;
  51252. /**
  51253. * Specify the list of lights casting shadow on the material.
  51254. * All scene shadow lights will be included if null.
  51255. */
  51256. shadowLights: Nullable<IShadowLight[]>;
  51257. protected _shadowLevel: float;
  51258. /**
  51259. * Helps adjusting the shadow to a softer level if required.
  51260. * 0 means black shadows and 1 means no shadows.
  51261. */
  51262. shadowLevel: float;
  51263. protected _sceneCenter: Vector3;
  51264. /**
  51265. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51266. * It is usually zero but might be interesting to modify according to your setup.
  51267. */
  51268. sceneCenter: Vector3;
  51269. protected _opacityFresnel: boolean;
  51270. /**
  51271. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51272. * This helps ensuring a nice transition when the camera goes under the ground.
  51273. */
  51274. opacityFresnel: boolean;
  51275. protected _reflectionFresnel: boolean;
  51276. /**
  51277. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51278. * This helps adding a mirror texture on the ground.
  51279. */
  51280. reflectionFresnel: boolean;
  51281. protected _reflectionFalloffDistance: number;
  51282. /**
  51283. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51284. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51285. */
  51286. reflectionFalloffDistance: number;
  51287. protected _reflectionAmount: number;
  51288. /**
  51289. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51290. */
  51291. reflectionAmount: number;
  51292. protected _reflectionReflectance0: number;
  51293. /**
  51294. * This specifies the weight of the reflection at grazing angle.
  51295. */
  51296. reflectionReflectance0: number;
  51297. protected _reflectionReflectance90: number;
  51298. /**
  51299. * This specifies the weight of the reflection at a perpendicular point of view.
  51300. */
  51301. reflectionReflectance90: number;
  51302. /**
  51303. * Sets the reflection reflectance fresnel values according to the default standard
  51304. * empirically know to work well :-)
  51305. */
  51306. set reflectionStandardFresnelWeight(value: number);
  51307. protected _useRGBColor: boolean;
  51308. /**
  51309. * Helps to directly use the maps channels instead of their level.
  51310. */
  51311. useRGBColor: boolean;
  51312. protected _enableNoise: boolean;
  51313. /**
  51314. * This helps reducing the banding effect that could occur on the background.
  51315. */
  51316. enableNoise: boolean;
  51317. /**
  51318. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51319. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51320. * Recommended to be keep at 1.0 except for special cases.
  51321. */
  51322. get fovMultiplier(): number;
  51323. set fovMultiplier(value: number);
  51324. private _fovMultiplier;
  51325. /**
  51326. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51327. */
  51328. useEquirectangularFOV: boolean;
  51329. private _maxSimultaneousLights;
  51330. /**
  51331. * Number of Simultaneous lights allowed on the material.
  51332. */
  51333. maxSimultaneousLights: int;
  51334. /**
  51335. * Default configuration related to image processing available in the Background Material.
  51336. */
  51337. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51338. /**
  51339. * Keep track of the image processing observer to allow dispose and replace.
  51340. */
  51341. private _imageProcessingObserver;
  51342. /**
  51343. * Attaches a new image processing configuration to the PBR Material.
  51344. * @param configuration (if null the scene configuration will be use)
  51345. */
  51346. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51347. /**
  51348. * Gets the image processing configuration used either in this material.
  51349. */
  51350. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51351. /**
  51352. * Sets the Default image processing configuration used either in the this material.
  51353. *
  51354. * If sets to null, the scene one is in use.
  51355. */
  51356. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51357. /**
  51358. * Gets wether the color curves effect is enabled.
  51359. */
  51360. get cameraColorCurvesEnabled(): boolean;
  51361. /**
  51362. * Sets wether the color curves effect is enabled.
  51363. */
  51364. set cameraColorCurvesEnabled(value: boolean);
  51365. /**
  51366. * Gets wether the color grading effect is enabled.
  51367. */
  51368. get cameraColorGradingEnabled(): boolean;
  51369. /**
  51370. * Gets wether the color grading effect is enabled.
  51371. */
  51372. set cameraColorGradingEnabled(value: boolean);
  51373. /**
  51374. * Gets wether tonemapping is enabled or not.
  51375. */
  51376. get cameraToneMappingEnabled(): boolean;
  51377. /**
  51378. * Sets wether tonemapping is enabled or not
  51379. */
  51380. set cameraToneMappingEnabled(value: boolean);
  51381. /**
  51382. * The camera exposure used on this material.
  51383. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51384. * This corresponds to a photographic exposure.
  51385. */
  51386. get cameraExposure(): float;
  51387. /**
  51388. * The camera exposure used on this material.
  51389. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51390. * This corresponds to a photographic exposure.
  51391. */
  51392. set cameraExposure(value: float);
  51393. /**
  51394. * Gets The camera contrast used on this material.
  51395. */
  51396. get cameraContrast(): float;
  51397. /**
  51398. * Sets The camera contrast used on this material.
  51399. */
  51400. set cameraContrast(value: float);
  51401. /**
  51402. * Gets the Color Grading 2D Lookup Texture.
  51403. */
  51404. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51405. /**
  51406. * Sets the Color Grading 2D Lookup Texture.
  51407. */
  51408. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51409. /**
  51410. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51411. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51412. * 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;
  51413. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51414. */
  51415. get cameraColorCurves(): Nullable<ColorCurves>;
  51416. /**
  51417. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51418. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51419. * 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;
  51420. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51421. */
  51422. set cameraColorCurves(value: Nullable<ColorCurves>);
  51423. /**
  51424. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51425. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51426. */
  51427. switchToBGR: boolean;
  51428. private _renderTargets;
  51429. private _reflectionControls;
  51430. private _white;
  51431. private _primaryShadowColor;
  51432. private _primaryHighlightColor;
  51433. /**
  51434. * Instantiates a Background Material in the given scene
  51435. * @param name The friendly name of the material
  51436. * @param scene The scene to add the material to
  51437. */
  51438. constructor(name: string, scene: Scene);
  51439. /**
  51440. * Gets a boolean indicating that current material needs to register RTT
  51441. */
  51442. get hasRenderTargetTextures(): boolean;
  51443. /**
  51444. * The entire material has been created in order to prevent overdraw.
  51445. * @returns false
  51446. */
  51447. needAlphaTesting(): boolean;
  51448. /**
  51449. * The entire material has been created in order to prevent overdraw.
  51450. * @returns true if blending is enable
  51451. */
  51452. needAlphaBlending(): boolean;
  51453. /**
  51454. * Checks wether the material is ready to be rendered for a given mesh.
  51455. * @param mesh The mesh to render
  51456. * @param subMesh The submesh to check against
  51457. * @param useInstances Specify wether or not the material is used with instances
  51458. * @returns true if all the dependencies are ready (Textures, Effects...)
  51459. */
  51460. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51461. /**
  51462. * Compute the primary color according to the chosen perceptual color.
  51463. */
  51464. private _computePrimaryColorFromPerceptualColor;
  51465. /**
  51466. * Compute the highlights and shadow colors according to their chosen levels.
  51467. */
  51468. private _computePrimaryColors;
  51469. /**
  51470. * Build the uniform buffer used in the material.
  51471. */
  51472. buildUniformLayout(): void;
  51473. /**
  51474. * Unbind the material.
  51475. */
  51476. unbind(): void;
  51477. /**
  51478. * Bind only the world matrix to the material.
  51479. * @param world The world matrix to bind.
  51480. */
  51481. bindOnlyWorldMatrix(world: Matrix): void;
  51482. /**
  51483. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51484. * @param world The world matrix to bind.
  51485. * @param subMesh The submesh to bind for.
  51486. */
  51487. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51488. /**
  51489. * Checks to see if a texture is used in the material.
  51490. * @param texture - Base texture to use.
  51491. * @returns - Boolean specifying if a texture is used in the material.
  51492. */
  51493. hasTexture(texture: BaseTexture): boolean;
  51494. /**
  51495. * Dispose the material.
  51496. * @param forceDisposeEffect Force disposal of the associated effect.
  51497. * @param forceDisposeTextures Force disposal of the associated textures.
  51498. */
  51499. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51500. /**
  51501. * Clones the material.
  51502. * @param name The cloned name.
  51503. * @returns The cloned material.
  51504. */
  51505. clone(name: string): BackgroundMaterial;
  51506. /**
  51507. * Serializes the current material to its JSON representation.
  51508. * @returns The JSON representation.
  51509. */
  51510. serialize(): any;
  51511. /**
  51512. * Gets the class name of the material
  51513. * @returns "BackgroundMaterial"
  51514. */
  51515. getClassName(): string;
  51516. /**
  51517. * Parse a JSON input to create back a background material.
  51518. * @param source The JSON data to parse
  51519. * @param scene The scene to create the parsed material in
  51520. * @param rootUrl The root url of the assets the material depends upon
  51521. * @returns the instantiated BackgroundMaterial.
  51522. */
  51523. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51524. }
  51525. }
  51526. declare module "babylonjs/Helpers/environmentHelper" {
  51527. import { Observable } from "babylonjs/Misc/observable";
  51528. import { Nullable } from "babylonjs/types";
  51529. import { Scene } from "babylonjs/scene";
  51530. import { Vector3 } from "babylonjs/Maths/math.vector";
  51531. import { Color3 } from "babylonjs/Maths/math.color";
  51532. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51533. import { Mesh } from "babylonjs/Meshes/mesh";
  51534. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51535. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51536. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51537. import "babylonjs/Meshes/Builders/planeBuilder";
  51538. import "babylonjs/Meshes/Builders/boxBuilder";
  51539. /**
  51540. * Represents the different options available during the creation of
  51541. * a Environment helper.
  51542. *
  51543. * This can control the default ground, skybox and image processing setup of your scene.
  51544. */
  51545. export interface IEnvironmentHelperOptions {
  51546. /**
  51547. * Specifies whether or not to create a ground.
  51548. * True by default.
  51549. */
  51550. createGround: boolean;
  51551. /**
  51552. * Specifies the ground size.
  51553. * 15 by default.
  51554. */
  51555. groundSize: number;
  51556. /**
  51557. * The texture used on the ground for the main color.
  51558. * Comes from the BabylonJS CDN by default.
  51559. *
  51560. * Remarks: Can be either a texture or a url.
  51561. */
  51562. groundTexture: string | BaseTexture;
  51563. /**
  51564. * The color mixed in the ground texture by default.
  51565. * BabylonJS clearColor by default.
  51566. */
  51567. groundColor: Color3;
  51568. /**
  51569. * Specifies the ground opacity.
  51570. * 1 by default.
  51571. */
  51572. groundOpacity: number;
  51573. /**
  51574. * Enables the ground to receive shadows.
  51575. * True by default.
  51576. */
  51577. enableGroundShadow: boolean;
  51578. /**
  51579. * Helps preventing the shadow to be fully black on the ground.
  51580. * 0.5 by default.
  51581. */
  51582. groundShadowLevel: number;
  51583. /**
  51584. * Creates a mirror texture attach to the ground.
  51585. * false by default.
  51586. */
  51587. enableGroundMirror: boolean;
  51588. /**
  51589. * Specifies the ground mirror size ratio.
  51590. * 0.3 by default as the default kernel is 64.
  51591. */
  51592. groundMirrorSizeRatio: number;
  51593. /**
  51594. * Specifies the ground mirror blur kernel size.
  51595. * 64 by default.
  51596. */
  51597. groundMirrorBlurKernel: number;
  51598. /**
  51599. * Specifies the ground mirror visibility amount.
  51600. * 1 by default
  51601. */
  51602. groundMirrorAmount: number;
  51603. /**
  51604. * Specifies the ground mirror reflectance weight.
  51605. * This uses the standard weight of the background material to setup the fresnel effect
  51606. * of the mirror.
  51607. * 1 by default.
  51608. */
  51609. groundMirrorFresnelWeight: number;
  51610. /**
  51611. * Specifies the ground mirror Falloff distance.
  51612. * This can helps reducing the size of the reflection.
  51613. * 0 by Default.
  51614. */
  51615. groundMirrorFallOffDistance: number;
  51616. /**
  51617. * Specifies the ground mirror texture type.
  51618. * Unsigned Int by Default.
  51619. */
  51620. groundMirrorTextureType: number;
  51621. /**
  51622. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  51623. * the shown objects.
  51624. */
  51625. groundYBias: number;
  51626. /**
  51627. * Specifies whether or not to create a skybox.
  51628. * True by default.
  51629. */
  51630. createSkybox: boolean;
  51631. /**
  51632. * Specifies the skybox size.
  51633. * 20 by default.
  51634. */
  51635. skyboxSize: number;
  51636. /**
  51637. * The texture used on the skybox for the main color.
  51638. * Comes from the BabylonJS CDN by default.
  51639. *
  51640. * Remarks: Can be either a texture or a url.
  51641. */
  51642. skyboxTexture: string | BaseTexture;
  51643. /**
  51644. * The color mixed in the skybox texture by default.
  51645. * BabylonJS clearColor by default.
  51646. */
  51647. skyboxColor: Color3;
  51648. /**
  51649. * The background rotation around the Y axis of the scene.
  51650. * This helps aligning the key lights of your scene with the background.
  51651. * 0 by default.
  51652. */
  51653. backgroundYRotation: number;
  51654. /**
  51655. * Compute automatically the size of the elements to best fit with the scene.
  51656. */
  51657. sizeAuto: boolean;
  51658. /**
  51659. * Default position of the rootMesh if autoSize is not true.
  51660. */
  51661. rootPosition: Vector3;
  51662. /**
  51663. * Sets up the image processing in the scene.
  51664. * true by default.
  51665. */
  51666. setupImageProcessing: boolean;
  51667. /**
  51668. * The texture used as your environment texture in the scene.
  51669. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  51670. *
  51671. * Remarks: Can be either a texture or a url.
  51672. */
  51673. environmentTexture: string | BaseTexture;
  51674. /**
  51675. * The value of the exposure to apply to the scene.
  51676. * 0.6 by default if setupImageProcessing is true.
  51677. */
  51678. cameraExposure: number;
  51679. /**
  51680. * The value of the contrast to apply to the scene.
  51681. * 1.6 by default if setupImageProcessing is true.
  51682. */
  51683. cameraContrast: number;
  51684. /**
  51685. * Specifies whether or not tonemapping should be enabled in the scene.
  51686. * true by default if setupImageProcessing is true.
  51687. */
  51688. toneMappingEnabled: boolean;
  51689. }
  51690. /**
  51691. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  51692. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  51693. * It also helps with the default setup of your imageProcessing configuration.
  51694. */
  51695. export class EnvironmentHelper {
  51696. /**
  51697. * Default ground texture URL.
  51698. */
  51699. private static _groundTextureCDNUrl;
  51700. /**
  51701. * Default skybox texture URL.
  51702. */
  51703. private static _skyboxTextureCDNUrl;
  51704. /**
  51705. * Default environment texture URL.
  51706. */
  51707. private static _environmentTextureCDNUrl;
  51708. /**
  51709. * Creates the default options for the helper.
  51710. */
  51711. private static _getDefaultOptions;
  51712. private _rootMesh;
  51713. /**
  51714. * Gets the root mesh created by the helper.
  51715. */
  51716. get rootMesh(): Mesh;
  51717. private _skybox;
  51718. /**
  51719. * Gets the skybox created by the helper.
  51720. */
  51721. get skybox(): Nullable<Mesh>;
  51722. private _skyboxTexture;
  51723. /**
  51724. * Gets the skybox texture created by the helper.
  51725. */
  51726. get skyboxTexture(): Nullable<BaseTexture>;
  51727. private _skyboxMaterial;
  51728. /**
  51729. * Gets the skybox material created by the helper.
  51730. */
  51731. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  51732. private _ground;
  51733. /**
  51734. * Gets the ground mesh created by the helper.
  51735. */
  51736. get ground(): Nullable<Mesh>;
  51737. private _groundTexture;
  51738. /**
  51739. * Gets the ground texture created by the helper.
  51740. */
  51741. get groundTexture(): Nullable<BaseTexture>;
  51742. private _groundMirror;
  51743. /**
  51744. * Gets the ground mirror created by the helper.
  51745. */
  51746. get groundMirror(): Nullable<MirrorTexture>;
  51747. /**
  51748. * Gets the ground mirror render list to helps pushing the meshes
  51749. * you wish in the ground reflection.
  51750. */
  51751. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  51752. private _groundMaterial;
  51753. /**
  51754. * Gets the ground material created by the helper.
  51755. */
  51756. get groundMaterial(): Nullable<BackgroundMaterial>;
  51757. /**
  51758. * Stores the creation options.
  51759. */
  51760. private readonly _scene;
  51761. private _options;
  51762. /**
  51763. * This observable will be notified with any error during the creation of the environment,
  51764. * mainly texture creation errors.
  51765. */
  51766. onErrorObservable: Observable<{
  51767. message?: string;
  51768. exception?: any;
  51769. }>;
  51770. /**
  51771. * constructor
  51772. * @param options Defines the options we want to customize the helper
  51773. * @param scene The scene to add the material to
  51774. */
  51775. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  51776. /**
  51777. * Updates the background according to the new options
  51778. * @param options
  51779. */
  51780. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  51781. /**
  51782. * Sets the primary color of all the available elements.
  51783. * @param color the main color to affect to the ground and the background
  51784. */
  51785. setMainColor(color: Color3): void;
  51786. /**
  51787. * Setup the image processing according to the specified options.
  51788. */
  51789. private _setupImageProcessing;
  51790. /**
  51791. * Setup the environment texture according to the specified options.
  51792. */
  51793. private _setupEnvironmentTexture;
  51794. /**
  51795. * Setup the background according to the specified options.
  51796. */
  51797. private _setupBackground;
  51798. /**
  51799. * Get the scene sizes according to the setup.
  51800. */
  51801. private _getSceneSize;
  51802. /**
  51803. * Setup the ground according to the specified options.
  51804. */
  51805. private _setupGround;
  51806. /**
  51807. * Setup the ground material according to the specified options.
  51808. */
  51809. private _setupGroundMaterial;
  51810. /**
  51811. * Setup the ground diffuse texture according to the specified options.
  51812. */
  51813. private _setupGroundDiffuseTexture;
  51814. /**
  51815. * Setup the ground mirror texture according to the specified options.
  51816. */
  51817. private _setupGroundMirrorTexture;
  51818. /**
  51819. * Setup the ground to receive the mirror texture.
  51820. */
  51821. private _setupMirrorInGroundMaterial;
  51822. /**
  51823. * Setup the skybox according to the specified options.
  51824. */
  51825. private _setupSkybox;
  51826. /**
  51827. * Setup the skybox material according to the specified options.
  51828. */
  51829. private _setupSkyboxMaterial;
  51830. /**
  51831. * Setup the skybox reflection texture according to the specified options.
  51832. */
  51833. private _setupSkyboxReflectionTexture;
  51834. private _errorHandler;
  51835. /**
  51836. * Dispose all the elements created by the Helper.
  51837. */
  51838. dispose(): void;
  51839. }
  51840. }
  51841. declare module "babylonjs/Helpers/photoDome" {
  51842. import { Observable } from "babylonjs/Misc/observable";
  51843. import { Nullable } from "babylonjs/types";
  51844. import { Scene } from "babylonjs/scene";
  51845. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51846. import { Mesh } from "babylonjs/Meshes/mesh";
  51847. import { Texture } from "babylonjs/Materials/Textures/texture";
  51848. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51849. import "babylonjs/Meshes/Builders/sphereBuilder";
  51850. /**
  51851. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  51852. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  51853. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  51854. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51855. */
  51856. export class PhotoDome extends TransformNode {
  51857. /**
  51858. * Define the image as a Monoscopic panoramic 360 image.
  51859. */
  51860. static readonly MODE_MONOSCOPIC: number;
  51861. /**
  51862. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51863. */
  51864. static readonly MODE_TOPBOTTOM: number;
  51865. /**
  51866. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51867. */
  51868. static readonly MODE_SIDEBYSIDE: number;
  51869. private _useDirectMapping;
  51870. /**
  51871. * The texture being displayed on the sphere
  51872. */
  51873. protected _photoTexture: Texture;
  51874. /**
  51875. * Gets or sets the texture being displayed on the sphere
  51876. */
  51877. get photoTexture(): Texture;
  51878. set photoTexture(value: Texture);
  51879. /**
  51880. * Observable raised when an error occured while loading the 360 image
  51881. */
  51882. onLoadErrorObservable: Observable<string>;
  51883. /**
  51884. * The skybox material
  51885. */
  51886. protected _material: BackgroundMaterial;
  51887. /**
  51888. * The surface used for the skybox
  51889. */
  51890. protected _mesh: Mesh;
  51891. /**
  51892. * Gets the mesh used for the skybox.
  51893. */
  51894. get mesh(): Mesh;
  51895. /**
  51896. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51897. * Also see the options.resolution property.
  51898. */
  51899. get fovMultiplier(): number;
  51900. set fovMultiplier(value: number);
  51901. private _imageMode;
  51902. /**
  51903. * Gets or set the current video mode for the video. It can be:
  51904. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  51905. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  51906. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  51907. */
  51908. get imageMode(): number;
  51909. set imageMode(value: number);
  51910. /**
  51911. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  51912. * @param name Element's name, child elements will append suffixes for their own names.
  51913. * @param urlsOfPhoto defines the url of the photo to display
  51914. * @param options defines an object containing optional or exposed sub element properties
  51915. * @param onError defines a callback called when an error occured while loading the texture
  51916. */
  51917. constructor(name: string, urlOfPhoto: string, options: {
  51918. resolution?: number;
  51919. size?: number;
  51920. useDirectMapping?: boolean;
  51921. faceForward?: boolean;
  51922. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  51923. private _onBeforeCameraRenderObserver;
  51924. private _changeImageMode;
  51925. /**
  51926. * Releases resources associated with this node.
  51927. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51928. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51929. */
  51930. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51931. }
  51932. }
  51933. declare module "babylonjs/Misc/rgbdTextureTools" {
  51934. import "babylonjs/Shaders/rgbdDecode.fragment";
  51935. import "babylonjs/Engines/Extensions/engine.renderTarget";
  51936. import { Texture } from "babylonjs/Materials/Textures/texture";
  51937. /**
  51938. * Class used to host RGBD texture specific utilities
  51939. */
  51940. export class RGBDTextureTools {
  51941. /**
  51942. * Expand the RGBD Texture from RGBD to Half Float if possible.
  51943. * @param texture the texture to expand.
  51944. */
  51945. static ExpandRGBDTexture(texture: Texture): void;
  51946. }
  51947. }
  51948. declare module "babylonjs/Misc/brdfTextureTools" {
  51949. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51950. import { Scene } from "babylonjs/scene";
  51951. /**
  51952. * Class used to host texture specific utilities
  51953. */
  51954. export class BRDFTextureTools {
  51955. /**
  51956. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  51957. * @param scene defines the hosting scene
  51958. * @returns the environment BRDF texture
  51959. */
  51960. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  51961. private static _environmentBRDFBase64Texture;
  51962. }
  51963. }
  51964. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  51965. import { Nullable } from "babylonjs/types";
  51966. import { Color3 } from "babylonjs/Maths/math.color";
  51967. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51968. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  51969. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  51970. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  51971. import { Engine } from "babylonjs/Engines/engine";
  51972. import { Scene } from "babylonjs/scene";
  51973. /**
  51974. * @hidden
  51975. */
  51976. export interface IMaterialClearCoatDefines {
  51977. CLEARCOAT: boolean;
  51978. CLEARCOAT_DEFAULTIOR: boolean;
  51979. CLEARCOAT_TEXTURE: boolean;
  51980. CLEARCOAT_TEXTUREDIRECTUV: number;
  51981. CLEARCOAT_BUMP: boolean;
  51982. CLEARCOAT_BUMPDIRECTUV: number;
  51983. CLEARCOAT_TINT: boolean;
  51984. CLEARCOAT_TINT_TEXTURE: boolean;
  51985. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  51986. /** @hidden */
  51987. _areTexturesDirty: boolean;
  51988. }
  51989. /**
  51990. * Define the code related to the clear coat parameters of the pbr material.
  51991. */
  51992. export class PBRClearCoatConfiguration {
  51993. /**
  51994. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  51995. * The default fits with a polyurethane material.
  51996. */
  51997. private static readonly _DefaultIndexOfRefraction;
  51998. private _isEnabled;
  51999. /**
  52000. * Defines if the clear coat is enabled in the material.
  52001. */
  52002. isEnabled: boolean;
  52003. /**
  52004. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52005. */
  52006. intensity: number;
  52007. /**
  52008. * Defines the clear coat layer roughness.
  52009. */
  52010. roughness: number;
  52011. private _indexOfRefraction;
  52012. /**
  52013. * Defines the index of refraction of the clear coat.
  52014. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52015. * The default fits with a polyurethane material.
  52016. * Changing the default value is more performance intensive.
  52017. */
  52018. indexOfRefraction: number;
  52019. private _texture;
  52020. /**
  52021. * Stores the clear coat values in a texture.
  52022. */
  52023. texture: Nullable<BaseTexture>;
  52024. private _bumpTexture;
  52025. /**
  52026. * Define the clear coat specific bump texture.
  52027. */
  52028. bumpTexture: Nullable<BaseTexture>;
  52029. private _isTintEnabled;
  52030. /**
  52031. * Defines if the clear coat tint is enabled in the material.
  52032. */
  52033. isTintEnabled: boolean;
  52034. /**
  52035. * Defines the clear coat tint of the material.
  52036. * This is only use if tint is enabled
  52037. */
  52038. tintColor: Color3;
  52039. /**
  52040. * Defines the distance at which the tint color should be found in the
  52041. * clear coat media.
  52042. * This is only use if tint is enabled
  52043. */
  52044. tintColorAtDistance: number;
  52045. /**
  52046. * Defines the clear coat layer thickness.
  52047. * This is only use if tint is enabled
  52048. */
  52049. tintThickness: number;
  52050. private _tintTexture;
  52051. /**
  52052. * Stores the clear tint values in a texture.
  52053. * rgb is tint
  52054. * a is a thickness factor
  52055. */
  52056. tintTexture: Nullable<BaseTexture>;
  52057. /** @hidden */
  52058. private _internalMarkAllSubMeshesAsTexturesDirty;
  52059. /** @hidden */
  52060. _markAllSubMeshesAsTexturesDirty(): void;
  52061. /**
  52062. * Instantiate a new istance of clear coat configuration.
  52063. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52064. */
  52065. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52066. /**
  52067. * Gets wehter the submesh is ready to be used or not.
  52068. * @param defines the list of "defines" to update.
  52069. * @param scene defines the scene the material belongs to.
  52070. * @param engine defines the engine the material belongs to.
  52071. * @param disableBumpMap defines wether the material disables bump or not.
  52072. * @returns - boolean indicating that the submesh is ready or not.
  52073. */
  52074. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52075. /**
  52076. * Checks to see if a texture is used in the material.
  52077. * @param defines the list of "defines" to update.
  52078. * @param scene defines the scene to the material belongs to.
  52079. */
  52080. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52081. /**
  52082. * Binds the material data.
  52083. * @param uniformBuffer defines the Uniform buffer to fill in.
  52084. * @param scene defines the scene the material belongs to.
  52085. * @param engine defines the engine the material belongs to.
  52086. * @param disableBumpMap defines wether the material disables bump or not.
  52087. * @param isFrozen defines wether the material is frozen or not.
  52088. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52089. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52090. */
  52091. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52092. /**
  52093. * Checks to see if a texture is used in the material.
  52094. * @param texture - Base texture to use.
  52095. * @returns - Boolean specifying if a texture is used in the material.
  52096. */
  52097. hasTexture(texture: BaseTexture): boolean;
  52098. /**
  52099. * Returns an array of the actively used textures.
  52100. * @param activeTextures Array of BaseTextures
  52101. */
  52102. getActiveTextures(activeTextures: BaseTexture[]): void;
  52103. /**
  52104. * Returns the animatable textures.
  52105. * @param animatables Array of animatable textures.
  52106. */
  52107. getAnimatables(animatables: IAnimatable[]): void;
  52108. /**
  52109. * Disposes the resources of the material.
  52110. * @param forceDisposeTextures - Forces the disposal of all textures.
  52111. */
  52112. dispose(forceDisposeTextures?: boolean): void;
  52113. /**
  52114. * Get the current class name of the texture useful for serialization or dynamic coding.
  52115. * @returns "PBRClearCoatConfiguration"
  52116. */
  52117. getClassName(): string;
  52118. /**
  52119. * Add fallbacks to the effect fallbacks list.
  52120. * @param defines defines the Base texture to use.
  52121. * @param fallbacks defines the current fallback list.
  52122. * @param currentRank defines the current fallback rank.
  52123. * @returns the new fallback rank.
  52124. */
  52125. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52126. /**
  52127. * Add the required uniforms to the current list.
  52128. * @param uniforms defines the current uniform list.
  52129. */
  52130. static AddUniforms(uniforms: string[]): void;
  52131. /**
  52132. * Add the required samplers to the current list.
  52133. * @param samplers defines the current sampler list.
  52134. */
  52135. static AddSamplers(samplers: string[]): void;
  52136. /**
  52137. * Add the required uniforms to the current buffer.
  52138. * @param uniformBuffer defines the current uniform buffer.
  52139. */
  52140. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52141. /**
  52142. * Makes a duplicate of the current configuration into another one.
  52143. * @param clearCoatConfiguration define the config where to copy the info
  52144. */
  52145. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52146. /**
  52147. * Serializes this clear coat configuration.
  52148. * @returns - An object with the serialized config.
  52149. */
  52150. serialize(): any;
  52151. /**
  52152. * Parses a anisotropy Configuration from a serialized object.
  52153. * @param source - Serialized object.
  52154. * @param scene Defines the scene we are parsing for
  52155. * @param rootUrl Defines the rootUrl to load from
  52156. */
  52157. parse(source: any, scene: Scene, rootUrl: string): void;
  52158. }
  52159. }
  52160. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52161. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52162. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52163. import { Vector2 } from "babylonjs/Maths/math.vector";
  52164. import { Scene } from "babylonjs/scene";
  52165. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52166. import { Nullable } from "babylonjs/types";
  52167. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52168. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52169. /**
  52170. * @hidden
  52171. */
  52172. export interface IMaterialAnisotropicDefines {
  52173. ANISOTROPIC: boolean;
  52174. ANISOTROPIC_TEXTURE: boolean;
  52175. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52176. MAINUV1: boolean;
  52177. _areTexturesDirty: boolean;
  52178. _needUVs: boolean;
  52179. }
  52180. /**
  52181. * Define the code related to the anisotropic parameters of the pbr material.
  52182. */
  52183. export class PBRAnisotropicConfiguration {
  52184. private _isEnabled;
  52185. /**
  52186. * Defines if the anisotropy is enabled in the material.
  52187. */
  52188. isEnabled: boolean;
  52189. /**
  52190. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52191. */
  52192. intensity: number;
  52193. /**
  52194. * Defines if the effect is along the tangents, bitangents or in between.
  52195. * By default, the effect is "strectching" the highlights along the tangents.
  52196. */
  52197. direction: Vector2;
  52198. private _texture;
  52199. /**
  52200. * Stores the anisotropy values in a texture.
  52201. * rg is direction (like normal from -1 to 1)
  52202. * b is a intensity
  52203. */
  52204. texture: Nullable<BaseTexture>;
  52205. /** @hidden */
  52206. private _internalMarkAllSubMeshesAsTexturesDirty;
  52207. /** @hidden */
  52208. _markAllSubMeshesAsTexturesDirty(): void;
  52209. /**
  52210. * Instantiate a new istance of anisotropy configuration.
  52211. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52212. */
  52213. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52214. /**
  52215. * Specifies that the submesh is ready to be used.
  52216. * @param defines the list of "defines" to update.
  52217. * @param scene defines the scene the material belongs to.
  52218. * @returns - boolean indicating that the submesh is ready or not.
  52219. */
  52220. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52221. /**
  52222. * Checks to see if a texture is used in the material.
  52223. * @param defines the list of "defines" to update.
  52224. * @param mesh the mesh we are preparing the defines for.
  52225. * @param scene defines the scene the material belongs to.
  52226. */
  52227. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52228. /**
  52229. * Binds the material data.
  52230. * @param uniformBuffer defines the Uniform buffer to fill in.
  52231. * @param scene defines the scene the material belongs to.
  52232. * @param isFrozen defines wether the material is frozen or not.
  52233. */
  52234. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52235. /**
  52236. * Checks to see if a texture is used in the material.
  52237. * @param texture - Base texture to use.
  52238. * @returns - Boolean specifying if a texture is used in the material.
  52239. */
  52240. hasTexture(texture: BaseTexture): boolean;
  52241. /**
  52242. * Returns an array of the actively used textures.
  52243. * @param activeTextures Array of BaseTextures
  52244. */
  52245. getActiveTextures(activeTextures: BaseTexture[]): void;
  52246. /**
  52247. * Returns the animatable textures.
  52248. * @param animatables Array of animatable textures.
  52249. */
  52250. getAnimatables(animatables: IAnimatable[]): void;
  52251. /**
  52252. * Disposes the resources of the material.
  52253. * @param forceDisposeTextures - Forces the disposal of all textures.
  52254. */
  52255. dispose(forceDisposeTextures?: boolean): void;
  52256. /**
  52257. * Get the current class name of the texture useful for serialization or dynamic coding.
  52258. * @returns "PBRAnisotropicConfiguration"
  52259. */
  52260. getClassName(): string;
  52261. /**
  52262. * Add fallbacks to the effect fallbacks list.
  52263. * @param defines defines the Base texture to use.
  52264. * @param fallbacks defines the current fallback list.
  52265. * @param currentRank defines the current fallback rank.
  52266. * @returns the new fallback rank.
  52267. */
  52268. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52269. /**
  52270. * Add the required uniforms to the current list.
  52271. * @param uniforms defines the current uniform list.
  52272. */
  52273. static AddUniforms(uniforms: string[]): void;
  52274. /**
  52275. * Add the required uniforms to the current buffer.
  52276. * @param uniformBuffer defines the current uniform buffer.
  52277. */
  52278. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52279. /**
  52280. * Add the required samplers to the current list.
  52281. * @param samplers defines the current sampler list.
  52282. */
  52283. static AddSamplers(samplers: string[]): void;
  52284. /**
  52285. * Makes a duplicate of the current configuration into another one.
  52286. * @param anisotropicConfiguration define the config where to copy the info
  52287. */
  52288. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52289. /**
  52290. * Serializes this anisotropy configuration.
  52291. * @returns - An object with the serialized config.
  52292. */
  52293. serialize(): any;
  52294. /**
  52295. * Parses a anisotropy Configuration from a serialized object.
  52296. * @param source - Serialized object.
  52297. * @param scene Defines the scene we are parsing for
  52298. * @param rootUrl Defines the rootUrl to load from
  52299. */
  52300. parse(source: any, scene: Scene, rootUrl: string): void;
  52301. }
  52302. }
  52303. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52304. import { Scene } from "babylonjs/scene";
  52305. /**
  52306. * @hidden
  52307. */
  52308. export interface IMaterialBRDFDefines {
  52309. BRDF_V_HEIGHT_CORRELATED: boolean;
  52310. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52311. SPHERICAL_HARMONICS: boolean;
  52312. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52313. /** @hidden */
  52314. _areMiscDirty: boolean;
  52315. }
  52316. /**
  52317. * Define the code related to the BRDF parameters of the pbr material.
  52318. */
  52319. export class PBRBRDFConfiguration {
  52320. /**
  52321. * Default value used for the energy conservation.
  52322. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52323. */
  52324. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52325. /**
  52326. * Default value used for the Smith Visibility Height Correlated mode.
  52327. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52328. */
  52329. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52330. /**
  52331. * Default value used for the IBL diffuse part.
  52332. * This can help switching back to the polynomials mode globally which is a tiny bit
  52333. * less GPU intensive at the drawback of a lower quality.
  52334. */
  52335. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52336. /**
  52337. * Default value used for activating energy conservation for the specular workflow.
  52338. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52339. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52340. */
  52341. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52342. private _useEnergyConservation;
  52343. /**
  52344. * Defines if the material uses energy conservation.
  52345. */
  52346. useEnergyConservation: boolean;
  52347. private _useSmithVisibilityHeightCorrelated;
  52348. /**
  52349. * LEGACY Mode set to false
  52350. * Defines if the material uses height smith correlated visibility term.
  52351. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52352. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52353. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52354. * Not relying on height correlated will also disable energy conservation.
  52355. */
  52356. useSmithVisibilityHeightCorrelated: boolean;
  52357. private _useSphericalHarmonics;
  52358. /**
  52359. * LEGACY Mode set to false
  52360. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52361. * diffuse part of the IBL.
  52362. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52363. * to the ground truth.
  52364. */
  52365. useSphericalHarmonics: boolean;
  52366. private _useSpecularGlossinessInputEnergyConservation;
  52367. /**
  52368. * Defines if the material uses energy conservation, when the specular workflow is active.
  52369. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52370. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52371. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52372. */
  52373. useSpecularGlossinessInputEnergyConservation: boolean;
  52374. /** @hidden */
  52375. private _internalMarkAllSubMeshesAsMiscDirty;
  52376. /** @hidden */
  52377. _markAllSubMeshesAsMiscDirty(): void;
  52378. /**
  52379. * Instantiate a new istance of clear coat configuration.
  52380. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52381. */
  52382. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52383. /**
  52384. * Checks to see if a texture is used in the material.
  52385. * @param defines the list of "defines" to update.
  52386. */
  52387. prepareDefines(defines: IMaterialBRDFDefines): void;
  52388. /**
  52389. * Get the current class name of the texture useful for serialization or dynamic coding.
  52390. * @returns "PBRClearCoatConfiguration"
  52391. */
  52392. getClassName(): string;
  52393. /**
  52394. * Makes a duplicate of the current configuration into another one.
  52395. * @param brdfConfiguration define the config where to copy the info
  52396. */
  52397. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52398. /**
  52399. * Serializes this BRDF configuration.
  52400. * @returns - An object with the serialized config.
  52401. */
  52402. serialize(): any;
  52403. /**
  52404. * Parses a anisotropy Configuration from a serialized object.
  52405. * @param source - Serialized object.
  52406. * @param scene Defines the scene we are parsing for
  52407. * @param rootUrl Defines the rootUrl to load from
  52408. */
  52409. parse(source: any, scene: Scene, rootUrl: string): void;
  52410. }
  52411. }
  52412. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52413. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52414. import { Color3 } from "babylonjs/Maths/math.color";
  52415. import { Scene } from "babylonjs/scene";
  52416. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52417. import { Nullable } from "babylonjs/types";
  52418. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52419. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52420. /**
  52421. * @hidden
  52422. */
  52423. export interface IMaterialSheenDefines {
  52424. SHEEN: boolean;
  52425. SHEEN_TEXTURE: boolean;
  52426. SHEEN_TEXTUREDIRECTUV: number;
  52427. SHEEN_LINKWITHALBEDO: boolean;
  52428. /** @hidden */
  52429. _areTexturesDirty: boolean;
  52430. }
  52431. /**
  52432. * Define the code related to the Sheen parameters of the pbr material.
  52433. */
  52434. export class PBRSheenConfiguration {
  52435. private _isEnabled;
  52436. /**
  52437. * Defines if the material uses sheen.
  52438. */
  52439. isEnabled: boolean;
  52440. private _linkSheenWithAlbedo;
  52441. /**
  52442. * Defines if the sheen is linked to the sheen color.
  52443. */
  52444. linkSheenWithAlbedo: boolean;
  52445. /**
  52446. * Defines the sheen intensity.
  52447. */
  52448. intensity: number;
  52449. /**
  52450. * Defines the sheen color.
  52451. */
  52452. color: Color3;
  52453. private _texture;
  52454. /**
  52455. * Stores the sheen tint values in a texture.
  52456. * rgb is tint
  52457. * a is a intensity
  52458. */
  52459. texture: Nullable<BaseTexture>;
  52460. /** @hidden */
  52461. private _internalMarkAllSubMeshesAsTexturesDirty;
  52462. /** @hidden */
  52463. _markAllSubMeshesAsTexturesDirty(): void;
  52464. /**
  52465. * Instantiate a new istance of clear coat configuration.
  52466. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52467. */
  52468. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52469. /**
  52470. * Specifies that the submesh is ready to be used.
  52471. * @param defines the list of "defines" to update.
  52472. * @param scene defines the scene the material belongs to.
  52473. * @returns - boolean indicating that the submesh is ready or not.
  52474. */
  52475. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52476. /**
  52477. * Checks to see if a texture is used in the material.
  52478. * @param defines the list of "defines" to update.
  52479. * @param scene defines the scene the material belongs to.
  52480. */
  52481. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52482. /**
  52483. * Binds the material data.
  52484. * @param uniformBuffer defines the Uniform buffer to fill in.
  52485. * @param scene defines the scene the material belongs to.
  52486. * @param isFrozen defines wether the material is frozen or not.
  52487. */
  52488. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52489. /**
  52490. * Checks to see if a texture is used in the material.
  52491. * @param texture - Base texture to use.
  52492. * @returns - Boolean specifying if a texture is used in the material.
  52493. */
  52494. hasTexture(texture: BaseTexture): boolean;
  52495. /**
  52496. * Returns an array of the actively used textures.
  52497. * @param activeTextures Array of BaseTextures
  52498. */
  52499. getActiveTextures(activeTextures: BaseTexture[]): void;
  52500. /**
  52501. * Returns the animatable textures.
  52502. * @param animatables Array of animatable textures.
  52503. */
  52504. getAnimatables(animatables: IAnimatable[]): void;
  52505. /**
  52506. * Disposes the resources of the material.
  52507. * @param forceDisposeTextures - Forces the disposal of all textures.
  52508. */
  52509. dispose(forceDisposeTextures?: boolean): void;
  52510. /**
  52511. * Get the current class name of the texture useful for serialization or dynamic coding.
  52512. * @returns "PBRSheenConfiguration"
  52513. */
  52514. getClassName(): string;
  52515. /**
  52516. * Add fallbacks to the effect fallbacks list.
  52517. * @param defines defines the Base texture to use.
  52518. * @param fallbacks defines the current fallback list.
  52519. * @param currentRank defines the current fallback rank.
  52520. * @returns the new fallback rank.
  52521. */
  52522. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52523. /**
  52524. * Add the required uniforms to the current list.
  52525. * @param uniforms defines the current uniform list.
  52526. */
  52527. static AddUniforms(uniforms: string[]): void;
  52528. /**
  52529. * Add the required uniforms to the current buffer.
  52530. * @param uniformBuffer defines the current uniform buffer.
  52531. */
  52532. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52533. /**
  52534. * Add the required samplers to the current list.
  52535. * @param samplers defines the current sampler list.
  52536. */
  52537. static AddSamplers(samplers: string[]): void;
  52538. /**
  52539. * Makes a duplicate of the current configuration into another one.
  52540. * @param sheenConfiguration define the config where to copy the info
  52541. */
  52542. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  52543. /**
  52544. * Serializes this BRDF configuration.
  52545. * @returns - An object with the serialized config.
  52546. */
  52547. serialize(): any;
  52548. /**
  52549. * Parses a anisotropy Configuration from a serialized object.
  52550. * @param source - Serialized object.
  52551. * @param scene Defines the scene we are parsing for
  52552. * @param rootUrl Defines the rootUrl to load from
  52553. */
  52554. parse(source: any, scene: Scene, rootUrl: string): void;
  52555. }
  52556. }
  52557. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  52558. import { Nullable } from "babylonjs/types";
  52559. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52560. import { Color3 } from "babylonjs/Maths/math.color";
  52561. import { SmartArray } from "babylonjs/Misc/smartArray";
  52562. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52563. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52564. import { Effect } from "babylonjs/Materials/effect";
  52565. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52566. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52567. import { Engine } from "babylonjs/Engines/engine";
  52568. import { Scene } from "babylonjs/scene";
  52569. /**
  52570. * @hidden
  52571. */
  52572. export interface IMaterialSubSurfaceDefines {
  52573. SUBSURFACE: boolean;
  52574. SS_REFRACTION: boolean;
  52575. SS_TRANSLUCENCY: boolean;
  52576. SS_SCATERRING: boolean;
  52577. SS_THICKNESSANDMASK_TEXTURE: boolean;
  52578. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  52579. SS_REFRACTIONMAP_3D: boolean;
  52580. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  52581. SS_LODINREFRACTIONALPHA: boolean;
  52582. SS_GAMMAREFRACTION: boolean;
  52583. SS_RGBDREFRACTION: boolean;
  52584. SS_LINEARSPECULARREFRACTION: boolean;
  52585. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  52586. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  52587. /** @hidden */
  52588. _areTexturesDirty: boolean;
  52589. }
  52590. /**
  52591. * Define the code related to the sub surface parameters of the pbr material.
  52592. */
  52593. export class PBRSubSurfaceConfiguration {
  52594. private _isRefractionEnabled;
  52595. /**
  52596. * Defines if the refraction is enabled in the material.
  52597. */
  52598. isRefractionEnabled: boolean;
  52599. private _isTranslucencyEnabled;
  52600. /**
  52601. * Defines if the translucency is enabled in the material.
  52602. */
  52603. isTranslucencyEnabled: boolean;
  52604. private _isScatteringEnabled;
  52605. /**
  52606. * Defines the refraction intensity of the material.
  52607. * The refraction when enabled replaces the Diffuse part of the material.
  52608. * The intensity helps transitionning between diffuse and refraction.
  52609. */
  52610. refractionIntensity: number;
  52611. /**
  52612. * Defines the translucency intensity of the material.
  52613. * When translucency has been enabled, this defines how much of the "translucency"
  52614. * is addded to the diffuse part of the material.
  52615. */
  52616. translucencyIntensity: number;
  52617. /**
  52618. * Defines the scattering intensity of the material.
  52619. * When scattering has been enabled, this defines how much of the "scattered light"
  52620. * is addded to the diffuse part of the material.
  52621. */
  52622. scatteringIntensity: number;
  52623. private _thicknessTexture;
  52624. /**
  52625. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  52626. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  52627. * 0 would mean minimumThickness
  52628. * 1 would mean maximumThickness
  52629. * The other channels might be use as a mask to vary the different effects intensity.
  52630. */
  52631. thicknessTexture: Nullable<BaseTexture>;
  52632. private _refractionTexture;
  52633. /**
  52634. * Defines the texture to use for refraction.
  52635. */
  52636. refractionTexture: Nullable<BaseTexture>;
  52637. private _indexOfRefraction;
  52638. /**
  52639. * Defines the index of refraction used in the material.
  52640. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  52641. */
  52642. indexOfRefraction: number;
  52643. private _invertRefractionY;
  52644. /**
  52645. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52646. */
  52647. invertRefractionY: boolean;
  52648. private _linkRefractionWithTransparency;
  52649. /**
  52650. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52651. * Materials half opaque for instance using refraction could benefit from this control.
  52652. */
  52653. linkRefractionWithTransparency: boolean;
  52654. /**
  52655. * Defines the minimum thickness stored in the thickness map.
  52656. * If no thickness map is defined, this value will be used to simulate thickness.
  52657. */
  52658. minimumThickness: number;
  52659. /**
  52660. * Defines the maximum thickness stored in the thickness map.
  52661. */
  52662. maximumThickness: number;
  52663. /**
  52664. * Defines the volume tint of the material.
  52665. * This is used for both translucency and scattering.
  52666. */
  52667. tintColor: Color3;
  52668. /**
  52669. * Defines the distance at which the tint color should be found in the media.
  52670. * This is used for refraction only.
  52671. */
  52672. tintColorAtDistance: number;
  52673. /**
  52674. * Defines how far each channel transmit through the media.
  52675. * It is defined as a color to simplify it selection.
  52676. */
  52677. diffusionDistance: Color3;
  52678. private _useMaskFromThicknessTexture;
  52679. /**
  52680. * Stores the intensity of the different subsurface effects in the thickness texture.
  52681. * * the green channel is the translucency intensity.
  52682. * * the blue channel is the scattering intensity.
  52683. * * the alpha channel is the refraction intensity.
  52684. */
  52685. useMaskFromThicknessTexture: boolean;
  52686. /** @hidden */
  52687. private _internalMarkAllSubMeshesAsTexturesDirty;
  52688. /** @hidden */
  52689. _markAllSubMeshesAsTexturesDirty(): void;
  52690. /**
  52691. * Instantiate a new istance of sub surface configuration.
  52692. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52693. */
  52694. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52695. /**
  52696. * Gets wehter the submesh is ready to be used or not.
  52697. * @param defines the list of "defines" to update.
  52698. * @param scene defines the scene the material belongs to.
  52699. * @returns - boolean indicating that the submesh is ready or not.
  52700. */
  52701. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  52702. /**
  52703. * Checks to see if a texture is used in the material.
  52704. * @param defines the list of "defines" to update.
  52705. * @param scene defines the scene to the material belongs to.
  52706. */
  52707. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  52708. /**
  52709. * Binds the material data.
  52710. * @param uniformBuffer defines the Uniform buffer to fill in.
  52711. * @param scene defines the scene the material belongs to.
  52712. * @param engine defines the engine the material belongs to.
  52713. * @param isFrozen defines wether the material is frozen or not.
  52714. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  52715. */
  52716. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  52717. /**
  52718. * Unbinds the material from the mesh.
  52719. * @param activeEffect defines the effect that should be unbound from.
  52720. * @returns true if unbound, otherwise false
  52721. */
  52722. unbind(activeEffect: Effect): boolean;
  52723. /**
  52724. * Returns the texture used for refraction or null if none is used.
  52725. * @param scene defines the scene the material belongs to.
  52726. * @returns - Refraction texture if present. If no refraction texture and refraction
  52727. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52728. */
  52729. private _getRefractionTexture;
  52730. /**
  52731. * Returns true if alpha blending should be disabled.
  52732. */
  52733. get disableAlphaBlending(): boolean;
  52734. /**
  52735. * Fills the list of render target textures.
  52736. * @param renderTargets the list of render targets to update
  52737. */
  52738. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  52739. /**
  52740. * Checks to see if a texture is used in the material.
  52741. * @param texture - Base texture to use.
  52742. * @returns - Boolean specifying if a texture is used in the material.
  52743. */
  52744. hasTexture(texture: BaseTexture): boolean;
  52745. /**
  52746. * Gets a boolean indicating that current material needs to register RTT
  52747. * @returns true if this uses a render target otherwise false.
  52748. */
  52749. hasRenderTargetTextures(): boolean;
  52750. /**
  52751. * Returns an array of the actively used textures.
  52752. * @param activeTextures Array of BaseTextures
  52753. */
  52754. getActiveTextures(activeTextures: BaseTexture[]): void;
  52755. /**
  52756. * Returns the animatable textures.
  52757. * @param animatables Array of animatable textures.
  52758. */
  52759. getAnimatables(animatables: IAnimatable[]): void;
  52760. /**
  52761. * Disposes the resources of the material.
  52762. * @param forceDisposeTextures - Forces the disposal of all textures.
  52763. */
  52764. dispose(forceDisposeTextures?: boolean): void;
  52765. /**
  52766. * Get the current class name of the texture useful for serialization or dynamic coding.
  52767. * @returns "PBRSubSurfaceConfiguration"
  52768. */
  52769. getClassName(): string;
  52770. /**
  52771. * Add fallbacks to the effect fallbacks list.
  52772. * @param defines defines the Base texture to use.
  52773. * @param fallbacks defines the current fallback list.
  52774. * @param currentRank defines the current fallback rank.
  52775. * @returns the new fallback rank.
  52776. */
  52777. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52778. /**
  52779. * Add the required uniforms to the current list.
  52780. * @param uniforms defines the current uniform list.
  52781. */
  52782. static AddUniforms(uniforms: string[]): void;
  52783. /**
  52784. * Add the required samplers to the current list.
  52785. * @param samplers defines the current sampler list.
  52786. */
  52787. static AddSamplers(samplers: string[]): void;
  52788. /**
  52789. * Add the required uniforms to the current buffer.
  52790. * @param uniformBuffer defines the current uniform buffer.
  52791. */
  52792. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52793. /**
  52794. * Makes a duplicate of the current configuration into another one.
  52795. * @param configuration define the config where to copy the info
  52796. */
  52797. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  52798. /**
  52799. * Serializes this Sub Surface configuration.
  52800. * @returns - An object with the serialized config.
  52801. */
  52802. serialize(): any;
  52803. /**
  52804. * Parses a anisotropy Configuration from a serialized object.
  52805. * @param source - Serialized object.
  52806. * @param scene Defines the scene we are parsing for
  52807. * @param rootUrl Defines the rootUrl to load from
  52808. */
  52809. parse(source: any, scene: Scene, rootUrl: string): void;
  52810. }
  52811. }
  52812. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  52813. /** @hidden */
  52814. export var pbrFragmentDeclaration: {
  52815. name: string;
  52816. shader: string;
  52817. };
  52818. }
  52819. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  52820. /** @hidden */
  52821. export var pbrUboDeclaration: {
  52822. name: string;
  52823. shader: string;
  52824. };
  52825. }
  52826. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  52827. /** @hidden */
  52828. export var pbrFragmentExtraDeclaration: {
  52829. name: string;
  52830. shader: string;
  52831. };
  52832. }
  52833. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  52834. /** @hidden */
  52835. export var pbrFragmentSamplersDeclaration: {
  52836. name: string;
  52837. shader: string;
  52838. };
  52839. }
  52840. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  52841. /** @hidden */
  52842. export var pbrHelperFunctions: {
  52843. name: string;
  52844. shader: string;
  52845. };
  52846. }
  52847. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  52848. /** @hidden */
  52849. export var harmonicsFunctions: {
  52850. name: string;
  52851. shader: string;
  52852. };
  52853. }
  52854. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  52855. /** @hidden */
  52856. export var pbrDirectLightingSetupFunctions: {
  52857. name: string;
  52858. shader: string;
  52859. };
  52860. }
  52861. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  52862. /** @hidden */
  52863. export var pbrDirectLightingFalloffFunctions: {
  52864. name: string;
  52865. shader: string;
  52866. };
  52867. }
  52868. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  52869. /** @hidden */
  52870. export var pbrBRDFFunctions: {
  52871. name: string;
  52872. shader: string;
  52873. };
  52874. }
  52875. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  52876. /** @hidden */
  52877. export var pbrDirectLightingFunctions: {
  52878. name: string;
  52879. shader: string;
  52880. };
  52881. }
  52882. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  52883. /** @hidden */
  52884. export var pbrIBLFunctions: {
  52885. name: string;
  52886. shader: string;
  52887. };
  52888. }
  52889. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  52890. /** @hidden */
  52891. export var pbrDebug: {
  52892. name: string;
  52893. shader: string;
  52894. };
  52895. }
  52896. declare module "babylonjs/Shaders/pbr.fragment" {
  52897. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  52898. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52899. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  52900. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52901. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52902. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  52903. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  52904. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  52905. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52906. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  52907. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52908. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  52909. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  52910. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  52911. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52912. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  52913. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  52914. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  52915. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  52916. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  52917. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  52918. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  52919. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  52920. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  52921. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  52922. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  52923. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  52924. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  52925. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  52926. /** @hidden */
  52927. export var pbrPixelShader: {
  52928. name: string;
  52929. shader: string;
  52930. };
  52931. }
  52932. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  52933. /** @hidden */
  52934. export var pbrVertexDeclaration: {
  52935. name: string;
  52936. shader: string;
  52937. };
  52938. }
  52939. declare module "babylonjs/Shaders/pbr.vertex" {
  52940. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  52941. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  52942. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  52943. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  52944. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  52945. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  52946. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  52947. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  52948. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  52949. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  52950. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  52951. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  52952. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  52953. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  52954. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  52955. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  52956. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  52957. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  52958. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  52959. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  52960. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  52961. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  52962. /** @hidden */
  52963. export var pbrVertexShader: {
  52964. name: string;
  52965. shader: string;
  52966. };
  52967. }
  52968. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  52969. import { Nullable } from "babylonjs/types";
  52970. import { Scene } from "babylonjs/scene";
  52971. import { Matrix } from "babylonjs/Maths/math.vector";
  52972. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52974. import { Mesh } from "babylonjs/Meshes/mesh";
  52975. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  52976. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  52977. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  52978. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  52979. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  52980. import { Color3 } from "babylonjs/Maths/math.color";
  52981. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52982. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  52983. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52984. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52985. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52986. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52987. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  52988. import "babylonjs/Shaders/pbr.fragment";
  52989. import "babylonjs/Shaders/pbr.vertex";
  52990. /**
  52991. * Manages the defines for the PBR Material.
  52992. * @hidden
  52993. */
  52994. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  52995. PBR: boolean;
  52996. MAINUV1: boolean;
  52997. MAINUV2: boolean;
  52998. UV1: boolean;
  52999. UV2: boolean;
  53000. ALBEDO: boolean;
  53001. ALBEDODIRECTUV: number;
  53002. VERTEXCOLOR: boolean;
  53003. AMBIENT: boolean;
  53004. AMBIENTDIRECTUV: number;
  53005. AMBIENTINGRAYSCALE: boolean;
  53006. OPACITY: boolean;
  53007. VERTEXALPHA: boolean;
  53008. OPACITYDIRECTUV: number;
  53009. OPACITYRGB: boolean;
  53010. ALPHATEST: boolean;
  53011. DEPTHPREPASS: boolean;
  53012. ALPHABLEND: boolean;
  53013. ALPHAFROMALBEDO: boolean;
  53014. ALPHATESTVALUE: string;
  53015. SPECULAROVERALPHA: boolean;
  53016. RADIANCEOVERALPHA: boolean;
  53017. ALPHAFRESNEL: boolean;
  53018. LINEARALPHAFRESNEL: boolean;
  53019. PREMULTIPLYALPHA: boolean;
  53020. EMISSIVE: boolean;
  53021. EMISSIVEDIRECTUV: number;
  53022. REFLECTIVITY: boolean;
  53023. REFLECTIVITYDIRECTUV: number;
  53024. SPECULARTERM: boolean;
  53025. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53026. MICROSURFACEAUTOMATIC: boolean;
  53027. LODBASEDMICROSFURACE: boolean;
  53028. MICROSURFACEMAP: boolean;
  53029. MICROSURFACEMAPDIRECTUV: number;
  53030. METALLICWORKFLOW: boolean;
  53031. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53032. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53033. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53034. AOSTOREINMETALMAPRED: boolean;
  53035. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53036. ENVIRONMENTBRDF: boolean;
  53037. ENVIRONMENTBRDF_RGBD: boolean;
  53038. NORMAL: boolean;
  53039. TANGENT: boolean;
  53040. BUMP: boolean;
  53041. BUMPDIRECTUV: number;
  53042. OBJECTSPACE_NORMALMAP: boolean;
  53043. PARALLAX: boolean;
  53044. PARALLAXOCCLUSION: boolean;
  53045. NORMALXYSCALE: boolean;
  53046. LIGHTMAP: boolean;
  53047. LIGHTMAPDIRECTUV: number;
  53048. USELIGHTMAPASSHADOWMAP: boolean;
  53049. GAMMALIGHTMAP: boolean;
  53050. RGBDLIGHTMAP: boolean;
  53051. REFLECTION: boolean;
  53052. REFLECTIONMAP_3D: boolean;
  53053. REFLECTIONMAP_SPHERICAL: boolean;
  53054. REFLECTIONMAP_PLANAR: boolean;
  53055. REFLECTIONMAP_CUBIC: boolean;
  53056. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53057. REFLECTIONMAP_PROJECTION: boolean;
  53058. REFLECTIONMAP_SKYBOX: boolean;
  53059. REFLECTIONMAP_EXPLICIT: boolean;
  53060. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53061. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53062. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53063. INVERTCUBICMAP: boolean;
  53064. USESPHERICALFROMREFLECTIONMAP: boolean;
  53065. USEIRRADIANCEMAP: boolean;
  53066. SPHERICAL_HARMONICS: boolean;
  53067. USESPHERICALINVERTEX: boolean;
  53068. REFLECTIONMAP_OPPOSITEZ: boolean;
  53069. LODINREFLECTIONALPHA: boolean;
  53070. GAMMAREFLECTION: boolean;
  53071. RGBDREFLECTION: boolean;
  53072. LINEARSPECULARREFLECTION: boolean;
  53073. RADIANCEOCCLUSION: boolean;
  53074. HORIZONOCCLUSION: boolean;
  53075. INSTANCES: boolean;
  53076. NUM_BONE_INFLUENCERS: number;
  53077. BonesPerMesh: number;
  53078. BONETEXTURE: boolean;
  53079. NONUNIFORMSCALING: boolean;
  53080. MORPHTARGETS: boolean;
  53081. MORPHTARGETS_NORMAL: boolean;
  53082. MORPHTARGETS_TANGENT: boolean;
  53083. MORPHTARGETS_UV: boolean;
  53084. NUM_MORPH_INFLUENCERS: number;
  53085. IMAGEPROCESSING: boolean;
  53086. VIGNETTE: boolean;
  53087. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53088. VIGNETTEBLENDMODEOPAQUE: boolean;
  53089. TONEMAPPING: boolean;
  53090. TONEMAPPING_ACES: boolean;
  53091. CONTRAST: boolean;
  53092. COLORCURVES: boolean;
  53093. COLORGRADING: boolean;
  53094. COLORGRADING3D: boolean;
  53095. SAMPLER3DGREENDEPTH: boolean;
  53096. SAMPLER3DBGRMAP: boolean;
  53097. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53098. EXPOSURE: boolean;
  53099. MULTIVIEW: boolean;
  53100. USEPHYSICALLIGHTFALLOFF: boolean;
  53101. USEGLTFLIGHTFALLOFF: boolean;
  53102. TWOSIDEDLIGHTING: boolean;
  53103. SHADOWFLOAT: boolean;
  53104. CLIPPLANE: boolean;
  53105. CLIPPLANE2: boolean;
  53106. CLIPPLANE3: boolean;
  53107. CLIPPLANE4: boolean;
  53108. CLIPPLANE5: boolean;
  53109. CLIPPLANE6: boolean;
  53110. POINTSIZE: boolean;
  53111. FOG: boolean;
  53112. LOGARITHMICDEPTH: boolean;
  53113. FORCENORMALFORWARD: boolean;
  53114. SPECULARAA: boolean;
  53115. CLEARCOAT: boolean;
  53116. CLEARCOAT_DEFAULTIOR: boolean;
  53117. CLEARCOAT_TEXTURE: boolean;
  53118. CLEARCOAT_TEXTUREDIRECTUV: number;
  53119. CLEARCOAT_BUMP: boolean;
  53120. CLEARCOAT_BUMPDIRECTUV: number;
  53121. CLEARCOAT_TINT: boolean;
  53122. CLEARCOAT_TINT_TEXTURE: boolean;
  53123. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53124. ANISOTROPIC: boolean;
  53125. ANISOTROPIC_TEXTURE: boolean;
  53126. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53127. BRDF_V_HEIGHT_CORRELATED: boolean;
  53128. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53129. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53130. SHEEN: boolean;
  53131. SHEEN_TEXTURE: boolean;
  53132. SHEEN_TEXTUREDIRECTUV: number;
  53133. SHEEN_LINKWITHALBEDO: boolean;
  53134. SUBSURFACE: boolean;
  53135. SS_REFRACTION: boolean;
  53136. SS_TRANSLUCENCY: boolean;
  53137. SS_SCATERRING: boolean;
  53138. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53139. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53140. SS_REFRACTIONMAP_3D: boolean;
  53141. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53142. SS_LODINREFRACTIONALPHA: boolean;
  53143. SS_GAMMAREFRACTION: boolean;
  53144. SS_RGBDREFRACTION: boolean;
  53145. SS_LINEARSPECULARREFRACTION: boolean;
  53146. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53147. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53148. UNLIT: boolean;
  53149. DEBUGMODE: number;
  53150. /**
  53151. * Initializes the PBR Material defines.
  53152. */
  53153. constructor();
  53154. /**
  53155. * Resets the PBR Material defines.
  53156. */
  53157. reset(): void;
  53158. }
  53159. /**
  53160. * The Physically based material base class of BJS.
  53161. *
  53162. * This offers the main features of a standard PBR material.
  53163. * For more information, please refer to the documentation :
  53164. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53165. */
  53166. export abstract class PBRBaseMaterial extends PushMaterial {
  53167. /**
  53168. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53169. */
  53170. static readonly PBRMATERIAL_OPAQUE: number;
  53171. /**
  53172. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53173. */
  53174. static readonly PBRMATERIAL_ALPHATEST: number;
  53175. /**
  53176. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53177. */
  53178. static readonly PBRMATERIAL_ALPHABLEND: number;
  53179. /**
  53180. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53181. * They are also discarded below the alpha cutoff threshold to improve performances.
  53182. */
  53183. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53184. /**
  53185. * Defines the default value of how much AO map is occluding the analytical lights
  53186. * (point spot...).
  53187. */
  53188. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53189. /**
  53190. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53191. */
  53192. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53193. /**
  53194. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53195. * to enhance interoperability with other engines.
  53196. */
  53197. static readonly LIGHTFALLOFF_GLTF: number;
  53198. /**
  53199. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53200. * to enhance interoperability with other materials.
  53201. */
  53202. static readonly LIGHTFALLOFF_STANDARD: number;
  53203. /**
  53204. * Intensity of the direct lights e.g. the four lights available in your scene.
  53205. * This impacts both the direct diffuse and specular highlights.
  53206. */
  53207. protected _directIntensity: number;
  53208. /**
  53209. * Intensity of the emissive part of the material.
  53210. * This helps controlling the emissive effect without modifying the emissive color.
  53211. */
  53212. protected _emissiveIntensity: number;
  53213. /**
  53214. * Intensity of the environment e.g. how much the environment will light the object
  53215. * either through harmonics for rough material or through the refelction for shiny ones.
  53216. */
  53217. protected _environmentIntensity: number;
  53218. /**
  53219. * This is a special control allowing the reduction of the specular highlights coming from the
  53220. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53221. */
  53222. protected _specularIntensity: number;
  53223. /**
  53224. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53225. */
  53226. private _lightingInfos;
  53227. /**
  53228. * Debug Control allowing disabling the bump map on this material.
  53229. */
  53230. protected _disableBumpMap: boolean;
  53231. /**
  53232. * AKA Diffuse Texture in standard nomenclature.
  53233. */
  53234. protected _albedoTexture: Nullable<BaseTexture>;
  53235. /**
  53236. * AKA Occlusion Texture in other nomenclature.
  53237. */
  53238. protected _ambientTexture: Nullable<BaseTexture>;
  53239. /**
  53240. * AKA Occlusion Texture Intensity in other nomenclature.
  53241. */
  53242. protected _ambientTextureStrength: number;
  53243. /**
  53244. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53245. * 1 means it completely occludes it
  53246. * 0 mean it has no impact
  53247. */
  53248. protected _ambientTextureImpactOnAnalyticalLights: number;
  53249. /**
  53250. * Stores the alpha values in a texture.
  53251. */
  53252. protected _opacityTexture: Nullable<BaseTexture>;
  53253. /**
  53254. * Stores the reflection values in a texture.
  53255. */
  53256. protected _reflectionTexture: Nullable<BaseTexture>;
  53257. /**
  53258. * Stores the emissive values in a texture.
  53259. */
  53260. protected _emissiveTexture: Nullable<BaseTexture>;
  53261. /**
  53262. * AKA Specular texture in other nomenclature.
  53263. */
  53264. protected _reflectivityTexture: Nullable<BaseTexture>;
  53265. /**
  53266. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53267. */
  53268. protected _metallicTexture: Nullable<BaseTexture>;
  53269. /**
  53270. * Specifies the metallic scalar of the metallic/roughness workflow.
  53271. * Can also be used to scale the metalness values of the metallic texture.
  53272. */
  53273. protected _metallic: Nullable<number>;
  53274. /**
  53275. * Specifies the roughness scalar of the metallic/roughness workflow.
  53276. * Can also be used to scale the roughness values of the metallic texture.
  53277. */
  53278. protected _roughness: Nullable<number>;
  53279. /**
  53280. * Specifies the an F0 factor to help configuring the material F0.
  53281. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53282. * to 0.5 the previously hard coded value stays the same.
  53283. * Can also be used to scale the F0 values of the metallic texture.
  53284. */
  53285. protected _metallicF0Factor: number;
  53286. /**
  53287. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53288. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53289. * your expectation as it multiplies with the texture data.
  53290. */
  53291. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53292. /**
  53293. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53294. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53295. */
  53296. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53297. /**
  53298. * Stores surface normal data used to displace a mesh in a texture.
  53299. */
  53300. protected _bumpTexture: Nullable<BaseTexture>;
  53301. /**
  53302. * Stores the pre-calculated light information of a mesh in a texture.
  53303. */
  53304. protected _lightmapTexture: Nullable<BaseTexture>;
  53305. /**
  53306. * The color of a material in ambient lighting.
  53307. */
  53308. protected _ambientColor: Color3;
  53309. /**
  53310. * AKA Diffuse Color in other nomenclature.
  53311. */
  53312. protected _albedoColor: Color3;
  53313. /**
  53314. * AKA Specular Color in other nomenclature.
  53315. */
  53316. protected _reflectivityColor: Color3;
  53317. /**
  53318. * The color applied when light is reflected from a material.
  53319. */
  53320. protected _reflectionColor: Color3;
  53321. /**
  53322. * The color applied when light is emitted from a material.
  53323. */
  53324. protected _emissiveColor: Color3;
  53325. /**
  53326. * AKA Glossiness in other nomenclature.
  53327. */
  53328. protected _microSurface: number;
  53329. /**
  53330. * Specifies that the material will use the light map as a show map.
  53331. */
  53332. protected _useLightmapAsShadowmap: boolean;
  53333. /**
  53334. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53335. * makes the reflect vector face the model (under horizon).
  53336. */
  53337. protected _useHorizonOcclusion: boolean;
  53338. /**
  53339. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53340. * too much the area relying on ambient texture to define their ambient occlusion.
  53341. */
  53342. protected _useRadianceOcclusion: boolean;
  53343. /**
  53344. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53345. */
  53346. protected _useAlphaFromAlbedoTexture: boolean;
  53347. /**
  53348. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53349. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53350. */
  53351. protected _useSpecularOverAlpha: boolean;
  53352. /**
  53353. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53354. */
  53355. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53356. /**
  53357. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53358. */
  53359. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53360. /**
  53361. * Specifies if the metallic texture contains the roughness information in its green channel.
  53362. */
  53363. protected _useRoughnessFromMetallicTextureGreen: boolean;
  53364. /**
  53365. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53366. */
  53367. protected _useMetallnessFromMetallicTextureBlue: boolean;
  53368. /**
  53369. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53370. */
  53371. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  53372. /**
  53373. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53374. */
  53375. protected _useAmbientInGrayScale: boolean;
  53376. /**
  53377. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53378. * The material will try to infer what glossiness each pixel should be.
  53379. */
  53380. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  53381. /**
  53382. * Defines the falloff type used in this material.
  53383. * It by default is Physical.
  53384. */
  53385. protected _lightFalloff: number;
  53386. /**
  53387. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53388. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53389. */
  53390. protected _useRadianceOverAlpha: boolean;
  53391. /**
  53392. * Allows using an object space normal map (instead of tangent space).
  53393. */
  53394. protected _useObjectSpaceNormalMap: boolean;
  53395. /**
  53396. * Allows using the bump map in parallax mode.
  53397. */
  53398. protected _useParallax: boolean;
  53399. /**
  53400. * Allows using the bump map in parallax occlusion mode.
  53401. */
  53402. protected _useParallaxOcclusion: boolean;
  53403. /**
  53404. * Controls the scale bias of the parallax mode.
  53405. */
  53406. protected _parallaxScaleBias: number;
  53407. /**
  53408. * If sets to true, disables all the lights affecting the material.
  53409. */
  53410. protected _disableLighting: boolean;
  53411. /**
  53412. * Number of Simultaneous lights allowed on the material.
  53413. */
  53414. protected _maxSimultaneousLights: number;
  53415. /**
  53416. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  53417. */
  53418. protected _invertNormalMapX: boolean;
  53419. /**
  53420. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  53421. */
  53422. protected _invertNormalMapY: boolean;
  53423. /**
  53424. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53425. */
  53426. protected _twoSidedLighting: boolean;
  53427. /**
  53428. * Defines the alpha limits in alpha test mode.
  53429. */
  53430. protected _alphaCutOff: number;
  53431. /**
  53432. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53433. */
  53434. protected _forceAlphaTest: boolean;
  53435. /**
  53436. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53437. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53438. */
  53439. protected _useAlphaFresnel: boolean;
  53440. /**
  53441. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53442. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53443. */
  53444. protected _useLinearAlphaFresnel: boolean;
  53445. /**
  53446. * The transparency mode of the material.
  53447. */
  53448. protected _transparencyMode: Nullable<number>;
  53449. /**
  53450. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  53451. * from cos thetav and roughness:
  53452. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  53453. */
  53454. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  53455. /**
  53456. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53457. */
  53458. protected _forceIrradianceInFragment: boolean;
  53459. /**
  53460. * Force normal to face away from face.
  53461. */
  53462. protected _forceNormalForward: boolean;
  53463. /**
  53464. * Enables specular anti aliasing in the PBR shader.
  53465. * It will both interacts on the Geometry for analytical and IBL lighting.
  53466. * It also prefilter the roughness map based on the bump values.
  53467. */
  53468. protected _enableSpecularAntiAliasing: boolean;
  53469. /**
  53470. * Default configuration related to image processing available in the PBR Material.
  53471. */
  53472. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  53473. /**
  53474. * Keep track of the image processing observer to allow dispose and replace.
  53475. */
  53476. private _imageProcessingObserver;
  53477. /**
  53478. * Attaches a new image processing configuration to the PBR Material.
  53479. * @param configuration
  53480. */
  53481. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  53482. /**
  53483. * Stores the available render targets.
  53484. */
  53485. private _renderTargets;
  53486. /**
  53487. * Sets the global ambient color for the material used in lighting calculations.
  53488. */
  53489. private _globalAmbientColor;
  53490. /**
  53491. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  53492. */
  53493. private _useLogarithmicDepth;
  53494. /**
  53495. * If set to true, no lighting calculations will be applied.
  53496. */
  53497. private _unlit;
  53498. private _debugMode;
  53499. /**
  53500. * @hidden
  53501. * This is reserved for the inspector.
  53502. * Defines the material debug mode.
  53503. * It helps seeing only some components of the material while troubleshooting.
  53504. */
  53505. debugMode: number;
  53506. /**
  53507. * @hidden
  53508. * This is reserved for the inspector.
  53509. * Specify from where on screen the debug mode should start.
  53510. * The value goes from -1 (full screen) to 1 (not visible)
  53511. * It helps with side by side comparison against the final render
  53512. * This defaults to -1
  53513. */
  53514. private debugLimit;
  53515. /**
  53516. * @hidden
  53517. * This is reserved for the inspector.
  53518. * As the default viewing range might not be enough (if the ambient is really small for instance)
  53519. * You can use the factor to better multiply the final value.
  53520. */
  53521. private debugFactor;
  53522. /**
  53523. * Defines the clear coat layer parameters for the material.
  53524. */
  53525. readonly clearCoat: PBRClearCoatConfiguration;
  53526. /**
  53527. * Defines the anisotropic parameters for the material.
  53528. */
  53529. readonly anisotropy: PBRAnisotropicConfiguration;
  53530. /**
  53531. * Defines the BRDF parameters for the material.
  53532. */
  53533. readonly brdf: PBRBRDFConfiguration;
  53534. /**
  53535. * Defines the Sheen parameters for the material.
  53536. */
  53537. readonly sheen: PBRSheenConfiguration;
  53538. /**
  53539. * Defines the SubSurface parameters for the material.
  53540. */
  53541. readonly subSurface: PBRSubSurfaceConfiguration;
  53542. /**
  53543. * Custom callback helping to override the default shader used in the material.
  53544. */
  53545. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  53546. protected _rebuildInParallel: boolean;
  53547. /**
  53548. * Instantiates a new PBRMaterial instance.
  53549. *
  53550. * @param name The material name
  53551. * @param scene The scene the material will be use in.
  53552. */
  53553. constructor(name: string, scene: Scene);
  53554. /**
  53555. * Gets a boolean indicating that current material needs to register RTT
  53556. */
  53557. get hasRenderTargetTextures(): boolean;
  53558. /**
  53559. * Gets the name of the material class.
  53560. */
  53561. getClassName(): string;
  53562. /**
  53563. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53564. */
  53565. get useLogarithmicDepth(): boolean;
  53566. /**
  53567. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  53568. */
  53569. set useLogarithmicDepth(value: boolean);
  53570. /**
  53571. * Gets the current transparency mode.
  53572. */
  53573. get transparencyMode(): Nullable<number>;
  53574. /**
  53575. * Sets the transparency mode of the material.
  53576. *
  53577. * | Value | Type | Description |
  53578. * | ----- | ----------------------------------- | ----------- |
  53579. * | 0 | OPAQUE | |
  53580. * | 1 | ALPHATEST | |
  53581. * | 2 | ALPHABLEND | |
  53582. * | 3 | ALPHATESTANDBLEND | |
  53583. *
  53584. */
  53585. set transparencyMode(value: Nullable<number>);
  53586. /**
  53587. * Returns true if alpha blending should be disabled.
  53588. */
  53589. private get _disableAlphaBlending();
  53590. /**
  53591. * Specifies whether or not this material should be rendered in alpha blend mode.
  53592. */
  53593. needAlphaBlending(): boolean;
  53594. /**
  53595. * Specifies if the mesh will require alpha blending.
  53596. * @param mesh - BJS mesh.
  53597. */
  53598. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  53599. /**
  53600. * Specifies whether or not this material should be rendered in alpha test mode.
  53601. */
  53602. needAlphaTesting(): boolean;
  53603. /**
  53604. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  53605. */
  53606. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  53607. /**
  53608. * Gets the texture used for the alpha test.
  53609. */
  53610. getAlphaTestTexture(): Nullable<BaseTexture>;
  53611. /**
  53612. * Specifies that the submesh is ready to be used.
  53613. * @param mesh - BJS mesh.
  53614. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  53615. * @param useInstances - Specifies that instances should be used.
  53616. * @returns - boolean indicating that the submesh is ready or not.
  53617. */
  53618. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  53619. /**
  53620. * Specifies if the material uses metallic roughness workflow.
  53621. * @returns boolean specifiying if the material uses metallic roughness workflow.
  53622. */
  53623. isMetallicWorkflow(): boolean;
  53624. private _prepareEffect;
  53625. private _prepareDefines;
  53626. /**
  53627. * Force shader compilation
  53628. */
  53629. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  53630. /**
  53631. * Initializes the uniform buffer layout for the shader.
  53632. */
  53633. buildUniformLayout(): void;
  53634. /**
  53635. * Unbinds the material from the mesh
  53636. */
  53637. unbind(): void;
  53638. /**
  53639. * Binds the submesh data.
  53640. * @param world - The world matrix.
  53641. * @param mesh - The BJS mesh.
  53642. * @param subMesh - A submesh of the BJS mesh.
  53643. */
  53644. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  53645. /**
  53646. * Returns the animatable textures.
  53647. * @returns - Array of animatable textures.
  53648. */
  53649. getAnimatables(): IAnimatable[];
  53650. /**
  53651. * Returns the texture used for reflections.
  53652. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  53653. */
  53654. private _getReflectionTexture;
  53655. /**
  53656. * Returns an array of the actively used textures.
  53657. * @returns - Array of BaseTextures
  53658. */
  53659. getActiveTextures(): BaseTexture[];
  53660. /**
  53661. * Checks to see if a texture is used in the material.
  53662. * @param texture - Base texture to use.
  53663. * @returns - Boolean specifying if a texture is used in the material.
  53664. */
  53665. hasTexture(texture: BaseTexture): boolean;
  53666. /**
  53667. * Disposes the resources of the material.
  53668. * @param forceDisposeEffect - Forces the disposal of effects.
  53669. * @param forceDisposeTextures - Forces the disposal of all textures.
  53670. */
  53671. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  53672. }
  53673. }
  53674. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  53675. import { Nullable } from "babylonjs/types";
  53676. import { Scene } from "babylonjs/scene";
  53677. import { Color3 } from "babylonjs/Maths/math.color";
  53678. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  53679. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  53680. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53681. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  53682. /**
  53683. * The Physically based material of BJS.
  53684. *
  53685. * This offers the main features of a standard PBR material.
  53686. * For more information, please refer to the documentation :
  53687. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53688. */
  53689. export class PBRMaterial extends PBRBaseMaterial {
  53690. /**
  53691. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53692. */
  53693. static readonly PBRMATERIAL_OPAQUE: number;
  53694. /**
  53695. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53696. */
  53697. static readonly PBRMATERIAL_ALPHATEST: number;
  53698. /**
  53699. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53700. */
  53701. static readonly PBRMATERIAL_ALPHABLEND: number;
  53702. /**
  53703. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53704. * They are also discarded below the alpha cutoff threshold to improve performances.
  53705. */
  53706. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53707. /**
  53708. * Defines the default value of how much AO map is occluding the analytical lights
  53709. * (point spot...).
  53710. */
  53711. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53712. /**
  53713. * Intensity of the direct lights e.g. the four lights available in your scene.
  53714. * This impacts both the direct diffuse and specular highlights.
  53715. */
  53716. directIntensity: number;
  53717. /**
  53718. * Intensity of the emissive part of the material.
  53719. * This helps controlling the emissive effect without modifying the emissive color.
  53720. */
  53721. emissiveIntensity: number;
  53722. /**
  53723. * Intensity of the environment e.g. how much the environment will light the object
  53724. * either through harmonics for rough material or through the refelction for shiny ones.
  53725. */
  53726. environmentIntensity: number;
  53727. /**
  53728. * This is a special control allowing the reduction of the specular highlights coming from the
  53729. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53730. */
  53731. specularIntensity: number;
  53732. /**
  53733. * Debug Control allowing disabling the bump map on this material.
  53734. */
  53735. disableBumpMap: boolean;
  53736. /**
  53737. * AKA Diffuse Texture in standard nomenclature.
  53738. */
  53739. albedoTexture: BaseTexture;
  53740. /**
  53741. * AKA Occlusion Texture in other nomenclature.
  53742. */
  53743. ambientTexture: BaseTexture;
  53744. /**
  53745. * AKA Occlusion Texture Intensity in other nomenclature.
  53746. */
  53747. ambientTextureStrength: number;
  53748. /**
  53749. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53750. * 1 means it completely occludes it
  53751. * 0 mean it has no impact
  53752. */
  53753. ambientTextureImpactOnAnalyticalLights: number;
  53754. /**
  53755. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  53756. */
  53757. opacityTexture: BaseTexture;
  53758. /**
  53759. * Stores the reflection values in a texture.
  53760. */
  53761. reflectionTexture: Nullable<BaseTexture>;
  53762. /**
  53763. * Stores the emissive values in a texture.
  53764. */
  53765. emissiveTexture: BaseTexture;
  53766. /**
  53767. * AKA Specular texture in other nomenclature.
  53768. */
  53769. reflectivityTexture: BaseTexture;
  53770. /**
  53771. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53772. */
  53773. metallicTexture: BaseTexture;
  53774. /**
  53775. * Specifies the metallic scalar of the metallic/roughness workflow.
  53776. * Can also be used to scale the metalness values of the metallic texture.
  53777. */
  53778. metallic: Nullable<number>;
  53779. /**
  53780. * Specifies the roughness scalar of the metallic/roughness workflow.
  53781. * Can also be used to scale the roughness values of the metallic texture.
  53782. */
  53783. roughness: Nullable<number>;
  53784. /**
  53785. * Specifies the an F0 factor to help configuring the material F0.
  53786. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53787. * to 0.5 the previously hard coded value stays the same.
  53788. * Can also be used to scale the F0 values of the metallic texture.
  53789. */
  53790. metallicF0Factor: number;
  53791. /**
  53792. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53793. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53794. * your expectation as it multiplies with the texture data.
  53795. */
  53796. useMetallicF0FactorFromMetallicTexture: boolean;
  53797. /**
  53798. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53799. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53800. */
  53801. microSurfaceTexture: BaseTexture;
  53802. /**
  53803. * Stores surface normal data used to displace a mesh in a texture.
  53804. */
  53805. bumpTexture: BaseTexture;
  53806. /**
  53807. * Stores the pre-calculated light information of a mesh in a texture.
  53808. */
  53809. lightmapTexture: BaseTexture;
  53810. /**
  53811. * Stores the refracted light information in a texture.
  53812. */
  53813. get refractionTexture(): Nullable<BaseTexture>;
  53814. set refractionTexture(value: Nullable<BaseTexture>);
  53815. /**
  53816. * The color of a material in ambient lighting.
  53817. */
  53818. ambientColor: Color3;
  53819. /**
  53820. * AKA Diffuse Color in other nomenclature.
  53821. */
  53822. albedoColor: Color3;
  53823. /**
  53824. * AKA Specular Color in other nomenclature.
  53825. */
  53826. reflectivityColor: Color3;
  53827. /**
  53828. * The color reflected from the material.
  53829. */
  53830. reflectionColor: Color3;
  53831. /**
  53832. * The color emitted from the material.
  53833. */
  53834. emissiveColor: Color3;
  53835. /**
  53836. * AKA Glossiness in other nomenclature.
  53837. */
  53838. microSurface: number;
  53839. /**
  53840. * source material index of refraction (IOR)' / 'destination material IOR.
  53841. */
  53842. get indexOfRefraction(): number;
  53843. set indexOfRefraction(value: number);
  53844. /**
  53845. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53846. */
  53847. get invertRefractionY(): boolean;
  53848. set invertRefractionY(value: boolean);
  53849. /**
  53850. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53851. * Materials half opaque for instance using refraction could benefit from this control.
  53852. */
  53853. get linkRefractionWithTransparency(): boolean;
  53854. set linkRefractionWithTransparency(value: boolean);
  53855. /**
  53856. * If true, the light map contains occlusion information instead of lighting info.
  53857. */
  53858. useLightmapAsShadowmap: boolean;
  53859. /**
  53860. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53861. */
  53862. useAlphaFromAlbedoTexture: boolean;
  53863. /**
  53864. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  53865. */
  53866. forceAlphaTest: boolean;
  53867. /**
  53868. * Defines the alpha limits in alpha test mode.
  53869. */
  53870. alphaCutOff: number;
  53871. /**
  53872. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  53873. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53874. */
  53875. useSpecularOverAlpha: boolean;
  53876. /**
  53877. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53878. */
  53879. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53880. /**
  53881. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53882. */
  53883. useRoughnessFromMetallicTextureAlpha: boolean;
  53884. /**
  53885. * Specifies if the metallic texture contains the roughness information in its green channel.
  53886. */
  53887. useRoughnessFromMetallicTextureGreen: boolean;
  53888. /**
  53889. * Specifies if the metallic texture contains the metallness information in its blue channel.
  53890. */
  53891. useMetallnessFromMetallicTextureBlue: boolean;
  53892. /**
  53893. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  53894. */
  53895. useAmbientOcclusionFromMetallicTextureRed: boolean;
  53896. /**
  53897. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  53898. */
  53899. useAmbientInGrayScale: boolean;
  53900. /**
  53901. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  53902. * The material will try to infer what glossiness each pixel should be.
  53903. */
  53904. useAutoMicroSurfaceFromReflectivityMap: boolean;
  53905. /**
  53906. * BJS is using an harcoded light falloff based on a manually sets up range.
  53907. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53908. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53909. */
  53910. get usePhysicalLightFalloff(): boolean;
  53911. /**
  53912. * BJS is using an harcoded light falloff based on a manually sets up range.
  53913. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  53914. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  53915. */
  53916. set usePhysicalLightFalloff(value: boolean);
  53917. /**
  53918. * In order to support the falloff compatibility with gltf, a special mode has been added
  53919. * to reproduce the gltf light falloff.
  53920. */
  53921. get useGLTFLightFalloff(): boolean;
  53922. /**
  53923. * In order to support the falloff compatibility with gltf, a special mode has been added
  53924. * to reproduce the gltf light falloff.
  53925. */
  53926. set useGLTFLightFalloff(value: boolean);
  53927. /**
  53928. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  53929. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  53930. */
  53931. useRadianceOverAlpha: boolean;
  53932. /**
  53933. * Allows using an object space normal map (instead of tangent space).
  53934. */
  53935. useObjectSpaceNormalMap: boolean;
  53936. /**
  53937. * Allows using the bump map in parallax mode.
  53938. */
  53939. useParallax: boolean;
  53940. /**
  53941. * Allows using the bump map in parallax occlusion mode.
  53942. */
  53943. useParallaxOcclusion: boolean;
  53944. /**
  53945. * Controls the scale bias of the parallax mode.
  53946. */
  53947. parallaxScaleBias: number;
  53948. /**
  53949. * If sets to true, disables all the lights affecting the material.
  53950. */
  53951. disableLighting: boolean;
  53952. /**
  53953. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  53954. */
  53955. forceIrradianceInFragment: boolean;
  53956. /**
  53957. * Number of Simultaneous lights allowed on the material.
  53958. */
  53959. maxSimultaneousLights: number;
  53960. /**
  53961. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  53962. */
  53963. invertNormalMapX: boolean;
  53964. /**
  53965. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  53966. */
  53967. invertNormalMapY: boolean;
  53968. /**
  53969. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  53970. */
  53971. twoSidedLighting: boolean;
  53972. /**
  53973. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53974. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  53975. */
  53976. useAlphaFresnel: boolean;
  53977. /**
  53978. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  53979. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  53980. */
  53981. useLinearAlphaFresnel: boolean;
  53982. /**
  53983. * Let user defines the brdf lookup texture used for IBL.
  53984. * A default 8bit version is embedded but you could point at :
  53985. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  53986. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  53987. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  53988. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  53989. */
  53990. environmentBRDFTexture: Nullable<BaseTexture>;
  53991. /**
  53992. * Force normal to face away from face.
  53993. */
  53994. forceNormalForward: boolean;
  53995. /**
  53996. * Enables specular anti aliasing in the PBR shader.
  53997. * It will both interacts on the Geometry for analytical and IBL lighting.
  53998. * It also prefilter the roughness map based on the bump values.
  53999. */
  54000. enableSpecularAntiAliasing: boolean;
  54001. /**
  54002. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54003. * makes the reflect vector face the model (under horizon).
  54004. */
  54005. useHorizonOcclusion: boolean;
  54006. /**
  54007. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54008. * too much the area relying on ambient texture to define their ambient occlusion.
  54009. */
  54010. useRadianceOcclusion: boolean;
  54011. /**
  54012. * If set to true, no lighting calculations will be applied.
  54013. */
  54014. unlit: boolean;
  54015. /**
  54016. * Gets the image processing configuration used either in this material.
  54017. */
  54018. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54019. /**
  54020. * Sets the Default image processing configuration used either in the this material.
  54021. *
  54022. * If sets to null, the scene one is in use.
  54023. */
  54024. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54025. /**
  54026. * Gets wether the color curves effect is enabled.
  54027. */
  54028. get cameraColorCurvesEnabled(): boolean;
  54029. /**
  54030. * Sets wether the color curves effect is enabled.
  54031. */
  54032. set cameraColorCurvesEnabled(value: boolean);
  54033. /**
  54034. * Gets wether the color grading effect is enabled.
  54035. */
  54036. get cameraColorGradingEnabled(): boolean;
  54037. /**
  54038. * Gets wether the color grading effect is enabled.
  54039. */
  54040. set cameraColorGradingEnabled(value: boolean);
  54041. /**
  54042. * Gets wether tonemapping is enabled or not.
  54043. */
  54044. get cameraToneMappingEnabled(): boolean;
  54045. /**
  54046. * Sets wether tonemapping is enabled or not
  54047. */
  54048. set cameraToneMappingEnabled(value: boolean);
  54049. /**
  54050. * The camera exposure used on this material.
  54051. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54052. * This corresponds to a photographic exposure.
  54053. */
  54054. get cameraExposure(): number;
  54055. /**
  54056. * The camera exposure used on this material.
  54057. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54058. * This corresponds to a photographic exposure.
  54059. */
  54060. set cameraExposure(value: number);
  54061. /**
  54062. * Gets The camera contrast used on this material.
  54063. */
  54064. get cameraContrast(): number;
  54065. /**
  54066. * Sets The camera contrast used on this material.
  54067. */
  54068. set cameraContrast(value: number);
  54069. /**
  54070. * Gets the Color Grading 2D Lookup Texture.
  54071. */
  54072. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54073. /**
  54074. * Sets the Color Grading 2D Lookup Texture.
  54075. */
  54076. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54077. /**
  54078. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54079. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54080. * 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;
  54081. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54082. */
  54083. get cameraColorCurves(): Nullable<ColorCurves>;
  54084. /**
  54085. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54086. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54087. * 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;
  54088. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54089. */
  54090. set cameraColorCurves(value: Nullable<ColorCurves>);
  54091. /**
  54092. * Instantiates a new PBRMaterial instance.
  54093. *
  54094. * @param name The material name
  54095. * @param scene The scene the material will be use in.
  54096. */
  54097. constructor(name: string, scene: Scene);
  54098. /**
  54099. * Returns the name of this material class.
  54100. */
  54101. getClassName(): string;
  54102. /**
  54103. * Makes a duplicate of the current material.
  54104. * @param name - name to use for the new material.
  54105. */
  54106. clone(name: string): PBRMaterial;
  54107. /**
  54108. * Serializes this PBR Material.
  54109. * @returns - An object with the serialized material.
  54110. */
  54111. serialize(): any;
  54112. /**
  54113. * Parses a PBR Material from a serialized object.
  54114. * @param source - Serialized object.
  54115. * @param scene - BJS scene instance.
  54116. * @param rootUrl - url for the scene object
  54117. * @returns - PBRMaterial
  54118. */
  54119. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54120. }
  54121. }
  54122. declare module "babylonjs/Misc/dds" {
  54123. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54124. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54125. import { Nullable } from "babylonjs/types";
  54126. import { Scene } from "babylonjs/scene";
  54127. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54128. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54129. /**
  54130. * Direct draw surface info
  54131. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54132. */
  54133. export interface DDSInfo {
  54134. /**
  54135. * Width of the texture
  54136. */
  54137. width: number;
  54138. /**
  54139. * Width of the texture
  54140. */
  54141. height: number;
  54142. /**
  54143. * Number of Mipmaps for the texture
  54144. * @see https://en.wikipedia.org/wiki/Mipmap
  54145. */
  54146. mipmapCount: number;
  54147. /**
  54148. * If the textures format is a known fourCC format
  54149. * @see https://www.fourcc.org/
  54150. */
  54151. isFourCC: boolean;
  54152. /**
  54153. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54154. */
  54155. isRGB: boolean;
  54156. /**
  54157. * If the texture is a lumincance format
  54158. */
  54159. isLuminance: boolean;
  54160. /**
  54161. * If this is a cube texture
  54162. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54163. */
  54164. isCube: boolean;
  54165. /**
  54166. * If the texture is a compressed format eg. FOURCC_DXT1
  54167. */
  54168. isCompressed: boolean;
  54169. /**
  54170. * The dxgiFormat of the texture
  54171. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54172. */
  54173. dxgiFormat: number;
  54174. /**
  54175. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54176. */
  54177. textureType: number;
  54178. /**
  54179. * Sphericle polynomial created for the dds texture
  54180. */
  54181. sphericalPolynomial?: SphericalPolynomial;
  54182. }
  54183. /**
  54184. * Class used to provide DDS decompression tools
  54185. */
  54186. export class DDSTools {
  54187. /**
  54188. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54189. */
  54190. static StoreLODInAlphaChannel: boolean;
  54191. /**
  54192. * Gets DDS information from an array buffer
  54193. * @param data defines the array buffer view to read data from
  54194. * @returns the DDS information
  54195. */
  54196. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54197. private static _FloatView;
  54198. private static _Int32View;
  54199. private static _ToHalfFloat;
  54200. private static _FromHalfFloat;
  54201. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54202. private static _GetHalfFloatRGBAArrayBuffer;
  54203. private static _GetFloatRGBAArrayBuffer;
  54204. private static _GetFloatAsUIntRGBAArrayBuffer;
  54205. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54206. private static _GetRGBAArrayBuffer;
  54207. private static _ExtractLongWordOrder;
  54208. private static _GetRGBArrayBuffer;
  54209. private static _GetLuminanceArrayBuffer;
  54210. /**
  54211. * Uploads DDS Levels to a Babylon Texture
  54212. * @hidden
  54213. */
  54214. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54215. }
  54216. module "babylonjs/Engines/thinEngine" {
  54217. interface ThinEngine {
  54218. /**
  54219. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54220. * @param rootUrl defines the url where the file to load is located
  54221. * @param scene defines the current scene
  54222. * @param lodScale defines scale to apply to the mip map selection
  54223. * @param lodOffset defines offset to apply to the mip map selection
  54224. * @param onLoad defines an optional callback raised when the texture is loaded
  54225. * @param onError defines an optional callback raised if there is an issue to load the texture
  54226. * @param format defines the format of the data
  54227. * @param forcedExtension defines the extension to use to pick the right loader
  54228. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54229. * @returns the cube texture as an InternalTexture
  54230. */
  54231. 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;
  54232. }
  54233. }
  54234. }
  54235. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54236. import { Nullable } from "babylonjs/types";
  54237. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54238. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54239. /**
  54240. * Implementation of the DDS Texture Loader.
  54241. * @hidden
  54242. */
  54243. export class _DDSTextureLoader implements IInternalTextureLoader {
  54244. /**
  54245. * Defines wether the loader supports cascade loading the different faces.
  54246. */
  54247. readonly supportCascades: boolean;
  54248. /**
  54249. * This returns if the loader support the current file information.
  54250. * @param extension defines the file extension of the file being loaded
  54251. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54252. * @param fallback defines the fallback internal texture if any
  54253. * @param isBase64 defines whether the texture is encoded as a base64
  54254. * @param isBuffer defines whether the texture data are stored as a buffer
  54255. * @returns true if the loader can load the specified file
  54256. */
  54257. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54258. /**
  54259. * Transform the url before loading if required.
  54260. * @param rootUrl the url of the texture
  54261. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54262. * @returns the transformed texture
  54263. */
  54264. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54265. /**
  54266. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54267. * @param rootUrl the url of the texture
  54268. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54269. * @returns the fallback texture
  54270. */
  54271. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54272. /**
  54273. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54274. * @param data contains the texture data
  54275. * @param texture defines the BabylonJS internal texture
  54276. * @param createPolynomials will be true if polynomials have been requested
  54277. * @param onLoad defines the callback to trigger once the texture is ready
  54278. * @param onError defines the callback to trigger in case of error
  54279. */
  54280. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54281. /**
  54282. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54283. * @param data contains the texture data
  54284. * @param texture defines the BabylonJS internal texture
  54285. * @param callback defines the method to call once ready to upload
  54286. */
  54287. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54288. }
  54289. }
  54290. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54291. import { Nullable } from "babylonjs/types";
  54292. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54293. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54294. /**
  54295. * Implementation of the ENV Texture Loader.
  54296. * @hidden
  54297. */
  54298. export class _ENVTextureLoader implements IInternalTextureLoader {
  54299. /**
  54300. * Defines wether the loader supports cascade loading the different faces.
  54301. */
  54302. readonly supportCascades: boolean;
  54303. /**
  54304. * This returns if the loader support the current file information.
  54305. * @param extension defines the file extension of the file being loaded
  54306. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54307. * @param fallback defines the fallback internal texture if any
  54308. * @param isBase64 defines whether the texture is encoded as a base64
  54309. * @param isBuffer defines whether the texture data are stored as a buffer
  54310. * @returns true if the loader can load the specified file
  54311. */
  54312. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54313. /**
  54314. * Transform the url before loading if required.
  54315. * @param rootUrl the url of the texture
  54316. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54317. * @returns the transformed texture
  54318. */
  54319. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54320. /**
  54321. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54322. * @param rootUrl the url of the texture
  54323. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54324. * @returns the fallback texture
  54325. */
  54326. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54327. /**
  54328. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54329. * @param data contains the texture data
  54330. * @param texture defines the BabylonJS internal texture
  54331. * @param createPolynomials will be true if polynomials have been requested
  54332. * @param onLoad defines the callback to trigger once the texture is ready
  54333. * @param onError defines the callback to trigger in case of error
  54334. */
  54335. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54336. /**
  54337. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54338. * @param data contains the texture data
  54339. * @param texture defines the BabylonJS internal texture
  54340. * @param callback defines the method to call once ready to upload
  54341. */
  54342. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54343. }
  54344. }
  54345. declare module "babylonjs/Misc/khronosTextureContainer" {
  54346. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54347. /**
  54348. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54349. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54350. */
  54351. export class KhronosTextureContainer {
  54352. /** contents of the KTX container file */
  54353. data: ArrayBufferView;
  54354. private static HEADER_LEN;
  54355. private static COMPRESSED_2D;
  54356. private static COMPRESSED_3D;
  54357. private static TEX_2D;
  54358. private static TEX_3D;
  54359. /**
  54360. * Gets the openGL type
  54361. */
  54362. glType: number;
  54363. /**
  54364. * Gets the openGL type size
  54365. */
  54366. glTypeSize: number;
  54367. /**
  54368. * Gets the openGL format
  54369. */
  54370. glFormat: number;
  54371. /**
  54372. * Gets the openGL internal format
  54373. */
  54374. glInternalFormat: number;
  54375. /**
  54376. * Gets the base internal format
  54377. */
  54378. glBaseInternalFormat: number;
  54379. /**
  54380. * Gets image width in pixel
  54381. */
  54382. pixelWidth: number;
  54383. /**
  54384. * Gets image height in pixel
  54385. */
  54386. pixelHeight: number;
  54387. /**
  54388. * Gets image depth in pixels
  54389. */
  54390. pixelDepth: number;
  54391. /**
  54392. * Gets the number of array elements
  54393. */
  54394. numberOfArrayElements: number;
  54395. /**
  54396. * Gets the number of faces
  54397. */
  54398. numberOfFaces: number;
  54399. /**
  54400. * Gets the number of mipmap levels
  54401. */
  54402. numberOfMipmapLevels: number;
  54403. /**
  54404. * Gets the bytes of key value data
  54405. */
  54406. bytesOfKeyValueData: number;
  54407. /**
  54408. * Gets the load type
  54409. */
  54410. loadType: number;
  54411. /**
  54412. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54413. */
  54414. isInvalid: boolean;
  54415. /**
  54416. * Creates a new KhronosTextureContainer
  54417. * @param data contents of the KTX container file
  54418. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54419. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54420. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54421. */
  54422. constructor(
  54423. /** contents of the KTX container file */
  54424. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  54425. /**
  54426. * Uploads KTX content to a Babylon Texture.
  54427. * It is assumed that the texture has already been created & is currently bound
  54428. * @hidden
  54429. */
  54430. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  54431. private _upload2DCompressedLevels;
  54432. }
  54433. }
  54434. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  54435. import { Nullable } from "babylonjs/types";
  54436. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54437. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54438. /**
  54439. * Implementation of the KTX Texture Loader.
  54440. * @hidden
  54441. */
  54442. export class _KTXTextureLoader implements IInternalTextureLoader {
  54443. /**
  54444. * Defines wether the loader supports cascade loading the different faces.
  54445. */
  54446. readonly supportCascades: boolean;
  54447. /**
  54448. * This returns if the loader support the current file information.
  54449. * @param extension defines the file extension of the file being loaded
  54450. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54451. * @param fallback defines the fallback internal texture if any
  54452. * @param isBase64 defines whether the texture is encoded as a base64
  54453. * @param isBuffer defines whether the texture data are stored as a buffer
  54454. * @returns true if the loader can load the specified file
  54455. */
  54456. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54457. /**
  54458. * Transform the url before loading if required.
  54459. * @param rootUrl the url of the texture
  54460. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54461. * @returns the transformed texture
  54462. */
  54463. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54464. /**
  54465. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54466. * @param rootUrl the url of the texture
  54467. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54468. * @returns the fallback texture
  54469. */
  54470. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54471. /**
  54472. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54473. * @param data contains the texture data
  54474. * @param texture defines the BabylonJS internal texture
  54475. * @param createPolynomials will be true if polynomials have been requested
  54476. * @param onLoad defines the callback to trigger once the texture is ready
  54477. * @param onError defines the callback to trigger in case of error
  54478. */
  54479. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54480. /**
  54481. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54482. * @param data contains the texture data
  54483. * @param texture defines the BabylonJS internal texture
  54484. * @param callback defines the method to call once ready to upload
  54485. */
  54486. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  54487. }
  54488. }
  54489. declare module "babylonjs/Helpers/sceneHelpers" {
  54490. import { Nullable } from "babylonjs/types";
  54491. import { Mesh } from "babylonjs/Meshes/mesh";
  54492. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54493. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  54494. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  54495. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54496. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54497. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54498. import "babylonjs/Meshes/Builders/boxBuilder";
  54499. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  54500. /** @hidden */
  54501. export var _forceSceneHelpersToBundle: boolean;
  54502. module "babylonjs/scene" {
  54503. interface Scene {
  54504. /**
  54505. * Creates a default light for the scene.
  54506. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  54507. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  54508. */
  54509. createDefaultLight(replace?: boolean): void;
  54510. /**
  54511. * Creates a default camera for the scene.
  54512. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  54513. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54514. * @param replace has default false, when true replaces the active camera in the scene
  54515. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  54516. */
  54517. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54518. /**
  54519. * Creates a default camera and a default light.
  54520. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  54521. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  54522. * @param replace has the default false, when true replaces the active camera/light in the scene
  54523. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  54524. */
  54525. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  54526. /**
  54527. * Creates a new sky box
  54528. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  54529. * @param environmentTexture defines the texture to use as environment texture
  54530. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  54531. * @param scale defines the overall scale of the skybox
  54532. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  54533. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  54534. * @returns a new mesh holding the sky box
  54535. */
  54536. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  54537. /**
  54538. * Creates a new environment
  54539. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  54540. * @param options defines the options you can use to configure the environment
  54541. * @returns the new EnvironmentHelper
  54542. */
  54543. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  54544. /**
  54545. * Creates a new VREXperienceHelper
  54546. * @see http://doc.babylonjs.com/how_to/webvr_helper
  54547. * @param webVROptions defines the options used to create the new VREXperienceHelper
  54548. * @returns a new VREXperienceHelper
  54549. */
  54550. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  54551. /**
  54552. * Creates a new WebXRDefaultExperience
  54553. * @see http://doc.babylonjs.com/how_to/webxr
  54554. * @param options experience options
  54555. * @returns a promise for a new WebXRDefaultExperience
  54556. */
  54557. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  54558. }
  54559. }
  54560. }
  54561. declare module "babylonjs/Helpers/videoDome" {
  54562. import { Scene } from "babylonjs/scene";
  54563. import { TransformNode } from "babylonjs/Meshes/transformNode";
  54564. import { Mesh } from "babylonjs/Meshes/mesh";
  54565. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  54566. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  54567. import "babylonjs/Meshes/Builders/sphereBuilder";
  54568. /**
  54569. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  54570. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  54571. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  54572. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  54573. */
  54574. export class VideoDome extends TransformNode {
  54575. /**
  54576. * Define the video source as a Monoscopic panoramic 360 video.
  54577. */
  54578. static readonly MODE_MONOSCOPIC: number;
  54579. /**
  54580. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54581. */
  54582. static readonly MODE_TOPBOTTOM: number;
  54583. /**
  54584. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54585. */
  54586. static readonly MODE_SIDEBYSIDE: number;
  54587. private _halfDome;
  54588. private _useDirectMapping;
  54589. /**
  54590. * The video texture being displayed on the sphere
  54591. */
  54592. protected _videoTexture: VideoTexture;
  54593. /**
  54594. * Gets the video texture being displayed on the sphere
  54595. */
  54596. get videoTexture(): VideoTexture;
  54597. /**
  54598. * The skybox material
  54599. */
  54600. protected _material: BackgroundMaterial;
  54601. /**
  54602. * The surface used for the skybox
  54603. */
  54604. protected _mesh: Mesh;
  54605. /**
  54606. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  54607. */
  54608. private _halfDomeMask;
  54609. /**
  54610. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  54611. * Also see the options.resolution property.
  54612. */
  54613. get fovMultiplier(): number;
  54614. set fovMultiplier(value: number);
  54615. private _videoMode;
  54616. /**
  54617. * Gets or set the current video mode for the video. It can be:
  54618. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  54619. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  54620. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  54621. */
  54622. get videoMode(): number;
  54623. set videoMode(value: number);
  54624. /**
  54625. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  54626. *
  54627. */
  54628. get halfDome(): boolean;
  54629. /**
  54630. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  54631. */
  54632. set halfDome(enabled: boolean);
  54633. /**
  54634. * Oberserver used in Stereoscopic VR Mode.
  54635. */
  54636. private _onBeforeCameraRenderObserver;
  54637. /**
  54638. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  54639. * @param name Element's name, child elements will append suffixes for their own names.
  54640. * @param urlsOrVideo defines the url(s) or the video element to use
  54641. * @param options An object containing optional or exposed sub element properties
  54642. */
  54643. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  54644. resolution?: number;
  54645. clickToPlay?: boolean;
  54646. autoPlay?: boolean;
  54647. loop?: boolean;
  54648. size?: number;
  54649. poster?: string;
  54650. faceForward?: boolean;
  54651. useDirectMapping?: boolean;
  54652. halfDomeMode?: boolean;
  54653. }, scene: Scene);
  54654. private _changeVideoMode;
  54655. /**
  54656. * Releases resources associated with this node.
  54657. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  54658. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  54659. */
  54660. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  54661. }
  54662. }
  54663. declare module "babylonjs/Helpers/index" {
  54664. export * from "babylonjs/Helpers/environmentHelper";
  54665. export * from "babylonjs/Helpers/photoDome";
  54666. export * from "babylonjs/Helpers/sceneHelpers";
  54667. export * from "babylonjs/Helpers/videoDome";
  54668. }
  54669. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  54670. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54671. import { IDisposable } from "babylonjs/scene";
  54672. import { Engine } from "babylonjs/Engines/engine";
  54673. /**
  54674. * This class can be used to get instrumentation data from a Babylon engine
  54675. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54676. */
  54677. export class EngineInstrumentation implements IDisposable {
  54678. /**
  54679. * Define the instrumented engine.
  54680. */
  54681. engine: Engine;
  54682. private _captureGPUFrameTime;
  54683. private _gpuFrameTimeToken;
  54684. private _gpuFrameTime;
  54685. private _captureShaderCompilationTime;
  54686. private _shaderCompilationTime;
  54687. private _onBeginFrameObserver;
  54688. private _onEndFrameObserver;
  54689. private _onBeforeShaderCompilationObserver;
  54690. private _onAfterShaderCompilationObserver;
  54691. /**
  54692. * Gets the perf counter used for GPU frame time
  54693. */
  54694. get gpuFrameTimeCounter(): PerfCounter;
  54695. /**
  54696. * Gets the GPU frame time capture status
  54697. */
  54698. get captureGPUFrameTime(): boolean;
  54699. /**
  54700. * Enable or disable the GPU frame time capture
  54701. */
  54702. set captureGPUFrameTime(value: boolean);
  54703. /**
  54704. * Gets the perf counter used for shader compilation time
  54705. */
  54706. get shaderCompilationTimeCounter(): PerfCounter;
  54707. /**
  54708. * Gets the shader compilation time capture status
  54709. */
  54710. get captureShaderCompilationTime(): boolean;
  54711. /**
  54712. * Enable or disable the shader compilation time capture
  54713. */
  54714. set captureShaderCompilationTime(value: boolean);
  54715. /**
  54716. * Instantiates a new engine instrumentation.
  54717. * This class can be used to get instrumentation data from a Babylon engine
  54718. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  54719. * @param engine Defines the engine to instrument
  54720. */
  54721. constructor(
  54722. /**
  54723. * Define the instrumented engine.
  54724. */
  54725. engine: Engine);
  54726. /**
  54727. * Dispose and release associated resources.
  54728. */
  54729. dispose(): void;
  54730. }
  54731. }
  54732. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  54733. import { Scene, IDisposable } from "babylonjs/scene";
  54734. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  54735. /**
  54736. * This class can be used to get instrumentation data from a Babylon engine
  54737. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54738. */
  54739. export class SceneInstrumentation implements IDisposable {
  54740. /**
  54741. * Defines the scene to instrument
  54742. */
  54743. scene: Scene;
  54744. private _captureActiveMeshesEvaluationTime;
  54745. private _activeMeshesEvaluationTime;
  54746. private _captureRenderTargetsRenderTime;
  54747. private _renderTargetsRenderTime;
  54748. private _captureFrameTime;
  54749. private _frameTime;
  54750. private _captureRenderTime;
  54751. private _renderTime;
  54752. private _captureInterFrameTime;
  54753. private _interFrameTime;
  54754. private _captureParticlesRenderTime;
  54755. private _particlesRenderTime;
  54756. private _captureSpritesRenderTime;
  54757. private _spritesRenderTime;
  54758. private _capturePhysicsTime;
  54759. private _physicsTime;
  54760. private _captureAnimationsTime;
  54761. private _animationsTime;
  54762. private _captureCameraRenderTime;
  54763. private _cameraRenderTime;
  54764. private _onBeforeActiveMeshesEvaluationObserver;
  54765. private _onAfterActiveMeshesEvaluationObserver;
  54766. private _onBeforeRenderTargetsRenderObserver;
  54767. private _onAfterRenderTargetsRenderObserver;
  54768. private _onAfterRenderObserver;
  54769. private _onBeforeDrawPhaseObserver;
  54770. private _onAfterDrawPhaseObserver;
  54771. private _onBeforeAnimationsObserver;
  54772. private _onBeforeParticlesRenderingObserver;
  54773. private _onAfterParticlesRenderingObserver;
  54774. private _onBeforeSpritesRenderingObserver;
  54775. private _onAfterSpritesRenderingObserver;
  54776. private _onBeforePhysicsObserver;
  54777. private _onAfterPhysicsObserver;
  54778. private _onAfterAnimationsObserver;
  54779. private _onBeforeCameraRenderObserver;
  54780. private _onAfterCameraRenderObserver;
  54781. /**
  54782. * Gets the perf counter used for active meshes evaluation time
  54783. */
  54784. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  54785. /**
  54786. * Gets the active meshes evaluation time capture status
  54787. */
  54788. get captureActiveMeshesEvaluationTime(): boolean;
  54789. /**
  54790. * Enable or disable the active meshes evaluation time capture
  54791. */
  54792. set captureActiveMeshesEvaluationTime(value: boolean);
  54793. /**
  54794. * Gets the perf counter used for render targets render time
  54795. */
  54796. get renderTargetsRenderTimeCounter(): PerfCounter;
  54797. /**
  54798. * Gets the render targets render time capture status
  54799. */
  54800. get captureRenderTargetsRenderTime(): boolean;
  54801. /**
  54802. * Enable or disable the render targets render time capture
  54803. */
  54804. set captureRenderTargetsRenderTime(value: boolean);
  54805. /**
  54806. * Gets the perf counter used for particles render time
  54807. */
  54808. get particlesRenderTimeCounter(): PerfCounter;
  54809. /**
  54810. * Gets the particles render time capture status
  54811. */
  54812. get captureParticlesRenderTime(): boolean;
  54813. /**
  54814. * Enable or disable the particles render time capture
  54815. */
  54816. set captureParticlesRenderTime(value: boolean);
  54817. /**
  54818. * Gets the perf counter used for sprites render time
  54819. */
  54820. get spritesRenderTimeCounter(): PerfCounter;
  54821. /**
  54822. * Gets the sprites render time capture status
  54823. */
  54824. get captureSpritesRenderTime(): boolean;
  54825. /**
  54826. * Enable or disable the sprites render time capture
  54827. */
  54828. set captureSpritesRenderTime(value: boolean);
  54829. /**
  54830. * Gets the perf counter used for physics time
  54831. */
  54832. get physicsTimeCounter(): PerfCounter;
  54833. /**
  54834. * Gets the physics time capture status
  54835. */
  54836. get capturePhysicsTime(): boolean;
  54837. /**
  54838. * Enable or disable the physics time capture
  54839. */
  54840. set capturePhysicsTime(value: boolean);
  54841. /**
  54842. * Gets the perf counter used for animations time
  54843. */
  54844. get animationsTimeCounter(): PerfCounter;
  54845. /**
  54846. * Gets the animations time capture status
  54847. */
  54848. get captureAnimationsTime(): boolean;
  54849. /**
  54850. * Enable or disable the animations time capture
  54851. */
  54852. set captureAnimationsTime(value: boolean);
  54853. /**
  54854. * Gets the perf counter used for frame time capture
  54855. */
  54856. get frameTimeCounter(): PerfCounter;
  54857. /**
  54858. * Gets the frame time capture status
  54859. */
  54860. get captureFrameTime(): boolean;
  54861. /**
  54862. * Enable or disable the frame time capture
  54863. */
  54864. set captureFrameTime(value: boolean);
  54865. /**
  54866. * Gets the perf counter used for inter-frames time capture
  54867. */
  54868. get interFrameTimeCounter(): PerfCounter;
  54869. /**
  54870. * Gets the inter-frames time capture status
  54871. */
  54872. get captureInterFrameTime(): boolean;
  54873. /**
  54874. * Enable or disable the inter-frames time capture
  54875. */
  54876. set captureInterFrameTime(value: boolean);
  54877. /**
  54878. * Gets the perf counter used for render time capture
  54879. */
  54880. get renderTimeCounter(): PerfCounter;
  54881. /**
  54882. * Gets the render time capture status
  54883. */
  54884. get captureRenderTime(): boolean;
  54885. /**
  54886. * Enable or disable the render time capture
  54887. */
  54888. set captureRenderTime(value: boolean);
  54889. /**
  54890. * Gets the perf counter used for camera render time capture
  54891. */
  54892. get cameraRenderTimeCounter(): PerfCounter;
  54893. /**
  54894. * Gets the camera render time capture status
  54895. */
  54896. get captureCameraRenderTime(): boolean;
  54897. /**
  54898. * Enable or disable the camera render time capture
  54899. */
  54900. set captureCameraRenderTime(value: boolean);
  54901. /**
  54902. * Gets the perf counter used for draw calls
  54903. */
  54904. get drawCallsCounter(): PerfCounter;
  54905. /**
  54906. * Instantiates a new scene instrumentation.
  54907. * This class can be used to get instrumentation data from a Babylon engine
  54908. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  54909. * @param scene Defines the scene to instrument
  54910. */
  54911. constructor(
  54912. /**
  54913. * Defines the scene to instrument
  54914. */
  54915. scene: Scene);
  54916. /**
  54917. * Dispose and release associated resources.
  54918. */
  54919. dispose(): void;
  54920. }
  54921. }
  54922. declare module "babylonjs/Instrumentation/index" {
  54923. export * from "babylonjs/Instrumentation/engineInstrumentation";
  54924. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  54925. export * from "babylonjs/Instrumentation/timeToken";
  54926. }
  54927. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  54928. /** @hidden */
  54929. export var glowMapGenerationPixelShader: {
  54930. name: string;
  54931. shader: string;
  54932. };
  54933. }
  54934. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  54935. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  54936. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  54937. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  54938. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  54939. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  54940. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  54941. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  54942. /** @hidden */
  54943. export var glowMapGenerationVertexShader: {
  54944. name: string;
  54945. shader: string;
  54946. };
  54947. }
  54948. declare module "babylonjs/Layers/effectLayer" {
  54949. import { Observable } from "babylonjs/Misc/observable";
  54950. import { Nullable } from "babylonjs/types";
  54951. import { Camera } from "babylonjs/Cameras/camera";
  54952. import { Scene } from "babylonjs/scene";
  54953. import { ISize } from "babylonjs/Maths/math.size";
  54954. import { Color4 } from "babylonjs/Maths/math.color";
  54955. import { Engine } from "babylonjs/Engines/engine";
  54956. import { SubMesh } from "babylonjs/Meshes/subMesh";
  54957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54958. import { Mesh } from "babylonjs/Meshes/mesh";
  54959. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54960. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54961. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54962. import { Effect } from "babylonjs/Materials/effect";
  54963. import { Material } from "babylonjs/Materials/material";
  54964. import "babylonjs/Shaders/glowMapGeneration.fragment";
  54965. import "babylonjs/Shaders/glowMapGeneration.vertex";
  54966. /**
  54967. * Effect layer options. This helps customizing the behaviour
  54968. * of the effect layer.
  54969. */
  54970. export interface IEffectLayerOptions {
  54971. /**
  54972. * Multiplication factor apply to the canvas size to compute the render target size
  54973. * used to generated the objects (the smaller the faster).
  54974. */
  54975. mainTextureRatio: number;
  54976. /**
  54977. * Enforces a fixed size texture to ensure effect stability across devices.
  54978. */
  54979. mainTextureFixedSize?: number;
  54980. /**
  54981. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  54982. */
  54983. alphaBlendingMode: number;
  54984. /**
  54985. * The camera attached to the layer.
  54986. */
  54987. camera: Nullable<Camera>;
  54988. /**
  54989. * The rendering group to draw the layer in.
  54990. */
  54991. renderingGroupId: number;
  54992. }
  54993. /**
  54994. * The effect layer Helps adding post process effect blended with the main pass.
  54995. *
  54996. * This can be for instance use to generate glow or higlight effects on the scene.
  54997. *
  54998. * The effect layer class can not be used directly and is intented to inherited from to be
  54999. * customized per effects.
  55000. */
  55001. export abstract class EffectLayer {
  55002. private _vertexBuffers;
  55003. private _indexBuffer;
  55004. private _cachedDefines;
  55005. private _effectLayerMapGenerationEffect;
  55006. private _effectLayerOptions;
  55007. private _mergeEffect;
  55008. protected _scene: Scene;
  55009. protected _engine: Engine;
  55010. protected _maxSize: number;
  55011. protected _mainTextureDesiredSize: ISize;
  55012. protected _mainTexture: RenderTargetTexture;
  55013. protected _shouldRender: boolean;
  55014. protected _postProcesses: PostProcess[];
  55015. protected _textures: BaseTexture[];
  55016. protected _emissiveTextureAndColor: {
  55017. texture: Nullable<BaseTexture>;
  55018. color: Color4;
  55019. };
  55020. /**
  55021. * The name of the layer
  55022. */
  55023. name: string;
  55024. /**
  55025. * The clear color of the texture used to generate the glow map.
  55026. */
  55027. neutralColor: Color4;
  55028. /**
  55029. * Specifies whether the highlight layer is enabled or not.
  55030. */
  55031. isEnabled: boolean;
  55032. /**
  55033. * Gets the camera attached to the layer.
  55034. */
  55035. get camera(): Nullable<Camera>;
  55036. /**
  55037. * Gets the rendering group id the layer should render in.
  55038. */
  55039. get renderingGroupId(): number;
  55040. set renderingGroupId(renderingGroupId: number);
  55041. /**
  55042. * An event triggered when the effect layer has been disposed.
  55043. */
  55044. onDisposeObservable: Observable<EffectLayer>;
  55045. /**
  55046. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55047. */
  55048. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55049. /**
  55050. * An event triggered when the generated texture is being merged in the scene.
  55051. */
  55052. onBeforeComposeObservable: Observable<EffectLayer>;
  55053. /**
  55054. * An event triggered when the mesh is rendered into the effect render target.
  55055. */
  55056. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55057. /**
  55058. * An event triggered after the mesh has been rendered into the effect render target.
  55059. */
  55060. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55061. /**
  55062. * An event triggered when the generated texture has been merged in the scene.
  55063. */
  55064. onAfterComposeObservable: Observable<EffectLayer>;
  55065. /**
  55066. * An event triggered when the efffect layer changes its size.
  55067. */
  55068. onSizeChangedObservable: Observable<EffectLayer>;
  55069. /** @hidden */
  55070. static _SceneComponentInitialization: (scene: Scene) => void;
  55071. /**
  55072. * Instantiates a new effect Layer and references it in the scene.
  55073. * @param name The name of the layer
  55074. * @param scene The scene to use the layer in
  55075. */
  55076. constructor(
  55077. /** The Friendly of the effect in the scene */
  55078. name: string, scene: Scene);
  55079. /**
  55080. * Get the effect name of the layer.
  55081. * @return The effect name
  55082. */
  55083. abstract getEffectName(): string;
  55084. /**
  55085. * Checks for the readiness of the element composing the layer.
  55086. * @param subMesh the mesh to check for
  55087. * @param useInstances specify whether or not to use instances to render the mesh
  55088. * @return true if ready otherwise, false
  55089. */
  55090. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55091. /**
  55092. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55093. * @returns true if the effect requires stencil during the main canvas render pass.
  55094. */
  55095. abstract needStencil(): boolean;
  55096. /**
  55097. * Create the merge effect. This is the shader use to blit the information back
  55098. * to the main canvas at the end of the scene rendering.
  55099. * @returns The effect containing the shader used to merge the effect on the main canvas
  55100. */
  55101. protected abstract _createMergeEffect(): Effect;
  55102. /**
  55103. * Creates the render target textures and post processes used in the effect layer.
  55104. */
  55105. protected abstract _createTextureAndPostProcesses(): void;
  55106. /**
  55107. * Implementation specific of rendering the generating effect on the main canvas.
  55108. * @param effect The effect used to render through
  55109. */
  55110. protected abstract _internalRender(effect: Effect): void;
  55111. /**
  55112. * Sets the required values for both the emissive texture and and the main color.
  55113. */
  55114. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55115. /**
  55116. * Free any resources and references associated to a mesh.
  55117. * Internal use
  55118. * @param mesh The mesh to free.
  55119. */
  55120. abstract _disposeMesh(mesh: Mesh): void;
  55121. /**
  55122. * Serializes this layer (Glow or Highlight for example)
  55123. * @returns a serialized layer object
  55124. */
  55125. abstract serialize?(): any;
  55126. /**
  55127. * Initializes the effect layer with the required options.
  55128. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55129. */
  55130. protected _init(options: Partial<IEffectLayerOptions>): void;
  55131. /**
  55132. * Generates the index buffer of the full screen quad blending to the main canvas.
  55133. */
  55134. private _generateIndexBuffer;
  55135. /**
  55136. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55137. */
  55138. private _generateVertexBuffer;
  55139. /**
  55140. * Sets the main texture desired size which is the closest power of two
  55141. * of the engine canvas size.
  55142. */
  55143. private _setMainTextureSize;
  55144. /**
  55145. * Creates the main texture for the effect layer.
  55146. */
  55147. protected _createMainTexture(): void;
  55148. /**
  55149. * Adds specific effects defines.
  55150. * @param defines The defines to add specifics to.
  55151. */
  55152. protected _addCustomEffectDefines(defines: string[]): void;
  55153. /**
  55154. * Checks for the readiness of the element composing the layer.
  55155. * @param subMesh the mesh to check for
  55156. * @param useInstances specify whether or not to use instances to render the mesh
  55157. * @param emissiveTexture the associated emissive texture used to generate the glow
  55158. * @return true if ready otherwise, false
  55159. */
  55160. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55161. /**
  55162. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55163. */
  55164. render(): void;
  55165. /**
  55166. * Determine if a given mesh will be used in the current effect.
  55167. * @param mesh mesh to test
  55168. * @returns true if the mesh will be used
  55169. */
  55170. hasMesh(mesh: AbstractMesh): boolean;
  55171. /**
  55172. * Returns true if the layer contains information to display, otherwise false.
  55173. * @returns true if the glow layer should be rendered
  55174. */
  55175. shouldRender(): boolean;
  55176. /**
  55177. * Returns true if the mesh should render, otherwise false.
  55178. * @param mesh The mesh to render
  55179. * @returns true if it should render otherwise false
  55180. */
  55181. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55182. /**
  55183. * Returns true if the mesh can be rendered, otherwise false.
  55184. * @param mesh The mesh to render
  55185. * @param material The material used on the mesh
  55186. * @returns true if it can be rendered otherwise false
  55187. */
  55188. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55189. /**
  55190. * Returns true if the mesh should render, otherwise false.
  55191. * @param mesh The mesh to render
  55192. * @returns true if it should render otherwise false
  55193. */
  55194. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55195. /**
  55196. * Renders the submesh passed in parameter to the generation map.
  55197. */
  55198. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55199. /**
  55200. * Defines whether the current material of the mesh should be use to render the effect.
  55201. * @param mesh defines the current mesh to render
  55202. */
  55203. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55204. /**
  55205. * Rebuild the required buffers.
  55206. * @hidden Internal use only.
  55207. */
  55208. _rebuild(): void;
  55209. /**
  55210. * Dispose only the render target textures and post process.
  55211. */
  55212. private _disposeTextureAndPostProcesses;
  55213. /**
  55214. * Dispose the highlight layer and free resources.
  55215. */
  55216. dispose(): void;
  55217. /**
  55218. * Gets the class name of the effect layer
  55219. * @returns the string with the class name of the effect layer
  55220. */
  55221. getClassName(): string;
  55222. /**
  55223. * Creates an effect layer from parsed effect layer data
  55224. * @param parsedEffectLayer defines effect layer data
  55225. * @param scene defines the current scene
  55226. * @param rootUrl defines the root URL containing the effect layer information
  55227. * @returns a parsed effect Layer
  55228. */
  55229. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55230. }
  55231. }
  55232. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55233. import { Scene } from "babylonjs/scene";
  55234. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55235. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55236. import { AbstractScene } from "babylonjs/abstractScene";
  55237. module "babylonjs/abstractScene" {
  55238. interface AbstractScene {
  55239. /**
  55240. * The list of effect layers (highlights/glow) added to the scene
  55241. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55242. * @see http://doc.babylonjs.com/how_to/glow_layer
  55243. */
  55244. effectLayers: Array<EffectLayer>;
  55245. /**
  55246. * Removes the given effect layer from this scene.
  55247. * @param toRemove defines the effect layer to remove
  55248. * @returns the index of the removed effect layer
  55249. */
  55250. removeEffectLayer(toRemove: EffectLayer): number;
  55251. /**
  55252. * Adds the given effect layer to this scene
  55253. * @param newEffectLayer defines the effect layer to add
  55254. */
  55255. addEffectLayer(newEffectLayer: EffectLayer): void;
  55256. }
  55257. }
  55258. /**
  55259. * Defines the layer scene component responsible to manage any effect layers
  55260. * in a given scene.
  55261. */
  55262. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55263. /**
  55264. * The component name helpfull to identify the component in the list of scene components.
  55265. */
  55266. readonly name: string;
  55267. /**
  55268. * The scene the component belongs to.
  55269. */
  55270. scene: Scene;
  55271. private _engine;
  55272. private _renderEffects;
  55273. private _needStencil;
  55274. private _previousStencilState;
  55275. /**
  55276. * Creates a new instance of the component for the given scene
  55277. * @param scene Defines the scene to register the component in
  55278. */
  55279. constructor(scene: Scene);
  55280. /**
  55281. * Registers the component in a given scene
  55282. */
  55283. register(): void;
  55284. /**
  55285. * Rebuilds the elements related to this component in case of
  55286. * context lost for instance.
  55287. */
  55288. rebuild(): void;
  55289. /**
  55290. * Serializes the component data to the specified json object
  55291. * @param serializationObject The object to serialize to
  55292. */
  55293. serialize(serializationObject: any): void;
  55294. /**
  55295. * Adds all the elements from the container to the scene
  55296. * @param container the container holding the elements
  55297. */
  55298. addFromContainer(container: AbstractScene): void;
  55299. /**
  55300. * Removes all the elements in the container from the scene
  55301. * @param container contains the elements to remove
  55302. * @param dispose if the removed element should be disposed (default: false)
  55303. */
  55304. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55305. /**
  55306. * Disposes the component and the associated ressources.
  55307. */
  55308. dispose(): void;
  55309. private _isReadyForMesh;
  55310. private _renderMainTexture;
  55311. private _setStencil;
  55312. private _setStencilBack;
  55313. private _draw;
  55314. private _drawCamera;
  55315. private _drawRenderingGroup;
  55316. }
  55317. }
  55318. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55319. /** @hidden */
  55320. export var glowMapMergePixelShader: {
  55321. name: string;
  55322. shader: string;
  55323. };
  55324. }
  55325. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55326. /** @hidden */
  55327. export var glowMapMergeVertexShader: {
  55328. name: string;
  55329. shader: string;
  55330. };
  55331. }
  55332. declare module "babylonjs/Layers/glowLayer" {
  55333. import { Nullable } from "babylonjs/types";
  55334. import { Camera } from "babylonjs/Cameras/camera";
  55335. import { Scene } from "babylonjs/scene";
  55336. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55338. import { Mesh } from "babylonjs/Meshes/mesh";
  55339. import { Texture } from "babylonjs/Materials/Textures/texture";
  55340. import { Effect } from "babylonjs/Materials/effect";
  55341. import { Material } from "babylonjs/Materials/material";
  55342. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55343. import { Color4 } from "babylonjs/Maths/math.color";
  55344. import "babylonjs/Shaders/glowMapMerge.fragment";
  55345. import "babylonjs/Shaders/glowMapMerge.vertex";
  55346. import "babylonjs/Layers/effectLayerSceneComponent";
  55347. module "babylonjs/abstractScene" {
  55348. interface AbstractScene {
  55349. /**
  55350. * Return a the first highlight layer of the scene with a given name.
  55351. * @param name The name of the highlight layer to look for.
  55352. * @return The highlight layer if found otherwise null.
  55353. */
  55354. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55355. }
  55356. }
  55357. /**
  55358. * Glow layer options. This helps customizing the behaviour
  55359. * of the glow layer.
  55360. */
  55361. export interface IGlowLayerOptions {
  55362. /**
  55363. * Multiplication factor apply to the canvas size to compute the render target size
  55364. * used to generated the glowing objects (the smaller the faster).
  55365. */
  55366. mainTextureRatio: number;
  55367. /**
  55368. * Enforces a fixed size texture to ensure resize independant blur.
  55369. */
  55370. mainTextureFixedSize?: number;
  55371. /**
  55372. * How big is the kernel of the blur texture.
  55373. */
  55374. blurKernelSize: number;
  55375. /**
  55376. * The camera attached to the layer.
  55377. */
  55378. camera: Nullable<Camera>;
  55379. /**
  55380. * Enable MSAA by chosing the number of samples.
  55381. */
  55382. mainTextureSamples?: number;
  55383. /**
  55384. * The rendering group to draw the layer in.
  55385. */
  55386. renderingGroupId: number;
  55387. }
  55388. /**
  55389. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55390. *
  55391. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55392. *
  55393. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55394. */
  55395. export class GlowLayer extends EffectLayer {
  55396. /**
  55397. * Effect Name of the layer.
  55398. */
  55399. static readonly EffectName: string;
  55400. /**
  55401. * The default blur kernel size used for the glow.
  55402. */
  55403. static DefaultBlurKernelSize: number;
  55404. /**
  55405. * The default texture size ratio used for the glow.
  55406. */
  55407. static DefaultTextureRatio: number;
  55408. /**
  55409. * Sets the kernel size of the blur.
  55410. */
  55411. set blurKernelSize(value: number);
  55412. /**
  55413. * Gets the kernel size of the blur.
  55414. */
  55415. get blurKernelSize(): number;
  55416. /**
  55417. * Sets the glow intensity.
  55418. */
  55419. set intensity(value: number);
  55420. /**
  55421. * Gets the glow intensity.
  55422. */
  55423. get intensity(): number;
  55424. private _options;
  55425. private _intensity;
  55426. private _horizontalBlurPostprocess1;
  55427. private _verticalBlurPostprocess1;
  55428. private _horizontalBlurPostprocess2;
  55429. private _verticalBlurPostprocess2;
  55430. private _blurTexture1;
  55431. private _blurTexture2;
  55432. private _postProcesses1;
  55433. private _postProcesses2;
  55434. private _includedOnlyMeshes;
  55435. private _excludedMeshes;
  55436. private _meshesUsingTheirOwnMaterials;
  55437. /**
  55438. * Callback used to let the user override the color selection on a per mesh basis
  55439. */
  55440. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  55441. /**
  55442. * Callback used to let the user override the texture selection on a per mesh basis
  55443. */
  55444. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  55445. /**
  55446. * Instantiates a new glow Layer and references it to the scene.
  55447. * @param name The name of the layer
  55448. * @param scene The scene to use the layer in
  55449. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  55450. */
  55451. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  55452. /**
  55453. * Get the effect name of the layer.
  55454. * @return The effect name
  55455. */
  55456. getEffectName(): string;
  55457. /**
  55458. * Create the merge effect. This is the shader use to blit the information back
  55459. * to the main canvas at the end of the scene rendering.
  55460. */
  55461. protected _createMergeEffect(): Effect;
  55462. /**
  55463. * Creates the render target textures and post processes used in the glow layer.
  55464. */
  55465. protected _createTextureAndPostProcesses(): void;
  55466. /**
  55467. * Checks for the readiness of the element composing the layer.
  55468. * @param subMesh the mesh to check for
  55469. * @param useInstances specify wether or not to use instances to render the mesh
  55470. * @param emissiveTexture the associated emissive texture used to generate the glow
  55471. * @return true if ready otherwise, false
  55472. */
  55473. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55474. /**
  55475. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55476. */
  55477. needStencil(): boolean;
  55478. /**
  55479. * Returns true if the mesh can be rendered, otherwise false.
  55480. * @param mesh The mesh to render
  55481. * @param material The material used on the mesh
  55482. * @returns true if it can be rendered otherwise false
  55483. */
  55484. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55485. /**
  55486. * Implementation specific of rendering the generating effect on the main canvas.
  55487. * @param effect The effect used to render through
  55488. */
  55489. protected _internalRender(effect: Effect): void;
  55490. /**
  55491. * Sets the required values for both the emissive texture and and the main color.
  55492. */
  55493. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55494. /**
  55495. * Returns true if the mesh should render, otherwise false.
  55496. * @param mesh The mesh to render
  55497. * @returns true if it should render otherwise false
  55498. */
  55499. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55500. /**
  55501. * Adds specific effects defines.
  55502. * @param defines The defines to add specifics to.
  55503. */
  55504. protected _addCustomEffectDefines(defines: string[]): void;
  55505. /**
  55506. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  55507. * @param mesh The mesh to exclude from the glow layer
  55508. */
  55509. addExcludedMesh(mesh: Mesh): void;
  55510. /**
  55511. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  55512. * @param mesh The mesh to remove
  55513. */
  55514. removeExcludedMesh(mesh: Mesh): void;
  55515. /**
  55516. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  55517. * @param mesh The mesh to include in the glow layer
  55518. */
  55519. addIncludedOnlyMesh(mesh: Mesh): void;
  55520. /**
  55521. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  55522. * @param mesh The mesh to remove
  55523. */
  55524. removeIncludedOnlyMesh(mesh: Mesh): void;
  55525. /**
  55526. * Determine if a given mesh will be used in the glow layer
  55527. * @param mesh The mesh to test
  55528. * @returns true if the mesh will be highlighted by the current glow layer
  55529. */
  55530. hasMesh(mesh: AbstractMesh): boolean;
  55531. /**
  55532. * Defines whether the current material of the mesh should be use to render the effect.
  55533. * @param mesh defines the current mesh to render
  55534. */
  55535. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55536. /**
  55537. * Add a mesh to be rendered through its own material and not with emissive only.
  55538. * @param mesh The mesh for which we need to use its material
  55539. */
  55540. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  55541. /**
  55542. * Remove a mesh from being rendered through its own material and not with emissive only.
  55543. * @param mesh The mesh for which we need to not use its material
  55544. */
  55545. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  55546. /**
  55547. * Free any resources and references associated to a mesh.
  55548. * Internal use
  55549. * @param mesh The mesh to free.
  55550. * @hidden
  55551. */
  55552. _disposeMesh(mesh: Mesh): void;
  55553. /**
  55554. * Gets the class name of the effect layer
  55555. * @returns the string with the class name of the effect layer
  55556. */
  55557. getClassName(): string;
  55558. /**
  55559. * Serializes this glow layer
  55560. * @returns a serialized glow layer object
  55561. */
  55562. serialize(): any;
  55563. /**
  55564. * Creates a Glow Layer from parsed glow layer data
  55565. * @param parsedGlowLayer defines glow layer data
  55566. * @param scene defines the current scene
  55567. * @param rootUrl defines the root URL containing the glow layer information
  55568. * @returns a parsed Glow Layer
  55569. */
  55570. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  55571. }
  55572. }
  55573. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  55574. /** @hidden */
  55575. export var glowBlurPostProcessPixelShader: {
  55576. name: string;
  55577. shader: string;
  55578. };
  55579. }
  55580. declare module "babylonjs/Layers/highlightLayer" {
  55581. import { Observable } from "babylonjs/Misc/observable";
  55582. import { Nullable } from "babylonjs/types";
  55583. import { Camera } from "babylonjs/Cameras/camera";
  55584. import { Scene } from "babylonjs/scene";
  55585. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55586. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55587. import { Mesh } from "babylonjs/Meshes/mesh";
  55588. import { Effect } from "babylonjs/Materials/effect";
  55589. import { Material } from "babylonjs/Materials/material";
  55590. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55591. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  55592. import "babylonjs/Shaders/glowMapMerge.fragment";
  55593. import "babylonjs/Shaders/glowMapMerge.vertex";
  55594. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  55595. module "babylonjs/abstractScene" {
  55596. interface AbstractScene {
  55597. /**
  55598. * Return a the first highlight layer of the scene with a given name.
  55599. * @param name The name of the highlight layer to look for.
  55600. * @return The highlight layer if found otherwise null.
  55601. */
  55602. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  55603. }
  55604. }
  55605. /**
  55606. * Highlight layer options. This helps customizing the behaviour
  55607. * of the highlight layer.
  55608. */
  55609. export interface IHighlightLayerOptions {
  55610. /**
  55611. * Multiplication factor apply to the canvas size to compute the render target size
  55612. * used to generated the glowing objects (the smaller the faster).
  55613. */
  55614. mainTextureRatio: number;
  55615. /**
  55616. * Enforces a fixed size texture to ensure resize independant blur.
  55617. */
  55618. mainTextureFixedSize?: number;
  55619. /**
  55620. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  55621. * of the picture to blur (the smaller the faster).
  55622. */
  55623. blurTextureSizeRatio: number;
  55624. /**
  55625. * How big in texel of the blur texture is the vertical blur.
  55626. */
  55627. blurVerticalSize: number;
  55628. /**
  55629. * How big in texel of the blur texture is the horizontal blur.
  55630. */
  55631. blurHorizontalSize: number;
  55632. /**
  55633. * Alpha blending mode used to apply the blur. Default is combine.
  55634. */
  55635. alphaBlendingMode: number;
  55636. /**
  55637. * The camera attached to the layer.
  55638. */
  55639. camera: Nullable<Camera>;
  55640. /**
  55641. * Should we display highlight as a solid stroke?
  55642. */
  55643. isStroke?: boolean;
  55644. /**
  55645. * The rendering group to draw the layer in.
  55646. */
  55647. renderingGroupId: number;
  55648. }
  55649. /**
  55650. * The highlight layer Helps adding a glow effect around a mesh.
  55651. *
  55652. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  55653. * glowy meshes to your scene.
  55654. *
  55655. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  55656. */
  55657. export class HighlightLayer extends EffectLayer {
  55658. name: string;
  55659. /**
  55660. * Effect Name of the highlight layer.
  55661. */
  55662. static readonly EffectName: string;
  55663. /**
  55664. * The neutral color used during the preparation of the glow effect.
  55665. * This is black by default as the blend operation is a blend operation.
  55666. */
  55667. static NeutralColor: Color4;
  55668. /**
  55669. * Stencil value used for glowing meshes.
  55670. */
  55671. static GlowingMeshStencilReference: number;
  55672. /**
  55673. * Stencil value used for the other meshes in the scene.
  55674. */
  55675. static NormalMeshStencilReference: number;
  55676. /**
  55677. * Specifies whether or not the inner glow is ACTIVE in the layer.
  55678. */
  55679. innerGlow: boolean;
  55680. /**
  55681. * Specifies whether or not the outer glow is ACTIVE in the layer.
  55682. */
  55683. outerGlow: boolean;
  55684. /**
  55685. * Specifies the horizontal size of the blur.
  55686. */
  55687. set blurHorizontalSize(value: number);
  55688. /**
  55689. * Specifies the vertical size of the blur.
  55690. */
  55691. set blurVerticalSize(value: number);
  55692. /**
  55693. * Gets the horizontal size of the blur.
  55694. */
  55695. get blurHorizontalSize(): number;
  55696. /**
  55697. * Gets the vertical size of the blur.
  55698. */
  55699. get blurVerticalSize(): number;
  55700. /**
  55701. * An event triggered when the highlight layer is being blurred.
  55702. */
  55703. onBeforeBlurObservable: Observable<HighlightLayer>;
  55704. /**
  55705. * An event triggered when the highlight layer has been blurred.
  55706. */
  55707. onAfterBlurObservable: Observable<HighlightLayer>;
  55708. private _instanceGlowingMeshStencilReference;
  55709. private _options;
  55710. private _downSamplePostprocess;
  55711. private _horizontalBlurPostprocess;
  55712. private _verticalBlurPostprocess;
  55713. private _blurTexture;
  55714. private _meshes;
  55715. private _excludedMeshes;
  55716. /**
  55717. * Instantiates a new highlight Layer and references it to the scene..
  55718. * @param name The name of the layer
  55719. * @param scene The scene to use the layer in
  55720. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  55721. */
  55722. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  55723. /**
  55724. * Get the effect name of the layer.
  55725. * @return The effect name
  55726. */
  55727. getEffectName(): string;
  55728. /**
  55729. * Create the merge effect. This is the shader use to blit the information back
  55730. * to the main canvas at the end of the scene rendering.
  55731. */
  55732. protected _createMergeEffect(): Effect;
  55733. /**
  55734. * Creates the render target textures and post processes used in the highlight layer.
  55735. */
  55736. protected _createTextureAndPostProcesses(): void;
  55737. /**
  55738. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  55739. */
  55740. needStencil(): boolean;
  55741. /**
  55742. * Checks for the readiness of the element composing the layer.
  55743. * @param subMesh the mesh to check for
  55744. * @param useInstances specify wether or not to use instances to render the mesh
  55745. * @param emissiveTexture the associated emissive texture used to generate the glow
  55746. * @return true if ready otherwise, false
  55747. */
  55748. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55749. /**
  55750. * Implementation specific of rendering the generating effect on the main canvas.
  55751. * @param effect The effect used to render through
  55752. */
  55753. protected _internalRender(effect: Effect): void;
  55754. /**
  55755. * Returns true if the layer contains information to display, otherwise false.
  55756. */
  55757. shouldRender(): boolean;
  55758. /**
  55759. * Returns true if the mesh should render, otherwise false.
  55760. * @param mesh The mesh to render
  55761. * @returns true if it should render otherwise false
  55762. */
  55763. protected _shouldRenderMesh(mesh: Mesh): boolean;
  55764. /**
  55765. * Sets the required values for both the emissive texture and and the main color.
  55766. */
  55767. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55768. /**
  55769. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  55770. * @param mesh The mesh to exclude from the highlight layer
  55771. */
  55772. addExcludedMesh(mesh: Mesh): void;
  55773. /**
  55774. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  55775. * @param mesh The mesh to highlight
  55776. */
  55777. removeExcludedMesh(mesh: Mesh): void;
  55778. /**
  55779. * Determine if a given mesh will be highlighted by the current HighlightLayer
  55780. * @param mesh mesh to test
  55781. * @returns true if the mesh will be highlighted by the current HighlightLayer
  55782. */
  55783. hasMesh(mesh: AbstractMesh): boolean;
  55784. /**
  55785. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  55786. * @param mesh The mesh to highlight
  55787. * @param color The color of the highlight
  55788. * @param glowEmissiveOnly Extract the glow from the emissive texture
  55789. */
  55790. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  55791. /**
  55792. * Remove a mesh from the highlight layer in order to make it stop glowing.
  55793. * @param mesh The mesh to highlight
  55794. */
  55795. removeMesh(mesh: Mesh): void;
  55796. /**
  55797. * Force the stencil to the normal expected value for none glowing parts
  55798. */
  55799. private _defaultStencilReference;
  55800. /**
  55801. * Free any resources and references associated to a mesh.
  55802. * Internal use
  55803. * @param mesh The mesh to free.
  55804. * @hidden
  55805. */
  55806. _disposeMesh(mesh: Mesh): void;
  55807. /**
  55808. * Dispose the highlight layer and free resources.
  55809. */
  55810. dispose(): void;
  55811. /**
  55812. * Gets the class name of the effect layer
  55813. * @returns the string with the class name of the effect layer
  55814. */
  55815. getClassName(): string;
  55816. /**
  55817. * Serializes this Highlight layer
  55818. * @returns a serialized Highlight layer object
  55819. */
  55820. serialize(): any;
  55821. /**
  55822. * Creates a Highlight layer from parsed Highlight layer data
  55823. * @param parsedHightlightLayer defines the Highlight layer data
  55824. * @param scene defines the current scene
  55825. * @param rootUrl defines the root URL containing the Highlight layer information
  55826. * @returns a parsed Highlight layer
  55827. */
  55828. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  55829. }
  55830. }
  55831. declare module "babylonjs/Layers/layerSceneComponent" {
  55832. import { Scene } from "babylonjs/scene";
  55833. import { ISceneComponent } from "babylonjs/sceneComponent";
  55834. import { Layer } from "babylonjs/Layers/layer";
  55835. import { AbstractScene } from "babylonjs/abstractScene";
  55836. module "babylonjs/abstractScene" {
  55837. interface AbstractScene {
  55838. /**
  55839. * The list of layers (background and foreground) of the scene
  55840. */
  55841. layers: Array<Layer>;
  55842. }
  55843. }
  55844. /**
  55845. * Defines the layer scene component responsible to manage any layers
  55846. * in a given scene.
  55847. */
  55848. export class LayerSceneComponent implements ISceneComponent {
  55849. /**
  55850. * The component name helpfull to identify the component in the list of scene components.
  55851. */
  55852. readonly name: string;
  55853. /**
  55854. * The scene the component belongs to.
  55855. */
  55856. scene: Scene;
  55857. private _engine;
  55858. /**
  55859. * Creates a new instance of the component for the given scene
  55860. * @param scene Defines the scene to register the component in
  55861. */
  55862. constructor(scene: Scene);
  55863. /**
  55864. * Registers the component in a given scene
  55865. */
  55866. register(): void;
  55867. /**
  55868. * Rebuilds the elements related to this component in case of
  55869. * context lost for instance.
  55870. */
  55871. rebuild(): void;
  55872. /**
  55873. * Disposes the component and the associated ressources.
  55874. */
  55875. dispose(): void;
  55876. private _draw;
  55877. private _drawCameraPredicate;
  55878. private _drawCameraBackground;
  55879. private _drawCameraForeground;
  55880. private _drawRenderTargetPredicate;
  55881. private _drawRenderTargetBackground;
  55882. private _drawRenderTargetForeground;
  55883. /**
  55884. * Adds all the elements from the container to the scene
  55885. * @param container the container holding the elements
  55886. */
  55887. addFromContainer(container: AbstractScene): void;
  55888. /**
  55889. * Removes all the elements in the container from the scene
  55890. * @param container contains the elements to remove
  55891. * @param dispose if the removed element should be disposed (default: false)
  55892. */
  55893. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55894. }
  55895. }
  55896. declare module "babylonjs/Shaders/layer.fragment" {
  55897. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55898. /** @hidden */
  55899. export var layerPixelShader: {
  55900. name: string;
  55901. shader: string;
  55902. };
  55903. }
  55904. declare module "babylonjs/Shaders/layer.vertex" {
  55905. /** @hidden */
  55906. export var layerVertexShader: {
  55907. name: string;
  55908. shader: string;
  55909. };
  55910. }
  55911. declare module "babylonjs/Layers/layer" {
  55912. import { Observable } from "babylonjs/Misc/observable";
  55913. import { Nullable } from "babylonjs/types";
  55914. import { Scene } from "babylonjs/scene";
  55915. import { Vector2 } from "babylonjs/Maths/math.vector";
  55916. import { Color4 } from "babylonjs/Maths/math.color";
  55917. import { Texture } from "babylonjs/Materials/Textures/texture";
  55918. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55919. import "babylonjs/Shaders/layer.fragment";
  55920. import "babylonjs/Shaders/layer.vertex";
  55921. /**
  55922. * This represents a full screen 2d layer.
  55923. * This can be useful to display a picture in the background of your scene for instance.
  55924. * @see https://www.babylonjs-playground.com/#08A2BS#1
  55925. */
  55926. export class Layer {
  55927. /**
  55928. * Define the name of the layer.
  55929. */
  55930. name: string;
  55931. /**
  55932. * Define the texture the layer should display.
  55933. */
  55934. texture: Nullable<Texture>;
  55935. /**
  55936. * Is the layer in background or foreground.
  55937. */
  55938. isBackground: boolean;
  55939. /**
  55940. * Define the color of the layer (instead of texture).
  55941. */
  55942. color: Color4;
  55943. /**
  55944. * Define the scale of the layer in order to zoom in out of the texture.
  55945. */
  55946. scale: Vector2;
  55947. /**
  55948. * Define an offset for the layer in order to shift the texture.
  55949. */
  55950. offset: Vector2;
  55951. /**
  55952. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  55953. */
  55954. alphaBlendingMode: number;
  55955. /**
  55956. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  55957. * Alpha test will not mix with the background color in case of transparency.
  55958. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  55959. */
  55960. alphaTest: boolean;
  55961. /**
  55962. * Define a mask to restrict the layer to only some of the scene cameras.
  55963. */
  55964. layerMask: number;
  55965. /**
  55966. * Define the list of render target the layer is visible into.
  55967. */
  55968. renderTargetTextures: RenderTargetTexture[];
  55969. /**
  55970. * Define if the layer is only used in renderTarget or if it also
  55971. * renders in the main frame buffer of the canvas.
  55972. */
  55973. renderOnlyInRenderTargetTextures: boolean;
  55974. private _scene;
  55975. private _vertexBuffers;
  55976. private _indexBuffer;
  55977. private _effect;
  55978. private _previousDefines;
  55979. /**
  55980. * An event triggered when the layer is disposed.
  55981. */
  55982. onDisposeObservable: Observable<Layer>;
  55983. private _onDisposeObserver;
  55984. /**
  55985. * Back compatibility with callback before the onDisposeObservable existed.
  55986. * The set callback will be triggered when the layer has been disposed.
  55987. */
  55988. set onDispose(callback: () => void);
  55989. /**
  55990. * An event triggered before rendering the scene
  55991. */
  55992. onBeforeRenderObservable: Observable<Layer>;
  55993. private _onBeforeRenderObserver;
  55994. /**
  55995. * Back compatibility with callback before the onBeforeRenderObservable existed.
  55996. * The set callback will be triggered just before rendering the layer.
  55997. */
  55998. set onBeforeRender(callback: () => void);
  55999. /**
  56000. * An event triggered after rendering the scene
  56001. */
  56002. onAfterRenderObservable: Observable<Layer>;
  56003. private _onAfterRenderObserver;
  56004. /**
  56005. * Back compatibility with callback before the onAfterRenderObservable existed.
  56006. * The set callback will be triggered just after rendering the layer.
  56007. */
  56008. set onAfterRender(callback: () => void);
  56009. /**
  56010. * Instantiates a new layer.
  56011. * This represents a full screen 2d layer.
  56012. * This can be useful to display a picture in the background of your scene for instance.
  56013. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56014. * @param name Define the name of the layer in the scene
  56015. * @param imgUrl Define the url of the texture to display in the layer
  56016. * @param scene Define the scene the layer belongs to
  56017. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56018. * @param color Defines a color for the layer
  56019. */
  56020. constructor(
  56021. /**
  56022. * Define the name of the layer.
  56023. */
  56024. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56025. private _createIndexBuffer;
  56026. /** @hidden */
  56027. _rebuild(): void;
  56028. /**
  56029. * Renders the layer in the scene.
  56030. */
  56031. render(): void;
  56032. /**
  56033. * Disposes and releases the associated ressources.
  56034. */
  56035. dispose(): void;
  56036. }
  56037. }
  56038. declare module "babylonjs/Layers/index" {
  56039. export * from "babylonjs/Layers/effectLayer";
  56040. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56041. export * from "babylonjs/Layers/glowLayer";
  56042. export * from "babylonjs/Layers/highlightLayer";
  56043. export * from "babylonjs/Layers/layer";
  56044. export * from "babylonjs/Layers/layerSceneComponent";
  56045. }
  56046. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56047. /** @hidden */
  56048. export var lensFlarePixelShader: {
  56049. name: string;
  56050. shader: string;
  56051. };
  56052. }
  56053. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56054. /** @hidden */
  56055. export var lensFlareVertexShader: {
  56056. name: string;
  56057. shader: string;
  56058. };
  56059. }
  56060. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56061. import { Scene } from "babylonjs/scene";
  56062. import { Vector3 } from "babylonjs/Maths/math.vector";
  56063. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56064. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56065. import "babylonjs/Shaders/lensFlare.fragment";
  56066. import "babylonjs/Shaders/lensFlare.vertex";
  56067. import { Viewport } from "babylonjs/Maths/math.viewport";
  56068. /**
  56069. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56070. * It is usually composed of several `lensFlare`.
  56071. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56072. */
  56073. export class LensFlareSystem {
  56074. /**
  56075. * Define the name of the lens flare system
  56076. */
  56077. name: string;
  56078. /**
  56079. * List of lens flares used in this system.
  56080. */
  56081. lensFlares: LensFlare[];
  56082. /**
  56083. * Define a limit from the border the lens flare can be visible.
  56084. */
  56085. borderLimit: number;
  56086. /**
  56087. * Define a viewport border we do not want to see the lens flare in.
  56088. */
  56089. viewportBorder: number;
  56090. /**
  56091. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56092. */
  56093. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56094. /**
  56095. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56096. */
  56097. layerMask: number;
  56098. /**
  56099. * Define the id of the lens flare system in the scene.
  56100. * (equal to name by default)
  56101. */
  56102. id: string;
  56103. private _scene;
  56104. private _emitter;
  56105. private _vertexBuffers;
  56106. private _indexBuffer;
  56107. private _effect;
  56108. private _positionX;
  56109. private _positionY;
  56110. private _isEnabled;
  56111. /** @hidden */
  56112. static _SceneComponentInitialization: (scene: Scene) => void;
  56113. /**
  56114. * Instantiates a lens flare system.
  56115. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56116. * It is usually composed of several `lensFlare`.
  56117. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56118. * @param name Define the name of the lens flare system in the scene
  56119. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56120. * @param scene Define the scene the lens flare system belongs to
  56121. */
  56122. constructor(
  56123. /**
  56124. * Define the name of the lens flare system
  56125. */
  56126. name: string, emitter: any, scene: Scene);
  56127. /**
  56128. * Define if the lens flare system is enabled.
  56129. */
  56130. get isEnabled(): boolean;
  56131. set isEnabled(value: boolean);
  56132. /**
  56133. * Get the scene the effects belongs to.
  56134. * @returns the scene holding the lens flare system
  56135. */
  56136. getScene(): Scene;
  56137. /**
  56138. * Get the emitter of the lens flare system.
  56139. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56140. * @returns the emitter of the lens flare system
  56141. */
  56142. getEmitter(): any;
  56143. /**
  56144. * Set the emitter of the lens flare system.
  56145. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56146. * @param newEmitter Define the new emitter of the system
  56147. */
  56148. setEmitter(newEmitter: any): void;
  56149. /**
  56150. * Get the lens flare system emitter position.
  56151. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56152. * @returns the position
  56153. */
  56154. getEmitterPosition(): Vector3;
  56155. /**
  56156. * @hidden
  56157. */
  56158. computeEffectivePosition(globalViewport: Viewport): boolean;
  56159. /** @hidden */
  56160. _isVisible(): boolean;
  56161. /**
  56162. * @hidden
  56163. */
  56164. render(): boolean;
  56165. /**
  56166. * Dispose and release the lens flare with its associated resources.
  56167. */
  56168. dispose(): void;
  56169. /**
  56170. * Parse a lens flare system from a JSON repressentation
  56171. * @param parsedLensFlareSystem Define the JSON to parse
  56172. * @param scene Define the scene the parsed system should be instantiated in
  56173. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56174. * @returns the parsed system
  56175. */
  56176. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56177. /**
  56178. * Serialize the current Lens Flare System into a JSON representation.
  56179. * @returns the serialized JSON
  56180. */
  56181. serialize(): any;
  56182. }
  56183. }
  56184. declare module "babylonjs/LensFlares/lensFlare" {
  56185. import { Nullable } from "babylonjs/types";
  56186. import { Color3 } from "babylonjs/Maths/math.color";
  56187. import { Texture } from "babylonjs/Materials/Textures/texture";
  56188. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56189. /**
  56190. * This represents one of the lens effect in a `lensFlareSystem`.
  56191. * It controls one of the indiviual texture used in the effect.
  56192. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56193. */
  56194. export class LensFlare {
  56195. /**
  56196. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56197. */
  56198. size: number;
  56199. /**
  56200. * 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.
  56201. */
  56202. position: number;
  56203. /**
  56204. * Define the lens color.
  56205. */
  56206. color: Color3;
  56207. /**
  56208. * Define the lens texture.
  56209. */
  56210. texture: Nullable<Texture>;
  56211. /**
  56212. * Define the alpha mode to render this particular lens.
  56213. */
  56214. alphaMode: number;
  56215. private _system;
  56216. /**
  56217. * Creates a new Lens Flare.
  56218. * This represents one of the lens effect in a `lensFlareSystem`.
  56219. * It controls one of the indiviual texture used in the effect.
  56220. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56221. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56222. * @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.
  56223. * @param color Define the lens color
  56224. * @param imgUrl Define the lens texture url
  56225. * @param system Define the `lensFlareSystem` this flare is part of
  56226. * @returns The newly created Lens Flare
  56227. */
  56228. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56229. /**
  56230. * Instantiates a new Lens Flare.
  56231. * This represents one of the lens effect in a `lensFlareSystem`.
  56232. * It controls one of the indiviual texture used in the effect.
  56233. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56234. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56235. * @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.
  56236. * @param color Define the lens color
  56237. * @param imgUrl Define the lens texture url
  56238. * @param system Define the `lensFlareSystem` this flare is part of
  56239. */
  56240. constructor(
  56241. /**
  56242. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56243. */
  56244. size: number,
  56245. /**
  56246. * 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.
  56247. */
  56248. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56249. /**
  56250. * Dispose and release the lens flare with its associated resources.
  56251. */
  56252. dispose(): void;
  56253. }
  56254. }
  56255. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56256. import { Nullable } from "babylonjs/types";
  56257. import { Scene } from "babylonjs/scene";
  56258. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56259. import { AbstractScene } from "babylonjs/abstractScene";
  56260. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56261. module "babylonjs/abstractScene" {
  56262. interface AbstractScene {
  56263. /**
  56264. * The list of lens flare system added to the scene
  56265. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56266. */
  56267. lensFlareSystems: Array<LensFlareSystem>;
  56268. /**
  56269. * Removes the given lens flare system from this scene.
  56270. * @param toRemove The lens flare system to remove
  56271. * @returns The index of the removed lens flare system
  56272. */
  56273. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56274. /**
  56275. * Adds the given lens flare system to this scene
  56276. * @param newLensFlareSystem The lens flare system to add
  56277. */
  56278. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56279. /**
  56280. * Gets a lens flare system using its name
  56281. * @param name defines the name to look for
  56282. * @returns the lens flare system or null if not found
  56283. */
  56284. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56285. /**
  56286. * Gets a lens flare system using its id
  56287. * @param id defines the id to look for
  56288. * @returns the lens flare system or null if not found
  56289. */
  56290. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56291. }
  56292. }
  56293. /**
  56294. * Defines the lens flare scene component responsible to manage any lens flares
  56295. * in a given scene.
  56296. */
  56297. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56298. /**
  56299. * The component name helpfull to identify the component in the list of scene components.
  56300. */
  56301. readonly name: string;
  56302. /**
  56303. * The scene the component belongs to.
  56304. */
  56305. scene: Scene;
  56306. /**
  56307. * Creates a new instance of the component for the given scene
  56308. * @param scene Defines the scene to register the component in
  56309. */
  56310. constructor(scene: Scene);
  56311. /**
  56312. * Registers the component in a given scene
  56313. */
  56314. register(): void;
  56315. /**
  56316. * Rebuilds the elements related to this component in case of
  56317. * context lost for instance.
  56318. */
  56319. rebuild(): void;
  56320. /**
  56321. * Adds all the elements from the container to the scene
  56322. * @param container the container holding the elements
  56323. */
  56324. addFromContainer(container: AbstractScene): void;
  56325. /**
  56326. * Removes all the elements in the container from the scene
  56327. * @param container contains the elements to remove
  56328. * @param dispose if the removed element should be disposed (default: false)
  56329. */
  56330. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56331. /**
  56332. * Serializes the component data to the specified json object
  56333. * @param serializationObject The object to serialize to
  56334. */
  56335. serialize(serializationObject: any): void;
  56336. /**
  56337. * Disposes the component and the associated ressources.
  56338. */
  56339. dispose(): void;
  56340. private _draw;
  56341. }
  56342. }
  56343. declare module "babylonjs/LensFlares/index" {
  56344. export * from "babylonjs/LensFlares/lensFlare";
  56345. export * from "babylonjs/LensFlares/lensFlareSystem";
  56346. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56347. }
  56348. declare module "babylonjs/Shaders/depth.fragment" {
  56349. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56350. /** @hidden */
  56351. export var depthPixelShader: {
  56352. name: string;
  56353. shader: string;
  56354. };
  56355. }
  56356. declare module "babylonjs/Shaders/depth.vertex" {
  56357. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56358. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56359. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56360. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56361. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56362. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56363. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56364. /** @hidden */
  56365. export var depthVertexShader: {
  56366. name: string;
  56367. shader: string;
  56368. };
  56369. }
  56370. declare module "babylonjs/Rendering/depthRenderer" {
  56371. import { Nullable } from "babylonjs/types";
  56372. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56373. import { Scene } from "babylonjs/scene";
  56374. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56375. import { Camera } from "babylonjs/Cameras/camera";
  56376. import "babylonjs/Shaders/depth.fragment";
  56377. import "babylonjs/Shaders/depth.vertex";
  56378. /**
  56379. * This represents a depth renderer in Babylon.
  56380. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56381. */
  56382. export class DepthRenderer {
  56383. private _scene;
  56384. private _depthMap;
  56385. private _effect;
  56386. private readonly _storeNonLinearDepth;
  56387. private readonly _clearColor;
  56388. /** Get if the depth renderer is using packed depth or not */
  56389. readonly isPacked: boolean;
  56390. private _cachedDefines;
  56391. private _camera;
  56392. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56393. enabled: boolean;
  56394. /**
  56395. * Specifiess that the depth renderer will only be used within
  56396. * the camera it is created for.
  56397. * This can help forcing its rendering during the camera processing.
  56398. */
  56399. useOnlyInActiveCamera: boolean;
  56400. /** @hidden */
  56401. static _SceneComponentInitialization: (scene: Scene) => void;
  56402. /**
  56403. * Instantiates a depth renderer
  56404. * @param scene The scene the renderer belongs to
  56405. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  56406. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  56407. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  56408. */
  56409. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  56410. /**
  56411. * Creates the depth rendering effect and checks if the effect is ready.
  56412. * @param subMesh The submesh to be used to render the depth map of
  56413. * @param useInstances If multiple world instances should be used
  56414. * @returns if the depth renderer is ready to render the depth map
  56415. */
  56416. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56417. /**
  56418. * Gets the texture which the depth map will be written to.
  56419. * @returns The depth map texture
  56420. */
  56421. getDepthMap(): RenderTargetTexture;
  56422. /**
  56423. * Disposes of the depth renderer.
  56424. */
  56425. dispose(): void;
  56426. }
  56427. }
  56428. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  56429. /** @hidden */
  56430. export var minmaxReduxPixelShader: {
  56431. name: string;
  56432. shader: string;
  56433. };
  56434. }
  56435. declare module "babylonjs/Misc/minMaxReducer" {
  56436. import { Nullable } from "babylonjs/types";
  56437. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56438. import { Camera } from "babylonjs/Cameras/camera";
  56439. import { Observer } from "babylonjs/Misc/observable";
  56440. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56441. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  56442. import { Observable } from "babylonjs/Misc/observable";
  56443. import "babylonjs/Shaders/minmaxRedux.fragment";
  56444. /**
  56445. * This class computes a min/max reduction from a texture: it means it computes the minimum
  56446. * and maximum values from all values of the texture.
  56447. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  56448. * The source values are read from the red channel of the texture.
  56449. */
  56450. export class MinMaxReducer {
  56451. /**
  56452. * Observable triggered when the computation has been performed
  56453. */
  56454. onAfterReductionPerformed: Observable<{
  56455. min: number;
  56456. max: number;
  56457. }>;
  56458. protected _camera: Camera;
  56459. protected _sourceTexture: Nullable<RenderTargetTexture>;
  56460. protected _reductionSteps: Nullable<Array<PostProcess>>;
  56461. protected _postProcessManager: PostProcessManager;
  56462. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  56463. protected _forceFullscreenViewport: boolean;
  56464. /**
  56465. * Creates a min/max reducer
  56466. * @param camera The camera to use for the post processes
  56467. */
  56468. constructor(camera: Camera);
  56469. /**
  56470. * Gets the texture used to read the values from.
  56471. */
  56472. get sourceTexture(): Nullable<RenderTargetTexture>;
  56473. /**
  56474. * Sets the source texture to read the values from.
  56475. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  56476. * because in such textures '1' value must not be taken into account to compute the maximum
  56477. * as this value is used to clear the texture.
  56478. * Note that the computation is not activated by calling this function, you must call activate() for that!
  56479. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  56480. * @param depthRedux Indicates if the texture is a depth texture or not
  56481. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  56482. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56483. */
  56484. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56485. /**
  56486. * Defines the refresh rate of the computation.
  56487. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56488. */
  56489. get refreshRate(): number;
  56490. set refreshRate(value: number);
  56491. protected _activated: boolean;
  56492. /**
  56493. * Gets the activation status of the reducer
  56494. */
  56495. get activated(): boolean;
  56496. /**
  56497. * Activates the reduction computation.
  56498. * When activated, the observers registered in onAfterReductionPerformed are
  56499. * called after the compuation is performed
  56500. */
  56501. activate(): void;
  56502. /**
  56503. * Deactivates the reduction computation.
  56504. */
  56505. deactivate(): void;
  56506. /**
  56507. * Disposes the min/max reducer
  56508. * @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.
  56509. */
  56510. dispose(disposeAll?: boolean): void;
  56511. }
  56512. }
  56513. declare module "babylonjs/Misc/depthReducer" {
  56514. import { Nullable } from "babylonjs/types";
  56515. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56516. import { Camera } from "babylonjs/Cameras/camera";
  56517. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56518. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  56519. /**
  56520. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  56521. */
  56522. export class DepthReducer extends MinMaxReducer {
  56523. private _depthRenderer;
  56524. private _depthRendererId;
  56525. /**
  56526. * Gets the depth renderer used for the computation.
  56527. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  56528. */
  56529. get depthRenderer(): Nullable<DepthRenderer>;
  56530. /**
  56531. * Creates a depth reducer
  56532. * @param camera The camera used to render the depth texture
  56533. */
  56534. constructor(camera: Camera);
  56535. /**
  56536. * Sets the depth renderer to use to generate the depth map
  56537. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  56538. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  56539. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  56540. */
  56541. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  56542. /** @hidden */
  56543. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  56544. /**
  56545. * Activates the reduction computation.
  56546. * When activated, the observers registered in onAfterReductionPerformed are
  56547. * called after the compuation is performed
  56548. */
  56549. activate(): void;
  56550. /**
  56551. * Deactivates the reduction computation.
  56552. */
  56553. deactivate(): void;
  56554. /**
  56555. * Disposes the depth reducer
  56556. * @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.
  56557. */
  56558. dispose(disposeAll?: boolean): void;
  56559. }
  56560. }
  56561. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  56562. import { Nullable } from "babylonjs/types";
  56563. import { Scene } from "babylonjs/scene";
  56564. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56565. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56566. import { Effect } from "babylonjs/Materials/effect";
  56567. import "babylonjs/Shaders/shadowMap.fragment";
  56568. import "babylonjs/Shaders/shadowMap.vertex";
  56569. import "babylonjs/Shaders/depthBoxBlur.fragment";
  56570. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  56571. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56572. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  56573. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  56574. /**
  56575. * A CSM implementation allowing casting shadows on large scenes.
  56576. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56577. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  56578. */
  56579. export class CascadedShadowGenerator extends ShadowGenerator {
  56580. private static readonly frustumCornersNDCSpace;
  56581. /**
  56582. * Name of the CSM class
  56583. */
  56584. static CLASSNAME: string;
  56585. /**
  56586. * Defines the default number of cascades used by the CSM.
  56587. */
  56588. static readonly DEFAULT_CASCADES_COUNT: number;
  56589. /**
  56590. * Defines the minimum number of cascades used by the CSM.
  56591. */
  56592. static readonly MIN_CASCADES_COUNT: number;
  56593. /**
  56594. * Defines the maximum number of cascades used by the CSM.
  56595. */
  56596. static readonly MAX_CASCADES_COUNT: number;
  56597. protected _validateFilter(filter: number): number;
  56598. /**
  56599. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  56600. */
  56601. penumbraDarkness: number;
  56602. private _numCascades;
  56603. /**
  56604. * Gets or set the number of cascades used by the CSM.
  56605. */
  56606. get numCascades(): number;
  56607. set numCascades(value: number);
  56608. /**
  56609. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  56610. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  56611. */
  56612. stabilizeCascades: boolean;
  56613. private _freezeShadowCastersBoundingInfo;
  56614. private _freezeShadowCastersBoundingInfoObservable;
  56615. /**
  56616. * Enables or disables the shadow casters bounding info computation.
  56617. * If your shadow casters don't move, you can disable this feature.
  56618. * If it is enabled, the bounding box computation is done every frame.
  56619. */
  56620. get freezeShadowCastersBoundingInfo(): boolean;
  56621. set freezeShadowCastersBoundingInfo(freeze: boolean);
  56622. private _scbiMin;
  56623. private _scbiMax;
  56624. protected _computeShadowCastersBoundingInfo(): void;
  56625. protected _shadowCastersBoundingInfo: BoundingInfo;
  56626. /**
  56627. * Gets or sets the shadow casters bounding info.
  56628. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  56629. * so that the system won't overwrite the bounds you provide
  56630. */
  56631. get shadowCastersBoundingInfo(): BoundingInfo;
  56632. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  56633. protected _breaksAreDirty: boolean;
  56634. protected _minDistance: number;
  56635. protected _maxDistance: number;
  56636. /**
  56637. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  56638. *
  56639. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  56640. * If you don't know these values, simply leave them to their defaults and don't call this function.
  56641. * @param min minimal distance for the breaks (default to 0.)
  56642. * @param max maximal distance for the breaks (default to 1.)
  56643. */
  56644. setMinMaxDistance(min: number, max: number): void;
  56645. /** Gets the minimal distance used in the cascade break computation */
  56646. get minDistance(): number;
  56647. /** Gets the maximal distance used in the cascade break computation */
  56648. get maxDistance(): number;
  56649. /**
  56650. * Gets the class name of that object
  56651. * @returns "CascadedShadowGenerator"
  56652. */
  56653. getClassName(): string;
  56654. private _cascadeMinExtents;
  56655. private _cascadeMaxExtents;
  56656. /**
  56657. * Gets a cascade minimum extents
  56658. * @param cascadeIndex index of the cascade
  56659. * @returns the minimum cascade extents
  56660. */
  56661. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  56662. /**
  56663. * Gets a cascade maximum extents
  56664. * @param cascadeIndex index of the cascade
  56665. * @returns the maximum cascade extents
  56666. */
  56667. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  56668. private _cascades;
  56669. private _currentLayer;
  56670. private _viewSpaceFrustumsZ;
  56671. private _viewMatrices;
  56672. private _projectionMatrices;
  56673. private _transformMatrices;
  56674. private _transformMatricesAsArray;
  56675. private _frustumLengths;
  56676. private _lightSizeUVCorrection;
  56677. private _depthCorrection;
  56678. private _frustumCornersWorldSpace;
  56679. private _frustumCenter;
  56680. private _shadowCameraPos;
  56681. private _shadowMaxZ;
  56682. /**
  56683. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  56684. * It defaults to camera.maxZ
  56685. */
  56686. get shadowMaxZ(): number;
  56687. /**
  56688. * Sets the shadow max z distance.
  56689. */
  56690. set shadowMaxZ(value: number);
  56691. protected _debug: boolean;
  56692. /**
  56693. * Gets or sets the debug flag.
  56694. * When enabled, the cascades are materialized by different colors on the screen.
  56695. */
  56696. get debug(): boolean;
  56697. set debug(dbg: boolean);
  56698. private _depthClamp;
  56699. /**
  56700. * Gets or sets the depth clamping value.
  56701. *
  56702. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  56703. * to account for the shadow casters far away.
  56704. *
  56705. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  56706. */
  56707. get depthClamp(): boolean;
  56708. set depthClamp(value: boolean);
  56709. private _cascadeBlendPercentage;
  56710. /**
  56711. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  56712. * It defaults to 0.1 (10% blending).
  56713. */
  56714. get cascadeBlendPercentage(): number;
  56715. set cascadeBlendPercentage(value: number);
  56716. private _lambda;
  56717. /**
  56718. * Gets or set the lambda parameter.
  56719. * This parameter is used to split the camera frustum and create the cascades.
  56720. * 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.
  56721. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  56722. */
  56723. get lambda(): number;
  56724. set lambda(value: number);
  56725. /**
  56726. * Gets the view matrix corresponding to a given cascade
  56727. * @param cascadeNum cascade to retrieve the view matrix from
  56728. * @returns the cascade view matrix
  56729. */
  56730. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  56731. /**
  56732. * Gets the projection matrix corresponding to a given cascade
  56733. * @param cascadeNum cascade to retrieve the projection matrix from
  56734. * @returns the cascade projection matrix
  56735. */
  56736. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  56737. /**
  56738. * Gets the transformation matrix corresponding to a given cascade
  56739. * @param cascadeNum cascade to retrieve the transformation matrix from
  56740. * @returns the cascade transformation matrix
  56741. */
  56742. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  56743. private _depthRenderer;
  56744. /**
  56745. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  56746. *
  56747. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  56748. *
  56749. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  56750. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  56751. * @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
  56752. */
  56753. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  56754. private _depthReducer;
  56755. private _autoCalcDepthBounds;
  56756. /**
  56757. * Gets or sets the autoCalcDepthBounds property.
  56758. *
  56759. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  56760. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  56761. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  56762. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  56763. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  56764. */
  56765. get autoCalcDepthBounds(): boolean;
  56766. set autoCalcDepthBounds(value: boolean);
  56767. /**
  56768. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  56769. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  56770. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  56771. * for setting the refresh rate on the renderer yourself!
  56772. */
  56773. get autoCalcDepthBoundsRefreshRate(): number;
  56774. set autoCalcDepthBoundsRefreshRate(value: number);
  56775. /**
  56776. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  56777. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  56778. * you change the camera near/far planes!
  56779. */
  56780. splitFrustum(): void;
  56781. private _splitFrustum;
  56782. private _computeMatrices;
  56783. private _computeFrustumInWorldSpace;
  56784. private _computeCascadeFrustum;
  56785. /** @hidden */
  56786. static _SceneComponentInitialization: (scene: Scene) => void;
  56787. /**
  56788. * Creates a Cascaded Shadow Generator object.
  56789. * A ShadowGenerator is the required tool to use the shadows.
  56790. * Each directional light casting shadows needs to use its own ShadowGenerator.
  56791. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  56792. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  56793. * @param light The directional light object generating the shadows.
  56794. * @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.
  56795. */
  56796. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  56797. protected _initializeGenerator(): void;
  56798. protected _createTargetRenderTexture(): void;
  56799. protected _initializeShadowMap(): void;
  56800. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  56801. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  56802. /**
  56803. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  56804. * @param defines Defines of the material we want to update
  56805. * @param lightIndex Index of the light in the enabled light list of the material
  56806. */
  56807. prepareDefines(defines: any, lightIndex: number): void;
  56808. /**
  56809. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  56810. * defined in the generator but impacting the effect).
  56811. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  56812. * @param effect The effect we are binfing the information for
  56813. */
  56814. bindShadowLight(lightIndex: string, effect: Effect): void;
  56815. /**
  56816. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  56817. * (eq to view projection * shadow projection matrices)
  56818. * @returns The transform matrix used to create the shadow map
  56819. */
  56820. getTransformMatrix(): Matrix;
  56821. /**
  56822. * Disposes the ShadowGenerator.
  56823. * Returns nothing.
  56824. */
  56825. dispose(): void;
  56826. /**
  56827. * Serializes the shadow generator setup to a json object.
  56828. * @returns The serialized JSON object
  56829. */
  56830. serialize(): any;
  56831. /**
  56832. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  56833. * @param parsedShadowGenerator The JSON object to parse
  56834. * @param scene The scene to create the shadow map for
  56835. * @returns The parsed shadow generator
  56836. */
  56837. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  56838. }
  56839. }
  56840. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  56841. import { Scene } from "babylonjs/scene";
  56842. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56843. import { AbstractScene } from "babylonjs/abstractScene";
  56844. /**
  56845. * Defines the shadow generator component responsible to manage any shadow generators
  56846. * in a given scene.
  56847. */
  56848. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  56849. /**
  56850. * The component name helpfull to identify the component in the list of scene components.
  56851. */
  56852. readonly name: string;
  56853. /**
  56854. * The scene the component belongs to.
  56855. */
  56856. scene: Scene;
  56857. /**
  56858. * Creates a new instance of the component for the given scene
  56859. * @param scene Defines the scene to register the component in
  56860. */
  56861. constructor(scene: Scene);
  56862. /**
  56863. * Registers the component in a given scene
  56864. */
  56865. register(): void;
  56866. /**
  56867. * Rebuilds the elements related to this component in case of
  56868. * context lost for instance.
  56869. */
  56870. rebuild(): void;
  56871. /**
  56872. * Serializes the component data to the specified json object
  56873. * @param serializationObject The object to serialize to
  56874. */
  56875. serialize(serializationObject: any): void;
  56876. /**
  56877. * Adds all the elements from the container to the scene
  56878. * @param container the container holding the elements
  56879. */
  56880. addFromContainer(container: AbstractScene): void;
  56881. /**
  56882. * Removes all the elements in the container from the scene
  56883. * @param container contains the elements to remove
  56884. * @param dispose if the removed element should be disposed (default: false)
  56885. */
  56886. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56887. /**
  56888. * Rebuilds the elements related to this component in case of
  56889. * context lost for instance.
  56890. */
  56891. dispose(): void;
  56892. private _gatherRenderTargets;
  56893. }
  56894. }
  56895. declare module "babylonjs/Lights/Shadows/index" {
  56896. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  56897. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  56898. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  56899. }
  56900. declare module "babylonjs/Lights/pointLight" {
  56901. import { Scene } from "babylonjs/scene";
  56902. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56903. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56904. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56905. import { Effect } from "babylonjs/Materials/effect";
  56906. /**
  56907. * A point light is a light defined by an unique point in world space.
  56908. * The light is emitted in every direction from this point.
  56909. * A good example of a point light is a standard light bulb.
  56910. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56911. */
  56912. export class PointLight extends ShadowLight {
  56913. private _shadowAngle;
  56914. /**
  56915. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56916. * This specifies what angle the shadow will use to be created.
  56917. *
  56918. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56919. */
  56920. get shadowAngle(): number;
  56921. /**
  56922. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56923. * This specifies what angle the shadow will use to be created.
  56924. *
  56925. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  56926. */
  56927. set shadowAngle(value: number);
  56928. /**
  56929. * Gets the direction if it has been set.
  56930. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56931. */
  56932. get direction(): Vector3;
  56933. /**
  56934. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  56935. */
  56936. set direction(value: Vector3);
  56937. /**
  56938. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  56939. * A PointLight emits the light in every direction.
  56940. * It can cast shadows.
  56941. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  56942. * ```javascript
  56943. * var pointLight = new PointLight("pl", camera.position, scene);
  56944. * ```
  56945. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56946. * @param name The light friendly name
  56947. * @param position The position of the point light in the scene
  56948. * @param scene The scene the lights belongs to
  56949. */
  56950. constructor(name: string, position: Vector3, scene: Scene);
  56951. /**
  56952. * Returns the string "PointLight"
  56953. * @returns the class name
  56954. */
  56955. getClassName(): string;
  56956. /**
  56957. * Returns the integer 0.
  56958. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56959. */
  56960. getTypeID(): number;
  56961. /**
  56962. * Specifies wether or not the shadowmap should be a cube texture.
  56963. * @returns true if the shadowmap needs to be a cube texture.
  56964. */
  56965. needCube(): boolean;
  56966. /**
  56967. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  56968. * @param faceIndex The index of the face we are computed the direction to generate shadow
  56969. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  56970. */
  56971. getShadowDirection(faceIndex?: number): Vector3;
  56972. /**
  56973. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  56974. * - fov = PI / 2
  56975. * - aspect ratio : 1.0
  56976. * - z-near and far equal to the active camera minZ and maxZ.
  56977. * Returns the PointLight.
  56978. */
  56979. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56980. protected _buildUniformLayout(): void;
  56981. /**
  56982. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  56983. * @param effect The effect to update
  56984. * @param lightIndex The index of the light in the effect to update
  56985. * @returns The point light
  56986. */
  56987. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  56988. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56989. /**
  56990. * Prepares the list of defines specific to the light type.
  56991. * @param defines the list of defines
  56992. * @param lightIndex defines the index of the light for the effect
  56993. */
  56994. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56995. }
  56996. }
  56997. declare module "babylonjs/Lights/index" {
  56998. export * from "babylonjs/Lights/light";
  56999. export * from "babylonjs/Lights/shadowLight";
  57000. export * from "babylonjs/Lights/Shadows/index";
  57001. export * from "babylonjs/Lights/directionalLight";
  57002. export * from "babylonjs/Lights/hemisphericLight";
  57003. export * from "babylonjs/Lights/pointLight";
  57004. export * from "babylonjs/Lights/spotLight";
  57005. }
  57006. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57007. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57008. /**
  57009. * Header information of HDR texture files.
  57010. */
  57011. export interface HDRInfo {
  57012. /**
  57013. * The height of the texture in pixels.
  57014. */
  57015. height: number;
  57016. /**
  57017. * The width of the texture in pixels.
  57018. */
  57019. width: number;
  57020. /**
  57021. * The index of the beginning of the data in the binary file.
  57022. */
  57023. dataPosition: number;
  57024. }
  57025. /**
  57026. * This groups tools to convert HDR texture to native colors array.
  57027. */
  57028. export class HDRTools {
  57029. private static Ldexp;
  57030. private static Rgbe2float;
  57031. private static readStringLine;
  57032. /**
  57033. * Reads header information from an RGBE texture stored in a native array.
  57034. * More information on this format are available here:
  57035. * https://en.wikipedia.org/wiki/RGBE_image_format
  57036. *
  57037. * @param uint8array The binary file stored in native array.
  57038. * @return The header information.
  57039. */
  57040. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57041. /**
  57042. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57043. * This RGBE texture needs to store the information as a panorama.
  57044. *
  57045. * More information on this format are available here:
  57046. * https://en.wikipedia.org/wiki/RGBE_image_format
  57047. *
  57048. * @param buffer The binary file stored in an array buffer.
  57049. * @param size The expected size of the extracted cubemap.
  57050. * @return The Cube Map information.
  57051. */
  57052. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57053. /**
  57054. * Returns the pixels data extracted from an RGBE texture.
  57055. * This pixels will be stored left to right up to down in the R G B order in one array.
  57056. *
  57057. * More information on this format are available here:
  57058. * https://en.wikipedia.org/wiki/RGBE_image_format
  57059. *
  57060. * @param uint8array The binary file stored in an array buffer.
  57061. * @param hdrInfo The header information of the file.
  57062. * @return The pixels data in RGB right to left up to down order.
  57063. */
  57064. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57065. private static RGBE_ReadPixels_RLE;
  57066. }
  57067. }
  57068. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57069. import { Nullable } from "babylonjs/types";
  57070. import { Scene } from "babylonjs/scene";
  57071. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57072. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57073. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57074. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57075. /**
  57076. * This represents a texture coming from an HDR input.
  57077. *
  57078. * The only supported format is currently panorama picture stored in RGBE format.
  57079. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57080. */
  57081. export class HDRCubeTexture extends BaseTexture {
  57082. private static _facesMapping;
  57083. private _generateHarmonics;
  57084. private _noMipmap;
  57085. private _textureMatrix;
  57086. private _size;
  57087. private _onLoad;
  57088. private _onError;
  57089. /**
  57090. * The texture URL.
  57091. */
  57092. url: string;
  57093. /**
  57094. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57095. */
  57096. coordinatesMode: number;
  57097. protected _isBlocking: boolean;
  57098. /**
  57099. * Sets wether or not the texture is blocking during loading.
  57100. */
  57101. set isBlocking(value: boolean);
  57102. /**
  57103. * Gets wether or not the texture is blocking during loading.
  57104. */
  57105. get isBlocking(): boolean;
  57106. protected _rotationY: number;
  57107. /**
  57108. * Sets texture matrix rotation angle around Y axis in radians.
  57109. */
  57110. set rotationY(value: number);
  57111. /**
  57112. * Gets texture matrix rotation angle around Y axis radians.
  57113. */
  57114. get rotationY(): number;
  57115. /**
  57116. * Gets or sets the center of the bounding box associated with the cube texture
  57117. * It must define where the camera used to render the texture was set
  57118. */
  57119. boundingBoxPosition: Vector3;
  57120. private _boundingBoxSize;
  57121. /**
  57122. * Gets or sets the size of the bounding box associated with the cube texture
  57123. * When defined, the cubemap will switch to local mode
  57124. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57125. * @example https://www.babylonjs-playground.com/#RNASML
  57126. */
  57127. set boundingBoxSize(value: Vector3);
  57128. get boundingBoxSize(): Vector3;
  57129. /**
  57130. * Instantiates an HDRTexture from the following parameters.
  57131. *
  57132. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57133. * @param scene The scene the texture will be used in
  57134. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57135. * @param noMipmap Forces to not generate the mipmap if true
  57136. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57137. * @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)
  57138. * @param reserved Reserved flag for internal use.
  57139. */
  57140. 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>);
  57141. /**
  57142. * Get the current class name of the texture useful for serialization or dynamic coding.
  57143. * @returns "HDRCubeTexture"
  57144. */
  57145. getClassName(): string;
  57146. /**
  57147. * Occurs when the file is raw .hdr file.
  57148. */
  57149. private loadTexture;
  57150. clone(): HDRCubeTexture;
  57151. delayLoad(): void;
  57152. /**
  57153. * Get the texture reflection matrix used to rotate/transform the reflection.
  57154. * @returns the reflection matrix
  57155. */
  57156. getReflectionTextureMatrix(): Matrix;
  57157. /**
  57158. * Set the texture reflection matrix used to rotate/transform the reflection.
  57159. * @param value Define the reflection matrix to set
  57160. */
  57161. setReflectionTextureMatrix(value: Matrix): void;
  57162. /**
  57163. * Parses a JSON representation of an HDR Texture in order to create the texture
  57164. * @param parsedTexture Define the JSON representation
  57165. * @param scene Define the scene the texture should be created in
  57166. * @param rootUrl Define the root url in case we need to load relative dependencies
  57167. * @returns the newly created texture after parsing
  57168. */
  57169. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57170. serialize(): any;
  57171. }
  57172. }
  57173. declare module "babylonjs/Physics/physicsEngine" {
  57174. import { Nullable } from "babylonjs/types";
  57175. import { Vector3 } from "babylonjs/Maths/math.vector";
  57176. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57177. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57178. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57179. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57180. /**
  57181. * Class used to control physics engine
  57182. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57183. */
  57184. export class PhysicsEngine implements IPhysicsEngine {
  57185. private _physicsPlugin;
  57186. /**
  57187. * Global value used to control the smallest number supported by the simulation
  57188. */
  57189. static Epsilon: number;
  57190. private _impostors;
  57191. private _joints;
  57192. private _subTimeStep;
  57193. /**
  57194. * Gets the gravity vector used by the simulation
  57195. */
  57196. gravity: Vector3;
  57197. /**
  57198. * Factory used to create the default physics plugin.
  57199. * @returns The default physics plugin
  57200. */
  57201. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57202. /**
  57203. * Creates a new Physics Engine
  57204. * @param gravity defines the gravity vector used by the simulation
  57205. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57206. */
  57207. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57208. /**
  57209. * Sets the gravity vector used by the simulation
  57210. * @param gravity defines the gravity vector to use
  57211. */
  57212. setGravity(gravity: Vector3): void;
  57213. /**
  57214. * Set the time step of the physics engine.
  57215. * Default is 1/60.
  57216. * To slow it down, enter 1/600 for example.
  57217. * To speed it up, 1/30
  57218. * @param newTimeStep defines the new timestep to apply to this world.
  57219. */
  57220. setTimeStep(newTimeStep?: number): void;
  57221. /**
  57222. * Get the time step of the physics engine.
  57223. * @returns the current time step
  57224. */
  57225. getTimeStep(): number;
  57226. /**
  57227. * Set the sub time step of the physics engine.
  57228. * Default is 0 meaning there is no sub steps
  57229. * To increase physics resolution precision, set a small value (like 1 ms)
  57230. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57231. */
  57232. setSubTimeStep(subTimeStep?: number): void;
  57233. /**
  57234. * Get the sub time step of the physics engine.
  57235. * @returns the current sub time step
  57236. */
  57237. getSubTimeStep(): number;
  57238. /**
  57239. * Release all resources
  57240. */
  57241. dispose(): void;
  57242. /**
  57243. * Gets the name of the current physics plugin
  57244. * @returns the name of the plugin
  57245. */
  57246. getPhysicsPluginName(): string;
  57247. /**
  57248. * Adding a new impostor for the impostor tracking.
  57249. * This will be done by the impostor itself.
  57250. * @param impostor the impostor to add
  57251. */
  57252. addImpostor(impostor: PhysicsImpostor): void;
  57253. /**
  57254. * Remove an impostor from the engine.
  57255. * This impostor and its mesh will not longer be updated by the physics engine.
  57256. * @param impostor the impostor to remove
  57257. */
  57258. removeImpostor(impostor: PhysicsImpostor): void;
  57259. /**
  57260. * Add a joint to the physics engine
  57261. * @param mainImpostor defines the main impostor to which the joint is added.
  57262. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57263. * @param joint defines the joint that will connect both impostors.
  57264. */
  57265. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57266. /**
  57267. * Removes a joint from the simulation
  57268. * @param mainImpostor defines the impostor used with the joint
  57269. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57270. * @param joint defines the joint to remove
  57271. */
  57272. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57273. /**
  57274. * Called by the scene. No need to call it.
  57275. * @param delta defines the timespam between frames
  57276. */
  57277. _step(delta: number): void;
  57278. /**
  57279. * Gets the current plugin used to run the simulation
  57280. * @returns current plugin
  57281. */
  57282. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57283. /**
  57284. * Gets the list of physic impostors
  57285. * @returns an array of PhysicsImpostor
  57286. */
  57287. getImpostors(): Array<PhysicsImpostor>;
  57288. /**
  57289. * Gets the impostor for a physics enabled object
  57290. * @param object defines the object impersonated by the impostor
  57291. * @returns the PhysicsImpostor or null if not found
  57292. */
  57293. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57294. /**
  57295. * Gets the impostor for a physics body object
  57296. * @param body defines physics body used by the impostor
  57297. * @returns the PhysicsImpostor or null if not found
  57298. */
  57299. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57300. /**
  57301. * Does a raycast in the physics world
  57302. * @param from when should the ray start?
  57303. * @param to when should the ray end?
  57304. * @returns PhysicsRaycastResult
  57305. */
  57306. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57307. }
  57308. }
  57309. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57310. import { Nullable } from "babylonjs/types";
  57311. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57313. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57314. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57315. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57316. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57317. /** @hidden */
  57318. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57319. private _useDeltaForWorldStep;
  57320. world: any;
  57321. name: string;
  57322. private _physicsMaterials;
  57323. private _fixedTimeStep;
  57324. private _cannonRaycastResult;
  57325. private _raycastResult;
  57326. private _physicsBodysToRemoveAfterStep;
  57327. BJSCANNON: any;
  57328. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57329. setGravity(gravity: Vector3): void;
  57330. setTimeStep(timeStep: number): void;
  57331. getTimeStep(): number;
  57332. executeStep(delta: number): void;
  57333. private _removeMarkedPhysicsBodiesFromWorld;
  57334. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57335. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57336. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57337. private _processChildMeshes;
  57338. removePhysicsBody(impostor: PhysicsImpostor): void;
  57339. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57340. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57341. private _addMaterial;
  57342. private _checkWithEpsilon;
  57343. private _createShape;
  57344. private _createHeightmap;
  57345. private _minus90X;
  57346. private _plus90X;
  57347. private _tmpPosition;
  57348. private _tmpDeltaPosition;
  57349. private _tmpUnityRotation;
  57350. private _updatePhysicsBodyTransformation;
  57351. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57352. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57353. isSupported(): boolean;
  57354. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57355. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57356. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57357. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57358. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57359. getBodyMass(impostor: PhysicsImpostor): number;
  57360. getBodyFriction(impostor: PhysicsImpostor): number;
  57361. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57362. getBodyRestitution(impostor: PhysicsImpostor): number;
  57363. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57364. sleepBody(impostor: PhysicsImpostor): void;
  57365. wakeUpBody(impostor: PhysicsImpostor): void;
  57366. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57367. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57368. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57369. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57370. getRadius(impostor: PhysicsImpostor): number;
  57371. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57372. dispose(): void;
  57373. private _extendNamespace;
  57374. /**
  57375. * Does a raycast in the physics world
  57376. * @param from when should the ray start?
  57377. * @param to when should the ray end?
  57378. * @returns PhysicsRaycastResult
  57379. */
  57380. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57381. }
  57382. }
  57383. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57384. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57385. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57386. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57388. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57389. import { Nullable } from "babylonjs/types";
  57390. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57391. /** @hidden */
  57392. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57393. world: any;
  57394. name: string;
  57395. BJSOIMO: any;
  57396. private _raycastResult;
  57397. constructor(iterations?: number, oimoInjection?: any);
  57398. setGravity(gravity: Vector3): void;
  57399. setTimeStep(timeStep: number): void;
  57400. getTimeStep(): number;
  57401. private _tmpImpostorsArray;
  57402. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57403. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57404. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57405. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57406. private _tmpPositionVector;
  57407. removePhysicsBody(impostor: PhysicsImpostor): void;
  57408. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57409. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57410. isSupported(): boolean;
  57411. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57412. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57413. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57414. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57415. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57416. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57417. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57418. getBodyMass(impostor: PhysicsImpostor): number;
  57419. getBodyFriction(impostor: PhysicsImpostor): number;
  57420. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57421. getBodyRestitution(impostor: PhysicsImpostor): number;
  57422. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57423. sleepBody(impostor: PhysicsImpostor): void;
  57424. wakeUpBody(impostor: PhysicsImpostor): void;
  57425. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57426. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  57427. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  57428. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57429. getRadius(impostor: PhysicsImpostor): number;
  57430. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57431. dispose(): void;
  57432. /**
  57433. * Does a raycast in the physics world
  57434. * @param from when should the ray start?
  57435. * @param to when should the ray end?
  57436. * @returns PhysicsRaycastResult
  57437. */
  57438. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57439. }
  57440. }
  57441. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  57442. import { Nullable } from "babylonjs/types";
  57443. import { Scene } from "babylonjs/scene";
  57444. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  57445. import { Color4 } from "babylonjs/Maths/math.color";
  57446. import { Mesh } from "babylonjs/Meshes/mesh";
  57447. /**
  57448. * Class containing static functions to help procedurally build meshes
  57449. */
  57450. export class RibbonBuilder {
  57451. /**
  57452. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  57453. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  57454. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  57455. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  57456. * * 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
  57457. * * 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
  57458. * * 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
  57459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57461. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57462. * * 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
  57463. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  57464. * * 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
  57465. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  57466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57467. * @param name defines the name of the mesh
  57468. * @param options defines the options used to create the mesh
  57469. * @param scene defines the hosting scene
  57470. * @returns the ribbon mesh
  57471. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  57472. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57473. */
  57474. static CreateRibbon(name: string, options: {
  57475. pathArray: Vector3[][];
  57476. closeArray?: boolean;
  57477. closePath?: boolean;
  57478. offset?: number;
  57479. updatable?: boolean;
  57480. sideOrientation?: number;
  57481. frontUVs?: Vector4;
  57482. backUVs?: Vector4;
  57483. instance?: Mesh;
  57484. invertUV?: boolean;
  57485. uvs?: Vector2[];
  57486. colors?: Color4[];
  57487. }, scene?: Nullable<Scene>): Mesh;
  57488. }
  57489. }
  57490. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  57491. import { Nullable } from "babylonjs/types";
  57492. import { Scene } from "babylonjs/scene";
  57493. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  57494. import { Mesh } from "babylonjs/Meshes/mesh";
  57495. /**
  57496. * Class containing static functions to help procedurally build meshes
  57497. */
  57498. export class ShapeBuilder {
  57499. /**
  57500. * 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.
  57501. * * 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.
  57502. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57503. * * 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.
  57504. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  57505. * * 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
  57506. * * 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
  57507. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  57508. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57509. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57510. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  57511. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  57512. * @param name defines the name of the mesh
  57513. * @param options defines the options used to create the mesh
  57514. * @param scene defines the hosting scene
  57515. * @returns the extruded shape mesh
  57516. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57517. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57518. */
  57519. static ExtrudeShape(name: string, options: {
  57520. shape: Vector3[];
  57521. path: Vector3[];
  57522. scale?: number;
  57523. rotation?: number;
  57524. cap?: number;
  57525. updatable?: boolean;
  57526. sideOrientation?: number;
  57527. frontUVs?: Vector4;
  57528. backUVs?: Vector4;
  57529. instance?: Mesh;
  57530. invertUV?: boolean;
  57531. }, scene?: Nullable<Scene>): Mesh;
  57532. /**
  57533. * Creates an custom extruded shape mesh.
  57534. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  57535. * * 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.
  57536. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  57537. * * 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
  57538. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  57539. * * 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
  57540. * * It must returns a float value that will be the scale value applied to the shape on each path point
  57541. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  57542. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  57543. * * 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
  57544. * * 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
  57545. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  57546. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  57547. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  57548. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  57549. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  57550. * @param name defines the name of the mesh
  57551. * @param options defines the options used to create the mesh
  57552. * @param scene defines the hosting scene
  57553. * @returns the custom extruded shape mesh
  57554. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  57555. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  57556. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  57557. */
  57558. static ExtrudeShapeCustom(name: string, options: {
  57559. shape: Vector3[];
  57560. path: Vector3[];
  57561. scaleFunction?: any;
  57562. rotationFunction?: any;
  57563. ribbonCloseArray?: boolean;
  57564. ribbonClosePath?: boolean;
  57565. cap?: number;
  57566. updatable?: boolean;
  57567. sideOrientation?: number;
  57568. frontUVs?: Vector4;
  57569. backUVs?: Vector4;
  57570. instance?: Mesh;
  57571. invertUV?: boolean;
  57572. }, scene?: Nullable<Scene>): Mesh;
  57573. private static _ExtrudeShapeGeneric;
  57574. }
  57575. }
  57576. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  57577. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  57578. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57579. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57580. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57581. import { Nullable } from "babylonjs/types";
  57582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57583. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57584. /**
  57585. * AmmoJS Physics plugin
  57586. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  57587. * @see https://github.com/kripken/ammo.js/
  57588. */
  57589. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  57590. private _useDeltaForWorldStep;
  57591. /**
  57592. * Reference to the Ammo library
  57593. */
  57594. bjsAMMO: any;
  57595. /**
  57596. * Created ammoJS world which physics bodies are added to
  57597. */
  57598. world: any;
  57599. /**
  57600. * Name of the plugin
  57601. */
  57602. name: string;
  57603. private _timeStep;
  57604. private _fixedTimeStep;
  57605. private _maxSteps;
  57606. private _tmpQuaternion;
  57607. private _tmpAmmoTransform;
  57608. private _tmpAmmoQuaternion;
  57609. private _tmpAmmoConcreteContactResultCallback;
  57610. private _collisionConfiguration;
  57611. private _dispatcher;
  57612. private _overlappingPairCache;
  57613. private _solver;
  57614. private _softBodySolver;
  57615. private _tmpAmmoVectorA;
  57616. private _tmpAmmoVectorB;
  57617. private _tmpAmmoVectorC;
  57618. private _tmpAmmoVectorD;
  57619. private _tmpContactCallbackResult;
  57620. private _tmpAmmoVectorRCA;
  57621. private _tmpAmmoVectorRCB;
  57622. private _raycastResult;
  57623. private static readonly DISABLE_COLLISION_FLAG;
  57624. private static readonly KINEMATIC_FLAG;
  57625. private static readonly DISABLE_DEACTIVATION_FLAG;
  57626. /**
  57627. * Initializes the ammoJS plugin
  57628. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  57629. * @param ammoInjection can be used to inject your own ammo reference
  57630. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  57631. */
  57632. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  57633. /**
  57634. * Sets the gravity of the physics world (m/(s^2))
  57635. * @param gravity Gravity to set
  57636. */
  57637. setGravity(gravity: Vector3): void;
  57638. /**
  57639. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  57640. * @param timeStep timestep to use in seconds
  57641. */
  57642. setTimeStep(timeStep: number): void;
  57643. /**
  57644. * 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)
  57645. * @param fixedTimeStep fixedTimeStep to use in seconds
  57646. */
  57647. setFixedTimeStep(fixedTimeStep: number): void;
  57648. /**
  57649. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  57650. * @param maxSteps the maximum number of steps by the physics engine per frame
  57651. */
  57652. setMaxSteps(maxSteps: number): void;
  57653. /**
  57654. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  57655. * @returns the current timestep in seconds
  57656. */
  57657. getTimeStep(): number;
  57658. /**
  57659. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  57660. */
  57661. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  57662. private _isImpostorInContact;
  57663. private _isImpostorPairInContact;
  57664. private _stepSimulation;
  57665. /**
  57666. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  57667. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  57668. * After the step the babylon meshes are set to the position of the physics imposters
  57669. * @param delta amount of time to step forward
  57670. * @param impostors array of imposters to update before/after the step
  57671. */
  57672. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  57673. /**
  57674. * Update babylon mesh to match physics world object
  57675. * @param impostor imposter to match
  57676. */
  57677. private _afterSoftStep;
  57678. /**
  57679. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57680. * @param impostor imposter to match
  57681. */
  57682. private _ropeStep;
  57683. /**
  57684. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  57685. * @param impostor imposter to match
  57686. */
  57687. private _softbodyOrClothStep;
  57688. private _tmpVector;
  57689. private _tmpMatrix;
  57690. /**
  57691. * Applies an impulse on the imposter
  57692. * @param impostor imposter to apply impulse to
  57693. * @param force amount of force to be applied to the imposter
  57694. * @param contactPoint the location to apply the impulse on the imposter
  57695. */
  57696. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57697. /**
  57698. * Applies a force on the imposter
  57699. * @param impostor imposter to apply force
  57700. * @param force amount of force to be applied to the imposter
  57701. * @param contactPoint the location to apply the force on the imposter
  57702. */
  57703. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57704. /**
  57705. * Creates a physics body using the plugin
  57706. * @param impostor the imposter to create the physics body on
  57707. */
  57708. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57709. /**
  57710. * Removes the physics body from the imposter and disposes of the body's memory
  57711. * @param impostor imposter to remove the physics body from
  57712. */
  57713. removePhysicsBody(impostor: PhysicsImpostor): void;
  57714. /**
  57715. * Generates a joint
  57716. * @param impostorJoint the imposter joint to create the joint with
  57717. */
  57718. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57719. /**
  57720. * Removes a joint
  57721. * @param impostorJoint the imposter joint to remove the joint from
  57722. */
  57723. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57724. private _addMeshVerts;
  57725. /**
  57726. * Initialise the soft body vertices to match its object's (mesh) vertices
  57727. * Softbody vertices (nodes) are in world space and to match this
  57728. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  57729. * @param impostor to create the softbody for
  57730. */
  57731. private _softVertexData;
  57732. /**
  57733. * Create an impostor's soft body
  57734. * @param impostor to create the softbody for
  57735. */
  57736. private _createSoftbody;
  57737. /**
  57738. * Create cloth for an impostor
  57739. * @param impostor to create the softbody for
  57740. */
  57741. private _createCloth;
  57742. /**
  57743. * Create rope for an impostor
  57744. * @param impostor to create the softbody for
  57745. */
  57746. private _createRope;
  57747. /**
  57748. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  57749. * @param impostor to create the custom physics shape for
  57750. */
  57751. private _createCustom;
  57752. private _addHullVerts;
  57753. private _createShape;
  57754. /**
  57755. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  57756. * @param impostor imposter containing the physics body and babylon object
  57757. */
  57758. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57759. /**
  57760. * Sets the babylon object's position/rotation from the physics body's position/rotation
  57761. * @param impostor imposter containing the physics body and babylon object
  57762. * @param newPosition new position
  57763. * @param newRotation new rotation
  57764. */
  57765. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57766. /**
  57767. * If this plugin is supported
  57768. * @returns true if its supported
  57769. */
  57770. isSupported(): boolean;
  57771. /**
  57772. * Sets the linear velocity of the physics body
  57773. * @param impostor imposter to set the velocity on
  57774. * @param velocity velocity to set
  57775. */
  57776. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57777. /**
  57778. * Sets the angular velocity of the physics body
  57779. * @param impostor imposter to set the velocity on
  57780. * @param velocity velocity to set
  57781. */
  57782. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57783. /**
  57784. * gets the linear velocity
  57785. * @param impostor imposter to get linear velocity from
  57786. * @returns linear velocity
  57787. */
  57788. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57789. /**
  57790. * gets the angular velocity
  57791. * @param impostor imposter to get angular velocity from
  57792. * @returns angular velocity
  57793. */
  57794. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57795. /**
  57796. * Sets the mass of physics body
  57797. * @param impostor imposter to set the mass on
  57798. * @param mass mass to set
  57799. */
  57800. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57801. /**
  57802. * Gets the mass of the physics body
  57803. * @param impostor imposter to get the mass from
  57804. * @returns mass
  57805. */
  57806. getBodyMass(impostor: PhysicsImpostor): number;
  57807. /**
  57808. * Gets friction of the impostor
  57809. * @param impostor impostor to get friction from
  57810. * @returns friction value
  57811. */
  57812. getBodyFriction(impostor: PhysicsImpostor): number;
  57813. /**
  57814. * Sets friction of the impostor
  57815. * @param impostor impostor to set friction on
  57816. * @param friction friction value
  57817. */
  57818. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57819. /**
  57820. * Gets restitution of the impostor
  57821. * @param impostor impostor to get restitution from
  57822. * @returns restitution value
  57823. */
  57824. getBodyRestitution(impostor: PhysicsImpostor): number;
  57825. /**
  57826. * Sets resitution of the impostor
  57827. * @param impostor impostor to set resitution on
  57828. * @param restitution resitution value
  57829. */
  57830. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57831. /**
  57832. * Gets pressure inside the impostor
  57833. * @param impostor impostor to get pressure from
  57834. * @returns pressure value
  57835. */
  57836. getBodyPressure(impostor: PhysicsImpostor): number;
  57837. /**
  57838. * Sets pressure inside a soft body impostor
  57839. * Cloth and rope must remain 0 pressure
  57840. * @param impostor impostor to set pressure on
  57841. * @param pressure pressure value
  57842. */
  57843. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  57844. /**
  57845. * Gets stiffness of the impostor
  57846. * @param impostor impostor to get stiffness from
  57847. * @returns pressure value
  57848. */
  57849. getBodyStiffness(impostor: PhysicsImpostor): number;
  57850. /**
  57851. * Sets stiffness of the impostor
  57852. * @param impostor impostor to set stiffness on
  57853. * @param stiffness stiffness value from 0 to 1
  57854. */
  57855. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  57856. /**
  57857. * Gets velocityIterations of the impostor
  57858. * @param impostor impostor to get velocity iterations from
  57859. * @returns velocityIterations value
  57860. */
  57861. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  57862. /**
  57863. * Sets velocityIterations of the impostor
  57864. * @param impostor impostor to set velocity iterations on
  57865. * @param velocityIterations velocityIterations value
  57866. */
  57867. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  57868. /**
  57869. * Gets positionIterations of the impostor
  57870. * @param impostor impostor to get position iterations from
  57871. * @returns positionIterations value
  57872. */
  57873. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  57874. /**
  57875. * Sets positionIterations of the impostor
  57876. * @param impostor impostor to set position on
  57877. * @param positionIterations positionIterations value
  57878. */
  57879. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  57880. /**
  57881. * Append an anchor to a cloth object
  57882. * @param impostor is the cloth impostor to add anchor to
  57883. * @param otherImpostor is the rigid impostor to anchor to
  57884. * @param width ratio across width from 0 to 1
  57885. * @param height ratio up height from 0 to 1
  57886. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  57887. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57888. */
  57889. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57890. /**
  57891. * Append an hook to a rope object
  57892. * @param impostor is the rope impostor to add hook to
  57893. * @param otherImpostor is the rigid impostor to hook to
  57894. * @param length ratio along the rope from 0 to 1
  57895. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  57896. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  57897. */
  57898. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  57899. /**
  57900. * Sleeps the physics body and stops it from being active
  57901. * @param impostor impostor to sleep
  57902. */
  57903. sleepBody(impostor: PhysicsImpostor): void;
  57904. /**
  57905. * Activates the physics body
  57906. * @param impostor impostor to activate
  57907. */
  57908. wakeUpBody(impostor: PhysicsImpostor): void;
  57909. /**
  57910. * Updates the distance parameters of the joint
  57911. * @param joint joint to update
  57912. * @param maxDistance maximum distance of the joint
  57913. * @param minDistance minimum distance of the joint
  57914. */
  57915. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  57916. /**
  57917. * Sets a motor on the joint
  57918. * @param joint joint to set motor on
  57919. * @param speed speed of the motor
  57920. * @param maxForce maximum force of the motor
  57921. * @param motorIndex index of the motor
  57922. */
  57923. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57924. /**
  57925. * Sets the motors limit
  57926. * @param joint joint to set limit on
  57927. * @param upperLimit upper limit
  57928. * @param lowerLimit lower limit
  57929. */
  57930. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57931. /**
  57932. * Syncs the position and rotation of a mesh with the impostor
  57933. * @param mesh mesh to sync
  57934. * @param impostor impostor to update the mesh with
  57935. */
  57936. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57937. /**
  57938. * Gets the radius of the impostor
  57939. * @param impostor impostor to get radius from
  57940. * @returns the radius
  57941. */
  57942. getRadius(impostor: PhysicsImpostor): number;
  57943. /**
  57944. * Gets the box size of the impostor
  57945. * @param impostor impostor to get box size from
  57946. * @param result the resulting box size
  57947. */
  57948. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57949. /**
  57950. * Disposes of the impostor
  57951. */
  57952. dispose(): void;
  57953. /**
  57954. * Does a raycast in the physics world
  57955. * @param from when should the ray start?
  57956. * @param to when should the ray end?
  57957. * @returns PhysicsRaycastResult
  57958. */
  57959. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57960. }
  57961. }
  57962. declare module "babylonjs/Probes/reflectionProbe" {
  57963. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57964. import { Vector3 } from "babylonjs/Maths/math.vector";
  57965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57966. import { Nullable } from "babylonjs/types";
  57967. import { Scene } from "babylonjs/scene";
  57968. module "babylonjs/abstractScene" {
  57969. interface AbstractScene {
  57970. /**
  57971. * The list of reflection probes added to the scene
  57972. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57973. */
  57974. reflectionProbes: Array<ReflectionProbe>;
  57975. /**
  57976. * Removes the given reflection probe from this scene.
  57977. * @param toRemove The reflection probe to remove
  57978. * @returns The index of the removed reflection probe
  57979. */
  57980. removeReflectionProbe(toRemove: ReflectionProbe): number;
  57981. /**
  57982. * Adds the given reflection probe to this scene.
  57983. * @param newReflectionProbe The reflection probe to add
  57984. */
  57985. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  57986. }
  57987. }
  57988. /**
  57989. * Class used to generate realtime reflection / refraction cube textures
  57990. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  57991. */
  57992. export class ReflectionProbe {
  57993. /** defines the name of the probe */
  57994. name: string;
  57995. private _scene;
  57996. private _renderTargetTexture;
  57997. private _projectionMatrix;
  57998. private _viewMatrix;
  57999. private _target;
  58000. private _add;
  58001. private _attachedMesh;
  58002. private _invertYAxis;
  58003. /** Gets or sets probe position (center of the cube map) */
  58004. position: Vector3;
  58005. /**
  58006. * Creates a new reflection probe
  58007. * @param name defines the name of the probe
  58008. * @param size defines the texture resolution (for each face)
  58009. * @param scene defines the hosting scene
  58010. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58011. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58012. */
  58013. constructor(
  58014. /** defines the name of the probe */
  58015. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58016. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58017. get samples(): number;
  58018. set samples(value: number);
  58019. /** Gets or sets the refresh rate to use (on every frame by default) */
  58020. get refreshRate(): number;
  58021. set refreshRate(value: number);
  58022. /**
  58023. * Gets the hosting scene
  58024. * @returns a Scene
  58025. */
  58026. getScene(): Scene;
  58027. /** Gets the internal CubeTexture used to render to */
  58028. get cubeTexture(): RenderTargetTexture;
  58029. /** Gets the list of meshes to render */
  58030. get renderList(): Nullable<AbstractMesh[]>;
  58031. /**
  58032. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58033. * @param mesh defines the mesh to attach to
  58034. */
  58035. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58036. /**
  58037. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58038. * @param renderingGroupId The rendering group id corresponding to its index
  58039. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58040. */
  58041. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58042. /**
  58043. * Clean all associated resources
  58044. */
  58045. dispose(): void;
  58046. /**
  58047. * Converts the reflection probe information to a readable string for debug purpose.
  58048. * @param fullDetails Supports for multiple levels of logging within scene loading
  58049. * @returns the human readable reflection probe info
  58050. */
  58051. toString(fullDetails?: boolean): string;
  58052. /**
  58053. * Get the class name of the relfection probe.
  58054. * @returns "ReflectionProbe"
  58055. */
  58056. getClassName(): string;
  58057. /**
  58058. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58059. * @returns The JSON representation of the texture
  58060. */
  58061. serialize(): any;
  58062. /**
  58063. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58064. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58065. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58066. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58067. * @returns The parsed reflection probe if successful
  58068. */
  58069. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58070. }
  58071. }
  58072. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58073. /** @hidden */
  58074. export var _BabylonLoaderRegistered: boolean;
  58075. /**
  58076. * Helps setting up some configuration for the babylon file loader.
  58077. */
  58078. export class BabylonFileLoaderConfiguration {
  58079. /**
  58080. * The loader does not allow injecting custom physix engine into the plugins.
  58081. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58082. * So you could set this variable to your engine import to make it work.
  58083. */
  58084. static LoaderInjectedPhysicsEngine: any;
  58085. }
  58086. }
  58087. declare module "babylonjs/Loading/Plugins/index" {
  58088. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58089. }
  58090. declare module "babylonjs/Loading/index" {
  58091. export * from "babylonjs/Loading/loadingScreen";
  58092. export * from "babylonjs/Loading/Plugins/index";
  58093. export * from "babylonjs/Loading/sceneLoader";
  58094. export * from "babylonjs/Loading/sceneLoaderFlags";
  58095. }
  58096. declare module "babylonjs/Materials/Background/index" {
  58097. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58098. }
  58099. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58100. import { Scene } from "babylonjs/scene";
  58101. import { Color3 } from "babylonjs/Maths/math.color";
  58102. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58103. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58104. /**
  58105. * The Physically based simple base material of BJS.
  58106. *
  58107. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58108. * It is used as the base class for both the specGloss and metalRough conventions.
  58109. */
  58110. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58111. /**
  58112. * Number of Simultaneous lights allowed on the material.
  58113. */
  58114. maxSimultaneousLights: number;
  58115. /**
  58116. * If sets to true, disables all the lights affecting the material.
  58117. */
  58118. disableLighting: boolean;
  58119. /**
  58120. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58121. */
  58122. environmentTexture: BaseTexture;
  58123. /**
  58124. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58125. */
  58126. invertNormalMapX: boolean;
  58127. /**
  58128. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58129. */
  58130. invertNormalMapY: boolean;
  58131. /**
  58132. * Normal map used in the model.
  58133. */
  58134. normalTexture: BaseTexture;
  58135. /**
  58136. * Emissivie color used to self-illuminate the model.
  58137. */
  58138. emissiveColor: Color3;
  58139. /**
  58140. * Emissivie texture used to self-illuminate the model.
  58141. */
  58142. emissiveTexture: BaseTexture;
  58143. /**
  58144. * Occlusion Channel Strenght.
  58145. */
  58146. occlusionStrength: number;
  58147. /**
  58148. * Occlusion Texture of the material (adding extra occlusion effects).
  58149. */
  58150. occlusionTexture: BaseTexture;
  58151. /**
  58152. * Defines the alpha limits in alpha test mode.
  58153. */
  58154. alphaCutOff: number;
  58155. /**
  58156. * Gets the current double sided mode.
  58157. */
  58158. get doubleSided(): boolean;
  58159. /**
  58160. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58161. */
  58162. set doubleSided(value: boolean);
  58163. /**
  58164. * Stores the pre-calculated light information of a mesh in a texture.
  58165. */
  58166. lightmapTexture: BaseTexture;
  58167. /**
  58168. * If true, the light map contains occlusion information instead of lighting info.
  58169. */
  58170. useLightmapAsShadowmap: boolean;
  58171. /**
  58172. * Instantiates a new PBRMaterial instance.
  58173. *
  58174. * @param name The material name
  58175. * @param scene The scene the material will be use in.
  58176. */
  58177. constructor(name: string, scene: Scene);
  58178. getClassName(): string;
  58179. }
  58180. }
  58181. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58182. import { Scene } from "babylonjs/scene";
  58183. import { Color3 } from "babylonjs/Maths/math.color";
  58184. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58185. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58186. /**
  58187. * The PBR material of BJS following the metal roughness convention.
  58188. *
  58189. * This fits to the PBR convention in the GLTF definition:
  58190. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58191. */
  58192. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58193. /**
  58194. * The base color has two different interpretations depending on the value of metalness.
  58195. * When the material is a metal, the base color is the specific measured reflectance value
  58196. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58197. * of the material.
  58198. */
  58199. baseColor: Color3;
  58200. /**
  58201. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58202. * well as opacity information in the alpha channel.
  58203. */
  58204. baseTexture: BaseTexture;
  58205. /**
  58206. * Specifies the metallic scalar value of the material.
  58207. * Can also be used to scale the metalness values of the metallic texture.
  58208. */
  58209. metallic: number;
  58210. /**
  58211. * Specifies the roughness scalar value of the material.
  58212. * Can also be used to scale the roughness values of the metallic texture.
  58213. */
  58214. roughness: number;
  58215. /**
  58216. * Texture containing both the metallic value in the B channel and the
  58217. * roughness value in the G channel to keep better precision.
  58218. */
  58219. metallicRoughnessTexture: BaseTexture;
  58220. /**
  58221. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58222. *
  58223. * @param name The material name
  58224. * @param scene The scene the material will be use in.
  58225. */
  58226. constructor(name: string, scene: Scene);
  58227. /**
  58228. * Return the currrent class name of the material.
  58229. */
  58230. getClassName(): string;
  58231. /**
  58232. * Makes a duplicate of the current material.
  58233. * @param name - name to use for the new material.
  58234. */
  58235. clone(name: string): PBRMetallicRoughnessMaterial;
  58236. /**
  58237. * Serialize the material to a parsable JSON object.
  58238. */
  58239. serialize(): any;
  58240. /**
  58241. * Parses a JSON object correponding to the serialize function.
  58242. */
  58243. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58244. }
  58245. }
  58246. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58247. import { Scene } from "babylonjs/scene";
  58248. import { Color3 } from "babylonjs/Maths/math.color";
  58249. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58250. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58251. /**
  58252. * The PBR material of BJS following the specular glossiness convention.
  58253. *
  58254. * This fits to the PBR convention in the GLTF definition:
  58255. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58256. */
  58257. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58258. /**
  58259. * Specifies the diffuse color of the material.
  58260. */
  58261. diffuseColor: Color3;
  58262. /**
  58263. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58264. * channel.
  58265. */
  58266. diffuseTexture: BaseTexture;
  58267. /**
  58268. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58269. */
  58270. specularColor: Color3;
  58271. /**
  58272. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58273. */
  58274. glossiness: number;
  58275. /**
  58276. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58277. */
  58278. specularGlossinessTexture: BaseTexture;
  58279. /**
  58280. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58281. *
  58282. * @param name The material name
  58283. * @param scene The scene the material will be use in.
  58284. */
  58285. constructor(name: string, scene: Scene);
  58286. /**
  58287. * Return the currrent class name of the material.
  58288. */
  58289. getClassName(): string;
  58290. /**
  58291. * Makes a duplicate of the current material.
  58292. * @param name - name to use for the new material.
  58293. */
  58294. clone(name: string): PBRSpecularGlossinessMaterial;
  58295. /**
  58296. * Serialize the material to a parsable JSON object.
  58297. */
  58298. serialize(): any;
  58299. /**
  58300. * Parses a JSON object correponding to the serialize function.
  58301. */
  58302. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58303. }
  58304. }
  58305. declare module "babylonjs/Materials/PBR/index" {
  58306. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58307. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58308. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58309. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58310. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58311. }
  58312. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58313. import { Nullable } from "babylonjs/types";
  58314. import { Scene } from "babylonjs/scene";
  58315. import { Matrix } from "babylonjs/Maths/math.vector";
  58316. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58317. /**
  58318. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58319. * It can help converting any input color in a desired output one. This can then be used to create effects
  58320. * from sepia, black and white to sixties or futuristic rendering...
  58321. *
  58322. * The only supported format is currently 3dl.
  58323. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58324. */
  58325. export class ColorGradingTexture extends BaseTexture {
  58326. /**
  58327. * The current texture matrix. (will always be identity in color grading texture)
  58328. */
  58329. private _textureMatrix;
  58330. /**
  58331. * The texture URL.
  58332. */
  58333. url: string;
  58334. /**
  58335. * Empty line regex stored for GC.
  58336. */
  58337. private static _noneEmptyLineRegex;
  58338. private _engine;
  58339. /**
  58340. * Instantiates a ColorGradingTexture from the following parameters.
  58341. *
  58342. * @param url The location of the color gradind data (currently only supporting 3dl)
  58343. * @param scene The scene the texture will be used in
  58344. */
  58345. constructor(url: string, scene: Scene);
  58346. /**
  58347. * Returns the texture matrix used in most of the material.
  58348. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58349. */
  58350. getTextureMatrix(): Matrix;
  58351. /**
  58352. * Occurs when the file being loaded is a .3dl LUT file.
  58353. */
  58354. private load3dlTexture;
  58355. /**
  58356. * Starts the loading process of the texture.
  58357. */
  58358. private loadTexture;
  58359. /**
  58360. * Clones the color gradind texture.
  58361. */
  58362. clone(): ColorGradingTexture;
  58363. /**
  58364. * Called during delayed load for textures.
  58365. */
  58366. delayLoad(): void;
  58367. /**
  58368. * Parses a color grading texture serialized by Babylon.
  58369. * @param parsedTexture The texture information being parsedTexture
  58370. * @param scene The scene to load the texture in
  58371. * @param rootUrl The root url of the data assets to load
  58372. * @return A color gradind texture
  58373. */
  58374. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58375. /**
  58376. * Serializes the LUT texture to json format.
  58377. */
  58378. serialize(): any;
  58379. }
  58380. }
  58381. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58382. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58383. import { Scene } from "babylonjs/scene";
  58384. import { Nullable } from "babylonjs/types";
  58385. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58386. /**
  58387. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58388. */
  58389. export class EquiRectangularCubeTexture extends BaseTexture {
  58390. /** The six faces of the cube. */
  58391. private static _FacesMapping;
  58392. private _noMipmap;
  58393. private _onLoad;
  58394. private _onError;
  58395. /** The size of the cubemap. */
  58396. private _size;
  58397. /** The buffer of the image. */
  58398. private _buffer;
  58399. /** The width of the input image. */
  58400. private _width;
  58401. /** The height of the input image. */
  58402. private _height;
  58403. /** The URL to the image. */
  58404. url: string;
  58405. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  58406. coordinatesMode: number;
  58407. /**
  58408. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  58409. * @param url The location of the image
  58410. * @param scene The scene the texture will be used in
  58411. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  58412. * @param noMipmap Forces to not generate the mipmap if true
  58413. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58414. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58415. * @param onLoad — defines a callback called when texture is loaded
  58416. * @param onError — defines a callback called if there is an error
  58417. */
  58418. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  58419. /**
  58420. * Load the image data, by putting the image on a canvas and extracting its buffer.
  58421. */
  58422. private loadImage;
  58423. /**
  58424. * Convert the image buffer into a cubemap and create a CubeTexture.
  58425. */
  58426. private loadTexture;
  58427. /**
  58428. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  58429. * @param buffer The ArrayBuffer that should be converted.
  58430. * @returns The buffer as Float32Array.
  58431. */
  58432. private getFloat32ArrayFromArrayBuffer;
  58433. /**
  58434. * Get the current class name of the texture useful for serialization or dynamic coding.
  58435. * @returns "EquiRectangularCubeTexture"
  58436. */
  58437. getClassName(): string;
  58438. /**
  58439. * Create a clone of the current EquiRectangularCubeTexture and return it.
  58440. * @returns A clone of the current EquiRectangularCubeTexture.
  58441. */
  58442. clone(): EquiRectangularCubeTexture;
  58443. }
  58444. }
  58445. declare module "babylonjs/Misc/tga" {
  58446. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58447. /**
  58448. * Based on jsTGALoader - Javascript loader for TGA file
  58449. * By Vincent Thibault
  58450. * @see http://blog.robrowser.com/javascript-tga-loader.html
  58451. */
  58452. export class TGATools {
  58453. private static _TYPE_INDEXED;
  58454. private static _TYPE_RGB;
  58455. private static _TYPE_GREY;
  58456. private static _TYPE_RLE_INDEXED;
  58457. private static _TYPE_RLE_RGB;
  58458. private static _TYPE_RLE_GREY;
  58459. private static _ORIGIN_MASK;
  58460. private static _ORIGIN_SHIFT;
  58461. private static _ORIGIN_BL;
  58462. private static _ORIGIN_BR;
  58463. private static _ORIGIN_UL;
  58464. private static _ORIGIN_UR;
  58465. /**
  58466. * Gets the header of a TGA file
  58467. * @param data defines the TGA data
  58468. * @returns the header
  58469. */
  58470. static GetTGAHeader(data: Uint8Array): any;
  58471. /**
  58472. * Uploads TGA content to a Babylon Texture
  58473. * @hidden
  58474. */
  58475. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  58476. /** @hidden */
  58477. 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;
  58478. /** @hidden */
  58479. 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;
  58480. /** @hidden */
  58481. 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;
  58482. /** @hidden */
  58483. 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;
  58484. /** @hidden */
  58485. 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;
  58486. /** @hidden */
  58487. 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;
  58488. }
  58489. }
  58490. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  58491. import { Nullable } from "babylonjs/types";
  58492. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58493. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58494. /**
  58495. * Implementation of the TGA Texture Loader.
  58496. * @hidden
  58497. */
  58498. export class _TGATextureLoader implements IInternalTextureLoader {
  58499. /**
  58500. * Defines wether the loader supports cascade loading the different faces.
  58501. */
  58502. readonly supportCascades: boolean;
  58503. /**
  58504. * This returns if the loader support the current file information.
  58505. * @param extension defines the file extension of the file being loaded
  58506. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58507. * @param fallback defines the fallback internal texture if any
  58508. * @param isBase64 defines whether the texture is encoded as a base64
  58509. * @param isBuffer defines whether the texture data are stored as a buffer
  58510. * @returns true if the loader can load the specified file
  58511. */
  58512. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58513. /**
  58514. * Transform the url before loading if required.
  58515. * @param rootUrl the url of the texture
  58516. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58517. * @returns the transformed texture
  58518. */
  58519. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58520. /**
  58521. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58522. * @param rootUrl the url of the texture
  58523. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58524. * @returns the fallback texture
  58525. */
  58526. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58527. /**
  58528. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  58529. * @param data contains the texture data
  58530. * @param texture defines the BabylonJS internal texture
  58531. * @param createPolynomials will be true if polynomials have been requested
  58532. * @param onLoad defines the callback to trigger once the texture is ready
  58533. * @param onError defines the callback to trigger in case of error
  58534. */
  58535. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58536. /**
  58537. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58538. * @param data contains the texture data
  58539. * @param texture defines the BabylonJS internal texture
  58540. * @param callback defines the method to call once ready to upload
  58541. */
  58542. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58543. }
  58544. }
  58545. declare module "babylonjs/Misc/basis" {
  58546. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58547. /**
  58548. * Info about the .basis files
  58549. */
  58550. class BasisFileInfo {
  58551. /**
  58552. * If the file has alpha
  58553. */
  58554. hasAlpha: boolean;
  58555. /**
  58556. * Info about each image of the basis file
  58557. */
  58558. images: Array<{
  58559. levels: Array<{
  58560. width: number;
  58561. height: number;
  58562. transcodedPixels: ArrayBufferView;
  58563. }>;
  58564. }>;
  58565. }
  58566. /**
  58567. * Result of transcoding a basis file
  58568. */
  58569. class TranscodeResult {
  58570. /**
  58571. * Info about the .basis file
  58572. */
  58573. fileInfo: BasisFileInfo;
  58574. /**
  58575. * Format to use when loading the file
  58576. */
  58577. format: number;
  58578. }
  58579. /**
  58580. * Configuration options for the Basis transcoder
  58581. */
  58582. export class BasisTranscodeConfiguration {
  58583. /**
  58584. * Supported compression formats used to determine the supported output format of the transcoder
  58585. */
  58586. supportedCompressionFormats?: {
  58587. /**
  58588. * etc1 compression format
  58589. */
  58590. etc1?: boolean;
  58591. /**
  58592. * s3tc compression format
  58593. */
  58594. s3tc?: boolean;
  58595. /**
  58596. * pvrtc compression format
  58597. */
  58598. pvrtc?: boolean;
  58599. /**
  58600. * etc2 compression format
  58601. */
  58602. etc2?: boolean;
  58603. };
  58604. /**
  58605. * If mipmap levels should be loaded for transcoded images (Default: true)
  58606. */
  58607. loadMipmapLevels?: boolean;
  58608. /**
  58609. * Index of a single image to load (Default: all images)
  58610. */
  58611. loadSingleImage?: number;
  58612. }
  58613. /**
  58614. * Used to load .Basis files
  58615. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  58616. */
  58617. export class BasisTools {
  58618. private static _IgnoreSupportedFormats;
  58619. /**
  58620. * URL to use when loading the basis transcoder
  58621. */
  58622. static JSModuleURL: string;
  58623. /**
  58624. * URL to use when loading the wasm module for the transcoder
  58625. */
  58626. static WasmModuleURL: string;
  58627. /**
  58628. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  58629. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  58630. * @returns internal format corresponding to the Basis format
  58631. */
  58632. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  58633. private static _WorkerPromise;
  58634. private static _Worker;
  58635. private static _actionId;
  58636. private static _CreateWorkerAsync;
  58637. /**
  58638. * Transcodes a loaded image file to compressed pixel data
  58639. * @param data image data to transcode
  58640. * @param config configuration options for the transcoding
  58641. * @returns a promise resulting in the transcoded image
  58642. */
  58643. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  58644. /**
  58645. * Loads a texture from the transcode result
  58646. * @param texture texture load to
  58647. * @param transcodeResult the result of transcoding the basis file to load from
  58648. */
  58649. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  58650. }
  58651. }
  58652. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  58653. import { Nullable } from "babylonjs/types";
  58654. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58655. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  58656. /**
  58657. * Loader for .basis file format
  58658. */
  58659. export class _BasisTextureLoader implements IInternalTextureLoader {
  58660. /**
  58661. * Defines whether the loader supports cascade loading the different faces.
  58662. */
  58663. readonly supportCascades: boolean;
  58664. /**
  58665. * This returns if the loader support the current file information.
  58666. * @param extension defines the file extension of the file being loaded
  58667. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58668. * @param fallback defines the fallback internal texture if any
  58669. * @param isBase64 defines whether the texture is encoded as a base64
  58670. * @param isBuffer defines whether the texture data are stored as a buffer
  58671. * @returns true if the loader can load the specified file
  58672. */
  58673. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  58674. /**
  58675. * Transform the url before loading if required.
  58676. * @param rootUrl the url of the texture
  58677. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58678. * @returns the transformed texture
  58679. */
  58680. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  58681. /**
  58682. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  58683. * @param rootUrl the url of the texture
  58684. * @param textureFormatInUse defines the current compressed format in use iun the engine
  58685. * @returns the fallback texture
  58686. */
  58687. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  58688. /**
  58689. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  58690. * @param data contains the texture data
  58691. * @param texture defines the BabylonJS internal texture
  58692. * @param createPolynomials will be true if polynomials have been requested
  58693. * @param onLoad defines the callback to trigger once the texture is ready
  58694. * @param onError defines the callback to trigger in case of error
  58695. */
  58696. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58697. /**
  58698. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  58699. * @param data contains the texture data
  58700. * @param texture defines the BabylonJS internal texture
  58701. * @param callback defines the method to call once ready to upload
  58702. */
  58703. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58704. }
  58705. }
  58706. declare module "babylonjs/Materials/Textures/Loaders/index" {
  58707. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  58708. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  58709. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  58710. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  58711. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  58712. }
  58713. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  58714. import { Scene } from "babylonjs/scene";
  58715. import { Texture } from "babylonjs/Materials/Textures/texture";
  58716. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58717. /**
  58718. * 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.
  58719. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58720. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58721. */
  58722. export class CustomProceduralTexture extends ProceduralTexture {
  58723. private _animate;
  58724. private _time;
  58725. private _config;
  58726. private _texturePath;
  58727. /**
  58728. * Instantiates a new Custom Procedural Texture.
  58729. * 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.
  58730. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  58731. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  58732. * @param name Define the name of the texture
  58733. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  58734. * @param size Define the size of the texture to create
  58735. * @param scene Define the scene the texture belongs to
  58736. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  58737. * @param generateMipMaps Define if the texture should creates mip maps or not
  58738. */
  58739. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58740. private _loadJson;
  58741. /**
  58742. * Is the texture ready to be used ? (rendered at least once)
  58743. * @returns true if ready, otherwise, false.
  58744. */
  58745. isReady(): boolean;
  58746. /**
  58747. * Render the texture to its associated render target.
  58748. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  58749. */
  58750. render(useCameraPostProcess?: boolean): void;
  58751. /**
  58752. * Update the list of dependant textures samplers in the shader.
  58753. */
  58754. updateTextures(): void;
  58755. /**
  58756. * Update the uniform values of the procedural texture in the shader.
  58757. */
  58758. updateShaderUniforms(): void;
  58759. /**
  58760. * Define if the texture animates or not.
  58761. */
  58762. get animate(): boolean;
  58763. set animate(value: boolean);
  58764. }
  58765. }
  58766. declare module "babylonjs/Shaders/noise.fragment" {
  58767. /** @hidden */
  58768. export var noisePixelShader: {
  58769. name: string;
  58770. shader: string;
  58771. };
  58772. }
  58773. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  58774. import { Nullable } from "babylonjs/types";
  58775. import { Scene } from "babylonjs/scene";
  58776. import { Texture } from "babylonjs/Materials/Textures/texture";
  58777. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58778. import "babylonjs/Shaders/noise.fragment";
  58779. /**
  58780. * Class used to generate noise procedural textures
  58781. */
  58782. export class NoiseProceduralTexture extends ProceduralTexture {
  58783. private _time;
  58784. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  58785. brightness: number;
  58786. /** Defines the number of octaves to process */
  58787. octaves: number;
  58788. /** Defines the level of persistence (0.8 by default) */
  58789. persistence: number;
  58790. /** Gets or sets animation speed factor (default is 1) */
  58791. animationSpeedFactor: number;
  58792. /**
  58793. * Creates a new NoiseProceduralTexture
  58794. * @param name defines the name fo the texture
  58795. * @param size defines the size of the texture (default is 256)
  58796. * @param scene defines the hosting scene
  58797. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  58798. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  58799. */
  58800. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  58801. private _updateShaderUniforms;
  58802. protected _getDefines(): string;
  58803. /** Generate the current state of the procedural texture */
  58804. render(useCameraPostProcess?: boolean): void;
  58805. /**
  58806. * Serializes this noise procedural texture
  58807. * @returns a serialized noise procedural texture object
  58808. */
  58809. serialize(): any;
  58810. /**
  58811. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  58812. * @param parsedTexture defines parsed texture data
  58813. * @param scene defines the current scene
  58814. * @param rootUrl defines the root URL containing noise procedural texture information
  58815. * @returns a parsed NoiseProceduralTexture
  58816. */
  58817. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  58818. }
  58819. }
  58820. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  58821. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  58822. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  58823. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  58824. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  58825. }
  58826. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  58827. import { Nullable } from "babylonjs/types";
  58828. import { Scene } from "babylonjs/scene";
  58829. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  58830. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  58831. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  58832. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58833. /**
  58834. * Raw cube texture where the raw buffers are passed in
  58835. */
  58836. export class RawCubeTexture extends CubeTexture {
  58837. /**
  58838. * Creates a cube texture where the raw buffers are passed in.
  58839. * @param scene defines the scene the texture is attached to
  58840. * @param data defines the array of data to use to create each face
  58841. * @param size defines the size of the textures
  58842. * @param format defines the format of the data
  58843. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  58844. * @param generateMipMaps defines if the engine should generate the mip levels
  58845. * @param invertY defines if data must be stored with Y axis inverted
  58846. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  58847. * @param compression defines the compression used (null by default)
  58848. */
  58849. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  58850. /**
  58851. * Updates the raw cube texture.
  58852. * @param data defines the data to store
  58853. * @param format defines the data format
  58854. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58855. * @param invertY defines if data must be stored with Y axis inverted
  58856. * @param compression defines the compression used (null by default)
  58857. * @param level defines which level of the texture to update
  58858. */
  58859. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  58860. /**
  58861. * Updates a raw cube texture with RGBD encoded data.
  58862. * @param data defines the array of data [mipmap][face] to use to create each face
  58863. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  58864. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  58865. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  58866. * @returns a promsie that resolves when the operation is complete
  58867. */
  58868. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  58869. /**
  58870. * Clones the raw cube texture.
  58871. * @return a new cube texture
  58872. */
  58873. clone(): CubeTexture;
  58874. /** @hidden */
  58875. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  58876. }
  58877. }
  58878. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  58879. import { Scene } from "babylonjs/scene";
  58880. import { Texture } from "babylonjs/Materials/Textures/texture";
  58881. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58882. /**
  58883. * Class used to store 3D textures containing user data
  58884. */
  58885. export class RawTexture3D extends Texture {
  58886. /** Gets or sets the texture format to use */
  58887. format: number;
  58888. private _engine;
  58889. /**
  58890. * Create a new RawTexture3D
  58891. * @param data defines the data of the texture
  58892. * @param width defines the width of the texture
  58893. * @param height defines the height of the texture
  58894. * @param depth defines the depth of the texture
  58895. * @param format defines the texture format to use
  58896. * @param scene defines the hosting scene
  58897. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58898. * @param invertY defines if texture must be stored with Y axis inverted
  58899. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58900. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58901. */
  58902. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58903. /** Gets or sets the texture format to use */
  58904. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58905. /**
  58906. * Update the texture with new data
  58907. * @param data defines the data to store in the texture
  58908. */
  58909. update(data: ArrayBufferView): void;
  58910. }
  58911. }
  58912. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  58913. import { Scene } from "babylonjs/scene";
  58914. import { Texture } from "babylonjs/Materials/Textures/texture";
  58915. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58916. /**
  58917. * Class used to store 2D array textures containing user data
  58918. */
  58919. export class RawTexture2DArray extends Texture {
  58920. /** Gets or sets the texture format to use */
  58921. format: number;
  58922. private _engine;
  58923. /**
  58924. * Create a new RawTexture2DArray
  58925. * @param data defines the data of the texture
  58926. * @param width defines the width of the texture
  58927. * @param height defines the height of the texture
  58928. * @param depth defines the number of layers of the texture
  58929. * @param format defines the texture format to use
  58930. * @param scene defines the hosting scene
  58931. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  58932. * @param invertY defines if texture must be stored with Y axis inverted
  58933. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58934. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  58935. */
  58936. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  58937. /** Gets or sets the texture format to use */
  58938. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  58939. /**
  58940. * Update the texture with new data
  58941. * @param data defines the data to store in the texture
  58942. */
  58943. update(data: ArrayBufferView): void;
  58944. }
  58945. }
  58946. declare module "babylonjs/Materials/Textures/refractionTexture" {
  58947. import { Scene } from "babylonjs/scene";
  58948. import { Plane } from "babylonjs/Maths/math.plane";
  58949. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58950. /**
  58951. * Creates a refraction texture used by refraction channel of the standard material.
  58952. * It is like a mirror but to see through a material.
  58953. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58954. */
  58955. export class RefractionTexture extends RenderTargetTexture {
  58956. /**
  58957. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  58958. * 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.
  58959. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58960. */
  58961. refractionPlane: Plane;
  58962. /**
  58963. * Define how deep under the surface we should see.
  58964. */
  58965. depth: number;
  58966. /**
  58967. * Creates a refraction texture used by refraction channel of the standard material.
  58968. * It is like a mirror but to see through a material.
  58969. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  58970. * @param name Define the texture name
  58971. * @param size Define the size of the underlying texture
  58972. * @param scene Define the scene the refraction belongs to
  58973. * @param generateMipMaps Define if we need to generate mips level for the refraction
  58974. */
  58975. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  58976. /**
  58977. * Clone the refraction texture.
  58978. * @returns the cloned texture
  58979. */
  58980. clone(): RefractionTexture;
  58981. /**
  58982. * Serialize the texture to a JSON representation you could use in Parse later on
  58983. * @returns the serialized JSON representation
  58984. */
  58985. serialize(): any;
  58986. }
  58987. }
  58988. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  58989. import { Nullable } from "babylonjs/types";
  58990. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58991. import { Matrix } from "babylonjs/Maths/math.vector";
  58992. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  58993. import "babylonjs/Engines/Extensions/engine.videoTexture";
  58994. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  58995. import { Scene } from "babylonjs/scene";
  58996. /**
  58997. * Defines the options related to the creation of an HtmlElementTexture
  58998. */
  58999. export interface IHtmlElementTextureOptions {
  59000. /**
  59001. * Defines wether mip maps should be created or not.
  59002. */
  59003. generateMipMaps?: boolean;
  59004. /**
  59005. * Defines the sampling mode of the texture.
  59006. */
  59007. samplingMode?: number;
  59008. /**
  59009. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59010. */
  59011. engine: Nullable<ThinEngine>;
  59012. /**
  59013. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59014. */
  59015. scene: Nullable<Scene>;
  59016. }
  59017. /**
  59018. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59019. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59020. * is automatically managed.
  59021. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59022. * in your application.
  59023. *
  59024. * As the update is not automatic, you need to call them manually.
  59025. */
  59026. export class HtmlElementTexture extends BaseTexture {
  59027. /**
  59028. * The texture URL.
  59029. */
  59030. element: HTMLVideoElement | HTMLCanvasElement;
  59031. private static readonly DefaultOptions;
  59032. private _textureMatrix;
  59033. private _engine;
  59034. private _isVideo;
  59035. private _generateMipMaps;
  59036. private _samplingMode;
  59037. /**
  59038. * Instantiates a HtmlElementTexture from the following parameters.
  59039. *
  59040. * @param name Defines the name of the texture
  59041. * @param element Defines the video or canvas the texture is filled with
  59042. * @param options Defines the other none mandatory texture creation options
  59043. */
  59044. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59045. private _createInternalTexture;
  59046. /**
  59047. * Returns the texture matrix used in most of the material.
  59048. */
  59049. getTextureMatrix(): Matrix;
  59050. /**
  59051. * Updates the content of the texture.
  59052. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59053. */
  59054. update(invertY?: Nullable<boolean>): void;
  59055. }
  59056. }
  59057. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59058. import { Vector2 } from "babylonjs/Maths/math.vector";
  59059. /**
  59060. * Defines the basic options interface of a TexturePacker Frame
  59061. */
  59062. export interface ITexturePackerFrame {
  59063. /**
  59064. * The frame ID
  59065. */
  59066. id: number;
  59067. /**
  59068. * The frames Scale
  59069. */
  59070. scale: Vector2;
  59071. /**
  59072. * The Frames offset
  59073. */
  59074. offset: Vector2;
  59075. }
  59076. /**
  59077. * This is a support class for frame Data on texture packer sets.
  59078. */
  59079. export class TexturePackerFrame implements ITexturePackerFrame {
  59080. /**
  59081. * The frame ID
  59082. */
  59083. id: number;
  59084. /**
  59085. * The frames Scale
  59086. */
  59087. scale: Vector2;
  59088. /**
  59089. * The Frames offset
  59090. */
  59091. offset: Vector2;
  59092. /**
  59093. * Initializes a texture package frame.
  59094. * @param id The numerical frame identifier
  59095. * @param scale Scalar Vector2 for UV frame
  59096. * @param offset Vector2 for the frame position in UV units.
  59097. * @returns TexturePackerFrame
  59098. */
  59099. constructor(id: number, scale: Vector2, offset: Vector2);
  59100. }
  59101. }
  59102. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59103. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59104. import { Scene } from "babylonjs/scene";
  59105. import { Nullable } from "babylonjs/types";
  59106. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59107. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59108. /**
  59109. * Defines the basic options interface of a TexturePacker
  59110. */
  59111. export interface ITexturePackerOptions {
  59112. /**
  59113. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59114. */
  59115. map?: string[];
  59116. /**
  59117. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59118. */
  59119. uvsIn?: string;
  59120. /**
  59121. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59122. */
  59123. uvsOut?: string;
  59124. /**
  59125. * number representing the layout style. Defaults to LAYOUT_STRIP
  59126. */
  59127. layout?: number;
  59128. /**
  59129. * number of columns if using custom column count layout(2). This defaults to 4.
  59130. */
  59131. colnum?: number;
  59132. /**
  59133. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59134. */
  59135. updateInputMeshes?: boolean;
  59136. /**
  59137. * boolean flag to dispose all the source textures. Defaults to true.
  59138. */
  59139. disposeSources?: boolean;
  59140. /**
  59141. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59142. */
  59143. fillBlanks?: boolean;
  59144. /**
  59145. * string value representing the context fill style color. Defaults to 'black'.
  59146. */
  59147. customFillColor?: string;
  59148. /**
  59149. * Width and Height Value of each Frame in the TexturePacker Sets
  59150. */
  59151. frameSize?: number;
  59152. /**
  59153. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59154. */
  59155. paddingRatio?: number;
  59156. /**
  59157. * Number that declares the fill method for the padding gutter.
  59158. */
  59159. paddingMode?: number;
  59160. /**
  59161. * If in SUBUV_COLOR padding mode what color to use.
  59162. */
  59163. paddingColor?: Color3 | Color4;
  59164. }
  59165. /**
  59166. * Defines the basic interface of a TexturePacker JSON File
  59167. */
  59168. export interface ITexturePackerJSON {
  59169. /**
  59170. * The frame ID
  59171. */
  59172. name: string;
  59173. /**
  59174. * The base64 channel data
  59175. */
  59176. sets: any;
  59177. /**
  59178. * The options of the Packer
  59179. */
  59180. options: ITexturePackerOptions;
  59181. /**
  59182. * The frame data of the Packer
  59183. */
  59184. frames: Array<number>;
  59185. }
  59186. /**
  59187. * This is a support class that generates a series of packed texture sets.
  59188. * @see https://doc.babylonjs.com/babylon101/materials
  59189. */
  59190. export class TexturePacker {
  59191. /** Packer Layout Constant 0 */
  59192. static readonly LAYOUT_STRIP: number;
  59193. /** Packer Layout Constant 1 */
  59194. static readonly LAYOUT_POWER2: number;
  59195. /** Packer Layout Constant 2 */
  59196. static readonly LAYOUT_COLNUM: number;
  59197. /** Packer Layout Constant 0 */
  59198. static readonly SUBUV_WRAP: number;
  59199. /** Packer Layout Constant 1 */
  59200. static readonly SUBUV_EXTEND: number;
  59201. /** Packer Layout Constant 2 */
  59202. static readonly SUBUV_COLOR: number;
  59203. /** The Name of the Texture Package */
  59204. name: string;
  59205. /** The scene scope of the TexturePacker */
  59206. scene: Scene;
  59207. /** The Meshes to target */
  59208. meshes: AbstractMesh[];
  59209. /** Arguments passed with the Constructor */
  59210. options: ITexturePackerOptions;
  59211. /** The promise that is started upon initialization */
  59212. promise: Nullable<Promise<TexturePacker | string>>;
  59213. /** The Container object for the channel sets that are generated */
  59214. sets: object;
  59215. /** The Container array for the frames that are generated */
  59216. frames: TexturePackerFrame[];
  59217. /** The expected number of textures the system is parsing. */
  59218. private _expecting;
  59219. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59220. private _paddingValue;
  59221. /**
  59222. * Initializes a texture package series from an array of meshes or a single mesh.
  59223. * @param name The name of the package
  59224. * @param meshes The target meshes to compose the package from
  59225. * @param options The arguments that texture packer should follow while building.
  59226. * @param scene The scene which the textures are scoped to.
  59227. * @returns TexturePacker
  59228. */
  59229. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59230. /**
  59231. * Starts the package process
  59232. * @param resolve The promises resolution function
  59233. * @returns TexturePacker
  59234. */
  59235. private _createFrames;
  59236. /**
  59237. * Calculates the Size of the Channel Sets
  59238. * @returns Vector2
  59239. */
  59240. private _calculateSize;
  59241. /**
  59242. * Calculates the UV data for the frames.
  59243. * @param baseSize the base frameSize
  59244. * @param padding the base frame padding
  59245. * @param dtSize size of the Dynamic Texture for that channel
  59246. * @param dtUnits is 1/dtSize
  59247. * @param update flag to update the input meshes
  59248. */
  59249. private _calculateMeshUVFrames;
  59250. /**
  59251. * Calculates the frames Offset.
  59252. * @param index of the frame
  59253. * @returns Vector2
  59254. */
  59255. private _getFrameOffset;
  59256. /**
  59257. * Updates a Mesh to the frame data
  59258. * @param mesh that is the target
  59259. * @param frameID or the frame index
  59260. */
  59261. private _updateMeshUV;
  59262. /**
  59263. * Updates a Meshes materials to use the texture packer channels
  59264. * @param m is the mesh to target
  59265. * @param force all channels on the packer to be set.
  59266. */
  59267. private _updateTextureReferences;
  59268. /**
  59269. * Public method to set a Mesh to a frame
  59270. * @param m that is the target
  59271. * @param frameID or the frame index
  59272. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59273. */
  59274. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59275. /**
  59276. * Starts the async promise to compile the texture packer.
  59277. * @returns Promise<void>
  59278. */
  59279. processAsync(): Promise<void>;
  59280. /**
  59281. * Disposes all textures associated with this packer
  59282. */
  59283. dispose(): void;
  59284. /**
  59285. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59286. * @param imageType is the image type to use.
  59287. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59288. */
  59289. download(imageType?: string, quality?: number): void;
  59290. /**
  59291. * Public method to load a texturePacker JSON file.
  59292. * @param data of the JSON file in string format.
  59293. */
  59294. updateFromJSON(data: string): void;
  59295. }
  59296. }
  59297. declare module "babylonjs/Materials/Textures/Packer/index" {
  59298. export * from "babylonjs/Materials/Textures/Packer/packer";
  59299. export * from "babylonjs/Materials/Textures/Packer/frame";
  59300. }
  59301. declare module "babylonjs/Materials/Textures/index" {
  59302. export * from "babylonjs/Materials/Textures/baseTexture";
  59303. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59304. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59305. export * from "babylonjs/Materials/Textures/cubeTexture";
  59306. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59307. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59308. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59309. export * from "babylonjs/Materials/Textures/internalTexture";
  59310. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59311. export * from "babylonjs/Materials/Textures/Loaders/index";
  59312. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59313. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59314. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59315. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59316. export * from "babylonjs/Materials/Textures/rawTexture";
  59317. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59318. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59319. export * from "babylonjs/Materials/Textures/refractionTexture";
  59320. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59321. export * from "babylonjs/Materials/Textures/texture";
  59322. export * from "babylonjs/Materials/Textures/videoTexture";
  59323. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59324. export * from "babylonjs/Materials/Textures/Packer/index";
  59325. }
  59326. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59327. /**
  59328. * Enum used to define the target of a block
  59329. */
  59330. export enum NodeMaterialBlockTargets {
  59331. /** Vertex shader */
  59332. Vertex = 1,
  59333. /** Fragment shader */
  59334. Fragment = 2,
  59335. /** Neutral */
  59336. Neutral = 4,
  59337. /** Vertex and Fragment */
  59338. VertexAndFragment = 3
  59339. }
  59340. }
  59341. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59342. /**
  59343. * Defines the kind of connection point for node based material
  59344. */
  59345. export enum NodeMaterialBlockConnectionPointTypes {
  59346. /** Float */
  59347. Float = 1,
  59348. /** Int */
  59349. Int = 2,
  59350. /** Vector2 */
  59351. Vector2 = 4,
  59352. /** Vector3 */
  59353. Vector3 = 8,
  59354. /** Vector4 */
  59355. Vector4 = 16,
  59356. /** Color3 */
  59357. Color3 = 32,
  59358. /** Color4 */
  59359. Color4 = 64,
  59360. /** Matrix */
  59361. Matrix = 128,
  59362. /** Detect type based on connection */
  59363. AutoDetect = 1024,
  59364. /** Output type that will be defined by input type */
  59365. BasedOnInput = 2048
  59366. }
  59367. }
  59368. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59369. /**
  59370. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59371. */
  59372. export enum NodeMaterialBlockConnectionPointMode {
  59373. /** Value is an uniform */
  59374. Uniform = 0,
  59375. /** Value is a mesh attribute */
  59376. Attribute = 1,
  59377. /** Value is a varying between vertex and fragment shaders */
  59378. Varying = 2,
  59379. /** Mode is undefined */
  59380. Undefined = 3
  59381. }
  59382. }
  59383. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59384. /**
  59385. * Enum used to define system values e.g. values automatically provided by the system
  59386. */
  59387. export enum NodeMaterialSystemValues {
  59388. /** World */
  59389. World = 1,
  59390. /** View */
  59391. View = 2,
  59392. /** Projection */
  59393. Projection = 3,
  59394. /** ViewProjection */
  59395. ViewProjection = 4,
  59396. /** WorldView */
  59397. WorldView = 5,
  59398. /** WorldViewProjection */
  59399. WorldViewProjection = 6,
  59400. /** CameraPosition */
  59401. CameraPosition = 7,
  59402. /** Fog Color */
  59403. FogColor = 8,
  59404. /** Delta time */
  59405. DeltaTime = 9
  59406. }
  59407. }
  59408. declare module "babylonjs/Materials/Node/Enums/index" {
  59409. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59410. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59411. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59412. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59413. }
  59414. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59415. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59416. /**
  59417. * Root class for all node material optimizers
  59418. */
  59419. export class NodeMaterialOptimizer {
  59420. /**
  59421. * Function used to optimize a NodeMaterial graph
  59422. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59423. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59424. */
  59425. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59426. }
  59427. }
  59428. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59429. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59430. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59431. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59432. import { Scene } from "babylonjs/scene";
  59433. /**
  59434. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  59435. */
  59436. export class TransformBlock extends NodeMaterialBlock {
  59437. /**
  59438. * Defines the value to use to complement W value to transform it to a Vector4
  59439. */
  59440. complementW: number;
  59441. /**
  59442. * Defines the value to use to complement z value to transform it to a Vector4
  59443. */
  59444. complementZ: number;
  59445. /**
  59446. * Creates a new TransformBlock
  59447. * @param name defines the block name
  59448. */
  59449. constructor(name: string);
  59450. /**
  59451. * Gets the current class name
  59452. * @returns the class name
  59453. */
  59454. getClassName(): string;
  59455. /**
  59456. * Gets the vector input
  59457. */
  59458. get vector(): NodeMaterialConnectionPoint;
  59459. /**
  59460. * Gets the output component
  59461. */
  59462. get output(): NodeMaterialConnectionPoint;
  59463. /**
  59464. * Gets the matrix transform input
  59465. */
  59466. get transform(): NodeMaterialConnectionPoint;
  59467. protected _buildBlock(state: NodeMaterialBuildState): this;
  59468. serialize(): any;
  59469. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59470. protected _dumpPropertiesCode(): string;
  59471. }
  59472. }
  59473. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  59474. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59475. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59476. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59477. /**
  59478. * Block used to output the vertex position
  59479. */
  59480. export class VertexOutputBlock extends NodeMaterialBlock {
  59481. /**
  59482. * Creates a new VertexOutputBlock
  59483. * @param name defines the block name
  59484. */
  59485. constructor(name: string);
  59486. /**
  59487. * Gets the current class name
  59488. * @returns the class name
  59489. */
  59490. getClassName(): string;
  59491. /**
  59492. * Gets the vector input component
  59493. */
  59494. get vector(): NodeMaterialConnectionPoint;
  59495. protected _buildBlock(state: NodeMaterialBuildState): this;
  59496. }
  59497. }
  59498. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  59499. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59500. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59501. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59502. /**
  59503. * Block used to output the final color
  59504. */
  59505. export class FragmentOutputBlock extends NodeMaterialBlock {
  59506. /**
  59507. * Create a new FragmentOutputBlock
  59508. * @param name defines the block name
  59509. */
  59510. constructor(name: string);
  59511. /**
  59512. * Gets the current class name
  59513. * @returns the class name
  59514. */
  59515. getClassName(): string;
  59516. /**
  59517. * Gets the rgba input component
  59518. */
  59519. get rgba(): NodeMaterialConnectionPoint;
  59520. /**
  59521. * Gets the rgb input component
  59522. */
  59523. get rgb(): NodeMaterialConnectionPoint;
  59524. /**
  59525. * Gets the a input component
  59526. */
  59527. get a(): NodeMaterialConnectionPoint;
  59528. protected _buildBlock(state: NodeMaterialBuildState): this;
  59529. }
  59530. }
  59531. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  59532. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59533. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59534. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59535. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59536. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59537. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59538. import { Effect } from "babylonjs/Materials/effect";
  59539. import { Mesh } from "babylonjs/Meshes/mesh";
  59540. import { Nullable } from "babylonjs/types";
  59541. import { Scene } from "babylonjs/scene";
  59542. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59543. /**
  59544. * Block used to read a reflection texture from a sampler
  59545. */
  59546. export class ReflectionTextureBlock extends NodeMaterialBlock {
  59547. private _define3DName;
  59548. private _defineCubicName;
  59549. private _defineExplicitName;
  59550. private _defineProjectionName;
  59551. private _defineLocalCubicName;
  59552. private _defineSphericalName;
  59553. private _definePlanarName;
  59554. private _defineEquirectangularName;
  59555. private _defineMirroredEquirectangularFixedName;
  59556. private _defineEquirectangularFixedName;
  59557. private _defineSkyboxName;
  59558. private _cubeSamplerName;
  59559. private _2DSamplerName;
  59560. private _positionUVWName;
  59561. private _directionWName;
  59562. private _reflectionCoordsName;
  59563. private _reflection2DCoordsName;
  59564. private _reflectionColorName;
  59565. private _reflectionMatrixName;
  59566. /**
  59567. * Gets or sets the texture associated with the node
  59568. */
  59569. texture: Nullable<BaseTexture>;
  59570. /**
  59571. * Create a new TextureBlock
  59572. * @param name defines the block name
  59573. */
  59574. constructor(name: string);
  59575. /**
  59576. * Gets the current class name
  59577. * @returns the class name
  59578. */
  59579. getClassName(): string;
  59580. /**
  59581. * Gets the world position input component
  59582. */
  59583. get position(): NodeMaterialConnectionPoint;
  59584. /**
  59585. * Gets the world position input component
  59586. */
  59587. get worldPosition(): NodeMaterialConnectionPoint;
  59588. /**
  59589. * Gets the world normal input component
  59590. */
  59591. get worldNormal(): NodeMaterialConnectionPoint;
  59592. /**
  59593. * Gets the world input component
  59594. */
  59595. get world(): NodeMaterialConnectionPoint;
  59596. /**
  59597. * Gets the camera (or eye) position component
  59598. */
  59599. get cameraPosition(): NodeMaterialConnectionPoint;
  59600. /**
  59601. * Gets the view input component
  59602. */
  59603. get view(): NodeMaterialConnectionPoint;
  59604. /**
  59605. * Gets the rgb output component
  59606. */
  59607. get rgb(): NodeMaterialConnectionPoint;
  59608. /**
  59609. * Gets the r output component
  59610. */
  59611. get r(): NodeMaterialConnectionPoint;
  59612. /**
  59613. * Gets the g output component
  59614. */
  59615. get g(): NodeMaterialConnectionPoint;
  59616. /**
  59617. * Gets the b output component
  59618. */
  59619. get b(): NodeMaterialConnectionPoint;
  59620. autoConfigure(material: NodeMaterial): void;
  59621. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  59622. isReady(): boolean;
  59623. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  59624. private _injectVertexCode;
  59625. private _writeOutput;
  59626. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  59627. protected _dumpPropertiesCode(): string;
  59628. serialize(): any;
  59629. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  59630. }
  59631. }
  59632. declare module "babylonjs/Materials/Node/nodeMaterial" {
  59633. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59634. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59635. import { Scene } from "babylonjs/scene";
  59636. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59637. import { Matrix } from "babylonjs/Maths/math.vector";
  59638. import { Mesh } from "babylonjs/Meshes/mesh";
  59639. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59640. import { Observable } from "babylonjs/Misc/observable";
  59641. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59642. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59643. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  59644. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59645. import { Nullable } from "babylonjs/types";
  59646. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  59647. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  59648. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  59649. /**
  59650. * Interface used to configure the node material editor
  59651. */
  59652. export interface INodeMaterialEditorOptions {
  59653. /** Define the URl to load node editor script */
  59654. editorURL?: string;
  59655. }
  59656. /** @hidden */
  59657. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  59658. NORMAL: boolean;
  59659. TANGENT: boolean;
  59660. UV1: boolean;
  59661. /** BONES */
  59662. NUM_BONE_INFLUENCERS: number;
  59663. BonesPerMesh: number;
  59664. BONETEXTURE: boolean;
  59665. /** MORPH TARGETS */
  59666. MORPHTARGETS: boolean;
  59667. MORPHTARGETS_NORMAL: boolean;
  59668. MORPHTARGETS_TANGENT: boolean;
  59669. MORPHTARGETS_UV: boolean;
  59670. NUM_MORPH_INFLUENCERS: number;
  59671. /** IMAGE PROCESSING */
  59672. IMAGEPROCESSING: boolean;
  59673. VIGNETTE: boolean;
  59674. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59675. VIGNETTEBLENDMODEOPAQUE: boolean;
  59676. TONEMAPPING: boolean;
  59677. TONEMAPPING_ACES: boolean;
  59678. CONTRAST: boolean;
  59679. EXPOSURE: boolean;
  59680. COLORCURVES: boolean;
  59681. COLORGRADING: boolean;
  59682. COLORGRADING3D: boolean;
  59683. SAMPLER3DGREENDEPTH: boolean;
  59684. SAMPLER3DBGRMAP: boolean;
  59685. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59686. /** MISC. */
  59687. BUMPDIRECTUV: number;
  59688. constructor();
  59689. setValue(name: string, value: boolean): void;
  59690. }
  59691. /**
  59692. * Class used to configure NodeMaterial
  59693. */
  59694. export interface INodeMaterialOptions {
  59695. /**
  59696. * Defines if blocks should emit comments
  59697. */
  59698. emitComments: boolean;
  59699. }
  59700. /**
  59701. * Class used to create a node based material built by assembling shader blocks
  59702. */
  59703. export class NodeMaterial extends PushMaterial {
  59704. private static _BuildIdGenerator;
  59705. private _options;
  59706. private _vertexCompilationState;
  59707. private _fragmentCompilationState;
  59708. private _sharedData;
  59709. private _buildId;
  59710. private _buildWasSuccessful;
  59711. private _cachedWorldViewMatrix;
  59712. private _cachedWorldViewProjectionMatrix;
  59713. private _optimizers;
  59714. private _animationFrame;
  59715. /** Define the Url to load node editor script */
  59716. static EditorURL: string;
  59717. /** Define the Url to load snippets */
  59718. static SnippetUrl: string;
  59719. private BJSNODEMATERIALEDITOR;
  59720. /** Get the inspector from bundle or global */
  59721. private _getGlobalNodeMaterialEditor;
  59722. /**
  59723. * Gets or sets data used by visual editor
  59724. * @see https://nme.babylonjs.com
  59725. */
  59726. editorData: any;
  59727. /**
  59728. * 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)
  59729. */
  59730. ignoreAlpha: boolean;
  59731. /**
  59732. * Defines the maximum number of lights that can be used in the material
  59733. */
  59734. maxSimultaneousLights: number;
  59735. /**
  59736. * Observable raised when the material is built
  59737. */
  59738. onBuildObservable: Observable<NodeMaterial>;
  59739. /**
  59740. * Gets or sets the root nodes of the material vertex shader
  59741. */
  59742. _vertexOutputNodes: NodeMaterialBlock[];
  59743. /**
  59744. * Gets or sets the root nodes of the material fragment (pixel) shader
  59745. */
  59746. _fragmentOutputNodes: NodeMaterialBlock[];
  59747. /** Gets or sets options to control the node material overall behavior */
  59748. get options(): INodeMaterialOptions;
  59749. set options(options: INodeMaterialOptions);
  59750. /**
  59751. * Default configuration related to image processing available in the standard Material.
  59752. */
  59753. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59754. /**
  59755. * Gets the image processing configuration used either in this material.
  59756. */
  59757. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  59758. /**
  59759. * Sets the Default image processing configuration used either in the this material.
  59760. *
  59761. * If sets to null, the scene one is in use.
  59762. */
  59763. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  59764. /**
  59765. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  59766. */
  59767. attachedBlocks: NodeMaterialBlock[];
  59768. /**
  59769. * Create a new node based material
  59770. * @param name defines the material name
  59771. * @param scene defines the hosting scene
  59772. * @param options defines creation option
  59773. */
  59774. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  59775. /**
  59776. * Gets the current class name of the material e.g. "NodeMaterial"
  59777. * @returns the class name
  59778. */
  59779. getClassName(): string;
  59780. /**
  59781. * Keep track of the image processing observer to allow dispose and replace.
  59782. */
  59783. private _imageProcessingObserver;
  59784. /**
  59785. * Attaches a new image processing configuration to the Standard Material.
  59786. * @param configuration
  59787. */
  59788. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59789. /**
  59790. * Get a block by its name
  59791. * @param name defines the name of the block to retrieve
  59792. * @returns the required block or null if not found
  59793. */
  59794. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  59795. /**
  59796. * Get a block by its name
  59797. * @param predicate defines the predicate used to find the good candidate
  59798. * @returns the required block or null if not found
  59799. */
  59800. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  59801. /**
  59802. * Get an input block by its name
  59803. * @param predicate defines the predicate used to find the good candidate
  59804. * @returns the required input block or null if not found
  59805. */
  59806. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  59807. /**
  59808. * Gets the list of input blocks attached to this material
  59809. * @returns an array of InputBlocks
  59810. */
  59811. getInputBlocks(): InputBlock[];
  59812. /**
  59813. * Adds a new optimizer to the list of optimizers
  59814. * @param optimizer defines the optimizers to add
  59815. * @returns the current material
  59816. */
  59817. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59818. /**
  59819. * Remove an optimizer from the list of optimizers
  59820. * @param optimizer defines the optimizers to remove
  59821. * @returns the current material
  59822. */
  59823. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  59824. /**
  59825. * Add a new block to the list of output nodes
  59826. * @param node defines the node to add
  59827. * @returns the current material
  59828. */
  59829. addOutputNode(node: NodeMaterialBlock): this;
  59830. /**
  59831. * Remove a block from the list of root nodes
  59832. * @param node defines the node to remove
  59833. * @returns the current material
  59834. */
  59835. removeOutputNode(node: NodeMaterialBlock): this;
  59836. private _addVertexOutputNode;
  59837. private _removeVertexOutputNode;
  59838. private _addFragmentOutputNode;
  59839. private _removeFragmentOutputNode;
  59840. /**
  59841. * Specifies if the material will require alpha blending
  59842. * @returns a boolean specifying if alpha blending is needed
  59843. */
  59844. needAlphaBlending(): boolean;
  59845. /**
  59846. * Specifies if this material should be rendered in alpha test mode
  59847. * @returns a boolean specifying if an alpha test is needed.
  59848. */
  59849. needAlphaTesting(): boolean;
  59850. private _initializeBlock;
  59851. private _resetDualBlocks;
  59852. /**
  59853. * Remove a block from the current node material
  59854. * @param block defines the block to remove
  59855. */
  59856. removeBlock(block: NodeMaterialBlock): void;
  59857. /**
  59858. * Build the material and generates the inner effect
  59859. * @param verbose defines if the build should log activity
  59860. */
  59861. build(verbose?: boolean): void;
  59862. /**
  59863. * Runs an otpimization phase to try to improve the shader code
  59864. */
  59865. optimize(): void;
  59866. private _prepareDefinesForAttributes;
  59867. /**
  59868. * Get if the submesh is ready to be used and all its information available.
  59869. * Child classes can use it to update shaders
  59870. * @param mesh defines the mesh to check
  59871. * @param subMesh defines which submesh to check
  59872. * @param useInstances specifies that instances should be used
  59873. * @returns a boolean indicating that the submesh is ready or not
  59874. */
  59875. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59876. /**
  59877. * Get a string representing the shaders built by the current node graph
  59878. */
  59879. get compiledShaders(): string;
  59880. /**
  59881. * Binds the world matrix to the material
  59882. * @param world defines the world transformation matrix
  59883. */
  59884. bindOnlyWorldMatrix(world: Matrix): void;
  59885. /**
  59886. * Binds the submesh to this material by preparing the effect and shader to draw
  59887. * @param world defines the world transformation matrix
  59888. * @param mesh defines the mesh containing the submesh
  59889. * @param subMesh defines the submesh to bind the material to
  59890. */
  59891. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59892. /**
  59893. * Gets the active textures from the material
  59894. * @returns an array of textures
  59895. */
  59896. getActiveTextures(): BaseTexture[];
  59897. /**
  59898. * Gets the list of texture blocks
  59899. * @returns an array of texture blocks
  59900. */
  59901. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  59902. /**
  59903. * Specifies if the material uses a texture
  59904. * @param texture defines the texture to check against the material
  59905. * @returns a boolean specifying if the material uses the texture
  59906. */
  59907. hasTexture(texture: BaseTexture): boolean;
  59908. /**
  59909. * Disposes the material
  59910. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  59911. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  59912. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  59913. */
  59914. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  59915. /** Creates the node editor window. */
  59916. private _createNodeEditor;
  59917. /**
  59918. * Launch the node material editor
  59919. * @param config Define the configuration of the editor
  59920. * @return a promise fulfilled when the node editor is visible
  59921. */
  59922. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  59923. /**
  59924. * Clear the current material
  59925. */
  59926. clear(): void;
  59927. /**
  59928. * Clear the current material and set it to a default state
  59929. */
  59930. setToDefault(): void;
  59931. /**
  59932. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  59933. * @param url defines the url to load from
  59934. * @returns a promise that will fullfil when the material is fully loaded
  59935. */
  59936. loadAsync(url: string): Promise<void>;
  59937. private _gatherBlocks;
  59938. /**
  59939. * Generate a string containing the code declaration required to create an equivalent of this material
  59940. * @returns a string
  59941. */
  59942. generateCode(): string;
  59943. /**
  59944. * Serializes this material in a JSON representation
  59945. * @returns the serialized material object
  59946. */
  59947. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  59948. private _restoreConnections;
  59949. /**
  59950. * Clear the current graph and load a new one from a serialization object
  59951. * @param source defines the JSON representation of the material
  59952. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59953. */
  59954. loadFromSerialization(source: any, rootUrl?: string): void;
  59955. /**
  59956. * Creates a node material from parsed material data
  59957. * @param source defines the JSON representation of the material
  59958. * @param scene defines the hosting scene
  59959. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59960. * @returns a new node material
  59961. */
  59962. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  59963. /**
  59964. * Creates a node material from a snippet saved in a remote file
  59965. * @param name defines the name of the material to create
  59966. * @param url defines the url to load from
  59967. * @param scene defines the hosting scene
  59968. * @returns a promise that will resolve to the new node material
  59969. */
  59970. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  59971. /**
  59972. * Creates a node material from a snippet saved by the node material editor
  59973. * @param snippetId defines the snippet to load
  59974. * @param scene defines the hosting scene
  59975. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  59976. * @returns a promise that will resolve to the new node material
  59977. */
  59978. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  59979. /**
  59980. * Creates a new node material set to default basic configuration
  59981. * @param name defines the name of the material
  59982. * @param scene defines the hosting scene
  59983. * @returns a new NodeMaterial
  59984. */
  59985. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  59986. }
  59987. }
  59988. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  59989. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59990. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59991. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59992. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59994. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  59995. import { Effect } from "babylonjs/Materials/effect";
  59996. import { Mesh } from "babylonjs/Meshes/mesh";
  59997. import { Nullable } from "babylonjs/types";
  59998. import { Texture } from "babylonjs/Materials/Textures/texture";
  59999. import { Scene } from "babylonjs/scene";
  60000. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60001. /**
  60002. * Block used to read a texture from a sampler
  60003. */
  60004. export class TextureBlock extends NodeMaterialBlock {
  60005. private _defineName;
  60006. private _linearDefineName;
  60007. private _tempTextureRead;
  60008. private _samplerName;
  60009. private _transformedUVName;
  60010. private _textureTransformName;
  60011. private _textureInfoName;
  60012. private _mainUVName;
  60013. private _mainUVDefineName;
  60014. /**
  60015. * Gets or sets the texture associated with the node
  60016. */
  60017. texture: Nullable<Texture>;
  60018. /**
  60019. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  60020. */
  60021. convertToGammaSpace: boolean;
  60022. /**
  60023. * Create a new TextureBlock
  60024. * @param name defines the block name
  60025. */
  60026. constructor(name: string);
  60027. /**
  60028. * Gets the current class name
  60029. * @returns the class name
  60030. */
  60031. getClassName(): string;
  60032. /**
  60033. * Gets the uv input component
  60034. */
  60035. get uv(): NodeMaterialConnectionPoint;
  60036. /**
  60037. * Gets the rgba output component
  60038. */
  60039. get rgba(): NodeMaterialConnectionPoint;
  60040. /**
  60041. * Gets the rgb output component
  60042. */
  60043. get rgb(): NodeMaterialConnectionPoint;
  60044. /**
  60045. * Gets the r output component
  60046. */
  60047. get r(): NodeMaterialConnectionPoint;
  60048. /**
  60049. * Gets the g output component
  60050. */
  60051. get g(): NodeMaterialConnectionPoint;
  60052. /**
  60053. * Gets the b output component
  60054. */
  60055. get b(): NodeMaterialConnectionPoint;
  60056. /**
  60057. * Gets the a output component
  60058. */
  60059. get a(): NodeMaterialConnectionPoint;
  60060. get target(): NodeMaterialBlockTargets;
  60061. autoConfigure(material: NodeMaterial): void;
  60062. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60063. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60064. isReady(): boolean;
  60065. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60066. private get _isMixed();
  60067. private _injectVertexCode;
  60068. private _writeTextureRead;
  60069. private _writeOutput;
  60070. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60071. protected _dumpPropertiesCode(): string;
  60072. serialize(): any;
  60073. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60074. }
  60075. }
  60076. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60077. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60078. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60079. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60080. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60081. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60082. import { Scene } from "babylonjs/scene";
  60083. /**
  60084. * Class used to store shared data between 2 NodeMaterialBuildState
  60085. */
  60086. export class NodeMaterialBuildStateSharedData {
  60087. /**
  60088. * Gets the list of emitted varyings
  60089. */
  60090. temps: string[];
  60091. /**
  60092. * Gets the list of emitted varyings
  60093. */
  60094. varyings: string[];
  60095. /**
  60096. * Gets the varying declaration string
  60097. */
  60098. varyingDeclaration: string;
  60099. /**
  60100. * Input blocks
  60101. */
  60102. inputBlocks: InputBlock[];
  60103. /**
  60104. * Input blocks
  60105. */
  60106. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60107. /**
  60108. * Bindable blocks (Blocks that need to set data to the effect)
  60109. */
  60110. bindableBlocks: NodeMaterialBlock[];
  60111. /**
  60112. * List of blocks that can provide a compilation fallback
  60113. */
  60114. blocksWithFallbacks: NodeMaterialBlock[];
  60115. /**
  60116. * List of blocks that can provide a define update
  60117. */
  60118. blocksWithDefines: NodeMaterialBlock[];
  60119. /**
  60120. * List of blocks that can provide a repeatable content
  60121. */
  60122. repeatableContentBlocks: NodeMaterialBlock[];
  60123. /**
  60124. * List of blocks that can provide a dynamic list of uniforms
  60125. */
  60126. dynamicUniformBlocks: NodeMaterialBlock[];
  60127. /**
  60128. * List of blocks that can block the isReady function for the material
  60129. */
  60130. blockingBlocks: NodeMaterialBlock[];
  60131. /**
  60132. * Gets the list of animated inputs
  60133. */
  60134. animatedInputs: InputBlock[];
  60135. /**
  60136. * Build Id used to avoid multiple recompilations
  60137. */
  60138. buildId: number;
  60139. /** List of emitted variables */
  60140. variableNames: {
  60141. [key: string]: number;
  60142. };
  60143. /** List of emitted defines */
  60144. defineNames: {
  60145. [key: string]: number;
  60146. };
  60147. /** Should emit comments? */
  60148. emitComments: boolean;
  60149. /** Emit build activity */
  60150. verbose: boolean;
  60151. /** Gets or sets the hosting scene */
  60152. scene: Scene;
  60153. /**
  60154. * Gets the compilation hints emitted at compilation time
  60155. */
  60156. hints: {
  60157. needWorldViewMatrix: boolean;
  60158. needWorldViewProjectionMatrix: boolean;
  60159. needAlphaBlending: boolean;
  60160. needAlphaTesting: boolean;
  60161. };
  60162. /**
  60163. * List of compilation checks
  60164. */
  60165. checks: {
  60166. emitVertex: boolean;
  60167. emitFragment: boolean;
  60168. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60169. };
  60170. /** Creates a new shared data */
  60171. constructor();
  60172. /**
  60173. * Emits console errors and exceptions if there is a failing check
  60174. */
  60175. emitErrors(): void;
  60176. }
  60177. }
  60178. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60179. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60180. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60181. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60182. /**
  60183. * Class used to store node based material build state
  60184. */
  60185. export class NodeMaterialBuildState {
  60186. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60187. supportUniformBuffers: boolean;
  60188. /**
  60189. * Gets the list of emitted attributes
  60190. */
  60191. attributes: string[];
  60192. /**
  60193. * Gets the list of emitted uniforms
  60194. */
  60195. uniforms: string[];
  60196. /**
  60197. * Gets the list of emitted constants
  60198. */
  60199. constants: string[];
  60200. /**
  60201. * Gets the list of emitted samplers
  60202. */
  60203. samplers: string[];
  60204. /**
  60205. * Gets the list of emitted functions
  60206. */
  60207. functions: {
  60208. [key: string]: string;
  60209. };
  60210. /**
  60211. * Gets the list of emitted extensions
  60212. */
  60213. extensions: {
  60214. [key: string]: string;
  60215. };
  60216. /**
  60217. * Gets the target of the compilation state
  60218. */
  60219. target: NodeMaterialBlockTargets;
  60220. /**
  60221. * Gets the list of emitted counters
  60222. */
  60223. counters: {
  60224. [key: string]: number;
  60225. };
  60226. /**
  60227. * Shared data between multiple NodeMaterialBuildState instances
  60228. */
  60229. sharedData: NodeMaterialBuildStateSharedData;
  60230. /** @hidden */
  60231. _vertexState: NodeMaterialBuildState;
  60232. /** @hidden */
  60233. _attributeDeclaration: string;
  60234. /** @hidden */
  60235. _uniformDeclaration: string;
  60236. /** @hidden */
  60237. _constantDeclaration: string;
  60238. /** @hidden */
  60239. _samplerDeclaration: string;
  60240. /** @hidden */
  60241. _varyingTransfer: string;
  60242. private _repeatableContentAnchorIndex;
  60243. /** @hidden */
  60244. _builtCompilationString: string;
  60245. /**
  60246. * Gets the emitted compilation strings
  60247. */
  60248. compilationString: string;
  60249. /**
  60250. * Finalize the compilation strings
  60251. * @param state defines the current compilation state
  60252. */
  60253. finalize(state: NodeMaterialBuildState): void;
  60254. /** @hidden */
  60255. get _repeatableContentAnchor(): string;
  60256. /** @hidden */
  60257. _getFreeVariableName(prefix: string): string;
  60258. /** @hidden */
  60259. _getFreeDefineName(prefix: string): string;
  60260. /** @hidden */
  60261. _excludeVariableName(name: string): void;
  60262. /** @hidden */
  60263. _emit2DSampler(name: string): void;
  60264. /** @hidden */
  60265. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60266. /** @hidden */
  60267. _emitExtension(name: string, extension: string): void;
  60268. /** @hidden */
  60269. _emitFunction(name: string, code: string, comments: string): void;
  60270. /** @hidden */
  60271. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60272. replaceStrings?: {
  60273. search: RegExp;
  60274. replace: string;
  60275. }[];
  60276. repeatKey?: string;
  60277. }): string;
  60278. /** @hidden */
  60279. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60280. repeatKey?: string;
  60281. removeAttributes?: boolean;
  60282. removeUniforms?: boolean;
  60283. removeVaryings?: boolean;
  60284. removeIfDef?: boolean;
  60285. replaceStrings?: {
  60286. search: RegExp;
  60287. replace: string;
  60288. }[];
  60289. }, storeKey?: string): void;
  60290. /** @hidden */
  60291. _registerTempVariable(name: string): boolean;
  60292. /** @hidden */
  60293. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60294. /** @hidden */
  60295. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60296. /** @hidden */
  60297. _emitFloat(value: number): string;
  60298. }
  60299. }
  60300. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60301. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60302. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60303. import { Nullable } from "babylonjs/types";
  60304. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60305. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60306. import { Effect } from "babylonjs/Materials/effect";
  60307. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60308. import { Mesh } from "babylonjs/Meshes/mesh";
  60309. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60310. import { Scene } from "babylonjs/scene";
  60311. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60312. /**
  60313. * Defines a block that can be used inside a node based material
  60314. */
  60315. export class NodeMaterialBlock {
  60316. private _buildId;
  60317. private _buildTarget;
  60318. private _target;
  60319. private _isFinalMerger;
  60320. private _isInput;
  60321. protected _isUnique: boolean;
  60322. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60323. inputsAreExclusive: boolean;
  60324. /** @hidden */
  60325. _codeVariableName: string;
  60326. /** @hidden */
  60327. _inputs: NodeMaterialConnectionPoint[];
  60328. /** @hidden */
  60329. _outputs: NodeMaterialConnectionPoint[];
  60330. /** @hidden */
  60331. _preparationId: number;
  60332. /**
  60333. * Gets or sets the name of the block
  60334. */
  60335. name: string;
  60336. /**
  60337. * Gets or sets the unique id of the node
  60338. */
  60339. uniqueId: number;
  60340. /**
  60341. * Gets or sets the comments associated with this block
  60342. */
  60343. comments: string;
  60344. /**
  60345. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60346. */
  60347. get isUnique(): boolean;
  60348. /**
  60349. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60350. */
  60351. get isFinalMerger(): boolean;
  60352. /**
  60353. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60354. */
  60355. get isInput(): boolean;
  60356. /**
  60357. * Gets or sets the build Id
  60358. */
  60359. get buildId(): number;
  60360. set buildId(value: number);
  60361. /**
  60362. * Gets or sets the target of the block
  60363. */
  60364. get target(): NodeMaterialBlockTargets;
  60365. set target(value: NodeMaterialBlockTargets);
  60366. /**
  60367. * Gets the list of input points
  60368. */
  60369. get inputs(): NodeMaterialConnectionPoint[];
  60370. /** Gets the list of output points */
  60371. get outputs(): NodeMaterialConnectionPoint[];
  60372. /**
  60373. * Find an input by its name
  60374. * @param name defines the name of the input to look for
  60375. * @returns the input or null if not found
  60376. */
  60377. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60378. /**
  60379. * Find an output by its name
  60380. * @param name defines the name of the outputto look for
  60381. * @returns the output or null if not found
  60382. */
  60383. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60384. /**
  60385. * Creates a new NodeMaterialBlock
  60386. * @param name defines the block name
  60387. * @param target defines the target of that block (Vertex by default)
  60388. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60389. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60390. */
  60391. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60392. /**
  60393. * Initialize the block and prepare the context for build
  60394. * @param state defines the state that will be used for the build
  60395. */
  60396. initialize(state: NodeMaterialBuildState): void;
  60397. /**
  60398. * Bind data to effect. Will only be called for blocks with isBindable === true
  60399. * @param effect defines the effect to bind data to
  60400. * @param nodeMaterial defines the hosting NodeMaterial
  60401. * @param mesh defines the mesh that will be rendered
  60402. */
  60403. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60404. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60405. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60406. protected _writeFloat(value: number): string;
  60407. /**
  60408. * Gets the current class name e.g. "NodeMaterialBlock"
  60409. * @returns the class name
  60410. */
  60411. getClassName(): string;
  60412. /**
  60413. * Register a new input. Must be called inside a block constructor
  60414. * @param name defines the connection point name
  60415. * @param type defines the connection point type
  60416. * @param isOptional defines a boolean indicating that this input can be omitted
  60417. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60418. * @returns the current block
  60419. */
  60420. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  60421. /**
  60422. * Register a new output. Must be called inside a block constructor
  60423. * @param name defines the connection point name
  60424. * @param type defines the connection point type
  60425. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  60426. * @returns the current block
  60427. */
  60428. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  60429. /**
  60430. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  60431. * @param forOutput defines an optional connection point to check compatibility with
  60432. * @returns the first available input or null
  60433. */
  60434. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  60435. /**
  60436. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  60437. * @param forBlock defines an optional block to check compatibility with
  60438. * @returns the first available input or null
  60439. */
  60440. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  60441. /**
  60442. * Gets the sibling of the given output
  60443. * @param current defines the current output
  60444. * @returns the next output in the list or null
  60445. */
  60446. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  60447. /**
  60448. * Connect current block with another block
  60449. * @param other defines the block to connect with
  60450. * @param options define the various options to help pick the right connections
  60451. * @returns the current block
  60452. */
  60453. connectTo(other: NodeMaterialBlock, options?: {
  60454. input?: string;
  60455. output?: string;
  60456. outputSwizzle?: string;
  60457. }): this | undefined;
  60458. protected _buildBlock(state: NodeMaterialBuildState): void;
  60459. /**
  60460. * Add uniforms, samplers and uniform buffers at compilation time
  60461. * @param state defines the state to update
  60462. * @param nodeMaterial defines the node material requesting the update
  60463. * @param defines defines the material defines to update
  60464. * @param uniformBuffers defines the list of uniform buffer names
  60465. */
  60466. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  60467. /**
  60468. * Add potential fallbacks if shader compilation fails
  60469. * @param mesh defines the mesh to be rendered
  60470. * @param fallbacks defines the current prioritized list of fallbacks
  60471. */
  60472. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60473. /**
  60474. * Initialize defines for shader compilation
  60475. * @param mesh defines the mesh to be rendered
  60476. * @param nodeMaterial defines the node material requesting the update
  60477. * @param defines defines the material defines to update
  60478. * @param useInstances specifies that instances should be used
  60479. */
  60480. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60481. /**
  60482. * Update defines for shader compilation
  60483. * @param mesh defines the mesh to be rendered
  60484. * @param nodeMaterial defines the node material requesting the update
  60485. * @param defines defines the material defines to update
  60486. * @param useInstances specifies that instances should be used
  60487. */
  60488. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60489. /**
  60490. * Lets the block try to connect some inputs automatically
  60491. * @param material defines the hosting NodeMaterial
  60492. */
  60493. autoConfigure(material: NodeMaterial): void;
  60494. /**
  60495. * Function called when a block is declared as repeatable content generator
  60496. * @param vertexShaderState defines the current compilation state for the vertex shader
  60497. * @param fragmentShaderState defines the current compilation state for the fragment shader
  60498. * @param mesh defines the mesh to be rendered
  60499. * @param defines defines the material defines to update
  60500. */
  60501. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  60502. /**
  60503. * Checks if the block is ready
  60504. * @param mesh defines the mesh to be rendered
  60505. * @param nodeMaterial defines the node material requesting the update
  60506. * @param defines defines the material defines to update
  60507. * @param useInstances specifies that instances should be used
  60508. * @returns true if the block is ready
  60509. */
  60510. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  60511. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  60512. private _processBuild;
  60513. /**
  60514. * Compile the current node and generate the shader code
  60515. * @param state defines the current compilation state (uniforms, samplers, current string)
  60516. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  60517. * @returns true if already built
  60518. */
  60519. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  60520. protected _inputRename(name: string): string;
  60521. protected _outputRename(name: string): string;
  60522. protected _dumpPropertiesCode(): string;
  60523. /** @hidden */
  60524. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  60525. /** @hidden */
  60526. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  60527. /**
  60528. * Clone the current block to a new identical block
  60529. * @param scene defines the hosting scene
  60530. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60531. * @returns a copy of the current block
  60532. */
  60533. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  60534. /**
  60535. * Serializes this block in a JSON representation
  60536. * @returns the serialized block object
  60537. */
  60538. serialize(): any;
  60539. /** @hidden */
  60540. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60541. /**
  60542. * Release resources
  60543. */
  60544. dispose(): void;
  60545. }
  60546. }
  60547. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  60548. /**
  60549. * Enum defining the type of animations supported by InputBlock
  60550. */
  60551. export enum AnimatedInputBlockTypes {
  60552. /** No animation */
  60553. None = 0,
  60554. /** Time based animation. Will only work for floats */
  60555. Time = 1
  60556. }
  60557. }
  60558. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  60559. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60560. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60561. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  60562. import { Nullable } from "babylonjs/types";
  60563. import { Effect } from "babylonjs/Materials/effect";
  60564. import { Matrix } from "babylonjs/Maths/math.vector";
  60565. import { Scene } from "babylonjs/scene";
  60566. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60567. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60568. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60569. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  60570. /**
  60571. * Block used to expose an input value
  60572. */
  60573. export class InputBlock extends NodeMaterialBlock {
  60574. private _mode;
  60575. private _associatedVariableName;
  60576. private _storedValue;
  60577. private _valueCallback;
  60578. private _type;
  60579. private _animationType;
  60580. /** Gets or set a value used to limit the range of float values */
  60581. min: number;
  60582. /** Gets or set a value used to limit the range of float values */
  60583. max: number;
  60584. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  60585. isBoolean: boolean;
  60586. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  60587. matrixMode: number;
  60588. /** @hidden */
  60589. _systemValue: Nullable<NodeMaterialSystemValues>;
  60590. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  60591. visibleInInspector: boolean;
  60592. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  60593. isConstant: boolean;
  60594. /** Gets or sets the group to use to display this block in the Inspector */
  60595. groupInInspector: string;
  60596. /**
  60597. * Gets or sets the connection point type (default is float)
  60598. */
  60599. get type(): NodeMaterialBlockConnectionPointTypes;
  60600. /**
  60601. * Creates a new InputBlock
  60602. * @param name defines the block name
  60603. * @param target defines the target of that block (Vertex by default)
  60604. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  60605. */
  60606. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  60607. /**
  60608. * Gets the output component
  60609. */
  60610. get output(): NodeMaterialConnectionPoint;
  60611. /**
  60612. * Set the source of this connection point to a vertex attribute
  60613. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  60614. * @returns the current connection point
  60615. */
  60616. setAsAttribute(attributeName?: string): InputBlock;
  60617. /**
  60618. * Set the source of this connection point to a system value
  60619. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  60620. * @returns the current connection point
  60621. */
  60622. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  60623. /**
  60624. * Gets or sets the value of that point.
  60625. * Please note that this value will be ignored if valueCallback is defined
  60626. */
  60627. get value(): any;
  60628. set value(value: any);
  60629. /**
  60630. * Gets or sets a callback used to get the value of that point.
  60631. * Please note that setting this value will force the connection point to ignore the value property
  60632. */
  60633. get valueCallback(): () => any;
  60634. set valueCallback(value: () => any);
  60635. /**
  60636. * Gets or sets the associated variable name in the shader
  60637. */
  60638. get associatedVariableName(): string;
  60639. set associatedVariableName(value: string);
  60640. /** Gets or sets the type of animation applied to the input */
  60641. get animationType(): AnimatedInputBlockTypes;
  60642. set animationType(value: AnimatedInputBlockTypes);
  60643. /**
  60644. * Gets a boolean indicating that this connection point not defined yet
  60645. */
  60646. get isUndefined(): boolean;
  60647. /**
  60648. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  60649. * In this case the connection point name must be the name of the uniform to use.
  60650. * Can only be set on inputs
  60651. */
  60652. get isUniform(): boolean;
  60653. set isUniform(value: boolean);
  60654. /**
  60655. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  60656. * In this case the connection point name must be the name of the attribute to use
  60657. * Can only be set on inputs
  60658. */
  60659. get isAttribute(): boolean;
  60660. set isAttribute(value: boolean);
  60661. /**
  60662. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  60663. * Can only be set on exit points
  60664. */
  60665. get isVarying(): boolean;
  60666. set isVarying(value: boolean);
  60667. /**
  60668. * Gets a boolean indicating that the current connection point is a system value
  60669. */
  60670. get isSystemValue(): boolean;
  60671. /**
  60672. * Gets or sets the current well known value or null if not defined as a system value
  60673. */
  60674. get systemValue(): Nullable<NodeMaterialSystemValues>;
  60675. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  60676. /**
  60677. * Gets the current class name
  60678. * @returns the class name
  60679. */
  60680. getClassName(): string;
  60681. /**
  60682. * Animate the input if animationType !== None
  60683. * @param scene defines the rendering scene
  60684. */
  60685. animate(scene: Scene): void;
  60686. private _emitDefine;
  60687. initialize(state: NodeMaterialBuildState): void;
  60688. /**
  60689. * Set the input block to its default value (based on its type)
  60690. */
  60691. setDefaultValue(): void;
  60692. private _emitConstant;
  60693. private _emit;
  60694. /** @hidden */
  60695. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  60696. /** @hidden */
  60697. _transmit(effect: Effect, scene: Scene): void;
  60698. protected _buildBlock(state: NodeMaterialBuildState): void;
  60699. protected _dumpPropertiesCode(): string;
  60700. serialize(): any;
  60701. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60702. }
  60703. }
  60704. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  60705. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60706. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60707. import { Nullable } from "babylonjs/types";
  60708. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60709. import { Observable } from "babylonjs/Misc/observable";
  60710. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60711. /**
  60712. * Enum used to define the compatibility state between two connection points
  60713. */
  60714. export enum NodeMaterialConnectionPointCompatibilityStates {
  60715. /** Points are compatibles */
  60716. Compatible = 0,
  60717. /** Points are incompatible because of their types */
  60718. TypeIncompatible = 1,
  60719. /** Points are incompatible because of their targets (vertex vs fragment) */
  60720. TargetIncompatible = 2
  60721. }
  60722. /**
  60723. * Defines the direction of a connection point
  60724. */
  60725. export enum NodeMaterialConnectionPointDirection {
  60726. /** Input */
  60727. Input = 0,
  60728. /** Output */
  60729. Output = 1
  60730. }
  60731. /**
  60732. * Defines a connection point for a block
  60733. */
  60734. export class NodeMaterialConnectionPoint {
  60735. /** @hidden */
  60736. _ownerBlock: NodeMaterialBlock;
  60737. /** @hidden */
  60738. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  60739. private _endpoints;
  60740. private _associatedVariableName;
  60741. private _direction;
  60742. /** @hidden */
  60743. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60744. /** @hidden */
  60745. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  60746. private _type;
  60747. /** @hidden */
  60748. _enforceAssociatedVariableName: boolean;
  60749. /** Gets the direction of the point */
  60750. get direction(): NodeMaterialConnectionPointDirection;
  60751. /**
  60752. * Gets or sets the additional types supported by this connection point
  60753. */
  60754. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60755. /**
  60756. * Gets or sets the additional types excluded by this connection point
  60757. */
  60758. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  60759. /**
  60760. * Observable triggered when this point is connected
  60761. */
  60762. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  60763. /**
  60764. * Gets or sets the associated variable name in the shader
  60765. */
  60766. get associatedVariableName(): string;
  60767. set associatedVariableName(value: string);
  60768. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  60769. get innerType(): NodeMaterialBlockConnectionPointTypes;
  60770. /**
  60771. * Gets or sets the connection point type (default is float)
  60772. */
  60773. get type(): NodeMaterialBlockConnectionPointTypes;
  60774. set type(value: NodeMaterialBlockConnectionPointTypes);
  60775. /**
  60776. * Gets or sets the connection point name
  60777. */
  60778. name: string;
  60779. /**
  60780. * Gets or sets a boolean indicating that this connection point can be omitted
  60781. */
  60782. isOptional: boolean;
  60783. /**
  60784. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  60785. */
  60786. define: string;
  60787. /** @hidden */
  60788. _prioritizeVertex: boolean;
  60789. private _target;
  60790. /** Gets or sets the target of that connection point */
  60791. get target(): NodeMaterialBlockTargets;
  60792. set target(value: NodeMaterialBlockTargets);
  60793. /**
  60794. * Gets a boolean indicating that the current point is connected
  60795. */
  60796. get isConnected(): boolean;
  60797. /**
  60798. * Gets a boolean indicating that the current point is connected to an input block
  60799. */
  60800. get isConnectedToInputBlock(): boolean;
  60801. /**
  60802. * Gets a the connected input block (if any)
  60803. */
  60804. get connectInputBlock(): Nullable<InputBlock>;
  60805. /** Get the other side of the connection (if any) */
  60806. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  60807. /** Get the block that owns this connection point */
  60808. get ownerBlock(): NodeMaterialBlock;
  60809. /** Get the block connected on the other side of this connection (if any) */
  60810. get sourceBlock(): Nullable<NodeMaterialBlock>;
  60811. /** Get the block connected on the endpoints of this connection (if any) */
  60812. get connectedBlocks(): Array<NodeMaterialBlock>;
  60813. /** Gets the list of connected endpoints */
  60814. get endpoints(): NodeMaterialConnectionPoint[];
  60815. /** Gets a boolean indicating if that output point is connected to at least one input */
  60816. get hasEndpoints(): boolean;
  60817. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  60818. get isConnectedInVertexShader(): boolean;
  60819. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  60820. get isConnectedInFragmentShader(): boolean;
  60821. /**
  60822. * Creates a new connection point
  60823. * @param name defines the connection point name
  60824. * @param ownerBlock defines the block hosting this connection point
  60825. * @param direction defines the direction of the connection point
  60826. */
  60827. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  60828. /**
  60829. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  60830. * @returns the class name
  60831. */
  60832. getClassName(): string;
  60833. /**
  60834. * Gets a boolean indicating if the current point can be connected to another point
  60835. * @param connectionPoint defines the other connection point
  60836. * @returns a boolean
  60837. */
  60838. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  60839. /**
  60840. * Gets a number indicating if the current point can be connected to another point
  60841. * @param connectionPoint defines the other connection point
  60842. * @returns a number defining the compatibility state
  60843. */
  60844. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  60845. /**
  60846. * Connect this point to another connection point
  60847. * @param connectionPoint defines the other connection point
  60848. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  60849. * @returns the current connection point
  60850. */
  60851. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  60852. /**
  60853. * Disconnect this point from one of his endpoint
  60854. * @param endpoint defines the other connection point
  60855. * @returns the current connection point
  60856. */
  60857. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  60858. /**
  60859. * Serializes this point in a JSON representation
  60860. * @returns the serialized point object
  60861. */
  60862. serialize(): any;
  60863. /**
  60864. * Release resources
  60865. */
  60866. dispose(): void;
  60867. }
  60868. }
  60869. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  60870. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60871. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60872. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60873. import { Mesh } from "babylonjs/Meshes/mesh";
  60874. import { Effect } from "babylonjs/Materials/effect";
  60875. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60876. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60877. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  60878. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  60879. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60880. /**
  60881. * Block used to add support for vertex skinning (bones)
  60882. */
  60883. export class BonesBlock extends NodeMaterialBlock {
  60884. /**
  60885. * Creates a new BonesBlock
  60886. * @param name defines the block name
  60887. */
  60888. constructor(name: string);
  60889. /**
  60890. * Initialize the block and prepare the context for build
  60891. * @param state defines the state that will be used for the build
  60892. */
  60893. initialize(state: NodeMaterialBuildState): void;
  60894. /**
  60895. * Gets the current class name
  60896. * @returns the class name
  60897. */
  60898. getClassName(): string;
  60899. /**
  60900. * Gets the matrix indices input component
  60901. */
  60902. get matricesIndices(): NodeMaterialConnectionPoint;
  60903. /**
  60904. * Gets the matrix weights input component
  60905. */
  60906. get matricesWeights(): NodeMaterialConnectionPoint;
  60907. /**
  60908. * Gets the extra matrix indices input component
  60909. */
  60910. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  60911. /**
  60912. * Gets the extra matrix weights input component
  60913. */
  60914. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  60915. /**
  60916. * Gets the world input component
  60917. */
  60918. get world(): NodeMaterialConnectionPoint;
  60919. /**
  60920. * Gets the output component
  60921. */
  60922. get output(): NodeMaterialConnectionPoint;
  60923. autoConfigure(material: NodeMaterial): void;
  60924. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  60925. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60926. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60927. protected _buildBlock(state: NodeMaterialBuildState): this;
  60928. }
  60929. }
  60930. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  60931. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60932. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60933. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60935. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60936. /**
  60937. * Block used to add support for instances
  60938. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  60939. */
  60940. export class InstancesBlock extends NodeMaterialBlock {
  60941. /**
  60942. * Creates a new InstancesBlock
  60943. * @param name defines the block name
  60944. */
  60945. constructor(name: string);
  60946. /**
  60947. * Gets the current class name
  60948. * @returns the class name
  60949. */
  60950. getClassName(): string;
  60951. /**
  60952. * Gets the first world row input component
  60953. */
  60954. get world0(): NodeMaterialConnectionPoint;
  60955. /**
  60956. * Gets the second world row input component
  60957. */
  60958. get world1(): NodeMaterialConnectionPoint;
  60959. /**
  60960. * Gets the third world row input component
  60961. */
  60962. get world2(): NodeMaterialConnectionPoint;
  60963. /**
  60964. * Gets the forth world row input component
  60965. */
  60966. get world3(): NodeMaterialConnectionPoint;
  60967. /**
  60968. * Gets the world input component
  60969. */
  60970. get world(): NodeMaterialConnectionPoint;
  60971. /**
  60972. * Gets the output component
  60973. */
  60974. get output(): NodeMaterialConnectionPoint;
  60975. /**
  60976. * Gets the isntanceID component
  60977. */
  60978. get instanceID(): NodeMaterialConnectionPoint;
  60979. autoConfigure(material: NodeMaterial): void;
  60980. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60981. protected _buildBlock(state: NodeMaterialBuildState): this;
  60982. }
  60983. }
  60984. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  60985. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60986. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60987. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60989. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60990. import { Effect } from "babylonjs/Materials/effect";
  60991. import { Mesh } from "babylonjs/Meshes/mesh";
  60992. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  60993. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  60994. /**
  60995. * Block used to add morph targets support to vertex shader
  60996. */
  60997. export class MorphTargetsBlock extends NodeMaterialBlock {
  60998. private _repeatableContentAnchor;
  60999. /**
  61000. * Create a new MorphTargetsBlock
  61001. * @param name defines the block name
  61002. */
  61003. constructor(name: string);
  61004. /**
  61005. * Gets the current class name
  61006. * @returns the class name
  61007. */
  61008. getClassName(): string;
  61009. /**
  61010. * Gets the position input component
  61011. */
  61012. get position(): NodeMaterialConnectionPoint;
  61013. /**
  61014. * Gets the normal input component
  61015. */
  61016. get normal(): NodeMaterialConnectionPoint;
  61017. /**
  61018. * Gets the tangent input component
  61019. */
  61020. get tangent(): NodeMaterialConnectionPoint;
  61021. /**
  61022. * Gets the tangent input component
  61023. */
  61024. get uv(): NodeMaterialConnectionPoint;
  61025. /**
  61026. * Gets the position output component
  61027. */
  61028. get positionOutput(): NodeMaterialConnectionPoint;
  61029. /**
  61030. * Gets the normal output component
  61031. */
  61032. get normalOutput(): NodeMaterialConnectionPoint;
  61033. /**
  61034. * Gets the tangent output component
  61035. */
  61036. get tangentOutput(): NodeMaterialConnectionPoint;
  61037. /**
  61038. * Gets the tangent output component
  61039. */
  61040. get uvOutput(): NodeMaterialConnectionPoint;
  61041. initialize(state: NodeMaterialBuildState): void;
  61042. autoConfigure(material: NodeMaterial): void;
  61043. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61044. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61045. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61046. protected _buildBlock(state: NodeMaterialBuildState): this;
  61047. }
  61048. }
  61049. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61050. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61051. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61052. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61053. import { Nullable } from "babylonjs/types";
  61054. import { Scene } from "babylonjs/scene";
  61055. import { Effect } from "babylonjs/Materials/effect";
  61056. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61057. import { Mesh } from "babylonjs/Meshes/mesh";
  61058. import { Light } from "babylonjs/Lights/light";
  61059. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61060. /**
  61061. * Block used to get data information from a light
  61062. */
  61063. export class LightInformationBlock extends NodeMaterialBlock {
  61064. private _lightDataUniformName;
  61065. private _lightColorUniformName;
  61066. private _lightTypeDefineName;
  61067. /**
  61068. * Gets or sets the light associated with this block
  61069. */
  61070. light: Nullable<Light>;
  61071. /**
  61072. * Creates a new LightInformationBlock
  61073. * @param name defines the block name
  61074. */
  61075. constructor(name: string);
  61076. /**
  61077. * Gets the current class name
  61078. * @returns the class name
  61079. */
  61080. getClassName(): string;
  61081. /**
  61082. * Gets the world position input component
  61083. */
  61084. get worldPosition(): NodeMaterialConnectionPoint;
  61085. /**
  61086. * Gets the direction output component
  61087. */
  61088. get direction(): NodeMaterialConnectionPoint;
  61089. /**
  61090. * Gets the direction output component
  61091. */
  61092. get color(): NodeMaterialConnectionPoint;
  61093. /**
  61094. * Gets the direction output component
  61095. */
  61096. get intensity(): NodeMaterialConnectionPoint;
  61097. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61098. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61099. protected _buildBlock(state: NodeMaterialBuildState): this;
  61100. serialize(): any;
  61101. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61102. }
  61103. }
  61104. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61105. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61106. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61107. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61108. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61109. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61110. }
  61111. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61112. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61113. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61114. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61115. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61116. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61117. import { Effect } from "babylonjs/Materials/effect";
  61118. import { Mesh } from "babylonjs/Meshes/mesh";
  61119. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61120. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61121. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61122. /**
  61123. * Block used to add image processing support to fragment shader
  61124. */
  61125. export class ImageProcessingBlock extends NodeMaterialBlock {
  61126. /**
  61127. * Create a new ImageProcessingBlock
  61128. * @param name defines the block name
  61129. */
  61130. constructor(name: string);
  61131. /**
  61132. * Gets the current class name
  61133. * @returns the class name
  61134. */
  61135. getClassName(): string;
  61136. /**
  61137. * Gets the color input component
  61138. */
  61139. get color(): NodeMaterialConnectionPoint;
  61140. /**
  61141. * Gets the output component
  61142. */
  61143. get output(): NodeMaterialConnectionPoint;
  61144. /**
  61145. * Initialize the block and prepare the context for build
  61146. * @param state defines the state that will be used for the build
  61147. */
  61148. initialize(state: NodeMaterialBuildState): void;
  61149. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61150. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61151. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61152. protected _buildBlock(state: NodeMaterialBuildState): this;
  61153. }
  61154. }
  61155. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61156. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61157. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61158. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61159. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61160. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61161. import { Effect } from "babylonjs/Materials/effect";
  61162. import { Mesh } from "babylonjs/Meshes/mesh";
  61163. import { Scene } from "babylonjs/scene";
  61164. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61165. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61166. /**
  61167. * Block used to pertub normals based on a normal map
  61168. */
  61169. export class PerturbNormalBlock extends NodeMaterialBlock {
  61170. private _tangentSpaceParameterName;
  61171. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61172. invertX: boolean;
  61173. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61174. invertY: boolean;
  61175. /**
  61176. * Create a new PerturbNormalBlock
  61177. * @param name defines the block name
  61178. */
  61179. constructor(name: string);
  61180. /**
  61181. * Gets the current class name
  61182. * @returns the class name
  61183. */
  61184. getClassName(): string;
  61185. /**
  61186. * Gets the world position input component
  61187. */
  61188. get worldPosition(): NodeMaterialConnectionPoint;
  61189. /**
  61190. * Gets the world normal input component
  61191. */
  61192. get worldNormal(): NodeMaterialConnectionPoint;
  61193. /**
  61194. * Gets the world tangent input component
  61195. */
  61196. get worldTangent(): NodeMaterialConnectionPoint;
  61197. /**
  61198. * Gets the uv input component
  61199. */
  61200. get uv(): NodeMaterialConnectionPoint;
  61201. /**
  61202. * Gets the normal map color input component
  61203. */
  61204. get normalMapColor(): NodeMaterialConnectionPoint;
  61205. /**
  61206. * Gets the strength input component
  61207. */
  61208. get strength(): NodeMaterialConnectionPoint;
  61209. /**
  61210. * Gets the output component
  61211. */
  61212. get output(): NodeMaterialConnectionPoint;
  61213. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61214. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61215. autoConfigure(material: NodeMaterial): void;
  61216. protected _buildBlock(state: NodeMaterialBuildState): this;
  61217. protected _dumpPropertiesCode(): string;
  61218. serialize(): any;
  61219. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61220. }
  61221. }
  61222. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61223. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61224. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61225. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61226. /**
  61227. * Block used to discard a pixel if a value is smaller than a cutoff
  61228. */
  61229. export class DiscardBlock extends NodeMaterialBlock {
  61230. /**
  61231. * Create a new DiscardBlock
  61232. * @param name defines the block name
  61233. */
  61234. constructor(name: string);
  61235. /**
  61236. * Gets the current class name
  61237. * @returns the class name
  61238. */
  61239. getClassName(): string;
  61240. /**
  61241. * Gets the color input component
  61242. */
  61243. get value(): NodeMaterialConnectionPoint;
  61244. /**
  61245. * Gets the cutoff input component
  61246. */
  61247. get cutoff(): NodeMaterialConnectionPoint;
  61248. protected _buildBlock(state: NodeMaterialBuildState): this;
  61249. }
  61250. }
  61251. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61252. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61253. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61254. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61255. /**
  61256. * Block used to test if the fragment shader is front facing
  61257. */
  61258. export class FrontFacingBlock extends NodeMaterialBlock {
  61259. /**
  61260. * Creates a new FrontFacingBlock
  61261. * @param name defines the block name
  61262. */
  61263. constructor(name: string);
  61264. /**
  61265. * Gets the current class name
  61266. * @returns the class name
  61267. */
  61268. getClassName(): string;
  61269. /**
  61270. * Gets the output component
  61271. */
  61272. get output(): NodeMaterialConnectionPoint;
  61273. protected _buildBlock(state: NodeMaterialBuildState): this;
  61274. }
  61275. }
  61276. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61277. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61278. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61279. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61280. /**
  61281. * Block used to get the derivative value on x and y of a given input
  61282. */
  61283. export class DerivativeBlock extends NodeMaterialBlock {
  61284. /**
  61285. * Create a new DerivativeBlock
  61286. * @param name defines the block name
  61287. */
  61288. constructor(name: string);
  61289. /**
  61290. * Gets the current class name
  61291. * @returns the class name
  61292. */
  61293. getClassName(): string;
  61294. /**
  61295. * Gets the input component
  61296. */
  61297. get input(): NodeMaterialConnectionPoint;
  61298. /**
  61299. * Gets the derivative output on x
  61300. */
  61301. get dx(): NodeMaterialConnectionPoint;
  61302. /**
  61303. * Gets the derivative output on y
  61304. */
  61305. get dy(): NodeMaterialConnectionPoint;
  61306. protected _buildBlock(state: NodeMaterialBuildState): this;
  61307. }
  61308. }
  61309. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61310. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61311. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61312. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61313. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61314. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61315. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61316. }
  61317. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61318. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61319. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61320. import { Mesh } from "babylonjs/Meshes/mesh";
  61321. import { Effect } from "babylonjs/Materials/effect";
  61322. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61324. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61325. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61326. /**
  61327. * Block used to add support for scene fog
  61328. */
  61329. export class FogBlock extends NodeMaterialBlock {
  61330. private _fogDistanceName;
  61331. private _fogParameters;
  61332. /**
  61333. * Create a new FogBlock
  61334. * @param name defines the block name
  61335. */
  61336. constructor(name: string);
  61337. /**
  61338. * Gets the current class name
  61339. * @returns the class name
  61340. */
  61341. getClassName(): string;
  61342. /**
  61343. * Gets the world position input component
  61344. */
  61345. get worldPosition(): NodeMaterialConnectionPoint;
  61346. /**
  61347. * Gets the view input component
  61348. */
  61349. get view(): NodeMaterialConnectionPoint;
  61350. /**
  61351. * Gets the color input component
  61352. */
  61353. get input(): NodeMaterialConnectionPoint;
  61354. /**
  61355. * Gets the fog color input component
  61356. */
  61357. get fogColor(): NodeMaterialConnectionPoint;
  61358. /**
  61359. * Gets the output component
  61360. */
  61361. get output(): NodeMaterialConnectionPoint;
  61362. autoConfigure(material: NodeMaterial): void;
  61363. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61364. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61365. protected _buildBlock(state: NodeMaterialBuildState): this;
  61366. }
  61367. }
  61368. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61369. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61370. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61371. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61373. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61374. import { Effect } from "babylonjs/Materials/effect";
  61375. import { Mesh } from "babylonjs/Meshes/mesh";
  61376. import { Light } from "babylonjs/Lights/light";
  61377. import { Nullable } from "babylonjs/types";
  61378. import { Scene } from "babylonjs/scene";
  61379. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61380. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61381. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61382. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61383. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61384. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61385. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61386. /**
  61387. * Block used to add light in the fragment shader
  61388. */
  61389. export class LightBlock extends NodeMaterialBlock {
  61390. private _lightId;
  61391. /**
  61392. * Gets or sets the light associated with this block
  61393. */
  61394. light: Nullable<Light>;
  61395. /**
  61396. * Create a new LightBlock
  61397. * @param name defines the block name
  61398. */
  61399. constructor(name: string);
  61400. /**
  61401. * Gets the current class name
  61402. * @returns the class name
  61403. */
  61404. getClassName(): string;
  61405. /**
  61406. * Gets the world position input component
  61407. */
  61408. get worldPosition(): NodeMaterialConnectionPoint;
  61409. /**
  61410. * Gets the world normal input component
  61411. */
  61412. get worldNormal(): NodeMaterialConnectionPoint;
  61413. /**
  61414. * Gets the camera (or eye) position component
  61415. */
  61416. get cameraPosition(): NodeMaterialConnectionPoint;
  61417. /**
  61418. * Gets the glossiness component
  61419. */
  61420. get glossiness(): NodeMaterialConnectionPoint;
  61421. /**
  61422. * Gets the glossinness power component
  61423. */
  61424. get glossPower(): NodeMaterialConnectionPoint;
  61425. /**
  61426. * Gets the diffuse color component
  61427. */
  61428. get diffuseColor(): NodeMaterialConnectionPoint;
  61429. /**
  61430. * Gets the specular color component
  61431. */
  61432. get specularColor(): NodeMaterialConnectionPoint;
  61433. /**
  61434. * Gets the diffuse output component
  61435. */
  61436. get diffuseOutput(): NodeMaterialConnectionPoint;
  61437. /**
  61438. * Gets the specular output component
  61439. */
  61440. get specularOutput(): NodeMaterialConnectionPoint;
  61441. /**
  61442. * Gets the shadow output component
  61443. */
  61444. get shadow(): NodeMaterialConnectionPoint;
  61445. autoConfigure(material: NodeMaterial): void;
  61446. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61447. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61448. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61449. private _injectVertexCode;
  61450. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  61451. serialize(): any;
  61452. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61453. }
  61454. }
  61455. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  61456. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  61457. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  61458. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  61459. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  61460. }
  61461. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  61462. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61463. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61464. }
  61465. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  61466. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61467. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61468. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61469. /**
  61470. * Block used to multiply 2 values
  61471. */
  61472. export class MultiplyBlock extends NodeMaterialBlock {
  61473. /**
  61474. * Creates a new MultiplyBlock
  61475. * @param name defines the block name
  61476. */
  61477. constructor(name: string);
  61478. /**
  61479. * Gets the current class name
  61480. * @returns the class name
  61481. */
  61482. getClassName(): string;
  61483. /**
  61484. * Gets the left operand input component
  61485. */
  61486. get left(): NodeMaterialConnectionPoint;
  61487. /**
  61488. * Gets the right operand input component
  61489. */
  61490. get right(): NodeMaterialConnectionPoint;
  61491. /**
  61492. * Gets the output component
  61493. */
  61494. get output(): NodeMaterialConnectionPoint;
  61495. protected _buildBlock(state: NodeMaterialBuildState): this;
  61496. }
  61497. }
  61498. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  61499. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61500. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61501. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61502. /**
  61503. * Block used to add 2 vectors
  61504. */
  61505. export class AddBlock extends NodeMaterialBlock {
  61506. /**
  61507. * Creates a new AddBlock
  61508. * @param name defines the block name
  61509. */
  61510. constructor(name: string);
  61511. /**
  61512. * Gets the current class name
  61513. * @returns the class name
  61514. */
  61515. getClassName(): string;
  61516. /**
  61517. * Gets the left operand input component
  61518. */
  61519. get left(): NodeMaterialConnectionPoint;
  61520. /**
  61521. * Gets the right operand input component
  61522. */
  61523. get right(): NodeMaterialConnectionPoint;
  61524. /**
  61525. * Gets the output component
  61526. */
  61527. get output(): NodeMaterialConnectionPoint;
  61528. protected _buildBlock(state: NodeMaterialBuildState): this;
  61529. }
  61530. }
  61531. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  61532. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61533. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61534. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61535. /**
  61536. * Block used to scale a vector by a float
  61537. */
  61538. export class ScaleBlock extends NodeMaterialBlock {
  61539. /**
  61540. * Creates a new ScaleBlock
  61541. * @param name defines the block name
  61542. */
  61543. constructor(name: string);
  61544. /**
  61545. * Gets the current class name
  61546. * @returns the class name
  61547. */
  61548. getClassName(): string;
  61549. /**
  61550. * Gets the input component
  61551. */
  61552. get input(): NodeMaterialConnectionPoint;
  61553. /**
  61554. * Gets the factor input component
  61555. */
  61556. get factor(): NodeMaterialConnectionPoint;
  61557. /**
  61558. * Gets the output component
  61559. */
  61560. get output(): NodeMaterialConnectionPoint;
  61561. protected _buildBlock(state: NodeMaterialBuildState): this;
  61562. }
  61563. }
  61564. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  61565. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61566. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61567. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61568. import { Scene } from "babylonjs/scene";
  61569. /**
  61570. * Block used to clamp a float
  61571. */
  61572. export class ClampBlock extends NodeMaterialBlock {
  61573. /** Gets or sets the minimum range */
  61574. minimum: number;
  61575. /** Gets or sets the maximum range */
  61576. maximum: number;
  61577. /**
  61578. * Creates a new ClampBlock
  61579. * @param name defines the block name
  61580. */
  61581. constructor(name: string);
  61582. /**
  61583. * Gets the current class name
  61584. * @returns the class name
  61585. */
  61586. getClassName(): string;
  61587. /**
  61588. * Gets the value input component
  61589. */
  61590. get value(): NodeMaterialConnectionPoint;
  61591. /**
  61592. * Gets the output component
  61593. */
  61594. get output(): NodeMaterialConnectionPoint;
  61595. protected _buildBlock(state: NodeMaterialBuildState): this;
  61596. protected _dumpPropertiesCode(): string;
  61597. serialize(): any;
  61598. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61599. }
  61600. }
  61601. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  61602. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61603. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61604. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61605. /**
  61606. * Block used to apply a cross product between 2 vectors
  61607. */
  61608. export class CrossBlock extends NodeMaterialBlock {
  61609. /**
  61610. * Creates a new CrossBlock
  61611. * @param name defines the block name
  61612. */
  61613. constructor(name: string);
  61614. /**
  61615. * Gets the current class name
  61616. * @returns the class name
  61617. */
  61618. getClassName(): string;
  61619. /**
  61620. * Gets the left operand input component
  61621. */
  61622. get left(): NodeMaterialConnectionPoint;
  61623. /**
  61624. * Gets the right operand input component
  61625. */
  61626. get right(): NodeMaterialConnectionPoint;
  61627. /**
  61628. * Gets the output component
  61629. */
  61630. get output(): NodeMaterialConnectionPoint;
  61631. protected _buildBlock(state: NodeMaterialBuildState): this;
  61632. }
  61633. }
  61634. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  61635. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61636. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61637. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61638. /**
  61639. * Block used to apply a dot product between 2 vectors
  61640. */
  61641. export class DotBlock extends NodeMaterialBlock {
  61642. /**
  61643. * Creates a new DotBlock
  61644. * @param name defines the block name
  61645. */
  61646. constructor(name: string);
  61647. /**
  61648. * Gets the current class name
  61649. * @returns the class name
  61650. */
  61651. getClassName(): string;
  61652. /**
  61653. * Gets the left operand input component
  61654. */
  61655. get left(): NodeMaterialConnectionPoint;
  61656. /**
  61657. * Gets the right operand input component
  61658. */
  61659. get right(): NodeMaterialConnectionPoint;
  61660. /**
  61661. * Gets the output component
  61662. */
  61663. get output(): NodeMaterialConnectionPoint;
  61664. protected _buildBlock(state: NodeMaterialBuildState): this;
  61665. }
  61666. }
  61667. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  61668. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61669. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61670. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61671. import { Vector2 } from "babylonjs/Maths/math.vector";
  61672. import { Scene } from "babylonjs/scene";
  61673. /**
  61674. * Block used to remap a float from a range to a new one
  61675. */
  61676. export class RemapBlock extends NodeMaterialBlock {
  61677. /**
  61678. * Gets or sets the source range
  61679. */
  61680. sourceRange: Vector2;
  61681. /**
  61682. * Gets or sets the target range
  61683. */
  61684. targetRange: Vector2;
  61685. /**
  61686. * Creates a new RemapBlock
  61687. * @param name defines the block name
  61688. */
  61689. constructor(name: string);
  61690. /**
  61691. * Gets the current class name
  61692. * @returns the class name
  61693. */
  61694. getClassName(): string;
  61695. /**
  61696. * Gets the input component
  61697. */
  61698. get input(): NodeMaterialConnectionPoint;
  61699. /**
  61700. * Gets the source min input component
  61701. */
  61702. get sourceMin(): NodeMaterialConnectionPoint;
  61703. /**
  61704. * Gets the source max input component
  61705. */
  61706. get sourceMax(): NodeMaterialConnectionPoint;
  61707. /**
  61708. * Gets the target min input component
  61709. */
  61710. get targetMin(): NodeMaterialConnectionPoint;
  61711. /**
  61712. * Gets the target max input component
  61713. */
  61714. get targetMax(): NodeMaterialConnectionPoint;
  61715. /**
  61716. * Gets the output component
  61717. */
  61718. get output(): NodeMaterialConnectionPoint;
  61719. protected _buildBlock(state: NodeMaterialBuildState): this;
  61720. protected _dumpPropertiesCode(): string;
  61721. serialize(): any;
  61722. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61723. }
  61724. }
  61725. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  61726. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61727. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61728. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61729. /**
  61730. * Block used to normalize a vector
  61731. */
  61732. export class NormalizeBlock extends NodeMaterialBlock {
  61733. /**
  61734. * Creates a new NormalizeBlock
  61735. * @param name defines the block name
  61736. */
  61737. constructor(name: string);
  61738. /**
  61739. * Gets the current class name
  61740. * @returns the class name
  61741. */
  61742. getClassName(): string;
  61743. /**
  61744. * Gets the input component
  61745. */
  61746. get input(): NodeMaterialConnectionPoint;
  61747. /**
  61748. * Gets the output component
  61749. */
  61750. get output(): NodeMaterialConnectionPoint;
  61751. protected _buildBlock(state: NodeMaterialBuildState): this;
  61752. }
  61753. }
  61754. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  61755. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61756. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61757. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61758. import { Scene } from "babylonjs/scene";
  61759. /**
  61760. * Operations supported by the Trigonometry block
  61761. */
  61762. export enum TrigonometryBlockOperations {
  61763. /** Cos */
  61764. Cos = 0,
  61765. /** Sin */
  61766. Sin = 1,
  61767. /** Abs */
  61768. Abs = 2,
  61769. /** Exp */
  61770. Exp = 3,
  61771. /** Exp2 */
  61772. Exp2 = 4,
  61773. /** Round */
  61774. Round = 5,
  61775. /** Floor */
  61776. Floor = 6,
  61777. /** Ceiling */
  61778. Ceiling = 7,
  61779. /** Square root */
  61780. Sqrt = 8,
  61781. /** Log */
  61782. Log = 9,
  61783. /** Tangent */
  61784. Tan = 10,
  61785. /** Arc tangent */
  61786. ArcTan = 11,
  61787. /** Arc cosinus */
  61788. ArcCos = 12,
  61789. /** Arc sinus */
  61790. ArcSin = 13,
  61791. /** Fraction */
  61792. Fract = 14,
  61793. /** Sign */
  61794. Sign = 15,
  61795. /** To radians (from degrees) */
  61796. Radians = 16,
  61797. /** To degrees (from radians) */
  61798. Degrees = 17
  61799. }
  61800. /**
  61801. * Block used to apply trigonometry operation to floats
  61802. */
  61803. export class TrigonometryBlock extends NodeMaterialBlock {
  61804. /**
  61805. * Gets or sets the operation applied by the block
  61806. */
  61807. operation: TrigonometryBlockOperations;
  61808. /**
  61809. * Creates a new TrigonometryBlock
  61810. * @param name defines the block name
  61811. */
  61812. constructor(name: string);
  61813. /**
  61814. * Gets the current class name
  61815. * @returns the class name
  61816. */
  61817. getClassName(): string;
  61818. /**
  61819. * Gets the input component
  61820. */
  61821. get input(): NodeMaterialConnectionPoint;
  61822. /**
  61823. * Gets the output component
  61824. */
  61825. get output(): NodeMaterialConnectionPoint;
  61826. protected _buildBlock(state: NodeMaterialBuildState): this;
  61827. serialize(): any;
  61828. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61829. protected _dumpPropertiesCode(): string;
  61830. }
  61831. }
  61832. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  61833. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61834. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61835. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61836. /**
  61837. * Block used to create a Color3/4 out of individual inputs (one for each component)
  61838. */
  61839. export class ColorMergerBlock extends NodeMaterialBlock {
  61840. /**
  61841. * Create a new ColorMergerBlock
  61842. * @param name defines the block name
  61843. */
  61844. constructor(name: string);
  61845. /**
  61846. * Gets the current class name
  61847. * @returns the class name
  61848. */
  61849. getClassName(): string;
  61850. /**
  61851. * Gets the rgb component (input)
  61852. */
  61853. get rgbIn(): NodeMaterialConnectionPoint;
  61854. /**
  61855. * Gets the r component (input)
  61856. */
  61857. get r(): NodeMaterialConnectionPoint;
  61858. /**
  61859. * Gets the g component (input)
  61860. */
  61861. get g(): NodeMaterialConnectionPoint;
  61862. /**
  61863. * Gets the b component (input)
  61864. */
  61865. get b(): NodeMaterialConnectionPoint;
  61866. /**
  61867. * Gets the a component (input)
  61868. */
  61869. get a(): NodeMaterialConnectionPoint;
  61870. /**
  61871. * Gets the rgba component (output)
  61872. */
  61873. get rgba(): NodeMaterialConnectionPoint;
  61874. /**
  61875. * Gets the rgb component (output)
  61876. */
  61877. get rgbOut(): NodeMaterialConnectionPoint;
  61878. /**
  61879. * Gets the rgb component (output)
  61880. * @deprecated Please use rgbOut instead.
  61881. */
  61882. get rgb(): NodeMaterialConnectionPoint;
  61883. protected _buildBlock(state: NodeMaterialBuildState): this;
  61884. }
  61885. }
  61886. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  61887. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61888. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61889. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61890. /**
  61891. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  61892. */
  61893. export class VectorMergerBlock extends NodeMaterialBlock {
  61894. /**
  61895. * Create a new VectorMergerBlock
  61896. * @param name defines the block name
  61897. */
  61898. constructor(name: string);
  61899. /**
  61900. * Gets the current class name
  61901. * @returns the class name
  61902. */
  61903. getClassName(): string;
  61904. /**
  61905. * Gets the xyz component (input)
  61906. */
  61907. get xyzIn(): NodeMaterialConnectionPoint;
  61908. /**
  61909. * Gets the xy component (input)
  61910. */
  61911. get xyIn(): NodeMaterialConnectionPoint;
  61912. /**
  61913. * Gets the x component (input)
  61914. */
  61915. get x(): NodeMaterialConnectionPoint;
  61916. /**
  61917. * Gets the y component (input)
  61918. */
  61919. get y(): NodeMaterialConnectionPoint;
  61920. /**
  61921. * Gets the z component (input)
  61922. */
  61923. get z(): NodeMaterialConnectionPoint;
  61924. /**
  61925. * Gets the w component (input)
  61926. */
  61927. get w(): NodeMaterialConnectionPoint;
  61928. /**
  61929. * Gets the xyzw component (output)
  61930. */
  61931. get xyzw(): NodeMaterialConnectionPoint;
  61932. /**
  61933. * Gets the xyz component (output)
  61934. */
  61935. get xyzOut(): NodeMaterialConnectionPoint;
  61936. /**
  61937. * Gets the xy component (output)
  61938. */
  61939. get xyOut(): NodeMaterialConnectionPoint;
  61940. /**
  61941. * Gets the xy component (output)
  61942. * @deprecated Please use xyOut instead.
  61943. */
  61944. get xy(): NodeMaterialConnectionPoint;
  61945. /**
  61946. * Gets the xyz component (output)
  61947. * @deprecated Please use xyzOut instead.
  61948. */
  61949. get xyz(): NodeMaterialConnectionPoint;
  61950. protected _buildBlock(state: NodeMaterialBuildState): this;
  61951. }
  61952. }
  61953. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  61954. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61955. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61956. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61957. /**
  61958. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  61959. */
  61960. export class ColorSplitterBlock extends NodeMaterialBlock {
  61961. /**
  61962. * Create a new ColorSplitterBlock
  61963. * @param name defines the block name
  61964. */
  61965. constructor(name: string);
  61966. /**
  61967. * Gets the current class name
  61968. * @returns the class name
  61969. */
  61970. getClassName(): string;
  61971. /**
  61972. * Gets the rgba component (input)
  61973. */
  61974. get rgba(): NodeMaterialConnectionPoint;
  61975. /**
  61976. * Gets the rgb component (input)
  61977. */
  61978. get rgbIn(): NodeMaterialConnectionPoint;
  61979. /**
  61980. * Gets the rgb component (output)
  61981. */
  61982. get rgbOut(): NodeMaterialConnectionPoint;
  61983. /**
  61984. * Gets the r component (output)
  61985. */
  61986. get r(): NodeMaterialConnectionPoint;
  61987. /**
  61988. * Gets the g component (output)
  61989. */
  61990. get g(): NodeMaterialConnectionPoint;
  61991. /**
  61992. * Gets the b component (output)
  61993. */
  61994. get b(): NodeMaterialConnectionPoint;
  61995. /**
  61996. * Gets the a component (output)
  61997. */
  61998. get a(): NodeMaterialConnectionPoint;
  61999. protected _inputRename(name: string): string;
  62000. protected _outputRename(name: string): string;
  62001. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62002. }
  62003. }
  62004. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  62005. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62006. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62007. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62008. /**
  62009. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62010. */
  62011. export class VectorSplitterBlock extends NodeMaterialBlock {
  62012. /**
  62013. * Create a new VectorSplitterBlock
  62014. * @param name defines the block name
  62015. */
  62016. constructor(name: string);
  62017. /**
  62018. * Gets the current class name
  62019. * @returns the class name
  62020. */
  62021. getClassName(): string;
  62022. /**
  62023. * Gets the xyzw component (input)
  62024. */
  62025. get xyzw(): NodeMaterialConnectionPoint;
  62026. /**
  62027. * Gets the xyz component (input)
  62028. */
  62029. get xyzIn(): NodeMaterialConnectionPoint;
  62030. /**
  62031. * Gets the xy component (input)
  62032. */
  62033. get xyIn(): NodeMaterialConnectionPoint;
  62034. /**
  62035. * Gets the xyz component (output)
  62036. */
  62037. get xyzOut(): NodeMaterialConnectionPoint;
  62038. /**
  62039. * Gets the xy component (output)
  62040. */
  62041. get xyOut(): NodeMaterialConnectionPoint;
  62042. /**
  62043. * Gets the x component (output)
  62044. */
  62045. get x(): NodeMaterialConnectionPoint;
  62046. /**
  62047. * Gets the y component (output)
  62048. */
  62049. get y(): NodeMaterialConnectionPoint;
  62050. /**
  62051. * Gets the z component (output)
  62052. */
  62053. get z(): NodeMaterialConnectionPoint;
  62054. /**
  62055. * Gets the w component (output)
  62056. */
  62057. get w(): NodeMaterialConnectionPoint;
  62058. protected _inputRename(name: string): string;
  62059. protected _outputRename(name: string): string;
  62060. protected _buildBlock(state: NodeMaterialBuildState): this;
  62061. }
  62062. }
  62063. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62064. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62065. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62066. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62067. /**
  62068. * Block used to lerp between 2 values
  62069. */
  62070. export class LerpBlock extends NodeMaterialBlock {
  62071. /**
  62072. * Creates a new LerpBlock
  62073. * @param name defines the block name
  62074. */
  62075. constructor(name: string);
  62076. /**
  62077. * Gets the current class name
  62078. * @returns the class name
  62079. */
  62080. getClassName(): string;
  62081. /**
  62082. * Gets the left operand input component
  62083. */
  62084. get left(): NodeMaterialConnectionPoint;
  62085. /**
  62086. * Gets the right operand input component
  62087. */
  62088. get right(): NodeMaterialConnectionPoint;
  62089. /**
  62090. * Gets the gradient operand input component
  62091. */
  62092. get gradient(): NodeMaterialConnectionPoint;
  62093. /**
  62094. * Gets the output component
  62095. */
  62096. get output(): NodeMaterialConnectionPoint;
  62097. protected _buildBlock(state: NodeMaterialBuildState): this;
  62098. }
  62099. }
  62100. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62101. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62102. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62103. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62104. /**
  62105. * Block used to divide 2 vectors
  62106. */
  62107. export class DivideBlock extends NodeMaterialBlock {
  62108. /**
  62109. * Creates a new DivideBlock
  62110. * @param name defines the block name
  62111. */
  62112. constructor(name: string);
  62113. /**
  62114. * Gets the current class name
  62115. * @returns the class name
  62116. */
  62117. getClassName(): string;
  62118. /**
  62119. * Gets the left operand input component
  62120. */
  62121. get left(): NodeMaterialConnectionPoint;
  62122. /**
  62123. * Gets the right operand input component
  62124. */
  62125. get right(): NodeMaterialConnectionPoint;
  62126. /**
  62127. * Gets the output component
  62128. */
  62129. get output(): NodeMaterialConnectionPoint;
  62130. protected _buildBlock(state: NodeMaterialBuildState): this;
  62131. }
  62132. }
  62133. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62134. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62135. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62136. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62137. /**
  62138. * Block used to subtract 2 vectors
  62139. */
  62140. export class SubtractBlock extends NodeMaterialBlock {
  62141. /**
  62142. * Creates a new SubtractBlock
  62143. * @param name defines the block name
  62144. */
  62145. constructor(name: string);
  62146. /**
  62147. * Gets the current class name
  62148. * @returns the class name
  62149. */
  62150. getClassName(): string;
  62151. /**
  62152. * Gets the left operand input component
  62153. */
  62154. get left(): NodeMaterialConnectionPoint;
  62155. /**
  62156. * Gets the right operand input component
  62157. */
  62158. get right(): NodeMaterialConnectionPoint;
  62159. /**
  62160. * Gets the output component
  62161. */
  62162. get output(): NodeMaterialConnectionPoint;
  62163. protected _buildBlock(state: NodeMaterialBuildState): this;
  62164. }
  62165. }
  62166. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62167. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62168. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62169. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62170. /**
  62171. * Block used to step a value
  62172. */
  62173. export class StepBlock extends NodeMaterialBlock {
  62174. /**
  62175. * Creates a new StepBlock
  62176. * @param name defines the block name
  62177. */
  62178. constructor(name: string);
  62179. /**
  62180. * Gets the current class name
  62181. * @returns the class name
  62182. */
  62183. getClassName(): string;
  62184. /**
  62185. * Gets the value operand input component
  62186. */
  62187. get value(): NodeMaterialConnectionPoint;
  62188. /**
  62189. * Gets the edge operand input component
  62190. */
  62191. get edge(): NodeMaterialConnectionPoint;
  62192. /**
  62193. * Gets the output component
  62194. */
  62195. get output(): NodeMaterialConnectionPoint;
  62196. protected _buildBlock(state: NodeMaterialBuildState): this;
  62197. }
  62198. }
  62199. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62200. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62201. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62202. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62203. /**
  62204. * Block used to get the opposite (1 - x) of a value
  62205. */
  62206. export class OneMinusBlock extends NodeMaterialBlock {
  62207. /**
  62208. * Creates a new OneMinusBlock
  62209. * @param name defines the block name
  62210. */
  62211. constructor(name: string);
  62212. /**
  62213. * Gets the current class name
  62214. * @returns the class name
  62215. */
  62216. getClassName(): string;
  62217. /**
  62218. * Gets the input component
  62219. */
  62220. get input(): NodeMaterialConnectionPoint;
  62221. /**
  62222. * Gets the output component
  62223. */
  62224. get output(): NodeMaterialConnectionPoint;
  62225. protected _buildBlock(state: NodeMaterialBuildState): this;
  62226. }
  62227. }
  62228. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62229. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62230. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62231. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62232. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62233. /**
  62234. * Block used to get the view direction
  62235. */
  62236. export class ViewDirectionBlock extends NodeMaterialBlock {
  62237. /**
  62238. * Creates a new ViewDirectionBlock
  62239. * @param name defines the block name
  62240. */
  62241. constructor(name: string);
  62242. /**
  62243. * Gets the current class name
  62244. * @returns the class name
  62245. */
  62246. getClassName(): string;
  62247. /**
  62248. * Gets the world position component
  62249. */
  62250. get worldPosition(): NodeMaterialConnectionPoint;
  62251. /**
  62252. * Gets the camera position component
  62253. */
  62254. get cameraPosition(): NodeMaterialConnectionPoint;
  62255. /**
  62256. * Gets the output component
  62257. */
  62258. get output(): NodeMaterialConnectionPoint;
  62259. autoConfigure(material: NodeMaterial): void;
  62260. protected _buildBlock(state: NodeMaterialBuildState): this;
  62261. }
  62262. }
  62263. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62264. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62265. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62266. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62267. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62268. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62269. /**
  62270. * Block used to compute fresnel value
  62271. */
  62272. export class FresnelBlock extends NodeMaterialBlock {
  62273. /**
  62274. * Create a new FresnelBlock
  62275. * @param name defines the block name
  62276. */
  62277. constructor(name: string);
  62278. /**
  62279. * Gets the current class name
  62280. * @returns the class name
  62281. */
  62282. getClassName(): string;
  62283. /**
  62284. * Gets the world normal input component
  62285. */
  62286. get worldNormal(): NodeMaterialConnectionPoint;
  62287. /**
  62288. * Gets the view direction input component
  62289. */
  62290. get viewDirection(): NodeMaterialConnectionPoint;
  62291. /**
  62292. * Gets the bias input component
  62293. */
  62294. get bias(): NodeMaterialConnectionPoint;
  62295. /**
  62296. * Gets the camera (or eye) position component
  62297. */
  62298. get power(): NodeMaterialConnectionPoint;
  62299. /**
  62300. * Gets the fresnel output component
  62301. */
  62302. get fresnel(): NodeMaterialConnectionPoint;
  62303. autoConfigure(material: NodeMaterial): void;
  62304. protected _buildBlock(state: NodeMaterialBuildState): this;
  62305. }
  62306. }
  62307. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62308. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62309. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62310. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62311. /**
  62312. * Block used to get the max of 2 values
  62313. */
  62314. export class MaxBlock extends NodeMaterialBlock {
  62315. /**
  62316. * Creates a new MaxBlock
  62317. * @param name defines the block name
  62318. */
  62319. constructor(name: string);
  62320. /**
  62321. * Gets the current class name
  62322. * @returns the class name
  62323. */
  62324. getClassName(): string;
  62325. /**
  62326. * Gets the left operand input component
  62327. */
  62328. get left(): NodeMaterialConnectionPoint;
  62329. /**
  62330. * Gets the right operand input component
  62331. */
  62332. get right(): NodeMaterialConnectionPoint;
  62333. /**
  62334. * Gets the output component
  62335. */
  62336. get output(): NodeMaterialConnectionPoint;
  62337. protected _buildBlock(state: NodeMaterialBuildState): this;
  62338. }
  62339. }
  62340. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62341. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62342. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62343. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62344. /**
  62345. * Block used to get the min of 2 values
  62346. */
  62347. export class MinBlock extends NodeMaterialBlock {
  62348. /**
  62349. * Creates a new MinBlock
  62350. * @param name defines the block name
  62351. */
  62352. constructor(name: string);
  62353. /**
  62354. * Gets the current class name
  62355. * @returns the class name
  62356. */
  62357. getClassName(): string;
  62358. /**
  62359. * Gets the left operand input component
  62360. */
  62361. get left(): NodeMaterialConnectionPoint;
  62362. /**
  62363. * Gets the right operand input component
  62364. */
  62365. get right(): NodeMaterialConnectionPoint;
  62366. /**
  62367. * Gets the output component
  62368. */
  62369. get output(): NodeMaterialConnectionPoint;
  62370. protected _buildBlock(state: NodeMaterialBuildState): this;
  62371. }
  62372. }
  62373. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62374. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62375. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62376. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62377. /**
  62378. * Block used to get the distance between 2 values
  62379. */
  62380. export class DistanceBlock extends NodeMaterialBlock {
  62381. /**
  62382. * Creates a new DistanceBlock
  62383. * @param name defines the block name
  62384. */
  62385. constructor(name: string);
  62386. /**
  62387. * Gets the current class name
  62388. * @returns the class name
  62389. */
  62390. getClassName(): string;
  62391. /**
  62392. * Gets the left operand input component
  62393. */
  62394. get left(): NodeMaterialConnectionPoint;
  62395. /**
  62396. * Gets the right operand input component
  62397. */
  62398. get right(): NodeMaterialConnectionPoint;
  62399. /**
  62400. * Gets the output component
  62401. */
  62402. get output(): NodeMaterialConnectionPoint;
  62403. protected _buildBlock(state: NodeMaterialBuildState): this;
  62404. }
  62405. }
  62406. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62407. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62408. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62409. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62410. /**
  62411. * Block used to get the length of a vector
  62412. */
  62413. export class LengthBlock extends NodeMaterialBlock {
  62414. /**
  62415. * Creates a new LengthBlock
  62416. * @param name defines the block name
  62417. */
  62418. constructor(name: string);
  62419. /**
  62420. * Gets the current class name
  62421. * @returns the class name
  62422. */
  62423. getClassName(): string;
  62424. /**
  62425. * Gets the value input component
  62426. */
  62427. get value(): NodeMaterialConnectionPoint;
  62428. /**
  62429. * Gets the output component
  62430. */
  62431. get output(): NodeMaterialConnectionPoint;
  62432. protected _buildBlock(state: NodeMaterialBuildState): this;
  62433. }
  62434. }
  62435. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  62436. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62437. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62438. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62439. /**
  62440. * Block used to get negative version of a value (i.e. x * -1)
  62441. */
  62442. export class NegateBlock extends NodeMaterialBlock {
  62443. /**
  62444. * Creates a new NegateBlock
  62445. * @param name defines the block name
  62446. */
  62447. constructor(name: string);
  62448. /**
  62449. * Gets the current class name
  62450. * @returns the class name
  62451. */
  62452. getClassName(): string;
  62453. /**
  62454. * Gets the value input component
  62455. */
  62456. get value(): NodeMaterialConnectionPoint;
  62457. /**
  62458. * Gets the output component
  62459. */
  62460. get output(): NodeMaterialConnectionPoint;
  62461. protected _buildBlock(state: NodeMaterialBuildState): this;
  62462. }
  62463. }
  62464. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  62465. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62466. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62467. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62468. /**
  62469. * Block used to get the value of the first parameter raised to the power of the second
  62470. */
  62471. export class PowBlock extends NodeMaterialBlock {
  62472. /**
  62473. * Creates a new PowBlock
  62474. * @param name defines the block name
  62475. */
  62476. constructor(name: string);
  62477. /**
  62478. * Gets the current class name
  62479. * @returns the class name
  62480. */
  62481. getClassName(): string;
  62482. /**
  62483. * Gets the value operand input component
  62484. */
  62485. get value(): NodeMaterialConnectionPoint;
  62486. /**
  62487. * Gets the power operand input component
  62488. */
  62489. get power(): NodeMaterialConnectionPoint;
  62490. /**
  62491. * Gets the output component
  62492. */
  62493. get output(): NodeMaterialConnectionPoint;
  62494. protected _buildBlock(state: NodeMaterialBuildState): this;
  62495. }
  62496. }
  62497. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  62498. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62499. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62500. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62501. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62502. /**
  62503. * Block used to get a random number
  62504. */
  62505. export class RandomNumberBlock extends NodeMaterialBlock {
  62506. /**
  62507. * Creates a new RandomNumberBlock
  62508. * @param name defines the block name
  62509. */
  62510. constructor(name: string);
  62511. /**
  62512. * Gets the current class name
  62513. * @returns the class name
  62514. */
  62515. getClassName(): string;
  62516. /**
  62517. * Gets the seed input component
  62518. */
  62519. get seed(): NodeMaterialConnectionPoint;
  62520. /**
  62521. * Gets the output component
  62522. */
  62523. get output(): NodeMaterialConnectionPoint;
  62524. protected _buildBlock(state: NodeMaterialBuildState): this;
  62525. }
  62526. }
  62527. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  62528. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62529. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62530. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62531. /**
  62532. * Block used to compute arc tangent of 2 values
  62533. */
  62534. export class ArcTan2Block extends NodeMaterialBlock {
  62535. /**
  62536. * Creates a new ArcTan2Block
  62537. * @param name defines the block name
  62538. */
  62539. constructor(name: string);
  62540. /**
  62541. * Gets the current class name
  62542. * @returns the class name
  62543. */
  62544. getClassName(): string;
  62545. /**
  62546. * Gets the x operand input component
  62547. */
  62548. get x(): NodeMaterialConnectionPoint;
  62549. /**
  62550. * Gets the y operand input component
  62551. */
  62552. get y(): NodeMaterialConnectionPoint;
  62553. /**
  62554. * Gets the output component
  62555. */
  62556. get output(): NodeMaterialConnectionPoint;
  62557. protected _buildBlock(state: NodeMaterialBuildState): this;
  62558. }
  62559. }
  62560. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  62561. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62562. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62563. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62564. /**
  62565. * Block used to smooth step a value
  62566. */
  62567. export class SmoothStepBlock extends NodeMaterialBlock {
  62568. /**
  62569. * Creates a new SmoothStepBlock
  62570. * @param name defines the block name
  62571. */
  62572. constructor(name: string);
  62573. /**
  62574. * Gets the current class name
  62575. * @returns the class name
  62576. */
  62577. getClassName(): string;
  62578. /**
  62579. * Gets the value operand input component
  62580. */
  62581. get value(): NodeMaterialConnectionPoint;
  62582. /**
  62583. * Gets the first edge operand input component
  62584. */
  62585. get edge0(): NodeMaterialConnectionPoint;
  62586. /**
  62587. * Gets the second edge operand input component
  62588. */
  62589. get edge1(): NodeMaterialConnectionPoint;
  62590. /**
  62591. * Gets the output component
  62592. */
  62593. get output(): NodeMaterialConnectionPoint;
  62594. protected _buildBlock(state: NodeMaterialBuildState): this;
  62595. }
  62596. }
  62597. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  62598. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62599. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62600. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62601. /**
  62602. * Block used to get the reciprocal (1 / x) of a value
  62603. */
  62604. export class ReciprocalBlock extends NodeMaterialBlock {
  62605. /**
  62606. * Creates a new ReciprocalBlock
  62607. * @param name defines the block name
  62608. */
  62609. constructor(name: string);
  62610. /**
  62611. * Gets the current class name
  62612. * @returns the class name
  62613. */
  62614. getClassName(): string;
  62615. /**
  62616. * Gets the input component
  62617. */
  62618. get input(): NodeMaterialConnectionPoint;
  62619. /**
  62620. * Gets the output component
  62621. */
  62622. get output(): NodeMaterialConnectionPoint;
  62623. protected _buildBlock(state: NodeMaterialBuildState): this;
  62624. }
  62625. }
  62626. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  62627. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62628. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62629. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62630. /**
  62631. * Block used to replace a color by another one
  62632. */
  62633. export class ReplaceColorBlock extends NodeMaterialBlock {
  62634. /**
  62635. * Creates a new ReplaceColorBlock
  62636. * @param name defines the block name
  62637. */
  62638. constructor(name: string);
  62639. /**
  62640. * Gets the current class name
  62641. * @returns the class name
  62642. */
  62643. getClassName(): string;
  62644. /**
  62645. * Gets the value input component
  62646. */
  62647. get value(): NodeMaterialConnectionPoint;
  62648. /**
  62649. * Gets the reference input component
  62650. */
  62651. get reference(): NodeMaterialConnectionPoint;
  62652. /**
  62653. * Gets the distance input component
  62654. */
  62655. get distance(): NodeMaterialConnectionPoint;
  62656. /**
  62657. * Gets the replacement input component
  62658. */
  62659. get replacement(): NodeMaterialConnectionPoint;
  62660. /**
  62661. * Gets the output component
  62662. */
  62663. get output(): NodeMaterialConnectionPoint;
  62664. protected _buildBlock(state: NodeMaterialBuildState): this;
  62665. }
  62666. }
  62667. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  62668. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62669. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62670. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62671. /**
  62672. * Block used to posterize a value
  62673. * @see https://en.wikipedia.org/wiki/Posterization
  62674. */
  62675. export class PosterizeBlock extends NodeMaterialBlock {
  62676. /**
  62677. * Creates a new PosterizeBlock
  62678. * @param name defines the block name
  62679. */
  62680. constructor(name: string);
  62681. /**
  62682. * Gets the current class name
  62683. * @returns the class name
  62684. */
  62685. getClassName(): string;
  62686. /**
  62687. * Gets the value input component
  62688. */
  62689. get value(): NodeMaterialConnectionPoint;
  62690. /**
  62691. * Gets the steps input component
  62692. */
  62693. get steps(): NodeMaterialConnectionPoint;
  62694. /**
  62695. * Gets the output component
  62696. */
  62697. get output(): NodeMaterialConnectionPoint;
  62698. protected _buildBlock(state: NodeMaterialBuildState): this;
  62699. }
  62700. }
  62701. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  62702. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62703. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62704. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62705. import { Scene } from "babylonjs/scene";
  62706. /**
  62707. * Operations supported by the Wave block
  62708. */
  62709. export enum WaveBlockKind {
  62710. /** SawTooth */
  62711. SawTooth = 0,
  62712. /** Square */
  62713. Square = 1,
  62714. /** Triangle */
  62715. Triangle = 2
  62716. }
  62717. /**
  62718. * Block used to apply wave operation to floats
  62719. */
  62720. export class WaveBlock extends NodeMaterialBlock {
  62721. /**
  62722. * Gets or sets the kibnd of wave to be applied by the block
  62723. */
  62724. kind: WaveBlockKind;
  62725. /**
  62726. * Creates a new WaveBlock
  62727. * @param name defines the block name
  62728. */
  62729. constructor(name: string);
  62730. /**
  62731. * Gets the current class name
  62732. * @returns the class name
  62733. */
  62734. getClassName(): string;
  62735. /**
  62736. * Gets the input component
  62737. */
  62738. get input(): NodeMaterialConnectionPoint;
  62739. /**
  62740. * Gets the output component
  62741. */
  62742. get output(): NodeMaterialConnectionPoint;
  62743. protected _buildBlock(state: NodeMaterialBuildState): this;
  62744. serialize(): any;
  62745. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62746. }
  62747. }
  62748. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  62749. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62750. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62751. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62752. import { Color3 } from "babylonjs/Maths/math.color";
  62753. import { Scene } from "babylonjs/scene";
  62754. /**
  62755. * Class used to store a color step for the GradientBlock
  62756. */
  62757. export class GradientBlockColorStep {
  62758. /**
  62759. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62760. */
  62761. step: number;
  62762. /**
  62763. * Gets or sets the color associated with this step
  62764. */
  62765. color: Color3;
  62766. /**
  62767. * Creates a new GradientBlockColorStep
  62768. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  62769. * @param color defines the color associated with this step
  62770. */
  62771. constructor(
  62772. /**
  62773. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  62774. */
  62775. step: number,
  62776. /**
  62777. * Gets or sets the color associated with this step
  62778. */
  62779. color: Color3);
  62780. }
  62781. /**
  62782. * Block used to return a color from a gradient based on an input value between 0 and 1
  62783. */
  62784. export class GradientBlock extends NodeMaterialBlock {
  62785. /**
  62786. * Gets or sets the list of color steps
  62787. */
  62788. colorSteps: GradientBlockColorStep[];
  62789. /**
  62790. * Creates a new GradientBlock
  62791. * @param name defines the block name
  62792. */
  62793. constructor(name: string);
  62794. /**
  62795. * Gets the current class name
  62796. * @returns the class name
  62797. */
  62798. getClassName(): string;
  62799. /**
  62800. * Gets the gradient input component
  62801. */
  62802. get gradient(): NodeMaterialConnectionPoint;
  62803. /**
  62804. * Gets the output component
  62805. */
  62806. get output(): NodeMaterialConnectionPoint;
  62807. private _writeColorConstant;
  62808. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62809. serialize(): any;
  62810. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62811. protected _dumpPropertiesCode(): string;
  62812. }
  62813. }
  62814. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  62815. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62816. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62817. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62818. /**
  62819. * Block used to normalize lerp between 2 values
  62820. */
  62821. export class NLerpBlock extends NodeMaterialBlock {
  62822. /**
  62823. * Creates a new NLerpBlock
  62824. * @param name defines the block name
  62825. */
  62826. constructor(name: string);
  62827. /**
  62828. * Gets the current class name
  62829. * @returns the class name
  62830. */
  62831. getClassName(): string;
  62832. /**
  62833. * Gets the left operand input component
  62834. */
  62835. get left(): NodeMaterialConnectionPoint;
  62836. /**
  62837. * Gets the right operand input component
  62838. */
  62839. get right(): NodeMaterialConnectionPoint;
  62840. /**
  62841. * Gets the gradient operand input component
  62842. */
  62843. get gradient(): NodeMaterialConnectionPoint;
  62844. /**
  62845. * Gets the output component
  62846. */
  62847. get output(): NodeMaterialConnectionPoint;
  62848. protected _buildBlock(state: NodeMaterialBuildState): this;
  62849. }
  62850. }
  62851. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  62852. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62853. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62854. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62855. import { Scene } from "babylonjs/scene";
  62856. /**
  62857. * block used to Generate a Worley Noise 3D Noise Pattern
  62858. */
  62859. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  62860. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  62861. manhattanDistance: boolean;
  62862. /**
  62863. * Creates a new WorleyNoise3DBlock
  62864. * @param name defines the block name
  62865. */
  62866. constructor(name: string);
  62867. /**
  62868. * Gets the current class name
  62869. * @returns the class name
  62870. */
  62871. getClassName(): string;
  62872. /**
  62873. * Gets the seed input component
  62874. */
  62875. get seed(): NodeMaterialConnectionPoint;
  62876. /**
  62877. * Gets the jitter input component
  62878. */
  62879. get jitter(): NodeMaterialConnectionPoint;
  62880. /**
  62881. * Gets the output component
  62882. */
  62883. get output(): NodeMaterialConnectionPoint;
  62884. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62885. /**
  62886. * Exposes the properties to the UI?
  62887. */
  62888. protected _dumpPropertiesCode(): string;
  62889. /**
  62890. * Exposes the properties to the Seralize?
  62891. */
  62892. serialize(): any;
  62893. /**
  62894. * Exposes the properties to the deseralize?
  62895. */
  62896. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62897. }
  62898. }
  62899. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  62900. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62902. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62903. /**
  62904. * block used to Generate a Simplex Perlin 3d Noise Pattern
  62905. */
  62906. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  62907. /**
  62908. * Creates a new SimplexPerlin3DBlock
  62909. * @param name defines the block name
  62910. */
  62911. constructor(name: string);
  62912. /**
  62913. * Gets the current class name
  62914. * @returns the class name
  62915. */
  62916. getClassName(): string;
  62917. /**
  62918. * Gets the seed operand input component
  62919. */
  62920. get seed(): NodeMaterialConnectionPoint;
  62921. /**
  62922. * Gets the output component
  62923. */
  62924. get output(): NodeMaterialConnectionPoint;
  62925. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62926. }
  62927. }
  62928. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  62929. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62930. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62931. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62932. /**
  62933. * Block used to blend normals
  62934. */
  62935. export class NormalBlendBlock extends NodeMaterialBlock {
  62936. /**
  62937. * Creates a new NormalBlendBlock
  62938. * @param name defines the block name
  62939. */
  62940. constructor(name: string);
  62941. /**
  62942. * Gets the current class name
  62943. * @returns the class name
  62944. */
  62945. getClassName(): string;
  62946. /**
  62947. * Gets the first input component
  62948. */
  62949. get normalMap0(): NodeMaterialConnectionPoint;
  62950. /**
  62951. * Gets the second input component
  62952. */
  62953. get normalMap1(): NodeMaterialConnectionPoint;
  62954. /**
  62955. * Gets the output component
  62956. */
  62957. get output(): NodeMaterialConnectionPoint;
  62958. protected _buildBlock(state: NodeMaterialBuildState): this;
  62959. }
  62960. }
  62961. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  62962. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62963. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62964. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62965. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62966. /**
  62967. * Block used to rotate a 2d vector by a given angle
  62968. */
  62969. export class Rotate2dBlock extends NodeMaterialBlock {
  62970. /**
  62971. * Creates a new Rotate2dBlock
  62972. * @param name defines the block name
  62973. */
  62974. constructor(name: string);
  62975. /**
  62976. * Gets the current class name
  62977. * @returns the class name
  62978. */
  62979. getClassName(): string;
  62980. /**
  62981. * Gets the input vector
  62982. */
  62983. get input(): NodeMaterialConnectionPoint;
  62984. /**
  62985. * Gets the input angle
  62986. */
  62987. get angle(): NodeMaterialConnectionPoint;
  62988. /**
  62989. * Gets the output component
  62990. */
  62991. get output(): NodeMaterialConnectionPoint;
  62992. autoConfigure(material: NodeMaterial): void;
  62993. protected _buildBlock(state: NodeMaterialBuildState): this;
  62994. }
  62995. }
  62996. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  62997. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62998. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62999. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63000. /**
  63001. * Block used to get the reflected vector from a direction and a normal
  63002. */
  63003. export class ReflectBlock extends NodeMaterialBlock {
  63004. /**
  63005. * Creates a new ReflectBlock
  63006. * @param name defines the block name
  63007. */
  63008. constructor(name: string);
  63009. /**
  63010. * Gets the current class name
  63011. * @returns the class name
  63012. */
  63013. getClassName(): string;
  63014. /**
  63015. * Gets the incident component
  63016. */
  63017. get incident(): NodeMaterialConnectionPoint;
  63018. /**
  63019. * Gets the normal component
  63020. */
  63021. get normal(): NodeMaterialConnectionPoint;
  63022. /**
  63023. * Gets the output component
  63024. */
  63025. get output(): NodeMaterialConnectionPoint;
  63026. protected _buildBlock(state: NodeMaterialBuildState): this;
  63027. }
  63028. }
  63029. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  63030. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63031. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63032. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63033. /**
  63034. * Block used to get the refracted vector from a direction and a normal
  63035. */
  63036. export class RefractBlock extends NodeMaterialBlock {
  63037. /**
  63038. * Creates a new RefractBlock
  63039. * @param name defines the block name
  63040. */
  63041. constructor(name: string);
  63042. /**
  63043. * Gets the current class name
  63044. * @returns the class name
  63045. */
  63046. getClassName(): string;
  63047. /**
  63048. * Gets the incident component
  63049. */
  63050. get incident(): NodeMaterialConnectionPoint;
  63051. /**
  63052. * Gets the normal component
  63053. */
  63054. get normal(): NodeMaterialConnectionPoint;
  63055. /**
  63056. * Gets the index of refraction component
  63057. */
  63058. get ior(): NodeMaterialConnectionPoint;
  63059. /**
  63060. * Gets the output component
  63061. */
  63062. get output(): NodeMaterialConnectionPoint;
  63063. protected _buildBlock(state: NodeMaterialBuildState): this;
  63064. }
  63065. }
  63066. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63067. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63068. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63069. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63070. /**
  63071. * Block used to desaturate a color
  63072. */
  63073. export class DesaturateBlock extends NodeMaterialBlock {
  63074. /**
  63075. * Creates a new DesaturateBlock
  63076. * @param name defines the block name
  63077. */
  63078. constructor(name: string);
  63079. /**
  63080. * Gets the current class name
  63081. * @returns the class name
  63082. */
  63083. getClassName(): string;
  63084. /**
  63085. * Gets the color operand input component
  63086. */
  63087. get color(): NodeMaterialConnectionPoint;
  63088. /**
  63089. * Gets the level operand input component
  63090. */
  63091. get level(): NodeMaterialConnectionPoint;
  63092. /**
  63093. * Gets the output component
  63094. */
  63095. get output(): NodeMaterialConnectionPoint;
  63096. protected _buildBlock(state: NodeMaterialBuildState): this;
  63097. }
  63098. }
  63099. declare module "babylonjs/Materials/Node/Blocks/index" {
  63100. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63101. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63102. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63103. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63104. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63105. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63106. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63107. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63108. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63109. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63110. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63111. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63112. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63113. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63114. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63115. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63116. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63117. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63118. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63119. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63120. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63121. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63122. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63123. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63124. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63125. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63126. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63127. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63128. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63129. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63130. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63131. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63132. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63133. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63134. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63135. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63136. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63137. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63138. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63139. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63140. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63141. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63142. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63143. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63144. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63145. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63146. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63147. }
  63148. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63149. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63150. }
  63151. declare module "babylonjs/Materials/Node/index" {
  63152. export * from "babylonjs/Materials/Node/Enums/index";
  63153. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63154. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63155. export * from "babylonjs/Materials/Node/nodeMaterial";
  63156. export * from "babylonjs/Materials/Node/Blocks/index";
  63157. export * from "babylonjs/Materials/Node/Optimizers/index";
  63158. }
  63159. declare module "babylonjs/Materials/effectRenderer" {
  63160. import { Nullable } from "babylonjs/types";
  63161. import { Texture } from "babylonjs/Materials/Textures/texture";
  63162. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63163. import { Viewport } from "babylonjs/Maths/math.viewport";
  63164. import { Observable } from "babylonjs/Misc/observable";
  63165. import { Effect } from "babylonjs/Materials/effect";
  63166. import "babylonjs/Engines/Extensions/engine.renderTarget";
  63167. import "babylonjs/Shaders/postprocess.vertex";
  63168. /**
  63169. * Effect Render Options
  63170. */
  63171. export interface IEffectRendererOptions {
  63172. /**
  63173. * Defines the vertices positions.
  63174. */
  63175. positions?: number[];
  63176. /**
  63177. * Defines the indices.
  63178. */
  63179. indices?: number[];
  63180. }
  63181. /**
  63182. * Helper class to render one or more effects
  63183. */
  63184. export class EffectRenderer {
  63185. private engine;
  63186. private static _DefaultOptions;
  63187. private _vertexBuffers;
  63188. private _indexBuffer;
  63189. private _ringBufferIndex;
  63190. private _ringScreenBuffer;
  63191. private _fullscreenViewport;
  63192. private _getNextFrameBuffer;
  63193. /**
  63194. * Creates an effect renderer
  63195. * @param engine the engine to use for rendering
  63196. * @param options defines the options of the effect renderer
  63197. */
  63198. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63199. /**
  63200. * Sets the current viewport in normalized coordinates 0-1
  63201. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63202. */
  63203. setViewport(viewport?: Viewport): void;
  63204. /**
  63205. * Binds the embedded attributes buffer to the effect.
  63206. * @param effect Defines the effect to bind the attributes for
  63207. */
  63208. bindBuffers(effect: Effect): void;
  63209. /**
  63210. * Sets the current effect wrapper to use during draw.
  63211. * The effect needs to be ready before calling this api.
  63212. * This also sets the default full screen position attribute.
  63213. * @param effectWrapper Defines the effect to draw with
  63214. */
  63215. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63216. /**
  63217. * Draws a full screen quad.
  63218. */
  63219. draw(): void;
  63220. /**
  63221. * renders one or more effects to a specified texture
  63222. * @param effectWrappers list of effects to renderer
  63223. * @param outputTexture texture to draw to, if null it will render to the screen
  63224. */
  63225. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  63226. /**
  63227. * Disposes of the effect renderer
  63228. */
  63229. dispose(): void;
  63230. }
  63231. /**
  63232. * Options to create an EffectWrapper
  63233. */
  63234. interface EffectWrapperCreationOptions {
  63235. /**
  63236. * Engine to use to create the effect
  63237. */
  63238. engine: ThinEngine;
  63239. /**
  63240. * Fragment shader for the effect
  63241. */
  63242. fragmentShader: string;
  63243. /**
  63244. * Vertex shader for the effect
  63245. */
  63246. vertexShader?: string;
  63247. /**
  63248. * Attributes to use in the shader
  63249. */
  63250. attributeNames?: Array<string>;
  63251. /**
  63252. * Uniforms to use in the shader
  63253. */
  63254. uniformNames?: Array<string>;
  63255. /**
  63256. * Texture sampler names to use in the shader
  63257. */
  63258. samplerNames?: Array<string>;
  63259. /**
  63260. * The friendly name of the effect displayed in Spector.
  63261. */
  63262. name?: string;
  63263. }
  63264. /**
  63265. * Wraps an effect to be used for rendering
  63266. */
  63267. export class EffectWrapper {
  63268. /**
  63269. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63270. */
  63271. onApplyObservable: Observable<{}>;
  63272. /**
  63273. * The underlying effect
  63274. */
  63275. effect: Effect;
  63276. /**
  63277. * Creates an effect to be renderer
  63278. * @param creationOptions options to create the effect
  63279. */
  63280. constructor(creationOptions: EffectWrapperCreationOptions);
  63281. /**
  63282. * Disposes of the effect wrapper
  63283. */
  63284. dispose(): void;
  63285. }
  63286. }
  63287. declare module "babylonjs/Materials/index" {
  63288. export * from "babylonjs/Materials/Background/index";
  63289. export * from "babylonjs/Materials/colorCurves";
  63290. export * from "babylonjs/Materials/iEffectFallbacks";
  63291. export * from "babylonjs/Materials/effectFallbacks";
  63292. export * from "babylonjs/Materials/effect";
  63293. export * from "babylonjs/Materials/fresnelParameters";
  63294. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63295. export * from "babylonjs/Materials/material";
  63296. export * from "babylonjs/Materials/materialDefines";
  63297. export * from "babylonjs/Materials/materialHelper";
  63298. export * from "babylonjs/Materials/multiMaterial";
  63299. export * from "babylonjs/Materials/PBR/index";
  63300. export * from "babylonjs/Materials/pushMaterial";
  63301. export * from "babylonjs/Materials/shaderMaterial";
  63302. export * from "babylonjs/Materials/standardMaterial";
  63303. export * from "babylonjs/Materials/Textures/index";
  63304. export * from "babylonjs/Materials/uniformBuffer";
  63305. export * from "babylonjs/Materials/materialFlags";
  63306. export * from "babylonjs/Materials/Node/index";
  63307. export * from "babylonjs/Materials/effectRenderer";
  63308. }
  63309. declare module "babylonjs/Maths/index" {
  63310. export * from "babylonjs/Maths/math.scalar";
  63311. export * from "babylonjs/Maths/math";
  63312. export * from "babylonjs/Maths/sphericalPolynomial";
  63313. }
  63314. declare module "babylonjs/Misc/workerPool" {
  63315. import { IDisposable } from "babylonjs/scene";
  63316. /**
  63317. * Helper class to push actions to a pool of workers.
  63318. */
  63319. export class WorkerPool implements IDisposable {
  63320. private _workerInfos;
  63321. private _pendingActions;
  63322. /**
  63323. * Constructor
  63324. * @param workers Array of workers to use for actions
  63325. */
  63326. constructor(workers: Array<Worker>);
  63327. /**
  63328. * Terminates all workers and clears any pending actions.
  63329. */
  63330. dispose(): void;
  63331. /**
  63332. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63333. * pended until a worker has completed its action.
  63334. * @param action The action to perform. Call onComplete when the action is complete.
  63335. */
  63336. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63337. private _execute;
  63338. }
  63339. }
  63340. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63341. import { IDisposable } from "babylonjs/scene";
  63342. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63343. /**
  63344. * Configuration for Draco compression
  63345. */
  63346. export interface IDracoCompressionConfiguration {
  63347. /**
  63348. * Configuration for the decoder.
  63349. */
  63350. decoder: {
  63351. /**
  63352. * The url to the WebAssembly module.
  63353. */
  63354. wasmUrl?: string;
  63355. /**
  63356. * The url to the WebAssembly binary.
  63357. */
  63358. wasmBinaryUrl?: string;
  63359. /**
  63360. * The url to the fallback JavaScript module.
  63361. */
  63362. fallbackUrl?: string;
  63363. };
  63364. }
  63365. /**
  63366. * Draco compression (https://google.github.io/draco/)
  63367. *
  63368. * This class wraps the Draco module.
  63369. *
  63370. * **Encoder**
  63371. *
  63372. * The encoder is not currently implemented.
  63373. *
  63374. * **Decoder**
  63375. *
  63376. * 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.
  63377. *
  63378. * To update the configuration, use the following code:
  63379. * ```javascript
  63380. * DracoCompression.Configuration = {
  63381. * decoder: {
  63382. * wasmUrl: "<url to the WebAssembly library>",
  63383. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63384. * fallbackUrl: "<url to the fallback JavaScript library>",
  63385. * }
  63386. * };
  63387. * ```
  63388. *
  63389. * 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.
  63390. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63391. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63392. *
  63393. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63394. * ```javascript
  63395. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63396. * ```
  63397. *
  63398. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63399. */
  63400. export class DracoCompression implements IDisposable {
  63401. private _workerPoolPromise?;
  63402. private _decoderModulePromise?;
  63403. /**
  63404. * The configuration. Defaults to the following urls:
  63405. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63406. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63407. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63408. */
  63409. static Configuration: IDracoCompressionConfiguration;
  63410. /**
  63411. * Returns true if the decoder configuration is available.
  63412. */
  63413. static get DecoderAvailable(): boolean;
  63414. /**
  63415. * Default number of workers to create when creating the draco compression object.
  63416. */
  63417. static DefaultNumWorkers: number;
  63418. private static GetDefaultNumWorkers;
  63419. private static _Default;
  63420. /**
  63421. * Default instance for the draco compression object.
  63422. */
  63423. static get Default(): DracoCompression;
  63424. /**
  63425. * Constructor
  63426. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  63427. */
  63428. constructor(numWorkers?: number);
  63429. /**
  63430. * Stop all async operations and release resources.
  63431. */
  63432. dispose(): void;
  63433. /**
  63434. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  63435. * @returns a promise that resolves when ready
  63436. */
  63437. whenReadyAsync(): Promise<void>;
  63438. /**
  63439. * Decode Draco compressed mesh data to vertex data.
  63440. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  63441. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  63442. * @returns A promise that resolves with the decoded vertex data
  63443. */
  63444. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  63445. [kind: string]: number;
  63446. }): Promise<VertexData>;
  63447. }
  63448. }
  63449. declare module "babylonjs/Meshes/Compression/index" {
  63450. export * from "babylonjs/Meshes/Compression/dracoCompression";
  63451. }
  63452. declare module "babylonjs/Meshes/csg" {
  63453. import { Nullable } from "babylonjs/types";
  63454. import { Scene } from "babylonjs/scene";
  63455. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63456. import { Mesh } from "babylonjs/Meshes/mesh";
  63457. import { Material } from "babylonjs/Materials/material";
  63458. /**
  63459. * Class for building Constructive Solid Geometry
  63460. */
  63461. export class CSG {
  63462. private polygons;
  63463. /**
  63464. * The world matrix
  63465. */
  63466. matrix: Matrix;
  63467. /**
  63468. * Stores the position
  63469. */
  63470. position: Vector3;
  63471. /**
  63472. * Stores the rotation
  63473. */
  63474. rotation: Vector3;
  63475. /**
  63476. * Stores the rotation quaternion
  63477. */
  63478. rotationQuaternion: Nullable<Quaternion>;
  63479. /**
  63480. * Stores the scaling vector
  63481. */
  63482. scaling: Vector3;
  63483. /**
  63484. * Convert the Mesh to CSG
  63485. * @param mesh The Mesh to convert to CSG
  63486. * @returns A new CSG from the Mesh
  63487. */
  63488. static FromMesh(mesh: Mesh): CSG;
  63489. /**
  63490. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  63491. * @param polygons Polygons used to construct a CSG solid
  63492. */
  63493. private static FromPolygons;
  63494. /**
  63495. * Clones, or makes a deep copy, of the CSG
  63496. * @returns A new CSG
  63497. */
  63498. clone(): CSG;
  63499. /**
  63500. * Unions this CSG with another CSG
  63501. * @param csg The CSG to union against this CSG
  63502. * @returns The unioned CSG
  63503. */
  63504. union(csg: CSG): CSG;
  63505. /**
  63506. * Unions this CSG with another CSG in place
  63507. * @param csg The CSG to union against this CSG
  63508. */
  63509. unionInPlace(csg: CSG): void;
  63510. /**
  63511. * Subtracts this CSG with another CSG
  63512. * @param csg The CSG to subtract against this CSG
  63513. * @returns A new CSG
  63514. */
  63515. subtract(csg: CSG): CSG;
  63516. /**
  63517. * Subtracts this CSG with another CSG in place
  63518. * @param csg The CSG to subtact against this CSG
  63519. */
  63520. subtractInPlace(csg: CSG): void;
  63521. /**
  63522. * Intersect this CSG with another CSG
  63523. * @param csg The CSG to intersect against this CSG
  63524. * @returns A new CSG
  63525. */
  63526. intersect(csg: CSG): CSG;
  63527. /**
  63528. * Intersects this CSG with another CSG in place
  63529. * @param csg The CSG to intersect against this CSG
  63530. */
  63531. intersectInPlace(csg: CSG): void;
  63532. /**
  63533. * Return a new CSG solid with solid and empty space switched. This solid is
  63534. * not modified.
  63535. * @returns A new CSG solid with solid and empty space switched
  63536. */
  63537. inverse(): CSG;
  63538. /**
  63539. * Inverses the CSG in place
  63540. */
  63541. inverseInPlace(): void;
  63542. /**
  63543. * This is used to keep meshes transformations so they can be restored
  63544. * when we build back a Babylon Mesh
  63545. * NB : All CSG operations are performed in world coordinates
  63546. * @param csg The CSG to copy the transform attributes from
  63547. * @returns This CSG
  63548. */
  63549. copyTransformAttributes(csg: CSG): CSG;
  63550. /**
  63551. * Build Raw mesh from CSG
  63552. * Coordinates here are in world space
  63553. * @param name The name of the mesh geometry
  63554. * @param scene The Scene
  63555. * @param keepSubMeshes Specifies if the submeshes should be kept
  63556. * @returns A new Mesh
  63557. */
  63558. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63559. /**
  63560. * Build Mesh from CSG taking material and transforms into account
  63561. * @param name The name of the Mesh
  63562. * @param material The material of the Mesh
  63563. * @param scene The Scene
  63564. * @param keepSubMeshes Specifies if submeshes should be kept
  63565. * @returns The new Mesh
  63566. */
  63567. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  63568. }
  63569. }
  63570. declare module "babylonjs/Meshes/trailMesh" {
  63571. import { Mesh } from "babylonjs/Meshes/mesh";
  63572. import { Scene } from "babylonjs/scene";
  63573. import { TransformNode } from "babylonjs/Meshes/transformNode";
  63574. /**
  63575. * Class used to create a trail following a mesh
  63576. */
  63577. export class TrailMesh extends Mesh {
  63578. private _generator;
  63579. private _autoStart;
  63580. private _running;
  63581. private _diameter;
  63582. private _length;
  63583. private _sectionPolygonPointsCount;
  63584. private _sectionVectors;
  63585. private _sectionNormalVectors;
  63586. private _beforeRenderObserver;
  63587. /**
  63588. * @constructor
  63589. * @param name The value used by scene.getMeshByName() to do a lookup.
  63590. * @param generator The mesh or transform node to generate a trail.
  63591. * @param scene The scene to add this mesh to.
  63592. * @param diameter Diameter of trailing mesh. Default is 1.
  63593. * @param length Length of trailing mesh. Default is 60.
  63594. * @param autoStart Automatically start trailing mesh. Default true.
  63595. */
  63596. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  63597. /**
  63598. * "TrailMesh"
  63599. * @returns "TrailMesh"
  63600. */
  63601. getClassName(): string;
  63602. private _createMesh;
  63603. /**
  63604. * Start trailing mesh.
  63605. */
  63606. start(): void;
  63607. /**
  63608. * Stop trailing mesh.
  63609. */
  63610. stop(): void;
  63611. /**
  63612. * Update trailing mesh geometry.
  63613. */
  63614. update(): void;
  63615. /**
  63616. * Returns a new TrailMesh object.
  63617. * @param name is a string, the name given to the new mesh
  63618. * @param newGenerator use new generator object for cloned trail mesh
  63619. * @returns a new mesh
  63620. */
  63621. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  63622. /**
  63623. * Serializes this trail mesh
  63624. * @param serializationObject object to write serialization to
  63625. */
  63626. serialize(serializationObject: any): void;
  63627. /**
  63628. * Parses a serialized trail mesh
  63629. * @param parsedMesh the serialized mesh
  63630. * @param scene the scene to create the trail mesh in
  63631. * @returns the created trail mesh
  63632. */
  63633. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  63634. }
  63635. }
  63636. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  63637. import { Nullable } from "babylonjs/types";
  63638. import { Scene } from "babylonjs/scene";
  63639. import { Vector4 } from "babylonjs/Maths/math.vector";
  63640. import { Color4 } from "babylonjs/Maths/math.color";
  63641. import { Mesh } from "babylonjs/Meshes/mesh";
  63642. /**
  63643. * Class containing static functions to help procedurally build meshes
  63644. */
  63645. export class TiledBoxBuilder {
  63646. /**
  63647. * Creates a box mesh
  63648. * 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)
  63649. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63651. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63653. * @param name defines the name of the mesh
  63654. * @param options defines the options used to create the mesh
  63655. * @param scene defines the hosting scene
  63656. * @returns the box mesh
  63657. */
  63658. static CreateTiledBox(name: string, options: {
  63659. pattern?: number;
  63660. width?: number;
  63661. height?: number;
  63662. depth?: number;
  63663. tileSize?: number;
  63664. tileWidth?: number;
  63665. tileHeight?: number;
  63666. alignHorizontal?: number;
  63667. alignVertical?: number;
  63668. faceUV?: Vector4[];
  63669. faceColors?: Color4[];
  63670. sideOrientation?: number;
  63671. updatable?: boolean;
  63672. }, scene?: Nullable<Scene>): Mesh;
  63673. }
  63674. }
  63675. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  63676. import { Vector4 } from "babylonjs/Maths/math.vector";
  63677. import { Mesh } from "babylonjs/Meshes/mesh";
  63678. /**
  63679. * Class containing static functions to help procedurally build meshes
  63680. */
  63681. export class TorusKnotBuilder {
  63682. /**
  63683. * Creates a torus knot mesh
  63684. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  63685. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  63686. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  63687. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  63688. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63689. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  63691. * @param name defines the name of the mesh
  63692. * @param options defines the options used to create the mesh
  63693. * @param scene defines the hosting scene
  63694. * @returns the torus knot mesh
  63695. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  63696. */
  63697. static CreateTorusKnot(name: string, options: {
  63698. radius?: number;
  63699. tube?: number;
  63700. radialSegments?: number;
  63701. tubularSegments?: number;
  63702. p?: number;
  63703. q?: number;
  63704. updatable?: boolean;
  63705. sideOrientation?: number;
  63706. frontUVs?: Vector4;
  63707. backUVs?: Vector4;
  63708. }, scene: any): Mesh;
  63709. }
  63710. }
  63711. declare module "babylonjs/Meshes/polygonMesh" {
  63712. import { Scene } from "babylonjs/scene";
  63713. import { Vector2 } from "babylonjs/Maths/math.vector";
  63714. import { Mesh } from "babylonjs/Meshes/mesh";
  63715. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63716. import { Path2 } from "babylonjs/Maths/math.path";
  63717. /**
  63718. * Polygon
  63719. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  63720. */
  63721. export class Polygon {
  63722. /**
  63723. * Creates a rectangle
  63724. * @param xmin bottom X coord
  63725. * @param ymin bottom Y coord
  63726. * @param xmax top X coord
  63727. * @param ymax top Y coord
  63728. * @returns points that make the resulting rectation
  63729. */
  63730. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  63731. /**
  63732. * Creates a circle
  63733. * @param radius radius of circle
  63734. * @param cx scale in x
  63735. * @param cy scale in y
  63736. * @param numberOfSides number of sides that make up the circle
  63737. * @returns points that make the resulting circle
  63738. */
  63739. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  63740. /**
  63741. * Creates a polygon from input string
  63742. * @param input Input polygon data
  63743. * @returns the parsed points
  63744. */
  63745. static Parse(input: string): Vector2[];
  63746. /**
  63747. * Starts building a polygon from x and y coordinates
  63748. * @param x x coordinate
  63749. * @param y y coordinate
  63750. * @returns the started path2
  63751. */
  63752. static StartingAt(x: number, y: number): Path2;
  63753. }
  63754. /**
  63755. * Builds a polygon
  63756. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  63757. */
  63758. export class PolygonMeshBuilder {
  63759. private _points;
  63760. private _outlinepoints;
  63761. private _holes;
  63762. private _name;
  63763. private _scene;
  63764. private _epoints;
  63765. private _eholes;
  63766. private _addToepoint;
  63767. /**
  63768. * Babylon reference to the earcut plugin.
  63769. */
  63770. bjsEarcut: any;
  63771. /**
  63772. * Creates a PolygonMeshBuilder
  63773. * @param name name of the builder
  63774. * @param contours Path of the polygon
  63775. * @param scene scene to add to when creating the mesh
  63776. * @param earcutInjection can be used to inject your own earcut reference
  63777. */
  63778. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  63779. /**
  63780. * Adds a whole within the polygon
  63781. * @param hole Array of points defining the hole
  63782. * @returns this
  63783. */
  63784. addHole(hole: Vector2[]): PolygonMeshBuilder;
  63785. /**
  63786. * Creates the polygon
  63787. * @param updatable If the mesh should be updatable
  63788. * @param depth The depth of the mesh created
  63789. * @returns the created mesh
  63790. */
  63791. build(updatable?: boolean, depth?: number): Mesh;
  63792. /**
  63793. * Creates the polygon
  63794. * @param depth The depth of the mesh created
  63795. * @returns the created VertexData
  63796. */
  63797. buildVertexData(depth?: number): VertexData;
  63798. /**
  63799. * Adds a side to the polygon
  63800. * @param positions points that make the polygon
  63801. * @param normals normals of the polygon
  63802. * @param uvs uvs of the polygon
  63803. * @param indices indices of the polygon
  63804. * @param bounds bounds of the polygon
  63805. * @param points points of the polygon
  63806. * @param depth depth of the polygon
  63807. * @param flip flip of the polygon
  63808. */
  63809. private addSide;
  63810. }
  63811. }
  63812. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  63813. import { Scene } from "babylonjs/scene";
  63814. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63815. import { Color4 } from "babylonjs/Maths/math.color";
  63816. import { Mesh } from "babylonjs/Meshes/mesh";
  63817. import { Nullable } from "babylonjs/types";
  63818. /**
  63819. * Class containing static functions to help procedurally build meshes
  63820. */
  63821. export class PolygonBuilder {
  63822. /**
  63823. * Creates a polygon mesh
  63824. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  63825. * * 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
  63826. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63828. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  63829. * * Remember you can only change the shape positions, not their number when updating a polygon
  63830. * @param name defines the name of the mesh
  63831. * @param options defines the options used to create the mesh
  63832. * @param scene defines the hosting scene
  63833. * @param earcutInjection can be used to inject your own earcut reference
  63834. * @returns the polygon mesh
  63835. */
  63836. static CreatePolygon(name: string, options: {
  63837. shape: Vector3[];
  63838. holes?: Vector3[][];
  63839. depth?: number;
  63840. faceUV?: Vector4[];
  63841. faceColors?: Color4[];
  63842. updatable?: boolean;
  63843. sideOrientation?: number;
  63844. frontUVs?: Vector4;
  63845. backUVs?: Vector4;
  63846. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63847. /**
  63848. * Creates an extruded polygon mesh, with depth in the Y direction.
  63849. * * 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)
  63850. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  63851. * @param name defines the name of the mesh
  63852. * @param options defines the options used to create the mesh
  63853. * @param scene defines the hosting scene
  63854. * @param earcutInjection can be used to inject your own earcut reference
  63855. * @returns the polygon mesh
  63856. */
  63857. static ExtrudePolygon(name: string, options: {
  63858. shape: Vector3[];
  63859. holes?: Vector3[][];
  63860. depth?: number;
  63861. faceUV?: Vector4[];
  63862. faceColors?: Color4[];
  63863. updatable?: boolean;
  63864. sideOrientation?: number;
  63865. frontUVs?: Vector4;
  63866. backUVs?: Vector4;
  63867. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  63868. }
  63869. }
  63870. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  63871. import { Scene } from "babylonjs/scene";
  63872. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63873. import { Mesh } from "babylonjs/Meshes/mesh";
  63874. import { Nullable } from "babylonjs/types";
  63875. /**
  63876. * Class containing static functions to help procedurally build meshes
  63877. */
  63878. export class LatheBuilder {
  63879. /**
  63880. * Creates lathe mesh.
  63881. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  63882. * * 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
  63883. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  63884. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  63885. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  63886. * * 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
  63887. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  63888. * * 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
  63889. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63890. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63891. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63893. * @param name defines the name of the mesh
  63894. * @param options defines the options used to create the mesh
  63895. * @param scene defines the hosting scene
  63896. * @returns the lathe mesh
  63897. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  63898. */
  63899. static CreateLathe(name: string, options: {
  63900. shape: Vector3[];
  63901. radius?: number;
  63902. tessellation?: number;
  63903. clip?: number;
  63904. arc?: number;
  63905. closed?: boolean;
  63906. updatable?: boolean;
  63907. sideOrientation?: number;
  63908. frontUVs?: Vector4;
  63909. backUVs?: Vector4;
  63910. cap?: number;
  63911. invertUV?: boolean;
  63912. }, scene?: Nullable<Scene>): Mesh;
  63913. }
  63914. }
  63915. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  63916. import { Nullable } from "babylonjs/types";
  63917. import { Scene } from "babylonjs/scene";
  63918. import { Vector4 } from "babylonjs/Maths/math.vector";
  63919. import { Mesh } from "babylonjs/Meshes/mesh";
  63920. /**
  63921. * Class containing static functions to help procedurally build meshes
  63922. */
  63923. export class TiledPlaneBuilder {
  63924. /**
  63925. * Creates a tiled plane mesh
  63926. * * The parameter `pattern` will, depending on value, do nothing or
  63927. * * * flip (reflect about central vertical) alternate tiles across and up
  63928. * * * flip every tile on alternate rows
  63929. * * * rotate (180 degs) alternate tiles across and up
  63930. * * * rotate every tile on alternate rows
  63931. * * * flip and rotate alternate tiles across and up
  63932. * * * flip and rotate every tile on alternate rows
  63933. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  63934. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  63935. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63936. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  63937. * * 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)
  63938. * * 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)
  63939. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  63940. * @param name defines the name of the mesh
  63941. * @param options defines the options used to create the mesh
  63942. * @param scene defines the hosting scene
  63943. * @returns the box mesh
  63944. */
  63945. static CreateTiledPlane(name: string, options: {
  63946. pattern?: number;
  63947. tileSize?: number;
  63948. tileWidth?: number;
  63949. tileHeight?: number;
  63950. size?: number;
  63951. width?: number;
  63952. height?: number;
  63953. alignHorizontal?: number;
  63954. alignVertical?: number;
  63955. sideOrientation?: number;
  63956. frontUVs?: Vector4;
  63957. backUVs?: Vector4;
  63958. updatable?: boolean;
  63959. }, scene?: Nullable<Scene>): Mesh;
  63960. }
  63961. }
  63962. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  63963. import { Nullable } from "babylonjs/types";
  63964. import { Scene } from "babylonjs/scene";
  63965. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  63966. import { Mesh } from "babylonjs/Meshes/mesh";
  63967. /**
  63968. * Class containing static functions to help procedurally build meshes
  63969. */
  63970. export class TubeBuilder {
  63971. /**
  63972. * Creates a tube mesh.
  63973. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  63974. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  63975. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  63976. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  63977. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  63978. * * 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)
  63979. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  63980. * * 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
  63981. * * 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
  63982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  63983. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  63984. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  63985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  63986. * @param name defines the name of the mesh
  63987. * @param options defines the options used to create the mesh
  63988. * @param scene defines the hosting scene
  63989. * @returns the tube mesh
  63990. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  63991. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  63992. */
  63993. static CreateTube(name: string, options: {
  63994. path: Vector3[];
  63995. radius?: number;
  63996. tessellation?: number;
  63997. radiusFunction?: {
  63998. (i: number, distance: number): number;
  63999. };
  64000. cap?: number;
  64001. arc?: number;
  64002. updatable?: boolean;
  64003. sideOrientation?: number;
  64004. frontUVs?: Vector4;
  64005. backUVs?: Vector4;
  64006. instance?: Mesh;
  64007. invertUV?: boolean;
  64008. }, scene?: Nullable<Scene>): Mesh;
  64009. }
  64010. }
  64011. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  64012. import { Scene } from "babylonjs/scene";
  64013. import { Vector4 } from "babylonjs/Maths/math.vector";
  64014. import { Mesh } from "babylonjs/Meshes/mesh";
  64015. import { Nullable } from "babylonjs/types";
  64016. /**
  64017. * Class containing static functions to help procedurally build meshes
  64018. */
  64019. export class IcoSphereBuilder {
  64020. /**
  64021. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64022. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64023. * * 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`)
  64024. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64025. * * 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
  64026. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64027. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64028. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64029. * @param name defines the name of the mesh
  64030. * @param options defines the options used to create the mesh
  64031. * @param scene defines the hosting scene
  64032. * @returns the icosahedron mesh
  64033. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64034. */
  64035. static CreateIcoSphere(name: string, options: {
  64036. radius?: number;
  64037. radiusX?: number;
  64038. radiusY?: number;
  64039. radiusZ?: number;
  64040. flat?: boolean;
  64041. subdivisions?: number;
  64042. sideOrientation?: number;
  64043. frontUVs?: Vector4;
  64044. backUVs?: Vector4;
  64045. updatable?: boolean;
  64046. }, scene?: Nullable<Scene>): Mesh;
  64047. }
  64048. }
  64049. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64050. import { Vector3 } from "babylonjs/Maths/math.vector";
  64051. import { Mesh } from "babylonjs/Meshes/mesh";
  64052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64053. /**
  64054. * Class containing static functions to help procedurally build meshes
  64055. */
  64056. export class DecalBuilder {
  64057. /**
  64058. * Creates a decal mesh.
  64059. * 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
  64060. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64061. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64062. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64063. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64064. * @param name defines the name of the mesh
  64065. * @param sourceMesh defines the mesh where the decal must be applied
  64066. * @param options defines the options used to create the mesh
  64067. * @param scene defines the hosting scene
  64068. * @returns the decal mesh
  64069. * @see https://doc.babylonjs.com/how_to/decals
  64070. */
  64071. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64072. position?: Vector3;
  64073. normal?: Vector3;
  64074. size?: Vector3;
  64075. angle?: number;
  64076. }): Mesh;
  64077. }
  64078. }
  64079. declare module "babylonjs/Meshes/meshBuilder" {
  64080. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64081. import { Nullable } from "babylonjs/types";
  64082. import { Scene } from "babylonjs/scene";
  64083. import { Mesh } from "babylonjs/Meshes/mesh";
  64084. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64085. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64086. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64087. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64088. import { Plane } from "babylonjs/Maths/math.plane";
  64089. /**
  64090. * Class containing static functions to help procedurally build meshes
  64091. */
  64092. export class MeshBuilder {
  64093. /**
  64094. * Creates a box mesh
  64095. * * The parameter `size` sets the size (float) of each box side (default 1)
  64096. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64097. * * 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)
  64098. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64099. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64100. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64101. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64102. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64103. * @param name defines the name of the mesh
  64104. * @param options defines the options used to create the mesh
  64105. * @param scene defines the hosting scene
  64106. * @returns the box mesh
  64107. */
  64108. static CreateBox(name: string, options: {
  64109. size?: number;
  64110. width?: number;
  64111. height?: number;
  64112. depth?: number;
  64113. faceUV?: Vector4[];
  64114. faceColors?: Color4[];
  64115. sideOrientation?: number;
  64116. frontUVs?: Vector4;
  64117. backUVs?: Vector4;
  64118. updatable?: boolean;
  64119. }, scene?: Nullable<Scene>): Mesh;
  64120. /**
  64121. * Creates a tiled box mesh
  64122. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64123. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64124. * @param name defines the name of the mesh
  64125. * @param options defines the options used to create the mesh
  64126. * @param scene defines the hosting scene
  64127. * @returns the tiled box mesh
  64128. */
  64129. static CreateTiledBox(name: string, options: {
  64130. pattern?: number;
  64131. size?: number;
  64132. width?: number;
  64133. height?: number;
  64134. depth: number;
  64135. tileSize?: number;
  64136. tileWidth?: number;
  64137. tileHeight?: number;
  64138. faceUV?: Vector4[];
  64139. faceColors?: Color4[];
  64140. alignHorizontal?: number;
  64141. alignVertical?: number;
  64142. sideOrientation?: number;
  64143. updatable?: boolean;
  64144. }, scene?: Nullable<Scene>): Mesh;
  64145. /**
  64146. * Creates a sphere mesh
  64147. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64148. * * 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`)
  64149. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64150. * * 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
  64151. * * 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)
  64152. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64153. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64155. * @param name defines the name of the mesh
  64156. * @param options defines the options used to create the mesh
  64157. * @param scene defines the hosting scene
  64158. * @returns the sphere mesh
  64159. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64160. */
  64161. static CreateSphere(name: string, options: {
  64162. segments?: number;
  64163. diameter?: number;
  64164. diameterX?: number;
  64165. diameterY?: number;
  64166. diameterZ?: number;
  64167. arc?: number;
  64168. slice?: number;
  64169. sideOrientation?: number;
  64170. frontUVs?: Vector4;
  64171. backUVs?: Vector4;
  64172. updatable?: boolean;
  64173. }, scene?: Nullable<Scene>): Mesh;
  64174. /**
  64175. * Creates a plane polygonal mesh. By default, this is a disc
  64176. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64177. * * 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
  64178. * * 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
  64179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64180. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64182. * @param name defines the name of the mesh
  64183. * @param options defines the options used to create the mesh
  64184. * @param scene defines the hosting scene
  64185. * @returns the plane polygonal mesh
  64186. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64187. */
  64188. static CreateDisc(name: string, options: {
  64189. radius?: number;
  64190. tessellation?: number;
  64191. arc?: number;
  64192. updatable?: boolean;
  64193. sideOrientation?: number;
  64194. frontUVs?: Vector4;
  64195. backUVs?: Vector4;
  64196. }, scene?: Nullable<Scene>): Mesh;
  64197. /**
  64198. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64199. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64200. * * 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`)
  64201. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64202. * * 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
  64203. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64204. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64205. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64206. * @param name defines the name of the mesh
  64207. * @param options defines the options used to create the mesh
  64208. * @param scene defines the hosting scene
  64209. * @returns the icosahedron mesh
  64210. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64211. */
  64212. static CreateIcoSphere(name: string, options: {
  64213. radius?: number;
  64214. radiusX?: number;
  64215. radiusY?: number;
  64216. radiusZ?: number;
  64217. flat?: boolean;
  64218. subdivisions?: number;
  64219. sideOrientation?: number;
  64220. frontUVs?: Vector4;
  64221. backUVs?: Vector4;
  64222. updatable?: boolean;
  64223. }, scene?: Nullable<Scene>): Mesh;
  64224. /**
  64225. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64226. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64227. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64228. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64229. * * 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
  64230. * * 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
  64231. * * 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
  64232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64233. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64234. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64235. * * 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
  64236. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64237. * * 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
  64238. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64239. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64240. * @param name defines the name of the mesh
  64241. * @param options defines the options used to create the mesh
  64242. * @param scene defines the hosting scene
  64243. * @returns the ribbon mesh
  64244. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64245. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64246. */
  64247. static CreateRibbon(name: string, options: {
  64248. pathArray: Vector3[][];
  64249. closeArray?: boolean;
  64250. closePath?: boolean;
  64251. offset?: number;
  64252. updatable?: boolean;
  64253. sideOrientation?: number;
  64254. frontUVs?: Vector4;
  64255. backUVs?: Vector4;
  64256. instance?: Mesh;
  64257. invertUV?: boolean;
  64258. uvs?: Vector2[];
  64259. colors?: Color4[];
  64260. }, scene?: Nullable<Scene>): Mesh;
  64261. /**
  64262. * Creates a cylinder or a cone mesh
  64263. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64264. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64265. * * 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.
  64266. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64267. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64268. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64269. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64270. * * 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).
  64271. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64272. * * 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).
  64273. * * 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
  64274. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64275. * * 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
  64276. * * 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.
  64277. * * If `enclose` is false, a ring surface is one element.
  64278. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64279. * * 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
  64280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64281. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64283. * @param name defines the name of the mesh
  64284. * @param options defines the options used to create the mesh
  64285. * @param scene defines the hosting scene
  64286. * @returns the cylinder mesh
  64287. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64288. */
  64289. static CreateCylinder(name: string, options: {
  64290. height?: number;
  64291. diameterTop?: number;
  64292. diameterBottom?: number;
  64293. diameter?: number;
  64294. tessellation?: number;
  64295. subdivisions?: number;
  64296. arc?: number;
  64297. faceColors?: Color4[];
  64298. faceUV?: Vector4[];
  64299. updatable?: boolean;
  64300. hasRings?: boolean;
  64301. enclose?: boolean;
  64302. cap?: number;
  64303. sideOrientation?: number;
  64304. frontUVs?: Vector4;
  64305. backUVs?: Vector4;
  64306. }, scene?: Nullable<Scene>): Mesh;
  64307. /**
  64308. * Creates a torus mesh
  64309. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64310. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64311. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64312. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64313. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64314. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64315. * @param name defines the name of the mesh
  64316. * @param options defines the options used to create the mesh
  64317. * @param scene defines the hosting scene
  64318. * @returns the torus mesh
  64319. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64320. */
  64321. static CreateTorus(name: string, options: {
  64322. diameter?: number;
  64323. thickness?: number;
  64324. tessellation?: number;
  64325. updatable?: boolean;
  64326. sideOrientation?: number;
  64327. frontUVs?: Vector4;
  64328. backUVs?: Vector4;
  64329. }, scene?: Nullable<Scene>): Mesh;
  64330. /**
  64331. * Creates a torus knot mesh
  64332. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64333. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64334. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64335. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64336. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64337. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64338. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64339. * @param name defines the name of the mesh
  64340. * @param options defines the options used to create the mesh
  64341. * @param scene defines the hosting scene
  64342. * @returns the torus knot mesh
  64343. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64344. */
  64345. static CreateTorusKnot(name: string, options: {
  64346. radius?: number;
  64347. tube?: number;
  64348. radialSegments?: number;
  64349. tubularSegments?: number;
  64350. p?: number;
  64351. q?: number;
  64352. updatable?: boolean;
  64353. sideOrientation?: number;
  64354. frontUVs?: Vector4;
  64355. backUVs?: Vector4;
  64356. }, scene?: Nullable<Scene>): Mesh;
  64357. /**
  64358. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64359. * * 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
  64360. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64361. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64362. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64363. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64364. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64365. * * 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
  64366. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64367. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64368. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64369. * @param name defines the name of the new line system
  64370. * @param options defines the options used to create the line system
  64371. * @param scene defines the hosting scene
  64372. * @returns a new line system mesh
  64373. */
  64374. static CreateLineSystem(name: string, options: {
  64375. lines: Vector3[][];
  64376. updatable?: boolean;
  64377. instance?: Nullable<LinesMesh>;
  64378. colors?: Nullable<Color4[][]>;
  64379. useVertexAlpha?: boolean;
  64380. }, scene: Nullable<Scene>): LinesMesh;
  64381. /**
  64382. * Creates a line mesh
  64383. * 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
  64384. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64385. * * The parameter `points` is an array successive Vector3
  64386. * * 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
  64387. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64388. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64389. * * When updating an instance, remember that only point positions can change, not the number of points
  64390. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64391. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64392. * @param name defines the name of the new line system
  64393. * @param options defines the options used to create the line system
  64394. * @param scene defines the hosting scene
  64395. * @returns a new line mesh
  64396. */
  64397. static CreateLines(name: string, options: {
  64398. points: Vector3[];
  64399. updatable?: boolean;
  64400. instance?: Nullable<LinesMesh>;
  64401. colors?: Color4[];
  64402. useVertexAlpha?: boolean;
  64403. }, scene?: Nullable<Scene>): LinesMesh;
  64404. /**
  64405. * Creates a dashed line mesh
  64406. * * 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
  64407. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64408. * * The parameter `points` is an array successive Vector3
  64409. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64410. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64411. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  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. * * When updating an instance, remember that only point positions can change, not the number of points
  64414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64415. * @param name defines the name of the mesh
  64416. * @param options defines the options used to create the mesh
  64417. * @param scene defines the hosting scene
  64418. * @returns the dashed line mesh
  64419. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  64420. */
  64421. static CreateDashedLines(name: string, options: {
  64422. points: Vector3[];
  64423. dashSize?: number;
  64424. gapSize?: number;
  64425. dashNb?: number;
  64426. updatable?: boolean;
  64427. instance?: LinesMesh;
  64428. }, scene?: Nullable<Scene>): LinesMesh;
  64429. /**
  64430. * 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.
  64431. * * 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.
  64432. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64433. * * 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.
  64434. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  64435. * * 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
  64436. * * 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
  64437. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  64438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64439. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64440. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  64441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64442. * @param name defines the name of the mesh
  64443. * @param options defines the options used to create the mesh
  64444. * @param scene defines the hosting scene
  64445. * @returns the extruded shape mesh
  64446. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64447. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64448. */
  64449. static ExtrudeShape(name: string, options: {
  64450. shape: Vector3[];
  64451. path: Vector3[];
  64452. scale?: number;
  64453. rotation?: number;
  64454. cap?: number;
  64455. updatable?: boolean;
  64456. sideOrientation?: number;
  64457. frontUVs?: Vector4;
  64458. backUVs?: Vector4;
  64459. instance?: Mesh;
  64460. invertUV?: boolean;
  64461. }, scene?: Nullable<Scene>): Mesh;
  64462. /**
  64463. * Creates an custom extruded shape mesh.
  64464. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  64465. * * 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.
  64466. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  64467. * * 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
  64468. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  64469. * * 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
  64470. * * It must returns a float value that will be the scale value applied to the shape on each path point
  64471. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  64472. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  64473. * * 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
  64474. * * 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
  64475. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  64476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64477. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64478. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64480. * @param name defines the name of the mesh
  64481. * @param options defines the options used to create the mesh
  64482. * @param scene defines the hosting scene
  64483. * @returns the custom extruded shape mesh
  64484. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  64485. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64486. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  64487. */
  64488. static ExtrudeShapeCustom(name: string, options: {
  64489. shape: Vector3[];
  64490. path: Vector3[];
  64491. scaleFunction?: any;
  64492. rotationFunction?: any;
  64493. ribbonCloseArray?: boolean;
  64494. ribbonClosePath?: boolean;
  64495. cap?: number;
  64496. updatable?: boolean;
  64497. sideOrientation?: number;
  64498. frontUVs?: Vector4;
  64499. backUVs?: Vector4;
  64500. instance?: Mesh;
  64501. invertUV?: boolean;
  64502. }, scene?: Nullable<Scene>): Mesh;
  64503. /**
  64504. * Creates lathe mesh.
  64505. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64506. * * 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
  64507. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64508. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64509. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64510. * * 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
  64511. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64512. * * 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
  64513. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64514. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64515. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64516. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64517. * @param name defines the name of the mesh
  64518. * @param options defines the options used to create the mesh
  64519. * @param scene defines the hosting scene
  64520. * @returns the lathe mesh
  64521. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64522. */
  64523. static CreateLathe(name: string, options: {
  64524. shape: Vector3[];
  64525. radius?: number;
  64526. tessellation?: number;
  64527. clip?: number;
  64528. arc?: number;
  64529. closed?: boolean;
  64530. updatable?: boolean;
  64531. sideOrientation?: number;
  64532. frontUVs?: Vector4;
  64533. backUVs?: Vector4;
  64534. cap?: number;
  64535. invertUV?: boolean;
  64536. }, scene?: Nullable<Scene>): Mesh;
  64537. /**
  64538. * Creates a tiled plane mesh
  64539. * * You can set a limited pattern arrangement with the tiles
  64540. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64541. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  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 plane mesh
  64547. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64548. */
  64549. static CreateTiledPlane(name: string, options: {
  64550. pattern?: number;
  64551. tileSize?: number;
  64552. tileWidth?: number;
  64553. tileHeight?: number;
  64554. size?: number;
  64555. width?: number;
  64556. height?: number;
  64557. alignHorizontal?: number;
  64558. alignVertical?: number;
  64559. sideOrientation?: number;
  64560. frontUVs?: Vector4;
  64561. backUVs?: Vector4;
  64562. updatable?: boolean;
  64563. }, scene?: Nullable<Scene>): Mesh;
  64564. /**
  64565. * Creates a plane mesh
  64566. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  64567. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  64568. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  64569. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64570. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64571. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64572. * @param name defines the name of the mesh
  64573. * @param options defines the options used to create the mesh
  64574. * @param scene defines the hosting scene
  64575. * @returns the plane mesh
  64576. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  64577. */
  64578. static CreatePlane(name: string, options: {
  64579. size?: number;
  64580. width?: number;
  64581. height?: number;
  64582. sideOrientation?: number;
  64583. frontUVs?: Vector4;
  64584. backUVs?: Vector4;
  64585. updatable?: boolean;
  64586. sourcePlane?: Plane;
  64587. }, scene?: Nullable<Scene>): Mesh;
  64588. /**
  64589. * Creates a ground mesh
  64590. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  64591. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  64592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64593. * @param name defines the name of the mesh
  64594. * @param options defines the options used to create the mesh
  64595. * @param scene defines the hosting scene
  64596. * @returns the ground mesh
  64597. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  64598. */
  64599. static CreateGround(name: string, options: {
  64600. width?: number;
  64601. height?: number;
  64602. subdivisions?: number;
  64603. subdivisionsX?: number;
  64604. subdivisionsY?: number;
  64605. updatable?: boolean;
  64606. }, scene?: Nullable<Scene>): Mesh;
  64607. /**
  64608. * Creates a tiled ground mesh
  64609. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  64610. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  64611. * * 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
  64612. * * 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
  64613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64614. * @param name defines the name of the mesh
  64615. * @param options defines the options used to create the mesh
  64616. * @param scene defines the hosting scene
  64617. * @returns the tiled ground mesh
  64618. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  64619. */
  64620. static CreateTiledGround(name: string, options: {
  64621. xmin: number;
  64622. zmin: number;
  64623. xmax: number;
  64624. zmax: number;
  64625. subdivisions?: {
  64626. w: number;
  64627. h: number;
  64628. };
  64629. precision?: {
  64630. w: number;
  64631. h: number;
  64632. };
  64633. updatable?: boolean;
  64634. }, scene?: Nullable<Scene>): Mesh;
  64635. /**
  64636. * Creates a ground mesh from a height map
  64637. * * The parameter `url` sets the URL of the height map image resource.
  64638. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  64639. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  64640. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  64641. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  64642. * * 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.
  64643. * * 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).
  64644. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  64645. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64646. * @param name defines the name of the mesh
  64647. * @param url defines the url to the height map
  64648. * @param options defines the options used to create the mesh
  64649. * @param scene defines the hosting scene
  64650. * @returns the ground mesh
  64651. * @see https://doc.babylonjs.com/babylon101/height_map
  64652. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  64653. */
  64654. static CreateGroundFromHeightMap(name: string, url: string, options: {
  64655. width?: number;
  64656. height?: number;
  64657. subdivisions?: number;
  64658. minHeight?: number;
  64659. maxHeight?: number;
  64660. colorFilter?: Color3;
  64661. alphaFilter?: number;
  64662. updatable?: boolean;
  64663. onReady?: (mesh: GroundMesh) => void;
  64664. }, scene?: Nullable<Scene>): GroundMesh;
  64665. /**
  64666. * Creates a polygon mesh
  64667. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64668. * * 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
  64669. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64671. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64672. * * Remember you can only change the shape positions, not their number when updating a polygon
  64673. * @param name defines the name of the mesh
  64674. * @param options defines the options used to create the mesh
  64675. * @param scene defines the hosting scene
  64676. * @param earcutInjection can be used to inject your own earcut reference
  64677. * @returns the polygon mesh
  64678. */
  64679. static CreatePolygon(name: string, options: {
  64680. shape: Vector3[];
  64681. holes?: Vector3[][];
  64682. depth?: number;
  64683. faceUV?: Vector4[];
  64684. faceColors?: Color4[];
  64685. updatable?: boolean;
  64686. sideOrientation?: number;
  64687. frontUVs?: Vector4;
  64688. backUVs?: Vector4;
  64689. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64690. /**
  64691. * Creates an extruded polygon mesh, with depth in the Y direction.
  64692. * * 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)
  64693. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64694. * @param name defines the name of the mesh
  64695. * @param options defines the options used to create the mesh
  64696. * @param scene defines the hosting scene
  64697. * @param earcutInjection can be used to inject your own earcut reference
  64698. * @returns the polygon mesh
  64699. */
  64700. static ExtrudePolygon(name: string, options: {
  64701. shape: Vector3[];
  64702. holes?: Vector3[][];
  64703. depth?: number;
  64704. faceUV?: Vector4[];
  64705. faceColors?: Color4[];
  64706. updatable?: boolean;
  64707. sideOrientation?: number;
  64708. frontUVs?: Vector4;
  64709. backUVs?: Vector4;
  64710. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64711. /**
  64712. * Creates a tube mesh.
  64713. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64714. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64715. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64716. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64717. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64718. * * 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)
  64719. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64720. * * 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
  64721. * * 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
  64722. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64723. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64724. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64725. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64726. * @param name defines the name of the mesh
  64727. * @param options defines the options used to create the mesh
  64728. * @param scene defines the hosting scene
  64729. * @returns the tube mesh
  64730. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64731. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64732. */
  64733. static CreateTube(name: string, options: {
  64734. path: Vector3[];
  64735. radius?: number;
  64736. tessellation?: number;
  64737. radiusFunction?: {
  64738. (i: number, distance: number): number;
  64739. };
  64740. cap?: number;
  64741. arc?: number;
  64742. updatable?: boolean;
  64743. sideOrientation?: number;
  64744. frontUVs?: Vector4;
  64745. backUVs?: Vector4;
  64746. instance?: Mesh;
  64747. invertUV?: boolean;
  64748. }, scene?: Nullable<Scene>): Mesh;
  64749. /**
  64750. * Creates a polyhedron mesh
  64751. * * 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
  64752. * * The parameter `size` (positive float, default 1) sets the polygon size
  64753. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  64754. * * 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`
  64755. * * 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
  64756. * * 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)`)
  64757. * * 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
  64758. * * 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
  64759. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64760. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64762. * @param name defines the name of the mesh
  64763. * @param options defines the options used to create the mesh
  64764. * @param scene defines the hosting scene
  64765. * @returns the polyhedron mesh
  64766. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  64767. */
  64768. static CreatePolyhedron(name: string, options: {
  64769. type?: number;
  64770. size?: number;
  64771. sizeX?: number;
  64772. sizeY?: number;
  64773. sizeZ?: number;
  64774. custom?: any;
  64775. faceUV?: Vector4[];
  64776. faceColors?: Color4[];
  64777. flat?: boolean;
  64778. updatable?: boolean;
  64779. sideOrientation?: number;
  64780. frontUVs?: Vector4;
  64781. backUVs?: Vector4;
  64782. }, scene?: Nullable<Scene>): Mesh;
  64783. /**
  64784. * Creates a decal mesh.
  64785. * 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
  64786. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64787. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64788. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64789. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64790. * @param name defines the name of the mesh
  64791. * @param sourceMesh defines the mesh where the decal must be applied
  64792. * @param options defines the options used to create the mesh
  64793. * @param scene defines the hosting scene
  64794. * @returns the decal mesh
  64795. * @see https://doc.babylonjs.com/how_to/decals
  64796. */
  64797. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64798. position?: Vector3;
  64799. normal?: Vector3;
  64800. size?: Vector3;
  64801. angle?: number;
  64802. }): Mesh;
  64803. }
  64804. }
  64805. declare module "babylonjs/Meshes/meshSimplification" {
  64806. import { Mesh } from "babylonjs/Meshes/mesh";
  64807. /**
  64808. * A simplifier interface for future simplification implementations
  64809. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64810. */
  64811. export interface ISimplifier {
  64812. /**
  64813. * Simplification of a given mesh according to the given settings.
  64814. * Since this requires computation, it is assumed that the function runs async.
  64815. * @param settings The settings of the simplification, including quality and distance
  64816. * @param successCallback A callback that will be called after the mesh was simplified.
  64817. * @param errorCallback in case of an error, this callback will be called. optional.
  64818. */
  64819. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  64820. }
  64821. /**
  64822. * Expected simplification settings.
  64823. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  64824. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64825. */
  64826. export interface ISimplificationSettings {
  64827. /**
  64828. * Gets or sets the expected quality
  64829. */
  64830. quality: number;
  64831. /**
  64832. * Gets or sets the distance when this optimized version should be used
  64833. */
  64834. distance: number;
  64835. /**
  64836. * Gets an already optimized mesh
  64837. */
  64838. optimizeMesh?: boolean;
  64839. }
  64840. /**
  64841. * Class used to specify simplification options
  64842. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64843. */
  64844. export class SimplificationSettings implements ISimplificationSettings {
  64845. /** expected quality */
  64846. quality: number;
  64847. /** distance when this optimized version should be used */
  64848. distance: number;
  64849. /** already optimized mesh */
  64850. optimizeMesh?: boolean | undefined;
  64851. /**
  64852. * Creates a SimplificationSettings
  64853. * @param quality expected quality
  64854. * @param distance distance when this optimized version should be used
  64855. * @param optimizeMesh already optimized mesh
  64856. */
  64857. constructor(
  64858. /** expected quality */
  64859. quality: number,
  64860. /** distance when this optimized version should be used */
  64861. distance: number,
  64862. /** already optimized mesh */
  64863. optimizeMesh?: boolean | undefined);
  64864. }
  64865. /**
  64866. * Interface used to define a simplification task
  64867. */
  64868. export interface ISimplificationTask {
  64869. /**
  64870. * Array of settings
  64871. */
  64872. settings: Array<ISimplificationSettings>;
  64873. /**
  64874. * Simplification type
  64875. */
  64876. simplificationType: SimplificationType;
  64877. /**
  64878. * Mesh to simplify
  64879. */
  64880. mesh: Mesh;
  64881. /**
  64882. * Callback called on success
  64883. */
  64884. successCallback?: () => void;
  64885. /**
  64886. * Defines if parallel processing can be used
  64887. */
  64888. parallelProcessing: boolean;
  64889. }
  64890. /**
  64891. * Queue used to order the simplification tasks
  64892. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64893. */
  64894. export class SimplificationQueue {
  64895. private _simplificationArray;
  64896. /**
  64897. * Gets a boolean indicating that the process is still running
  64898. */
  64899. running: boolean;
  64900. /**
  64901. * Creates a new queue
  64902. */
  64903. constructor();
  64904. /**
  64905. * Adds a new simplification task
  64906. * @param task defines a task to add
  64907. */
  64908. addTask(task: ISimplificationTask): void;
  64909. /**
  64910. * Execute next task
  64911. */
  64912. executeNext(): void;
  64913. /**
  64914. * Execute a simplification task
  64915. * @param task defines the task to run
  64916. */
  64917. runSimplification(task: ISimplificationTask): void;
  64918. private getSimplifier;
  64919. }
  64920. /**
  64921. * The implemented types of simplification
  64922. * At the moment only Quadratic Error Decimation is implemented
  64923. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64924. */
  64925. export enum SimplificationType {
  64926. /** Quadratic error decimation */
  64927. QUADRATIC = 0
  64928. }
  64929. }
  64930. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  64931. import { Scene } from "babylonjs/scene";
  64932. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  64933. import { ISceneComponent } from "babylonjs/sceneComponent";
  64934. module "babylonjs/scene" {
  64935. interface Scene {
  64936. /** @hidden (Backing field) */
  64937. _simplificationQueue: SimplificationQueue;
  64938. /**
  64939. * Gets or sets the simplification queue attached to the scene
  64940. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  64941. */
  64942. simplificationQueue: SimplificationQueue;
  64943. }
  64944. }
  64945. module "babylonjs/Meshes/mesh" {
  64946. interface Mesh {
  64947. /**
  64948. * Simplify the mesh according to the given array of settings.
  64949. * Function will return immediately and will simplify async
  64950. * @param settings a collection of simplification settings
  64951. * @param parallelProcessing should all levels calculate parallel or one after the other
  64952. * @param simplificationType the type of simplification to run
  64953. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  64954. * @returns the current mesh
  64955. */
  64956. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  64957. }
  64958. }
  64959. /**
  64960. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  64961. * created in a scene
  64962. */
  64963. export class SimplicationQueueSceneComponent implements ISceneComponent {
  64964. /**
  64965. * The component name helpfull to identify the component in the list of scene components.
  64966. */
  64967. readonly name: string;
  64968. /**
  64969. * The scene the component belongs to.
  64970. */
  64971. scene: Scene;
  64972. /**
  64973. * Creates a new instance of the component for the given scene
  64974. * @param scene Defines the scene to register the component in
  64975. */
  64976. constructor(scene: Scene);
  64977. /**
  64978. * Registers the component in a given scene
  64979. */
  64980. register(): void;
  64981. /**
  64982. * Rebuilds the elements related to this component in case of
  64983. * context lost for instance.
  64984. */
  64985. rebuild(): void;
  64986. /**
  64987. * Disposes the component and the associated ressources
  64988. */
  64989. dispose(): void;
  64990. private _beforeCameraUpdate;
  64991. }
  64992. }
  64993. declare module "babylonjs/Meshes/Builders/index" {
  64994. export * from "babylonjs/Meshes/Builders/boxBuilder";
  64995. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  64996. export * from "babylonjs/Meshes/Builders/discBuilder";
  64997. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  64998. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  64999. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  65000. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  65001. export * from "babylonjs/Meshes/Builders/torusBuilder";
  65002. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  65003. export * from "babylonjs/Meshes/Builders/linesBuilder";
  65004. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  65005. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  65006. export * from "babylonjs/Meshes/Builders/latheBuilder";
  65007. export * from "babylonjs/Meshes/Builders/planeBuilder";
  65008. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  65009. export * from "babylonjs/Meshes/Builders/groundBuilder";
  65010. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  65011. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  65012. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  65013. export * from "babylonjs/Meshes/Builders/decalBuilder";
  65014. }
  65015. declare module "babylonjs/Meshes/index" {
  65016. export * from "babylonjs/Meshes/abstractMesh";
  65017. export * from "babylonjs/Meshes/buffer";
  65018. export * from "babylonjs/Meshes/Compression/index";
  65019. export * from "babylonjs/Meshes/csg";
  65020. export * from "babylonjs/Meshes/geometry";
  65021. export * from "babylonjs/Meshes/groundMesh";
  65022. export * from "babylonjs/Meshes/trailMesh";
  65023. export * from "babylonjs/Meshes/instancedMesh";
  65024. export * from "babylonjs/Meshes/linesMesh";
  65025. export * from "babylonjs/Meshes/mesh";
  65026. export * from "babylonjs/Meshes/mesh.vertexData";
  65027. export * from "babylonjs/Meshes/meshBuilder";
  65028. export * from "babylonjs/Meshes/meshSimplification";
  65029. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  65030. export * from "babylonjs/Meshes/polygonMesh";
  65031. export * from "babylonjs/Meshes/subMesh";
  65032. export * from "babylonjs/Meshes/meshLODLevel";
  65033. export * from "babylonjs/Meshes/transformNode";
  65034. export * from "babylonjs/Meshes/Builders/index";
  65035. export * from "babylonjs/Meshes/dataBuffer";
  65036. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  65037. }
  65038. declare module "babylonjs/Morph/index" {
  65039. export * from "babylonjs/Morph/morphTarget";
  65040. export * from "babylonjs/Morph/morphTargetManager";
  65041. }
  65042. declare module "babylonjs/Navigation/INavigationEngine" {
  65043. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65044. import { Vector3 } from "babylonjs/Maths/math";
  65045. import { Mesh } from "babylonjs/Meshes/mesh";
  65046. import { Scene } from "babylonjs/scene";
  65047. /**
  65048. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65049. */
  65050. export interface INavigationEnginePlugin {
  65051. /**
  65052. * plugin name
  65053. */
  65054. name: string;
  65055. /**
  65056. * Creates a navigation mesh
  65057. * @param meshes array of all the geometry used to compute the navigatio mesh
  65058. * @param parameters bunch of parameters used to filter geometry
  65059. */
  65060. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65061. /**
  65062. * Create a navigation mesh debug mesh
  65063. * @param scene is where the mesh will be added
  65064. * @returns debug display mesh
  65065. */
  65066. createDebugNavMesh(scene: Scene): Mesh;
  65067. /**
  65068. * Get a navigation mesh constrained position, closest to the parameter position
  65069. * @param position world position
  65070. * @returns the closest point to position constrained by the navigation mesh
  65071. */
  65072. getClosestPoint(position: Vector3): Vector3;
  65073. /**
  65074. * Get a navigation mesh constrained position, within a particular radius
  65075. * @param position world position
  65076. * @param maxRadius the maximum distance to the constrained world position
  65077. * @returns the closest point to position constrained by the navigation mesh
  65078. */
  65079. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65080. /**
  65081. * Compute the final position from a segment made of destination-position
  65082. * @param position world position
  65083. * @param destination world position
  65084. * @returns the resulting point along the navmesh
  65085. */
  65086. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65087. /**
  65088. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65089. * @param start world position
  65090. * @param end world position
  65091. * @returns array containing world position composing the path
  65092. */
  65093. computePath(start: Vector3, end: Vector3): Vector3[];
  65094. /**
  65095. * If this plugin is supported
  65096. * @returns true if plugin is supported
  65097. */
  65098. isSupported(): boolean;
  65099. /**
  65100. * Create a new Crowd so you can add agents
  65101. * @param maxAgents the maximum agent count in the crowd
  65102. * @param maxAgentRadius the maximum radius an agent can have
  65103. * @param scene to attach the crowd to
  65104. * @returns the crowd you can add agents to
  65105. */
  65106. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65107. /**
  65108. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65109. * The queries will try to find a solution within those bounds
  65110. * default is (1,1,1)
  65111. * @param extent x,y,z value that define the extent around the queries point of reference
  65112. */
  65113. setDefaultQueryExtent(extent: Vector3): void;
  65114. /**
  65115. * Get the Bounding box extent specified by setDefaultQueryExtent
  65116. * @returns the box extent values
  65117. */
  65118. getDefaultQueryExtent(): Vector3;
  65119. /**
  65120. * Release all resources
  65121. */
  65122. dispose(): void;
  65123. }
  65124. /**
  65125. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65126. */
  65127. export interface ICrowd {
  65128. /**
  65129. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65130. * You can attach anything to that node. The node position is updated in the scene update tick.
  65131. * @param pos world position that will be constrained by the navigation mesh
  65132. * @param parameters agent parameters
  65133. * @param transform hooked to the agent that will be update by the scene
  65134. * @returns agent index
  65135. */
  65136. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65137. /**
  65138. * Returns the agent position in world space
  65139. * @param index agent index returned by addAgent
  65140. * @returns world space position
  65141. */
  65142. getAgentPosition(index: number): Vector3;
  65143. /**
  65144. * Gets the agent velocity in world space
  65145. * @param index agent index returned by addAgent
  65146. * @returns world space velocity
  65147. */
  65148. getAgentVelocity(index: number): Vector3;
  65149. /**
  65150. * remove a particular agent previously created
  65151. * @param index agent index returned by addAgent
  65152. */
  65153. removeAgent(index: number): void;
  65154. /**
  65155. * get the list of all agents attached to this crowd
  65156. * @returns list of agent indices
  65157. */
  65158. getAgents(): number[];
  65159. /**
  65160. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65161. * @param deltaTime in seconds
  65162. */
  65163. update(deltaTime: number): void;
  65164. /**
  65165. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65166. * @param index agent index returned by addAgent
  65167. * @param destination targeted world position
  65168. */
  65169. agentGoto(index: number, destination: Vector3): void;
  65170. /**
  65171. * Teleport the agent to a new position
  65172. * @param index agent index returned by addAgent
  65173. * @param destination targeted world position
  65174. */
  65175. agentTeleport(index: number, destination: Vector3): void;
  65176. /**
  65177. * Update agent parameters
  65178. * @param index agent index returned by addAgent
  65179. * @param parameters agent parameters
  65180. */
  65181. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65182. /**
  65183. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65184. * The queries will try to find a solution within those bounds
  65185. * default is (1,1,1)
  65186. * @param extent x,y,z value that define the extent around the queries point of reference
  65187. */
  65188. setDefaultQueryExtent(extent: Vector3): void;
  65189. /**
  65190. * Get the Bounding box extent specified by setDefaultQueryExtent
  65191. * @returns the box extent values
  65192. */
  65193. getDefaultQueryExtent(): Vector3;
  65194. /**
  65195. * Release all resources
  65196. */
  65197. dispose(): void;
  65198. }
  65199. /**
  65200. * Configures an agent
  65201. */
  65202. export interface IAgentParameters {
  65203. /**
  65204. * Agent radius. [Limit: >= 0]
  65205. */
  65206. radius: number;
  65207. /**
  65208. * Agent height. [Limit: > 0]
  65209. */
  65210. height: number;
  65211. /**
  65212. * Maximum allowed acceleration. [Limit: >= 0]
  65213. */
  65214. maxAcceleration: number;
  65215. /**
  65216. * Maximum allowed speed. [Limit: >= 0]
  65217. */
  65218. maxSpeed: number;
  65219. /**
  65220. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65221. */
  65222. collisionQueryRange: number;
  65223. /**
  65224. * The path visibility optimization range. [Limit: > 0]
  65225. */
  65226. pathOptimizationRange: number;
  65227. /**
  65228. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65229. */
  65230. separationWeight: number;
  65231. }
  65232. /**
  65233. * Configures the navigation mesh creation
  65234. */
  65235. export interface INavMeshParameters {
  65236. /**
  65237. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65238. */
  65239. cs: number;
  65240. /**
  65241. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65242. */
  65243. ch: number;
  65244. /**
  65245. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65246. */
  65247. walkableSlopeAngle: number;
  65248. /**
  65249. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65250. * be considered walkable. [Limit: >= 3] [Units: vx]
  65251. */
  65252. walkableHeight: number;
  65253. /**
  65254. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65255. */
  65256. walkableClimb: number;
  65257. /**
  65258. * The distance to erode/shrink the walkable area of the heightfield away from
  65259. * obstructions. [Limit: >=0] [Units: vx]
  65260. */
  65261. walkableRadius: number;
  65262. /**
  65263. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65264. */
  65265. maxEdgeLen: number;
  65266. /**
  65267. * The maximum distance a simplfied contour's border edges should deviate
  65268. * the original raw contour. [Limit: >=0] [Units: vx]
  65269. */
  65270. maxSimplificationError: number;
  65271. /**
  65272. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65273. */
  65274. minRegionArea: number;
  65275. /**
  65276. * Any regions with a span count smaller than this value will, if possible,
  65277. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65278. */
  65279. mergeRegionArea: number;
  65280. /**
  65281. * The maximum number of vertices allowed for polygons generated during the
  65282. * contour to polygon conversion process. [Limit: >= 3]
  65283. */
  65284. maxVertsPerPoly: number;
  65285. /**
  65286. * Sets the sampling distance to use when generating the detail mesh.
  65287. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65288. */
  65289. detailSampleDist: number;
  65290. /**
  65291. * The maximum distance the detail mesh surface should deviate from heightfield
  65292. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65293. */
  65294. detailSampleMaxError: number;
  65295. }
  65296. }
  65297. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65298. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65299. import { Mesh } from "babylonjs/Meshes/mesh";
  65300. import { Scene } from "babylonjs/scene";
  65301. import { Vector3 } from "babylonjs/Maths/math";
  65302. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65303. /**
  65304. * RecastJS navigation plugin
  65305. */
  65306. export class RecastJSPlugin implements INavigationEnginePlugin {
  65307. /**
  65308. * Reference to the Recast library
  65309. */
  65310. bjsRECAST: any;
  65311. /**
  65312. * plugin name
  65313. */
  65314. name: string;
  65315. /**
  65316. * the first navmesh created. We might extend this to support multiple navmeshes
  65317. */
  65318. navMesh: any;
  65319. /**
  65320. * Initializes the recastJS plugin
  65321. * @param recastInjection can be used to inject your own recast reference
  65322. */
  65323. constructor(recastInjection?: any);
  65324. /**
  65325. * Creates a navigation mesh
  65326. * @param meshes array of all the geometry used to compute the navigatio mesh
  65327. * @param parameters bunch of parameters used to filter geometry
  65328. */
  65329. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65330. /**
  65331. * Create a navigation mesh debug mesh
  65332. * @param scene is where the mesh will be added
  65333. * @returns debug display mesh
  65334. */
  65335. createDebugNavMesh(scene: Scene): Mesh;
  65336. /**
  65337. * Get a navigation mesh constrained position, closest to the parameter position
  65338. * @param position world position
  65339. * @returns the closest point to position constrained by the navigation mesh
  65340. */
  65341. getClosestPoint(position: Vector3): Vector3;
  65342. /**
  65343. * Get a navigation mesh constrained position, within a particular radius
  65344. * @param position world position
  65345. * @param maxRadius the maximum distance to the constrained world position
  65346. * @returns the closest point to position constrained by the navigation mesh
  65347. */
  65348. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65349. /**
  65350. * Compute the final position from a segment made of destination-position
  65351. * @param position world position
  65352. * @param destination world position
  65353. * @returns the resulting point along the navmesh
  65354. */
  65355. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65356. /**
  65357. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65358. * @param start world position
  65359. * @param end world position
  65360. * @returns array containing world position composing the path
  65361. */
  65362. computePath(start: Vector3, end: Vector3): Vector3[];
  65363. /**
  65364. * Create a new Crowd so you can add agents
  65365. * @param maxAgents the maximum agent count in the crowd
  65366. * @param maxAgentRadius the maximum radius an agent can have
  65367. * @param scene to attach the crowd to
  65368. * @returns the crowd you can add agents to
  65369. */
  65370. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65371. /**
  65372. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65373. * The queries will try to find a solution within those bounds
  65374. * default is (1,1,1)
  65375. * @param extent x,y,z value that define the extent around the queries point of reference
  65376. */
  65377. setDefaultQueryExtent(extent: Vector3): void;
  65378. /**
  65379. * Get the Bounding box extent specified by setDefaultQueryExtent
  65380. * @returns the box extent values
  65381. */
  65382. getDefaultQueryExtent(): Vector3;
  65383. /**
  65384. * Disposes
  65385. */
  65386. dispose(): void;
  65387. /**
  65388. * If this plugin is supported
  65389. * @returns true if plugin is supported
  65390. */
  65391. isSupported(): boolean;
  65392. }
  65393. /**
  65394. * Recast detour crowd implementation
  65395. */
  65396. export class RecastJSCrowd implements ICrowd {
  65397. /**
  65398. * Recast/detour plugin
  65399. */
  65400. bjsRECASTPlugin: RecastJSPlugin;
  65401. /**
  65402. * Link to the detour crowd
  65403. */
  65404. recastCrowd: any;
  65405. /**
  65406. * One transform per agent
  65407. */
  65408. transforms: TransformNode[];
  65409. /**
  65410. * All agents created
  65411. */
  65412. agents: number[];
  65413. /**
  65414. * Link to the scene is kept to unregister the crowd from the scene
  65415. */
  65416. private _scene;
  65417. /**
  65418. * Observer for crowd updates
  65419. */
  65420. private _onBeforeAnimationsObserver;
  65421. /**
  65422. * Constructor
  65423. * @param plugin recastJS plugin
  65424. * @param maxAgents the maximum agent count in the crowd
  65425. * @param maxAgentRadius the maximum radius an agent can have
  65426. * @param scene to attach the crowd to
  65427. * @returns the crowd you can add agents to
  65428. */
  65429. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  65430. /**
  65431. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65432. * You can attach anything to that node. The node position is updated in the scene update tick.
  65433. * @param pos world position that will be constrained by the navigation mesh
  65434. * @param parameters agent parameters
  65435. * @param transform hooked to the agent that will be update by the scene
  65436. * @returns agent index
  65437. */
  65438. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65439. /**
  65440. * Returns the agent position in world space
  65441. * @param index agent index returned by addAgent
  65442. * @returns world space position
  65443. */
  65444. getAgentPosition(index: number): Vector3;
  65445. /**
  65446. * Returns the agent velocity in world space
  65447. * @param index agent index returned by addAgent
  65448. * @returns world space velocity
  65449. */
  65450. getAgentVelocity(index: number): Vector3;
  65451. /**
  65452. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65453. * @param index agent index returned by addAgent
  65454. * @param destination targeted world position
  65455. */
  65456. agentGoto(index: number, destination: Vector3): void;
  65457. /**
  65458. * Teleport the agent to a new position
  65459. * @param index agent index returned by addAgent
  65460. * @param destination targeted world position
  65461. */
  65462. agentTeleport(index: number, destination: Vector3): void;
  65463. /**
  65464. * Update agent parameters
  65465. * @param index agent index returned by addAgent
  65466. * @param parameters agent parameters
  65467. */
  65468. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65469. /**
  65470. * remove a particular agent previously created
  65471. * @param index agent index returned by addAgent
  65472. */
  65473. removeAgent(index: number): void;
  65474. /**
  65475. * get the list of all agents attached to this crowd
  65476. * @returns list of agent indices
  65477. */
  65478. getAgents(): number[];
  65479. /**
  65480. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65481. * @param deltaTime in seconds
  65482. */
  65483. update(deltaTime: number): void;
  65484. /**
  65485. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65486. * The queries will try to find a solution within those bounds
  65487. * default is (1,1,1)
  65488. * @param extent x,y,z value that define the extent around the queries point of reference
  65489. */
  65490. setDefaultQueryExtent(extent: Vector3): void;
  65491. /**
  65492. * Get the Bounding box extent specified by setDefaultQueryExtent
  65493. * @returns the box extent values
  65494. */
  65495. getDefaultQueryExtent(): Vector3;
  65496. /**
  65497. * Release all resources
  65498. */
  65499. dispose(): void;
  65500. }
  65501. }
  65502. declare module "babylonjs/Navigation/Plugins/index" {
  65503. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  65504. }
  65505. declare module "babylonjs/Navigation/index" {
  65506. export * from "babylonjs/Navigation/INavigationEngine";
  65507. export * from "babylonjs/Navigation/Plugins/index";
  65508. }
  65509. declare module "babylonjs/Offline/database" {
  65510. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  65511. /**
  65512. * Class used to enable access to IndexedDB
  65513. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  65514. */
  65515. export class Database implements IOfflineProvider {
  65516. private _callbackManifestChecked;
  65517. private _currentSceneUrl;
  65518. private _db;
  65519. private _enableSceneOffline;
  65520. private _enableTexturesOffline;
  65521. private _manifestVersionFound;
  65522. private _mustUpdateRessources;
  65523. private _hasReachedQuota;
  65524. private _isSupported;
  65525. private _idbFactory;
  65526. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  65527. private static IsUASupportingBlobStorage;
  65528. /**
  65529. * Gets a boolean indicating if Database storate is enabled (off by default)
  65530. */
  65531. static IDBStorageEnabled: boolean;
  65532. /**
  65533. * Gets a boolean indicating if scene must be saved in the database
  65534. */
  65535. get enableSceneOffline(): boolean;
  65536. /**
  65537. * Gets a boolean indicating if textures must be saved in the database
  65538. */
  65539. get enableTexturesOffline(): boolean;
  65540. /**
  65541. * Creates a new Database
  65542. * @param urlToScene defines the url to load the scene
  65543. * @param callbackManifestChecked defines the callback to use when manifest is checked
  65544. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  65545. */
  65546. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  65547. private static _ParseURL;
  65548. private static _ReturnFullUrlLocation;
  65549. private _checkManifestFile;
  65550. /**
  65551. * Open the database and make it available
  65552. * @param successCallback defines the callback to call on success
  65553. * @param errorCallback defines the callback to call on error
  65554. */
  65555. open(successCallback: () => void, errorCallback: () => void): void;
  65556. /**
  65557. * Loads an image from the database
  65558. * @param url defines the url to load from
  65559. * @param image defines the target DOM image
  65560. */
  65561. loadImage(url: string, image: HTMLImageElement): void;
  65562. private _loadImageFromDBAsync;
  65563. private _saveImageIntoDBAsync;
  65564. private _checkVersionFromDB;
  65565. private _loadVersionFromDBAsync;
  65566. private _saveVersionIntoDBAsync;
  65567. /**
  65568. * Loads a file from database
  65569. * @param url defines the URL to load from
  65570. * @param sceneLoaded defines a callback to call on success
  65571. * @param progressCallBack defines a callback to call when progress changed
  65572. * @param errorCallback defines a callback to call on error
  65573. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  65574. */
  65575. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  65576. private _loadFileAsync;
  65577. private _saveFileAsync;
  65578. /**
  65579. * Validates if xhr data is correct
  65580. * @param xhr defines the request to validate
  65581. * @param dataType defines the expected data type
  65582. * @returns true if data is correct
  65583. */
  65584. private static _ValidateXHRData;
  65585. }
  65586. }
  65587. declare module "babylonjs/Offline/index" {
  65588. export * from "babylonjs/Offline/database";
  65589. export * from "babylonjs/Offline/IOfflineProvider";
  65590. }
  65591. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  65592. /** @hidden */
  65593. export var gpuUpdateParticlesPixelShader: {
  65594. name: string;
  65595. shader: string;
  65596. };
  65597. }
  65598. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  65599. /** @hidden */
  65600. export var gpuUpdateParticlesVertexShader: {
  65601. name: string;
  65602. shader: string;
  65603. };
  65604. }
  65605. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  65606. /** @hidden */
  65607. export var clipPlaneFragmentDeclaration2: {
  65608. name: string;
  65609. shader: string;
  65610. };
  65611. }
  65612. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  65613. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  65614. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65615. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65616. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65617. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  65618. /** @hidden */
  65619. export var gpuRenderParticlesPixelShader: {
  65620. name: string;
  65621. shader: string;
  65622. };
  65623. }
  65624. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  65625. /** @hidden */
  65626. export var clipPlaneVertexDeclaration2: {
  65627. name: string;
  65628. shader: string;
  65629. };
  65630. }
  65631. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  65632. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  65633. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  65634. /** @hidden */
  65635. export var gpuRenderParticlesVertexShader: {
  65636. name: string;
  65637. shader: string;
  65638. };
  65639. }
  65640. declare module "babylonjs/Particles/gpuParticleSystem" {
  65641. import { Nullable } from "babylonjs/types";
  65642. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  65643. import { Observable } from "babylonjs/Misc/observable";
  65644. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  65645. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  65646. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  65647. import { Scene, IDisposable } from "babylonjs/scene";
  65648. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  65649. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  65650. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  65651. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  65652. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  65653. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  65654. /**
  65655. * This represents a GPU particle system in Babylon
  65656. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  65657. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  65658. */
  65659. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  65660. /**
  65661. * The layer mask we are rendering the particles through.
  65662. */
  65663. layerMask: number;
  65664. private _capacity;
  65665. private _activeCount;
  65666. private _currentActiveCount;
  65667. private _accumulatedCount;
  65668. private _renderEffect;
  65669. private _updateEffect;
  65670. private _buffer0;
  65671. private _buffer1;
  65672. private _spriteBuffer;
  65673. private _updateVAO;
  65674. private _renderVAO;
  65675. private _targetIndex;
  65676. private _sourceBuffer;
  65677. private _targetBuffer;
  65678. private _engine;
  65679. private _currentRenderId;
  65680. private _started;
  65681. private _stopped;
  65682. private _timeDelta;
  65683. private _randomTexture;
  65684. private _randomTexture2;
  65685. private _attributesStrideSize;
  65686. private _updateEffectOptions;
  65687. private _randomTextureSize;
  65688. private _actualFrame;
  65689. private readonly _rawTextureWidth;
  65690. /**
  65691. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  65692. */
  65693. static get IsSupported(): boolean;
  65694. /**
  65695. * An event triggered when the system is disposed.
  65696. */
  65697. onDisposeObservable: Observable<GPUParticleSystem>;
  65698. /**
  65699. * Gets the maximum number of particles active at the same time.
  65700. * @returns The max number of active particles.
  65701. */
  65702. getCapacity(): number;
  65703. /**
  65704. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  65705. * to override the particles.
  65706. */
  65707. forceDepthWrite: boolean;
  65708. /**
  65709. * Gets or set the number of active particles
  65710. */
  65711. get activeParticleCount(): number;
  65712. set activeParticleCount(value: number);
  65713. private _preWarmDone;
  65714. /**
  65715. * Is this system ready to be used/rendered
  65716. * @return true if the system is ready
  65717. */
  65718. isReady(): boolean;
  65719. /**
  65720. * Gets if the system has been started. (Note: this will still be true after stop is called)
  65721. * @returns True if it has been started, otherwise false.
  65722. */
  65723. isStarted(): boolean;
  65724. /**
  65725. * Starts the particle system and begins to emit
  65726. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  65727. */
  65728. start(delay?: number): void;
  65729. /**
  65730. * Stops the particle system.
  65731. */
  65732. stop(): void;
  65733. /**
  65734. * Remove all active particles
  65735. */
  65736. reset(): void;
  65737. /**
  65738. * Returns the string "GPUParticleSystem"
  65739. * @returns a string containing the class name
  65740. */
  65741. getClassName(): string;
  65742. private _colorGradientsTexture;
  65743. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  65744. /**
  65745. * Adds a new color gradient
  65746. * @param gradient defines the gradient to use (between 0 and 1)
  65747. * @param color1 defines the color to affect to the specified gradient
  65748. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  65749. * @returns the current particle system
  65750. */
  65751. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  65752. /**
  65753. * Remove a specific color gradient
  65754. * @param gradient defines the gradient to remove
  65755. * @returns the current particle system
  65756. */
  65757. removeColorGradient(gradient: number): GPUParticleSystem;
  65758. private _angularSpeedGradientsTexture;
  65759. private _sizeGradientsTexture;
  65760. private _velocityGradientsTexture;
  65761. private _limitVelocityGradientsTexture;
  65762. private _dragGradientsTexture;
  65763. private _addFactorGradient;
  65764. /**
  65765. * Adds a new size gradient
  65766. * @param gradient defines the gradient to use (between 0 and 1)
  65767. * @param factor defines the size factor to affect to the specified gradient
  65768. * @returns the current particle system
  65769. */
  65770. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  65771. /**
  65772. * Remove a specific size gradient
  65773. * @param gradient defines the gradient to remove
  65774. * @returns the current particle system
  65775. */
  65776. removeSizeGradient(gradient: number): GPUParticleSystem;
  65777. /**
  65778. * Adds a new angular speed gradient
  65779. * @param gradient defines the gradient to use (between 0 and 1)
  65780. * @param factor defines the angular speed to affect to the specified gradient
  65781. * @returns the current particle system
  65782. */
  65783. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  65784. /**
  65785. * Remove a specific angular speed gradient
  65786. * @param gradient defines the gradient to remove
  65787. * @returns the current particle system
  65788. */
  65789. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  65790. /**
  65791. * Adds a new velocity gradient
  65792. * @param gradient defines the gradient to use (between 0 and 1)
  65793. * @param factor defines the velocity to affect to the specified gradient
  65794. * @returns the current particle system
  65795. */
  65796. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65797. /**
  65798. * Remove a specific velocity gradient
  65799. * @param gradient defines the gradient to remove
  65800. * @returns the current particle system
  65801. */
  65802. removeVelocityGradient(gradient: number): GPUParticleSystem;
  65803. /**
  65804. * Adds a new limit velocity gradient
  65805. * @param gradient defines the gradient to use (between 0 and 1)
  65806. * @param factor defines the limit velocity value to affect to the specified gradient
  65807. * @returns the current particle system
  65808. */
  65809. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  65810. /**
  65811. * Remove a specific limit velocity gradient
  65812. * @param gradient defines the gradient to remove
  65813. * @returns the current particle system
  65814. */
  65815. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  65816. /**
  65817. * Adds a new drag gradient
  65818. * @param gradient defines the gradient to use (between 0 and 1)
  65819. * @param factor defines the drag value to affect to the specified gradient
  65820. * @returns the current particle system
  65821. */
  65822. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  65823. /**
  65824. * Remove a specific drag gradient
  65825. * @param gradient defines the gradient to remove
  65826. * @returns the current particle system
  65827. */
  65828. removeDragGradient(gradient: number): GPUParticleSystem;
  65829. /**
  65830. * Not supported by GPUParticleSystem
  65831. * @param gradient defines the gradient to use (between 0 and 1)
  65832. * @param factor defines the emit rate value to affect to the specified gradient
  65833. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65834. * @returns the current particle system
  65835. */
  65836. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65837. /**
  65838. * Not supported by GPUParticleSystem
  65839. * @param gradient defines the gradient to remove
  65840. * @returns the current particle system
  65841. */
  65842. removeEmitRateGradient(gradient: number): IParticleSystem;
  65843. /**
  65844. * Not supported by GPUParticleSystem
  65845. * @param gradient defines the gradient to use (between 0 and 1)
  65846. * @param factor defines the start size value to affect to the specified gradient
  65847. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65848. * @returns the current particle system
  65849. */
  65850. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65851. /**
  65852. * Not supported by GPUParticleSystem
  65853. * @param gradient defines the gradient to remove
  65854. * @returns the current particle system
  65855. */
  65856. removeStartSizeGradient(gradient: number): IParticleSystem;
  65857. /**
  65858. * Not supported by GPUParticleSystem
  65859. * @param gradient defines the gradient to use (between 0 and 1)
  65860. * @param min defines the color remap minimal range
  65861. * @param max defines the color remap maximal range
  65862. * @returns the current particle system
  65863. */
  65864. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65865. /**
  65866. * Not supported by GPUParticleSystem
  65867. * @param gradient defines the gradient to remove
  65868. * @returns the current particle system
  65869. */
  65870. removeColorRemapGradient(): IParticleSystem;
  65871. /**
  65872. * Not supported by GPUParticleSystem
  65873. * @param gradient defines the gradient to use (between 0 and 1)
  65874. * @param min defines the alpha remap minimal range
  65875. * @param max defines the alpha remap maximal range
  65876. * @returns the current particle system
  65877. */
  65878. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  65879. /**
  65880. * Not supported by GPUParticleSystem
  65881. * @param gradient defines the gradient to remove
  65882. * @returns the current particle system
  65883. */
  65884. removeAlphaRemapGradient(): IParticleSystem;
  65885. /**
  65886. * Not supported by GPUParticleSystem
  65887. * @param gradient defines the gradient to use (between 0 and 1)
  65888. * @param color defines the color to affect to the specified gradient
  65889. * @returns the current particle system
  65890. */
  65891. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  65892. /**
  65893. * Not supported by GPUParticleSystem
  65894. * @param gradient defines the gradient to remove
  65895. * @returns the current particle system
  65896. */
  65897. removeRampGradient(): IParticleSystem;
  65898. /**
  65899. * Not supported by GPUParticleSystem
  65900. * @returns the list of ramp gradients
  65901. */
  65902. getRampGradients(): Nullable<Array<Color3Gradient>>;
  65903. /**
  65904. * Not supported by GPUParticleSystem
  65905. * Gets or sets a boolean indicating that ramp gradients must be used
  65906. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  65907. */
  65908. get useRampGradients(): boolean;
  65909. set useRampGradients(value: boolean);
  65910. /**
  65911. * Not supported by GPUParticleSystem
  65912. * @param gradient defines the gradient to use (between 0 and 1)
  65913. * @param factor defines the life time factor to affect to the specified gradient
  65914. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  65915. * @returns the current particle system
  65916. */
  65917. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  65918. /**
  65919. * Not supported by GPUParticleSystem
  65920. * @param gradient defines the gradient to remove
  65921. * @returns the current particle system
  65922. */
  65923. removeLifeTimeGradient(gradient: number): IParticleSystem;
  65924. /**
  65925. * Instantiates a GPU particle system.
  65926. * 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.
  65927. * @param name The name of the particle system
  65928. * @param options The options used to create the system
  65929. * @param scene The scene the particle system belongs to
  65930. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  65931. */
  65932. constructor(name: string, options: Partial<{
  65933. capacity: number;
  65934. randomTextureSize: number;
  65935. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  65936. protected _reset(): void;
  65937. private _createUpdateVAO;
  65938. private _createRenderVAO;
  65939. private _initialize;
  65940. /** @hidden */
  65941. _recreateUpdateEffect(): void;
  65942. /** @hidden */
  65943. _recreateRenderEffect(): void;
  65944. /**
  65945. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  65946. * @param preWarm defines if we are in the pre-warmimg phase
  65947. */
  65948. animate(preWarm?: boolean): void;
  65949. private _createFactorGradientTexture;
  65950. private _createSizeGradientTexture;
  65951. private _createAngularSpeedGradientTexture;
  65952. private _createVelocityGradientTexture;
  65953. private _createLimitVelocityGradientTexture;
  65954. private _createDragGradientTexture;
  65955. private _createColorGradientTexture;
  65956. /**
  65957. * Renders the particle system in its current state
  65958. * @param preWarm defines if the system should only update the particles but not render them
  65959. * @returns the current number of particles
  65960. */
  65961. render(preWarm?: boolean): number;
  65962. /**
  65963. * Rebuilds the particle system
  65964. */
  65965. rebuild(): void;
  65966. private _releaseBuffers;
  65967. private _releaseVAOs;
  65968. /**
  65969. * Disposes the particle system and free the associated resources
  65970. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  65971. */
  65972. dispose(disposeTexture?: boolean): void;
  65973. /**
  65974. * Clones the particle system.
  65975. * @param name The name of the cloned object
  65976. * @param newEmitter The new emitter to use
  65977. * @returns the cloned particle system
  65978. */
  65979. clone(name: string, newEmitter: any): GPUParticleSystem;
  65980. /**
  65981. * Serializes the particle system to a JSON object.
  65982. * @returns the JSON object
  65983. */
  65984. serialize(): any;
  65985. /**
  65986. * Parses a JSON object to create a GPU particle system.
  65987. * @param parsedParticleSystem The JSON object to parse
  65988. * @param scene The scene to create the particle system in
  65989. * @param rootUrl The root url to use to load external dependencies like texture
  65990. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  65991. * @returns the parsed GPU particle system
  65992. */
  65993. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  65994. }
  65995. }
  65996. declare module "babylonjs/Particles/particleSystemSet" {
  65997. import { Nullable } from "babylonjs/types";
  65998. import { Color3 } from "babylonjs/Maths/math.color";
  65999. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66000. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66001. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66002. import { Scene, IDisposable } from "babylonjs/scene";
  66003. /**
  66004. * Represents a set of particle systems working together to create a specific effect
  66005. */
  66006. export class ParticleSystemSet implements IDisposable {
  66007. /**
  66008. * Gets or sets base Assets URL
  66009. */
  66010. static BaseAssetsUrl: string;
  66011. private _emitterCreationOptions;
  66012. private _emitterNode;
  66013. /**
  66014. * Gets the particle system list
  66015. */
  66016. systems: IParticleSystem[];
  66017. /**
  66018. * Gets the emitter node used with this set
  66019. */
  66020. get emitterNode(): Nullable<TransformNode>;
  66021. /**
  66022. * Creates a new emitter mesh as a sphere
  66023. * @param options defines the options used to create the sphere
  66024. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66025. * @param scene defines the hosting scene
  66026. */
  66027. setEmitterAsSphere(options: {
  66028. diameter: number;
  66029. segments: number;
  66030. color: Color3;
  66031. }, renderingGroupId: number, scene: Scene): void;
  66032. /**
  66033. * Starts all particle systems of the set
  66034. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66035. */
  66036. start(emitter?: AbstractMesh): void;
  66037. /**
  66038. * Release all associated resources
  66039. */
  66040. dispose(): void;
  66041. /**
  66042. * Serialize the set into a JSON compatible object
  66043. * @returns a JSON compatible representation of the set
  66044. */
  66045. serialize(): any;
  66046. /**
  66047. * Parse a new ParticleSystemSet from a serialized source
  66048. * @param data defines a JSON compatible representation of the set
  66049. * @param scene defines the hosting scene
  66050. * @param gpu defines if we want GPU particles or CPU particles
  66051. * @returns a new ParticleSystemSet
  66052. */
  66053. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66054. }
  66055. }
  66056. declare module "babylonjs/Particles/particleHelper" {
  66057. import { Nullable } from "babylonjs/types";
  66058. import { Scene } from "babylonjs/scene";
  66059. import { Vector3 } from "babylonjs/Maths/math.vector";
  66060. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66061. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66062. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66063. /**
  66064. * This class is made for on one-liner static method to help creating particle system set.
  66065. */
  66066. export class ParticleHelper {
  66067. /**
  66068. * Gets or sets base Assets URL
  66069. */
  66070. static BaseAssetsUrl: string;
  66071. /**
  66072. * Create a default particle system that you can tweak
  66073. * @param emitter defines the emitter to use
  66074. * @param capacity defines the system capacity (default is 500 particles)
  66075. * @param scene defines the hosting scene
  66076. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66077. * @returns the new Particle system
  66078. */
  66079. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66080. /**
  66081. * This is the main static method (one-liner) of this helper to create different particle systems
  66082. * @param type This string represents the type to the particle system to create
  66083. * @param scene The scene where the particle system should live
  66084. * @param gpu If the system will use gpu
  66085. * @returns the ParticleSystemSet created
  66086. */
  66087. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66088. /**
  66089. * Static function used to export a particle system to a ParticleSystemSet variable.
  66090. * Please note that the emitter shape is not exported
  66091. * @param systems defines the particle systems to export
  66092. * @returns the created particle system set
  66093. */
  66094. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66095. }
  66096. }
  66097. declare module "babylonjs/Particles/particleSystemComponent" {
  66098. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66099. import { Effect } from "babylonjs/Materials/effect";
  66100. import "babylonjs/Shaders/particles.vertex";
  66101. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66102. module "babylonjs/Engines/engine" {
  66103. interface Engine {
  66104. /**
  66105. * Create an effect to use with particle systems.
  66106. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66107. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66108. * @param uniformsNames defines a list of attribute names
  66109. * @param samplers defines an array of string used to represent textures
  66110. * @param defines defines the string containing the defines to use to compile the shaders
  66111. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66112. * @param onCompiled defines a function to call when the effect creation is successful
  66113. * @param onError defines a function to call when the effect creation has failed
  66114. * @returns the new Effect
  66115. */
  66116. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66117. }
  66118. }
  66119. module "babylonjs/Meshes/mesh" {
  66120. interface Mesh {
  66121. /**
  66122. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66123. * @returns an array of IParticleSystem
  66124. */
  66125. getEmittedParticleSystems(): IParticleSystem[];
  66126. /**
  66127. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66128. * @returns an array of IParticleSystem
  66129. */
  66130. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66131. }
  66132. }
  66133. /**
  66134. * @hidden
  66135. */
  66136. export var _IDoNeedToBeInTheBuild: number;
  66137. }
  66138. declare module "babylonjs/Particles/pointsCloudSystem" {
  66139. import { Color4 } from "babylonjs/Maths/math";
  66140. import { Mesh } from "babylonjs/Meshes/mesh";
  66141. import { Scene, IDisposable } from "babylonjs/scene";
  66142. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66143. /** Defines the 4 color options */
  66144. export enum PointColor {
  66145. /** color value */
  66146. Color = 2,
  66147. /** uv value */
  66148. UV = 1,
  66149. /** random value */
  66150. Random = 0,
  66151. /** stated value */
  66152. Stated = 3
  66153. }
  66154. /**
  66155. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66156. * 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.
  66157. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66158. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66159. *
  66160. * Full documentation here : TO BE ENTERED
  66161. */
  66162. export class PointsCloudSystem implements IDisposable {
  66163. /**
  66164. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66165. * Example : var p = SPS.particles[i];
  66166. */
  66167. particles: CloudPoint[];
  66168. /**
  66169. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66170. */
  66171. nbParticles: number;
  66172. /**
  66173. * This a counter for your own usage. It's not set by any SPS functions.
  66174. */
  66175. counter: number;
  66176. /**
  66177. * The PCS name. This name is also given to the underlying mesh.
  66178. */
  66179. name: string;
  66180. /**
  66181. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66182. */
  66183. mesh: Mesh;
  66184. /**
  66185. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66186. * Please read :
  66187. */
  66188. vars: any;
  66189. /**
  66190. * @hidden
  66191. */
  66192. _size: number;
  66193. private _scene;
  66194. private _promises;
  66195. private _positions;
  66196. private _indices;
  66197. private _normals;
  66198. private _colors;
  66199. private _uvs;
  66200. private _indices32;
  66201. private _positions32;
  66202. private _colors32;
  66203. private _uvs32;
  66204. private _updatable;
  66205. private _isVisibilityBoxLocked;
  66206. private _alwaysVisible;
  66207. private _groups;
  66208. private _groupCounter;
  66209. private _computeParticleColor;
  66210. private _computeParticleTexture;
  66211. private _computeParticleRotation;
  66212. private _computeBoundingBox;
  66213. private _isReady;
  66214. /**
  66215. * Creates a PCS (Points Cloud System) object
  66216. * @param name (String) is the PCS name, this will be the underlying mesh name
  66217. * @param pointSize (number) is the size for each point
  66218. * @param scene (Scene) is the scene in which the PCS is added
  66219. * @param options defines the options of the PCS e.g.
  66220. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  66221. */
  66222. constructor(name: string, pointSize: number, scene: Scene, options?: {
  66223. updatable?: boolean;
  66224. });
  66225. /**
  66226. * Builds the PCS underlying mesh. Returns a standard Mesh.
  66227. * If no points were added to the PCS, the returned mesh is just a single point.
  66228. * @returns a promise for the created mesh
  66229. */
  66230. buildMeshAsync(): Promise<Mesh>;
  66231. /**
  66232. * @hidden
  66233. */
  66234. private _buildMesh;
  66235. private _addParticle;
  66236. private _randomUnitVector;
  66237. private _getColorIndicesForCoord;
  66238. private _setPointsColorOrUV;
  66239. private _colorFromTexture;
  66240. private _calculateDensity;
  66241. /**
  66242. * Adds points to the PCS in random positions within a unit sphere
  66243. * @param nb (positive integer) the number of particles to be created from this model
  66244. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  66245. * @returns the number of groups in the system
  66246. */
  66247. addPoints(nb: number, pointFunction?: any): number;
  66248. /**
  66249. * Adds points to the PCS from the surface of the model shape
  66250. * @param mesh is any Mesh object that will be used as a surface model for the points
  66251. * @param nb (positive integer) the number of particles to be created from this model
  66252. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66253. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66254. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66255. * @returns the number of groups in the system
  66256. */
  66257. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66258. /**
  66259. * Adds points to the PCS inside the model shape
  66260. * @param mesh is any Mesh object that will be used as a surface model for the points
  66261. * @param nb (positive integer) the number of particles to be created from this model
  66262. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  66263. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  66264. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  66265. * @returns the number of groups in the system
  66266. */
  66267. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  66268. /**
  66269. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  66270. * This method calls `updateParticle()` for each particle of the SPS.
  66271. * For an animated SPS, it is usually called within the render loop.
  66272. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  66273. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  66274. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  66275. * @returns the PCS.
  66276. */
  66277. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  66278. /**
  66279. * Disposes the PCS.
  66280. */
  66281. dispose(): void;
  66282. /**
  66283. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  66284. * doc :
  66285. * @returns the PCS.
  66286. */
  66287. refreshVisibleSize(): PointsCloudSystem;
  66288. /**
  66289. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  66290. * @param size the size (float) of the visibility box
  66291. * note : this doesn't lock the PCS mesh bounding box.
  66292. * doc :
  66293. */
  66294. setVisibilityBox(size: number): void;
  66295. /**
  66296. * Gets whether the PCS is always visible or not
  66297. * doc :
  66298. */
  66299. get isAlwaysVisible(): boolean;
  66300. /**
  66301. * Sets the PCS as always visible or not
  66302. * doc :
  66303. */
  66304. set isAlwaysVisible(val: boolean);
  66305. /**
  66306. * Tells to `setParticles()` to compute the particle rotations or not
  66307. * Default value : false. The PCS is faster when it's set to false
  66308. * Note : particle rotations are only applied to parent particles
  66309. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  66310. */
  66311. set computeParticleRotation(val: boolean);
  66312. /**
  66313. * Tells to `setParticles()` to compute the particle colors or not.
  66314. * Default value : true. The PCS is faster when it's set to false.
  66315. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66316. */
  66317. set computeParticleColor(val: boolean);
  66318. set computeParticleTexture(val: boolean);
  66319. /**
  66320. * Gets if `setParticles()` computes the particle colors or not.
  66321. * Default value : false. The PCS is faster when it's set to false.
  66322. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  66323. */
  66324. get computeParticleColor(): boolean;
  66325. /**
  66326. * Gets if `setParticles()` computes the particle textures or not.
  66327. * Default value : false. The PCS is faster when it's set to false.
  66328. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  66329. */
  66330. get computeParticleTexture(): boolean;
  66331. /**
  66332. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  66333. */
  66334. set computeBoundingBox(val: boolean);
  66335. /**
  66336. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  66337. */
  66338. get computeBoundingBox(): boolean;
  66339. /**
  66340. * This function does nothing. It may be overwritten to set all the particle first values.
  66341. * The PCS doesn't call this function, you may have to call it by your own.
  66342. * doc :
  66343. */
  66344. initParticles(): void;
  66345. /**
  66346. * This function does nothing. It may be overwritten to recycle a particle
  66347. * The PCS doesn't call this function, you can to call it
  66348. * doc :
  66349. * @param particle The particle to recycle
  66350. * @returns the recycled particle
  66351. */
  66352. recycleParticle(particle: CloudPoint): CloudPoint;
  66353. /**
  66354. * Updates a particle : this function should be overwritten by the user.
  66355. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  66356. * doc :
  66357. * @example : just set a particle position or velocity and recycle conditions
  66358. * @param particle The particle to update
  66359. * @returns the updated particle
  66360. */
  66361. updateParticle(particle: CloudPoint): CloudPoint;
  66362. /**
  66363. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  66364. * This does nothing and may be overwritten by the user.
  66365. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66366. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66367. * @param update the boolean update value actually passed to setParticles()
  66368. */
  66369. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66370. /**
  66371. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  66372. * This will be passed three parameters.
  66373. * This does nothing and may be overwritten by the user.
  66374. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  66375. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  66376. * @param update the boolean update value actually passed to setParticles()
  66377. */
  66378. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  66379. }
  66380. }
  66381. declare module "babylonjs/Particles/cloudPoint" {
  66382. import { Nullable } from "babylonjs/types";
  66383. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  66384. import { Mesh } from "babylonjs/Meshes/mesh";
  66385. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  66386. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  66387. /**
  66388. * Represents one particle of a points cloud system.
  66389. */
  66390. export class CloudPoint {
  66391. /**
  66392. * particle global index
  66393. */
  66394. idx: number;
  66395. /**
  66396. * The color of the particle
  66397. */
  66398. color: Nullable<Color4>;
  66399. /**
  66400. * The world space position of the particle.
  66401. */
  66402. position: Vector3;
  66403. /**
  66404. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  66405. */
  66406. rotation: Vector3;
  66407. /**
  66408. * The world space rotation quaternion of the particle.
  66409. */
  66410. rotationQuaternion: Nullable<Quaternion>;
  66411. /**
  66412. * The uv of the particle.
  66413. */
  66414. uv: Nullable<Vector2>;
  66415. /**
  66416. * The current speed of the particle.
  66417. */
  66418. velocity: Vector3;
  66419. /**
  66420. * The pivot point in the particle local space.
  66421. */
  66422. pivot: Vector3;
  66423. /**
  66424. * Must the particle be translated from its pivot point in its local space ?
  66425. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  66426. * Default : false
  66427. */
  66428. translateFromPivot: boolean;
  66429. /**
  66430. * Index of this particle in the global "positions" array (Internal use)
  66431. * @hidden
  66432. */
  66433. _pos: number;
  66434. /**
  66435. * @hidden Index of this particle in the global "indices" array (Internal use)
  66436. */
  66437. _ind: number;
  66438. /**
  66439. * Group this particle belongs to
  66440. */
  66441. _group: PointsGroup;
  66442. /**
  66443. * Group id of this particle
  66444. */
  66445. groupId: number;
  66446. /**
  66447. * Index of the particle in its group id (Internal use)
  66448. */
  66449. idxInGroup: number;
  66450. /**
  66451. * @hidden Particle BoundingInfo object (Internal use)
  66452. */
  66453. _boundingInfo: BoundingInfo;
  66454. /**
  66455. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  66456. */
  66457. _pcs: PointsCloudSystem;
  66458. /**
  66459. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  66460. */
  66461. _stillInvisible: boolean;
  66462. /**
  66463. * @hidden Last computed particle rotation matrix
  66464. */
  66465. _rotationMatrix: number[];
  66466. /**
  66467. * Parent particle Id, if any.
  66468. * Default null.
  66469. */
  66470. parentId: Nullable<number>;
  66471. /**
  66472. * @hidden Internal global position in the PCS.
  66473. */
  66474. _globalPosition: Vector3;
  66475. /**
  66476. * Creates a Point Cloud object.
  66477. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  66478. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  66479. * @param group (PointsGroup) is the group the particle belongs to
  66480. * @param groupId (integer) is the group identifier in the PCS.
  66481. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  66482. * @param pcs defines the PCS it is associated to
  66483. */
  66484. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  66485. /**
  66486. * get point size
  66487. */
  66488. get size(): Vector3;
  66489. /**
  66490. * Set point size
  66491. */
  66492. set size(scale: Vector3);
  66493. /**
  66494. * Legacy support, changed quaternion to rotationQuaternion
  66495. */
  66496. get quaternion(): Nullable<Quaternion>;
  66497. /**
  66498. * Legacy support, changed quaternion to rotationQuaternion
  66499. */
  66500. set quaternion(q: Nullable<Quaternion>);
  66501. /**
  66502. * Returns a boolean. True if the particle intersects a mesh, else false
  66503. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  66504. * @param target is the object (point or mesh) what the intersection is computed against
  66505. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  66506. * @returns true if it intersects
  66507. */
  66508. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  66509. /**
  66510. * get the rotation matrix of the particle
  66511. * @hidden
  66512. */
  66513. getRotationMatrix(m: Matrix): void;
  66514. }
  66515. /**
  66516. * Represents a group of points in a points cloud system
  66517. * * PCS internal tool, don't use it manually.
  66518. */
  66519. export class PointsGroup {
  66520. /**
  66521. * The group id
  66522. * @hidden
  66523. */
  66524. groupID: number;
  66525. /**
  66526. * image data for group (internal use)
  66527. * @hidden
  66528. */
  66529. _groupImageData: Nullable<ArrayBufferView>;
  66530. /**
  66531. * Image Width (internal use)
  66532. * @hidden
  66533. */
  66534. _groupImgWidth: number;
  66535. /**
  66536. * Image Height (internal use)
  66537. * @hidden
  66538. */
  66539. _groupImgHeight: number;
  66540. /**
  66541. * Custom position function (internal use)
  66542. * @hidden
  66543. */
  66544. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  66545. /**
  66546. * density per facet for surface points
  66547. * @hidden
  66548. */
  66549. _groupDensity: number[];
  66550. /**
  66551. * Only when points are colored by texture carries pointer to texture list array
  66552. * @hidden
  66553. */
  66554. _textureNb: number;
  66555. /**
  66556. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  66557. * PCS internal tool, don't use it manually.
  66558. * @hidden
  66559. */
  66560. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  66561. }
  66562. }
  66563. declare module "babylonjs/Particles/index" {
  66564. export * from "babylonjs/Particles/baseParticleSystem";
  66565. export * from "babylonjs/Particles/EmitterTypes/index";
  66566. export * from "babylonjs/Particles/gpuParticleSystem";
  66567. export * from "babylonjs/Particles/IParticleSystem";
  66568. export * from "babylonjs/Particles/particle";
  66569. export * from "babylonjs/Particles/particleHelper";
  66570. export * from "babylonjs/Particles/particleSystem";
  66571. export * from "babylonjs/Particles/particleSystemComponent";
  66572. export * from "babylonjs/Particles/particleSystemSet";
  66573. export * from "babylonjs/Particles/solidParticle";
  66574. export * from "babylonjs/Particles/solidParticleSystem";
  66575. export * from "babylonjs/Particles/cloudPoint";
  66576. export * from "babylonjs/Particles/pointsCloudSystem";
  66577. export * from "babylonjs/Particles/subEmitter";
  66578. }
  66579. declare module "babylonjs/Physics/physicsEngineComponent" {
  66580. import { Nullable } from "babylonjs/types";
  66581. import { Observable, Observer } from "babylonjs/Misc/observable";
  66582. import { Vector3 } from "babylonjs/Maths/math.vector";
  66583. import { Mesh } from "babylonjs/Meshes/mesh";
  66584. import { ISceneComponent } from "babylonjs/sceneComponent";
  66585. import { Scene } from "babylonjs/scene";
  66586. import { Node } from "babylonjs/node";
  66587. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  66588. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66589. module "babylonjs/scene" {
  66590. interface Scene {
  66591. /** @hidden (Backing field) */
  66592. _physicsEngine: Nullable<IPhysicsEngine>;
  66593. /** @hidden */
  66594. _physicsTimeAccumulator: number;
  66595. /**
  66596. * Gets the current physics engine
  66597. * @returns a IPhysicsEngine or null if none attached
  66598. */
  66599. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  66600. /**
  66601. * Enables physics to the current scene
  66602. * @param gravity defines the scene's gravity for the physics engine
  66603. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  66604. * @return a boolean indicating if the physics engine was initialized
  66605. */
  66606. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  66607. /**
  66608. * Disables and disposes the physics engine associated with the scene
  66609. */
  66610. disablePhysicsEngine(): void;
  66611. /**
  66612. * Gets a boolean indicating if there is an active physics engine
  66613. * @returns a boolean indicating if there is an active physics engine
  66614. */
  66615. isPhysicsEnabled(): boolean;
  66616. /**
  66617. * Deletes a physics compound impostor
  66618. * @param compound defines the compound to delete
  66619. */
  66620. deleteCompoundImpostor(compound: any): void;
  66621. /**
  66622. * An event triggered when physic simulation is about to be run
  66623. */
  66624. onBeforePhysicsObservable: Observable<Scene>;
  66625. /**
  66626. * An event triggered when physic simulation has been done
  66627. */
  66628. onAfterPhysicsObservable: Observable<Scene>;
  66629. }
  66630. }
  66631. module "babylonjs/Meshes/abstractMesh" {
  66632. interface AbstractMesh {
  66633. /** @hidden */
  66634. _physicsImpostor: Nullable<PhysicsImpostor>;
  66635. /**
  66636. * Gets or sets impostor used for physic simulation
  66637. * @see http://doc.babylonjs.com/features/physics_engine
  66638. */
  66639. physicsImpostor: Nullable<PhysicsImpostor>;
  66640. /**
  66641. * Gets the current physics impostor
  66642. * @see http://doc.babylonjs.com/features/physics_engine
  66643. * @returns a physics impostor or null
  66644. */
  66645. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  66646. /** Apply a physic impulse to the mesh
  66647. * @param force defines the force to apply
  66648. * @param contactPoint defines where to apply the force
  66649. * @returns the current mesh
  66650. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  66651. */
  66652. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  66653. /**
  66654. * Creates a physic joint between two meshes
  66655. * @param otherMesh defines the other mesh to use
  66656. * @param pivot1 defines the pivot to use on this mesh
  66657. * @param pivot2 defines the pivot to use on the other mesh
  66658. * @param options defines additional options (can be plugin dependent)
  66659. * @returns the current mesh
  66660. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  66661. */
  66662. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  66663. /** @hidden */
  66664. _disposePhysicsObserver: Nullable<Observer<Node>>;
  66665. }
  66666. }
  66667. /**
  66668. * Defines the physics engine scene component responsible to manage a physics engine
  66669. */
  66670. export class PhysicsEngineSceneComponent implements ISceneComponent {
  66671. /**
  66672. * The component name helpful to identify the component in the list of scene components.
  66673. */
  66674. readonly name: string;
  66675. /**
  66676. * The scene the component belongs to.
  66677. */
  66678. scene: Scene;
  66679. /**
  66680. * Creates a new instance of the component for the given scene
  66681. * @param scene Defines the scene to register the component in
  66682. */
  66683. constructor(scene: Scene);
  66684. /**
  66685. * Registers the component in a given scene
  66686. */
  66687. register(): void;
  66688. /**
  66689. * Rebuilds the elements related to this component in case of
  66690. * context lost for instance.
  66691. */
  66692. rebuild(): void;
  66693. /**
  66694. * Disposes the component and the associated ressources
  66695. */
  66696. dispose(): void;
  66697. }
  66698. }
  66699. declare module "babylonjs/Physics/physicsHelper" {
  66700. import { Nullable } from "babylonjs/types";
  66701. import { Vector3 } from "babylonjs/Maths/math.vector";
  66702. import { Mesh } from "babylonjs/Meshes/mesh";
  66703. import { Scene } from "babylonjs/scene";
  66704. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  66705. /**
  66706. * A helper for physics simulations
  66707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66708. */
  66709. export class PhysicsHelper {
  66710. private _scene;
  66711. private _physicsEngine;
  66712. /**
  66713. * Initializes the Physics helper
  66714. * @param scene Babylon.js scene
  66715. */
  66716. constructor(scene: Scene);
  66717. /**
  66718. * Applies a radial explosion impulse
  66719. * @param origin the origin of the explosion
  66720. * @param radiusOrEventOptions the radius or the options of radial explosion
  66721. * @param strength the explosion strength
  66722. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66723. * @returns A physics radial explosion event, or null
  66724. */
  66725. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66726. /**
  66727. * Applies a radial explosion force
  66728. * @param origin the origin of the explosion
  66729. * @param radiusOrEventOptions the radius or the options of radial explosion
  66730. * @param strength the explosion strength
  66731. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66732. * @returns A physics radial explosion event, or null
  66733. */
  66734. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  66735. /**
  66736. * Creates a gravitational field
  66737. * @param origin the origin of the explosion
  66738. * @param radiusOrEventOptions the radius or the options of radial explosion
  66739. * @param strength the explosion strength
  66740. * @param falloff possible options: Constant & Linear. Defaults to Constant
  66741. * @returns A physics gravitational field event, or null
  66742. */
  66743. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  66744. /**
  66745. * Creates a physics updraft event
  66746. * @param origin the origin of the updraft
  66747. * @param radiusOrEventOptions the radius or the options of the updraft
  66748. * @param strength the strength of the updraft
  66749. * @param height the height of the updraft
  66750. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  66751. * @returns A physics updraft event, or null
  66752. */
  66753. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  66754. /**
  66755. * Creates a physics vortex event
  66756. * @param origin the of the vortex
  66757. * @param radiusOrEventOptions the radius or the options of the vortex
  66758. * @param strength the strength of the vortex
  66759. * @param height the height of the vortex
  66760. * @returns a Physics vortex event, or null
  66761. * A physics vortex event or null
  66762. */
  66763. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  66764. }
  66765. /**
  66766. * Represents a physics radial explosion event
  66767. */
  66768. class PhysicsRadialExplosionEvent {
  66769. private _scene;
  66770. private _options;
  66771. private _sphere;
  66772. private _dataFetched;
  66773. /**
  66774. * Initializes a radial explosioin event
  66775. * @param _scene BabylonJS scene
  66776. * @param _options The options for the vortex event
  66777. */
  66778. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  66779. /**
  66780. * Returns the data related to the radial explosion event (sphere).
  66781. * @returns The radial explosion event data
  66782. */
  66783. getData(): PhysicsRadialExplosionEventData;
  66784. /**
  66785. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  66786. * @param impostor A physics imposter
  66787. * @param origin the origin of the explosion
  66788. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  66789. */
  66790. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  66791. /**
  66792. * Triggers affecterd impostors callbacks
  66793. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  66794. */
  66795. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  66796. /**
  66797. * Disposes the sphere.
  66798. * @param force Specifies if the sphere should be disposed by force
  66799. */
  66800. dispose(force?: boolean): void;
  66801. /*** Helpers ***/
  66802. private _prepareSphere;
  66803. private _intersectsWithSphere;
  66804. }
  66805. /**
  66806. * Represents a gravitational field event
  66807. */
  66808. class PhysicsGravitationalFieldEvent {
  66809. private _physicsHelper;
  66810. private _scene;
  66811. private _origin;
  66812. private _options;
  66813. private _tickCallback;
  66814. private _sphere;
  66815. private _dataFetched;
  66816. /**
  66817. * Initializes the physics gravitational field event
  66818. * @param _physicsHelper A physics helper
  66819. * @param _scene BabylonJS scene
  66820. * @param _origin The origin position of the gravitational field event
  66821. * @param _options The options for the vortex event
  66822. */
  66823. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  66824. /**
  66825. * Returns the data related to the gravitational field event (sphere).
  66826. * @returns A gravitational field event
  66827. */
  66828. getData(): PhysicsGravitationalFieldEventData;
  66829. /**
  66830. * Enables the gravitational field.
  66831. */
  66832. enable(): void;
  66833. /**
  66834. * Disables the gravitational field.
  66835. */
  66836. disable(): void;
  66837. /**
  66838. * Disposes the sphere.
  66839. * @param force The force to dispose from the gravitational field event
  66840. */
  66841. dispose(force?: boolean): void;
  66842. private _tick;
  66843. }
  66844. /**
  66845. * Represents a physics updraft event
  66846. */
  66847. class PhysicsUpdraftEvent {
  66848. private _scene;
  66849. private _origin;
  66850. private _options;
  66851. private _physicsEngine;
  66852. private _originTop;
  66853. private _originDirection;
  66854. private _tickCallback;
  66855. private _cylinder;
  66856. private _cylinderPosition;
  66857. private _dataFetched;
  66858. /**
  66859. * Initializes the physics updraft event
  66860. * @param _scene BabylonJS scene
  66861. * @param _origin The origin position of the updraft
  66862. * @param _options The options for the updraft event
  66863. */
  66864. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  66865. /**
  66866. * Returns the data related to the updraft event (cylinder).
  66867. * @returns A physics updraft event
  66868. */
  66869. getData(): PhysicsUpdraftEventData;
  66870. /**
  66871. * Enables the updraft.
  66872. */
  66873. enable(): void;
  66874. /**
  66875. * Disables the updraft.
  66876. */
  66877. disable(): void;
  66878. /**
  66879. * Disposes the cylinder.
  66880. * @param force Specifies if the updraft should be disposed by force
  66881. */
  66882. dispose(force?: boolean): void;
  66883. private getImpostorHitData;
  66884. private _tick;
  66885. /*** Helpers ***/
  66886. private _prepareCylinder;
  66887. private _intersectsWithCylinder;
  66888. }
  66889. /**
  66890. * Represents a physics vortex event
  66891. */
  66892. class PhysicsVortexEvent {
  66893. private _scene;
  66894. private _origin;
  66895. private _options;
  66896. private _physicsEngine;
  66897. private _originTop;
  66898. private _tickCallback;
  66899. private _cylinder;
  66900. private _cylinderPosition;
  66901. private _dataFetched;
  66902. /**
  66903. * Initializes the physics vortex event
  66904. * @param _scene The BabylonJS scene
  66905. * @param _origin The origin position of the vortex
  66906. * @param _options The options for the vortex event
  66907. */
  66908. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  66909. /**
  66910. * Returns the data related to the vortex event (cylinder).
  66911. * @returns The physics vortex event data
  66912. */
  66913. getData(): PhysicsVortexEventData;
  66914. /**
  66915. * Enables the vortex.
  66916. */
  66917. enable(): void;
  66918. /**
  66919. * Disables the cortex.
  66920. */
  66921. disable(): void;
  66922. /**
  66923. * Disposes the sphere.
  66924. * @param force
  66925. */
  66926. dispose(force?: boolean): void;
  66927. private getImpostorHitData;
  66928. private _tick;
  66929. /*** Helpers ***/
  66930. private _prepareCylinder;
  66931. private _intersectsWithCylinder;
  66932. }
  66933. /**
  66934. * Options fot the radial explosion event
  66935. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66936. */
  66937. export class PhysicsRadialExplosionEventOptions {
  66938. /**
  66939. * The radius of the sphere for the radial explosion.
  66940. */
  66941. radius: number;
  66942. /**
  66943. * The strenth of the explosion.
  66944. */
  66945. strength: number;
  66946. /**
  66947. * The strenght of the force in correspondence to the distance of the affected object
  66948. */
  66949. falloff: PhysicsRadialImpulseFalloff;
  66950. /**
  66951. * Sphere options for the radial explosion.
  66952. */
  66953. sphere: {
  66954. segments: number;
  66955. diameter: number;
  66956. };
  66957. /**
  66958. * Sphere options for the radial explosion.
  66959. */
  66960. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  66961. }
  66962. /**
  66963. * Options fot the updraft event
  66964. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66965. */
  66966. export class PhysicsUpdraftEventOptions {
  66967. /**
  66968. * The radius of the cylinder for the vortex
  66969. */
  66970. radius: number;
  66971. /**
  66972. * The strenth of the updraft.
  66973. */
  66974. strength: number;
  66975. /**
  66976. * The height of the cylinder for the updraft.
  66977. */
  66978. height: number;
  66979. /**
  66980. * The mode for the the updraft.
  66981. */
  66982. updraftMode: PhysicsUpdraftMode;
  66983. }
  66984. /**
  66985. * Options fot the vortex event
  66986. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  66987. */
  66988. export class PhysicsVortexEventOptions {
  66989. /**
  66990. * The radius of the cylinder for the vortex
  66991. */
  66992. radius: number;
  66993. /**
  66994. * The strenth of the vortex.
  66995. */
  66996. strength: number;
  66997. /**
  66998. * The height of the cylinder for the vortex.
  66999. */
  67000. height: number;
  67001. /**
  67002. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67003. */
  67004. centripetalForceThreshold: number;
  67005. /**
  67006. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67007. */
  67008. centripetalForceMultiplier: number;
  67009. /**
  67010. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67011. */
  67012. centrifugalForceMultiplier: number;
  67013. /**
  67014. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67015. */
  67016. updraftForceMultiplier: number;
  67017. }
  67018. /**
  67019. * The strenght of the force in correspondence to the distance of the affected object
  67020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67021. */
  67022. export enum PhysicsRadialImpulseFalloff {
  67023. /** Defines that impulse is constant in strength across it's whole radius */
  67024. Constant = 0,
  67025. /** Defines that impulse gets weaker if it's further from the origin */
  67026. Linear = 1
  67027. }
  67028. /**
  67029. * The strength of the force in correspondence to the distance of the affected object
  67030. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67031. */
  67032. export enum PhysicsUpdraftMode {
  67033. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67034. Center = 0,
  67035. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67036. Perpendicular = 1
  67037. }
  67038. /**
  67039. * Interface for a physics hit data
  67040. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67041. */
  67042. export interface PhysicsHitData {
  67043. /**
  67044. * The force applied at the contact point
  67045. */
  67046. force: Vector3;
  67047. /**
  67048. * The contact point
  67049. */
  67050. contactPoint: Vector3;
  67051. /**
  67052. * The distance from the origin to the contact point
  67053. */
  67054. distanceFromOrigin: number;
  67055. }
  67056. /**
  67057. * Interface for radial explosion event data
  67058. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67059. */
  67060. export interface PhysicsRadialExplosionEventData {
  67061. /**
  67062. * A sphere used for the radial explosion event
  67063. */
  67064. sphere: Mesh;
  67065. }
  67066. /**
  67067. * Interface for gravitational field event data
  67068. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67069. */
  67070. export interface PhysicsGravitationalFieldEventData {
  67071. /**
  67072. * A sphere mesh used for the gravitational field event
  67073. */
  67074. sphere: Mesh;
  67075. }
  67076. /**
  67077. * Interface for updraft event data
  67078. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67079. */
  67080. export interface PhysicsUpdraftEventData {
  67081. /**
  67082. * A cylinder used for the updraft event
  67083. */
  67084. cylinder: Mesh;
  67085. }
  67086. /**
  67087. * Interface for vortex event data
  67088. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67089. */
  67090. export interface PhysicsVortexEventData {
  67091. /**
  67092. * A cylinder used for the vortex event
  67093. */
  67094. cylinder: Mesh;
  67095. }
  67096. /**
  67097. * Interface for an affected physics impostor
  67098. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67099. */
  67100. export interface PhysicsAffectedImpostorWithData {
  67101. /**
  67102. * The impostor affected by the effect
  67103. */
  67104. impostor: PhysicsImpostor;
  67105. /**
  67106. * The data about the hit/horce from the explosion
  67107. */
  67108. hitData: PhysicsHitData;
  67109. }
  67110. }
  67111. declare module "babylonjs/Physics/Plugins/index" {
  67112. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67113. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67114. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67115. }
  67116. declare module "babylonjs/Physics/index" {
  67117. export * from "babylonjs/Physics/IPhysicsEngine";
  67118. export * from "babylonjs/Physics/physicsEngine";
  67119. export * from "babylonjs/Physics/physicsEngineComponent";
  67120. export * from "babylonjs/Physics/physicsHelper";
  67121. export * from "babylonjs/Physics/physicsImpostor";
  67122. export * from "babylonjs/Physics/physicsJoint";
  67123. export * from "babylonjs/Physics/Plugins/index";
  67124. }
  67125. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67126. /** @hidden */
  67127. export var blackAndWhitePixelShader: {
  67128. name: string;
  67129. shader: string;
  67130. };
  67131. }
  67132. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67133. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67134. import { Camera } from "babylonjs/Cameras/camera";
  67135. import { Engine } from "babylonjs/Engines/engine";
  67136. import "babylonjs/Shaders/blackAndWhite.fragment";
  67137. /**
  67138. * Post process used to render in black and white
  67139. */
  67140. export class BlackAndWhitePostProcess extends PostProcess {
  67141. /**
  67142. * Linear about to convert he result to black and white (default: 1)
  67143. */
  67144. degree: number;
  67145. /**
  67146. * Creates a black and white post process
  67147. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67148. * @param name The name of the effect.
  67149. * @param options The required width/height ratio to downsize to before computing the render pass.
  67150. * @param camera The camera to apply the render pass to.
  67151. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67152. * @param engine The engine which the post process will be applied. (default: current engine)
  67153. * @param reusable If the post process can be reused on the same frame. (default: false)
  67154. */
  67155. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67156. }
  67157. }
  67158. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67159. import { Nullable } from "babylonjs/types";
  67160. import { Camera } from "babylonjs/Cameras/camera";
  67161. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67162. import { Engine } from "babylonjs/Engines/engine";
  67163. /**
  67164. * This represents a set of one or more post processes in Babylon.
  67165. * A post process can be used to apply a shader to a texture after it is rendered.
  67166. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67167. */
  67168. export class PostProcessRenderEffect {
  67169. private _postProcesses;
  67170. private _getPostProcesses;
  67171. private _singleInstance;
  67172. private _cameras;
  67173. private _indicesForCamera;
  67174. /**
  67175. * Name of the effect
  67176. * @hidden
  67177. */
  67178. _name: string;
  67179. /**
  67180. * Instantiates a post process render effect.
  67181. * A post process can be used to apply a shader to a texture after it is rendered.
  67182. * @param engine The engine the effect is tied to
  67183. * @param name The name of the effect
  67184. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67185. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67186. */
  67187. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67188. /**
  67189. * Checks if all the post processes in the effect are supported.
  67190. */
  67191. get isSupported(): boolean;
  67192. /**
  67193. * Updates the current state of the effect
  67194. * @hidden
  67195. */
  67196. _update(): void;
  67197. /**
  67198. * Attaches the effect on cameras
  67199. * @param cameras The camera to attach to.
  67200. * @hidden
  67201. */
  67202. _attachCameras(cameras: Camera): void;
  67203. /**
  67204. * Attaches the effect on cameras
  67205. * @param cameras The camera to attach to.
  67206. * @hidden
  67207. */
  67208. _attachCameras(cameras: Camera[]): void;
  67209. /**
  67210. * Detaches the effect on cameras
  67211. * @param cameras The camera to detatch from.
  67212. * @hidden
  67213. */
  67214. _detachCameras(cameras: Camera): void;
  67215. /**
  67216. * Detatches the effect on cameras
  67217. * @param cameras The camera to detatch from.
  67218. * @hidden
  67219. */
  67220. _detachCameras(cameras: Camera[]): void;
  67221. /**
  67222. * Enables the effect on given cameras
  67223. * @param cameras The camera to enable.
  67224. * @hidden
  67225. */
  67226. _enable(cameras: Camera): void;
  67227. /**
  67228. * Enables the effect on given cameras
  67229. * @param cameras The camera to enable.
  67230. * @hidden
  67231. */
  67232. _enable(cameras: Nullable<Camera[]>): void;
  67233. /**
  67234. * Disables the effect on the given cameras
  67235. * @param cameras The camera to disable.
  67236. * @hidden
  67237. */
  67238. _disable(cameras: Camera): void;
  67239. /**
  67240. * Disables the effect on the given cameras
  67241. * @param cameras The camera to disable.
  67242. * @hidden
  67243. */
  67244. _disable(cameras: Nullable<Camera[]>): void;
  67245. /**
  67246. * Gets a list of the post processes contained in the effect.
  67247. * @param camera The camera to get the post processes on.
  67248. * @returns The list of the post processes in the effect.
  67249. */
  67250. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  67251. }
  67252. }
  67253. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  67254. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67255. /** @hidden */
  67256. export var extractHighlightsPixelShader: {
  67257. name: string;
  67258. shader: string;
  67259. };
  67260. }
  67261. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  67262. import { Nullable } from "babylonjs/types";
  67263. import { Camera } from "babylonjs/Cameras/camera";
  67264. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67265. import { Engine } from "babylonjs/Engines/engine";
  67266. import "babylonjs/Shaders/extractHighlights.fragment";
  67267. /**
  67268. * 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.
  67269. */
  67270. export class ExtractHighlightsPostProcess extends PostProcess {
  67271. /**
  67272. * The luminance threshold, pixels below this value will be set to black.
  67273. */
  67274. threshold: number;
  67275. /** @hidden */
  67276. _exposure: number;
  67277. /**
  67278. * Post process which has the input texture to be used when performing highlight extraction
  67279. * @hidden
  67280. */
  67281. _inputPostProcess: Nullable<PostProcess>;
  67282. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67283. }
  67284. }
  67285. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  67286. /** @hidden */
  67287. export var bloomMergePixelShader: {
  67288. name: string;
  67289. shader: string;
  67290. };
  67291. }
  67292. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  67293. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67294. import { Nullable } from "babylonjs/types";
  67295. import { Engine } from "babylonjs/Engines/engine";
  67296. import { Camera } from "babylonjs/Cameras/camera";
  67297. import "babylonjs/Shaders/bloomMerge.fragment";
  67298. /**
  67299. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67300. */
  67301. export class BloomMergePostProcess extends PostProcess {
  67302. /** Weight of the bloom to be added to the original input. */
  67303. weight: number;
  67304. /**
  67305. * Creates a new instance of @see BloomMergePostProcess
  67306. * @param name The name of the effect.
  67307. * @param originalFromInput Post process which's input will be used for the merge.
  67308. * @param blurred Blurred highlights post process which's output will be used.
  67309. * @param weight Weight of the bloom to be added to the original input.
  67310. * @param options The required width/height ratio to downsize to before computing the render pass.
  67311. * @param camera The camera to apply the render pass to.
  67312. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67313. * @param engine The engine which the post process will be applied. (default: current engine)
  67314. * @param reusable If the post process can be reused on the same frame. (default: false)
  67315. * @param textureType Type of textures used when performing the post process. (default: 0)
  67316. * @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)
  67317. */
  67318. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  67319. /** Weight of the bloom to be added to the original input. */
  67320. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67321. }
  67322. }
  67323. declare module "babylonjs/PostProcesses/bloomEffect" {
  67324. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67325. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67326. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  67327. import { Camera } from "babylonjs/Cameras/camera";
  67328. import { Scene } from "babylonjs/scene";
  67329. /**
  67330. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  67331. */
  67332. export class BloomEffect extends PostProcessRenderEffect {
  67333. private bloomScale;
  67334. /**
  67335. * @hidden Internal
  67336. */
  67337. _effects: Array<PostProcess>;
  67338. /**
  67339. * @hidden Internal
  67340. */
  67341. _downscale: ExtractHighlightsPostProcess;
  67342. private _blurX;
  67343. private _blurY;
  67344. private _merge;
  67345. /**
  67346. * The luminance threshold to find bright areas of the image to bloom.
  67347. */
  67348. get threshold(): number;
  67349. set threshold(value: number);
  67350. /**
  67351. * The strength of the bloom.
  67352. */
  67353. get weight(): number;
  67354. set weight(value: number);
  67355. /**
  67356. * Specifies the size of the bloom blur kernel, relative to the final output size
  67357. */
  67358. get kernel(): number;
  67359. set kernel(value: number);
  67360. /**
  67361. * Creates a new instance of @see BloomEffect
  67362. * @param scene The scene the effect belongs to.
  67363. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  67364. * @param bloomKernel The size of the kernel to be used when applying the blur.
  67365. * @param bloomWeight The the strength of bloom.
  67366. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67367. * @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)
  67368. */
  67369. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  67370. /**
  67371. * Disposes each of the internal effects for a given camera.
  67372. * @param camera The camera to dispose the effect on.
  67373. */
  67374. disposeEffects(camera: Camera): void;
  67375. /**
  67376. * @hidden Internal
  67377. */
  67378. _updateEffects(): void;
  67379. /**
  67380. * Internal
  67381. * @returns if all the contained post processes are ready.
  67382. * @hidden
  67383. */
  67384. _isReady(): boolean;
  67385. }
  67386. }
  67387. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  67388. /** @hidden */
  67389. export var chromaticAberrationPixelShader: {
  67390. name: string;
  67391. shader: string;
  67392. };
  67393. }
  67394. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  67395. import { Vector2 } from "babylonjs/Maths/math.vector";
  67396. import { Nullable } from "babylonjs/types";
  67397. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67398. import { Camera } from "babylonjs/Cameras/camera";
  67399. import { Engine } from "babylonjs/Engines/engine";
  67400. import "babylonjs/Shaders/chromaticAberration.fragment";
  67401. /**
  67402. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  67403. */
  67404. export class ChromaticAberrationPostProcess extends PostProcess {
  67405. /**
  67406. * The amount of seperation of rgb channels (default: 30)
  67407. */
  67408. aberrationAmount: number;
  67409. /**
  67410. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  67411. */
  67412. radialIntensity: number;
  67413. /**
  67414. * 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))
  67415. */
  67416. direction: Vector2;
  67417. /**
  67418. * 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))
  67419. */
  67420. centerPosition: Vector2;
  67421. /**
  67422. * Creates a new instance ChromaticAberrationPostProcess
  67423. * @param name The name of the effect.
  67424. * @param screenWidth The width of the screen to apply the effect on.
  67425. * @param screenHeight The height of the screen to apply the effect on.
  67426. * @param options The required width/height ratio to downsize to before computing the render pass.
  67427. * @param camera The camera to apply the render pass to.
  67428. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67429. * @param engine The engine which the post process will be applied. (default: current engine)
  67430. * @param reusable If the post process can be reused on the same frame. (default: false)
  67431. * @param textureType Type of textures used when performing the post process. (default: 0)
  67432. * @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)
  67433. */
  67434. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67435. }
  67436. }
  67437. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  67438. /** @hidden */
  67439. export var circleOfConfusionPixelShader: {
  67440. name: string;
  67441. shader: string;
  67442. };
  67443. }
  67444. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  67445. import { Nullable } from "babylonjs/types";
  67446. import { Engine } from "babylonjs/Engines/engine";
  67447. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67448. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67449. import { Camera } from "babylonjs/Cameras/camera";
  67450. import "babylonjs/Shaders/circleOfConfusion.fragment";
  67451. /**
  67452. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  67453. */
  67454. export class CircleOfConfusionPostProcess extends PostProcess {
  67455. /**
  67456. * 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.
  67457. */
  67458. lensSize: number;
  67459. /**
  67460. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67461. */
  67462. fStop: number;
  67463. /**
  67464. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67465. */
  67466. focusDistance: number;
  67467. /**
  67468. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  67469. */
  67470. focalLength: number;
  67471. private _depthTexture;
  67472. /**
  67473. * Creates a new instance CircleOfConfusionPostProcess
  67474. * @param name The name of the effect.
  67475. * @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.
  67476. * @param options The required width/height ratio to downsize to before computing the render pass.
  67477. * @param camera The camera to apply the render pass to.
  67478. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67479. * @param engine The engine which the post process will be applied. (default: current engine)
  67480. * @param reusable If the post process can be reused on the same frame. (default: false)
  67481. * @param textureType Type of textures used when performing the post process. (default: 0)
  67482. * @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)
  67483. */
  67484. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67485. /**
  67486. * 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.
  67487. */
  67488. set depthTexture(value: RenderTargetTexture);
  67489. }
  67490. }
  67491. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  67492. /** @hidden */
  67493. export var colorCorrectionPixelShader: {
  67494. name: string;
  67495. shader: string;
  67496. };
  67497. }
  67498. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  67499. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67500. import { Engine } from "babylonjs/Engines/engine";
  67501. import { Camera } from "babylonjs/Cameras/camera";
  67502. import "babylonjs/Shaders/colorCorrection.fragment";
  67503. /**
  67504. *
  67505. * This post-process allows the modification of rendered colors by using
  67506. * a 'look-up table' (LUT). This effect is also called Color Grading.
  67507. *
  67508. * The object needs to be provided an url to a texture containing the color
  67509. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  67510. * Use an image editing software to tweak the LUT to match your needs.
  67511. *
  67512. * For an example of a color LUT, see here:
  67513. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  67514. * For explanations on color grading, see here:
  67515. * @see http://udn.epicgames.com/Three/ColorGrading.html
  67516. *
  67517. */
  67518. export class ColorCorrectionPostProcess extends PostProcess {
  67519. private _colorTableTexture;
  67520. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67521. }
  67522. }
  67523. declare module "babylonjs/Shaders/convolution.fragment" {
  67524. /** @hidden */
  67525. export var convolutionPixelShader: {
  67526. name: string;
  67527. shader: string;
  67528. };
  67529. }
  67530. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  67531. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67532. import { Nullable } from "babylonjs/types";
  67533. import { Camera } from "babylonjs/Cameras/camera";
  67534. import { Engine } from "babylonjs/Engines/engine";
  67535. import "babylonjs/Shaders/convolution.fragment";
  67536. /**
  67537. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  67538. * input texture to perform effects such as edge detection or sharpening
  67539. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  67540. */
  67541. export class ConvolutionPostProcess extends PostProcess {
  67542. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67543. kernel: number[];
  67544. /**
  67545. * Creates a new instance ConvolutionPostProcess
  67546. * @param name The name of the effect.
  67547. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  67548. * @param options The required width/height ratio to downsize to before computing the render pass.
  67549. * @param camera The camera to apply the render pass to.
  67550. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67551. * @param engine The engine which the post process will be applied. (default: current engine)
  67552. * @param reusable If the post process can be reused on the same frame. (default: false)
  67553. * @param textureType Type of textures used when performing the post process. (default: 0)
  67554. */
  67555. constructor(name: string,
  67556. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  67557. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67558. /**
  67559. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67560. */
  67561. static EdgeDetect0Kernel: number[];
  67562. /**
  67563. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67564. */
  67565. static EdgeDetect1Kernel: number[];
  67566. /**
  67567. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67568. */
  67569. static EdgeDetect2Kernel: number[];
  67570. /**
  67571. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67572. */
  67573. static SharpenKernel: number[];
  67574. /**
  67575. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67576. */
  67577. static EmbossKernel: number[];
  67578. /**
  67579. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  67580. */
  67581. static GaussianKernel: number[];
  67582. }
  67583. }
  67584. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  67585. import { Nullable } from "babylonjs/types";
  67586. import { Vector2 } from "babylonjs/Maths/math.vector";
  67587. import { Camera } from "babylonjs/Cameras/camera";
  67588. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67589. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  67590. import { Engine } from "babylonjs/Engines/engine";
  67591. import { Scene } from "babylonjs/scene";
  67592. /**
  67593. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  67594. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  67595. * based on samples that have a large difference in distance than the center pixel.
  67596. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  67597. */
  67598. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  67599. direction: Vector2;
  67600. /**
  67601. * Creates a new instance CircleOfConfusionPostProcess
  67602. * @param name The name of the effect.
  67603. * @param scene The scene the effect belongs to.
  67604. * @param direction The direction the blur should be applied.
  67605. * @param kernel The size of the kernel used to blur.
  67606. * @param options The required width/height ratio to downsize to before computing the render pass.
  67607. * @param camera The camera to apply the render pass to.
  67608. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  67609. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  67610. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67611. * @param engine The engine which the post process will be applied. (default: current engine)
  67612. * @param reusable If the post process can be reused on the same frame. (default: false)
  67613. * @param textureType Type of textures used when performing the post process. (default: 0)
  67614. * @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)
  67615. */
  67616. 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);
  67617. }
  67618. }
  67619. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  67620. /** @hidden */
  67621. export var depthOfFieldMergePixelShader: {
  67622. name: string;
  67623. shader: string;
  67624. };
  67625. }
  67626. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  67627. import { Nullable } from "babylonjs/types";
  67628. import { Camera } from "babylonjs/Cameras/camera";
  67629. import { Effect } from "babylonjs/Materials/effect";
  67630. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67631. import { Engine } from "babylonjs/Engines/engine";
  67632. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  67633. /**
  67634. * Options to be set when merging outputs from the default pipeline.
  67635. */
  67636. export class DepthOfFieldMergePostProcessOptions {
  67637. /**
  67638. * The original image to merge on top of
  67639. */
  67640. originalFromInput: PostProcess;
  67641. /**
  67642. * Parameters to perform the merge of the depth of field effect
  67643. */
  67644. depthOfField?: {
  67645. circleOfConfusion: PostProcess;
  67646. blurSteps: Array<PostProcess>;
  67647. };
  67648. /**
  67649. * Parameters to perform the merge of bloom effect
  67650. */
  67651. bloom?: {
  67652. blurred: PostProcess;
  67653. weight: number;
  67654. };
  67655. }
  67656. /**
  67657. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  67658. */
  67659. export class DepthOfFieldMergePostProcess extends PostProcess {
  67660. private blurSteps;
  67661. /**
  67662. * Creates a new instance of DepthOfFieldMergePostProcess
  67663. * @param name The name of the effect.
  67664. * @param originalFromInput Post process which's input will be used for the merge.
  67665. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  67666. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  67667. * @param options The required width/height ratio to downsize to before computing the render pass.
  67668. * @param camera The camera to apply the render pass to.
  67669. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67670. * @param engine The engine which the post process will be applied. (default: current engine)
  67671. * @param reusable If the post process can be reused on the same frame. (default: false)
  67672. * @param textureType Type of textures used when performing the post process. (default: 0)
  67673. * @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)
  67674. */
  67675. 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);
  67676. /**
  67677. * Updates the effect with the current post process compile time values and recompiles the shader.
  67678. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  67679. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  67680. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  67681. * @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
  67682. * @param onCompiled Called when the shader has been compiled.
  67683. * @param onError Called if there is an error when compiling a shader.
  67684. */
  67685. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  67686. }
  67687. }
  67688. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  67689. import { Nullable } from "babylonjs/types";
  67690. import { Camera } from "babylonjs/Cameras/camera";
  67691. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  67692. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67693. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  67694. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  67695. import { Scene } from "babylonjs/scene";
  67696. /**
  67697. * Specifies the level of max blur that should be applied when using the depth of field effect
  67698. */
  67699. export enum DepthOfFieldEffectBlurLevel {
  67700. /**
  67701. * Subtle blur
  67702. */
  67703. Low = 0,
  67704. /**
  67705. * Medium blur
  67706. */
  67707. Medium = 1,
  67708. /**
  67709. * Large blur
  67710. */
  67711. High = 2
  67712. }
  67713. /**
  67714. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  67715. */
  67716. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  67717. private _circleOfConfusion;
  67718. /**
  67719. * @hidden Internal, blurs from high to low
  67720. */
  67721. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  67722. private _depthOfFieldBlurY;
  67723. private _dofMerge;
  67724. /**
  67725. * @hidden Internal post processes in depth of field effect
  67726. */
  67727. _effects: Array<PostProcess>;
  67728. /**
  67729. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  67730. */
  67731. set focalLength(value: number);
  67732. get focalLength(): number;
  67733. /**
  67734. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  67735. */
  67736. set fStop(value: number);
  67737. get fStop(): number;
  67738. /**
  67739. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  67740. */
  67741. set focusDistance(value: number);
  67742. get focusDistance(): number;
  67743. /**
  67744. * 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.
  67745. */
  67746. set lensSize(value: number);
  67747. get lensSize(): number;
  67748. /**
  67749. * Creates a new instance DepthOfFieldEffect
  67750. * @param scene The scene the effect belongs to.
  67751. * @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.
  67752. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  67753. * @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)
  67754. */
  67755. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  67756. /**
  67757. * Get the current class name of the current effet
  67758. * @returns "DepthOfFieldEffect"
  67759. */
  67760. getClassName(): string;
  67761. /**
  67762. * 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.
  67763. */
  67764. set depthTexture(value: RenderTargetTexture);
  67765. /**
  67766. * Disposes each of the internal effects for a given camera.
  67767. * @param camera The camera to dispose the effect on.
  67768. */
  67769. disposeEffects(camera: Camera): void;
  67770. /**
  67771. * @hidden Internal
  67772. */
  67773. _updateEffects(): void;
  67774. /**
  67775. * Internal
  67776. * @returns if all the contained post processes are ready.
  67777. * @hidden
  67778. */
  67779. _isReady(): boolean;
  67780. }
  67781. }
  67782. declare module "babylonjs/Shaders/displayPass.fragment" {
  67783. /** @hidden */
  67784. export var displayPassPixelShader: {
  67785. name: string;
  67786. shader: string;
  67787. };
  67788. }
  67789. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  67790. import { Nullable } from "babylonjs/types";
  67791. import { Camera } from "babylonjs/Cameras/camera";
  67792. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67793. import { Engine } from "babylonjs/Engines/engine";
  67794. import "babylonjs/Shaders/displayPass.fragment";
  67795. /**
  67796. * DisplayPassPostProcess which produces an output the same as it's input
  67797. */
  67798. export class DisplayPassPostProcess extends PostProcess {
  67799. /**
  67800. * Creates the DisplayPassPostProcess
  67801. * @param name The name of the effect.
  67802. * @param options The required width/height ratio to downsize to before computing the render pass.
  67803. * @param camera The camera to apply the render pass to.
  67804. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67805. * @param engine The engine which the post process will be applied. (default: current engine)
  67806. * @param reusable If the post process can be reused on the same frame. (default: false)
  67807. */
  67808. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67809. }
  67810. }
  67811. declare module "babylonjs/Shaders/filter.fragment" {
  67812. /** @hidden */
  67813. export var filterPixelShader: {
  67814. name: string;
  67815. shader: string;
  67816. };
  67817. }
  67818. declare module "babylonjs/PostProcesses/filterPostProcess" {
  67819. import { Nullable } from "babylonjs/types";
  67820. import { Matrix } from "babylonjs/Maths/math.vector";
  67821. import { Camera } from "babylonjs/Cameras/camera";
  67822. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67823. import { Engine } from "babylonjs/Engines/engine";
  67824. import "babylonjs/Shaders/filter.fragment";
  67825. /**
  67826. * Applies a kernel filter to the image
  67827. */
  67828. export class FilterPostProcess extends PostProcess {
  67829. /** The matrix to be applied to the image */
  67830. kernelMatrix: Matrix;
  67831. /**
  67832. *
  67833. * @param name The name of the effect.
  67834. * @param kernelMatrix The matrix to be applied to the image
  67835. * @param options The required width/height ratio to downsize to before computing the render pass.
  67836. * @param camera The camera to apply the render pass to.
  67837. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67838. * @param engine The engine which the post process will be applied. (default: current engine)
  67839. * @param reusable If the post process can be reused on the same frame. (default: false)
  67840. */
  67841. constructor(name: string,
  67842. /** The matrix to be applied to the image */
  67843. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67844. }
  67845. }
  67846. declare module "babylonjs/Shaders/fxaa.fragment" {
  67847. /** @hidden */
  67848. export var fxaaPixelShader: {
  67849. name: string;
  67850. shader: string;
  67851. };
  67852. }
  67853. declare module "babylonjs/Shaders/fxaa.vertex" {
  67854. /** @hidden */
  67855. export var fxaaVertexShader: {
  67856. name: string;
  67857. shader: string;
  67858. };
  67859. }
  67860. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  67861. import { Nullable } from "babylonjs/types";
  67862. import { Camera } from "babylonjs/Cameras/camera";
  67863. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67864. import { Engine } from "babylonjs/Engines/engine";
  67865. import "babylonjs/Shaders/fxaa.fragment";
  67866. import "babylonjs/Shaders/fxaa.vertex";
  67867. /**
  67868. * Fxaa post process
  67869. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  67870. */
  67871. export class FxaaPostProcess extends PostProcess {
  67872. /** @hidden */
  67873. texelWidth: number;
  67874. /** @hidden */
  67875. texelHeight: number;
  67876. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67877. private _getDefines;
  67878. }
  67879. }
  67880. declare module "babylonjs/Shaders/grain.fragment" {
  67881. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67882. /** @hidden */
  67883. export var grainPixelShader: {
  67884. name: string;
  67885. shader: string;
  67886. };
  67887. }
  67888. declare module "babylonjs/PostProcesses/grainPostProcess" {
  67889. import { Nullable } from "babylonjs/types";
  67890. import { Camera } from "babylonjs/Cameras/camera";
  67891. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67892. import { Engine } from "babylonjs/Engines/engine";
  67893. import "babylonjs/Shaders/grain.fragment";
  67894. /**
  67895. * The GrainPostProcess adds noise to the image at mid luminance levels
  67896. */
  67897. export class GrainPostProcess extends PostProcess {
  67898. /**
  67899. * The intensity of the grain added (default: 30)
  67900. */
  67901. intensity: number;
  67902. /**
  67903. * If the grain should be randomized on every frame
  67904. */
  67905. animated: boolean;
  67906. /**
  67907. * Creates a new instance of @see GrainPostProcess
  67908. * @param name The name of the effect.
  67909. * @param options The required width/height ratio to downsize to before computing the render pass.
  67910. * @param camera The camera to apply the render pass to.
  67911. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67912. * @param engine The engine which the post process will be applied. (default: current engine)
  67913. * @param reusable If the post process can be reused on the same frame. (default: false)
  67914. * @param textureType Type of textures used when performing the post process. (default: 0)
  67915. * @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)
  67916. */
  67917. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  67918. }
  67919. }
  67920. declare module "babylonjs/Shaders/highlights.fragment" {
  67921. /** @hidden */
  67922. export var highlightsPixelShader: {
  67923. name: string;
  67924. shader: string;
  67925. };
  67926. }
  67927. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  67928. import { Nullable } from "babylonjs/types";
  67929. import { Camera } from "babylonjs/Cameras/camera";
  67930. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67931. import { Engine } from "babylonjs/Engines/engine";
  67932. import "babylonjs/Shaders/highlights.fragment";
  67933. /**
  67934. * Extracts highlights from the image
  67935. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67936. */
  67937. export class HighlightsPostProcess extends PostProcess {
  67938. /**
  67939. * Extracts highlights from the image
  67940. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  67941. * @param name The name of the effect.
  67942. * @param options The required width/height ratio to downsize to before computing the render pass.
  67943. * @param camera The camera to apply the render pass to.
  67944. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67945. * @param engine The engine which the post process will be applied. (default: current engine)
  67946. * @param reusable If the post process can be reused on the same frame. (default: false)
  67947. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  67948. */
  67949. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  67950. }
  67951. }
  67952. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  67953. /** @hidden */
  67954. export var mrtFragmentDeclaration: {
  67955. name: string;
  67956. shader: string;
  67957. };
  67958. }
  67959. declare module "babylonjs/Shaders/geometry.fragment" {
  67960. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  67961. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  67962. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  67963. /** @hidden */
  67964. export var geometryPixelShader: {
  67965. name: string;
  67966. shader: string;
  67967. };
  67968. }
  67969. declare module "babylonjs/Shaders/geometry.vertex" {
  67970. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  67971. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  67972. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  67973. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  67974. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  67975. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  67976. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  67977. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  67978. /** @hidden */
  67979. export var geometryVertexShader: {
  67980. name: string;
  67981. shader: string;
  67982. };
  67983. }
  67984. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  67985. import { Matrix } from "babylonjs/Maths/math.vector";
  67986. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67987. import { Mesh } from "babylonjs/Meshes/mesh";
  67988. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  67989. import { Effect } from "babylonjs/Materials/effect";
  67990. import { Scene } from "babylonjs/scene";
  67991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67992. import "babylonjs/Shaders/geometry.fragment";
  67993. import "babylonjs/Shaders/geometry.vertex";
  67994. /** @hidden */
  67995. interface ISavedTransformationMatrix {
  67996. world: Matrix;
  67997. viewProjection: Matrix;
  67998. }
  67999. /**
  68000. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68001. */
  68002. export class GeometryBufferRenderer {
  68003. /**
  68004. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68005. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68006. */
  68007. static readonly POSITION_TEXTURE_TYPE: number;
  68008. /**
  68009. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68010. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68011. */
  68012. static readonly VELOCITY_TEXTURE_TYPE: number;
  68013. /**
  68014. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68015. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68016. */
  68017. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68018. /**
  68019. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68020. * in order to compute objects velocities when enableVelocity is set to "true"
  68021. * @hidden
  68022. */
  68023. _previousTransformationMatrices: {
  68024. [index: number]: ISavedTransformationMatrix;
  68025. };
  68026. /**
  68027. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68028. * in order to compute objects velocities when enableVelocity is set to "true"
  68029. * @hidden
  68030. */
  68031. _previousBonesTransformationMatrices: {
  68032. [index: number]: Float32Array;
  68033. };
  68034. /**
  68035. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68036. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68037. */
  68038. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68039. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68040. renderTransparentMeshes: boolean;
  68041. private _scene;
  68042. private _multiRenderTarget;
  68043. private _ratio;
  68044. private _enablePosition;
  68045. private _enableVelocity;
  68046. private _enableReflectivity;
  68047. private _positionIndex;
  68048. private _velocityIndex;
  68049. private _reflectivityIndex;
  68050. protected _effect: Effect;
  68051. protected _cachedDefines: string;
  68052. /**
  68053. * Set the render list (meshes to be rendered) used in the G buffer.
  68054. */
  68055. set renderList(meshes: Mesh[]);
  68056. /**
  68057. * Gets wether or not G buffer are supported by the running hardware.
  68058. * This requires draw buffer supports
  68059. */
  68060. get isSupported(): boolean;
  68061. /**
  68062. * Returns the index of the given texture type in the G-Buffer textures array
  68063. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68064. * @returns the index of the given texture type in the G-Buffer textures array
  68065. */
  68066. getTextureIndex(textureType: number): number;
  68067. /**
  68068. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68069. */
  68070. get enablePosition(): boolean;
  68071. /**
  68072. * Sets whether or not objects positions are enabled for the G buffer.
  68073. */
  68074. set enablePosition(enable: boolean);
  68075. /**
  68076. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68077. */
  68078. get enableVelocity(): boolean;
  68079. /**
  68080. * Sets wether or not objects velocities are enabled for the G buffer.
  68081. */
  68082. set enableVelocity(enable: boolean);
  68083. /**
  68084. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68085. */
  68086. get enableReflectivity(): boolean;
  68087. /**
  68088. * Sets wether or not objects roughness are enabled for the G buffer.
  68089. */
  68090. set enableReflectivity(enable: boolean);
  68091. /**
  68092. * Gets the scene associated with the buffer.
  68093. */
  68094. get scene(): Scene;
  68095. /**
  68096. * Gets the ratio used by the buffer during its creation.
  68097. * How big is the buffer related to the main canvas.
  68098. */
  68099. get ratio(): number;
  68100. /** @hidden */
  68101. static _SceneComponentInitialization: (scene: Scene) => void;
  68102. /**
  68103. * Creates a new G Buffer for the scene
  68104. * @param scene The scene the buffer belongs to
  68105. * @param ratio How big is the buffer related to the main canvas.
  68106. */
  68107. constructor(scene: Scene, ratio?: number);
  68108. /**
  68109. * Checks wether everything is ready to render a submesh to the G buffer.
  68110. * @param subMesh the submesh to check readiness for
  68111. * @param useInstances is the mesh drawn using instance or not
  68112. * @returns true if ready otherwise false
  68113. */
  68114. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68115. /**
  68116. * Gets the current underlying G Buffer.
  68117. * @returns the buffer
  68118. */
  68119. getGBuffer(): MultiRenderTarget;
  68120. /**
  68121. * Gets the number of samples used to render the buffer (anti aliasing).
  68122. */
  68123. get samples(): number;
  68124. /**
  68125. * Sets the number of samples used to render the buffer (anti aliasing).
  68126. */
  68127. set samples(value: number);
  68128. /**
  68129. * Disposes the renderer and frees up associated resources.
  68130. */
  68131. dispose(): void;
  68132. protected _createRenderTargets(): void;
  68133. private _copyBonesTransformationMatrices;
  68134. }
  68135. }
  68136. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68137. import { Nullable } from "babylonjs/types";
  68138. import { Scene } from "babylonjs/scene";
  68139. import { ISceneComponent } from "babylonjs/sceneComponent";
  68140. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68141. module "babylonjs/scene" {
  68142. interface Scene {
  68143. /** @hidden (Backing field) */
  68144. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68145. /**
  68146. * Gets or Sets the current geometry buffer associated to the scene.
  68147. */
  68148. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68149. /**
  68150. * Enables a GeometryBufferRender and associates it with the scene
  68151. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68152. * @returns the GeometryBufferRenderer
  68153. */
  68154. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68155. /**
  68156. * Disables the GeometryBufferRender associated with the scene
  68157. */
  68158. disableGeometryBufferRenderer(): void;
  68159. }
  68160. }
  68161. /**
  68162. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68163. * in several rendering techniques.
  68164. */
  68165. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68166. /**
  68167. * The component name helpful to identify the component in the list of scene components.
  68168. */
  68169. readonly name: string;
  68170. /**
  68171. * The scene the component belongs to.
  68172. */
  68173. scene: Scene;
  68174. /**
  68175. * Creates a new instance of the component for the given scene
  68176. * @param scene Defines the scene to register the component in
  68177. */
  68178. constructor(scene: Scene);
  68179. /**
  68180. * Registers the component in a given scene
  68181. */
  68182. register(): void;
  68183. /**
  68184. * Rebuilds the elements related to this component in case of
  68185. * context lost for instance.
  68186. */
  68187. rebuild(): void;
  68188. /**
  68189. * Disposes the component and the associated ressources
  68190. */
  68191. dispose(): void;
  68192. private _gatherRenderTargets;
  68193. }
  68194. }
  68195. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68196. /** @hidden */
  68197. export var motionBlurPixelShader: {
  68198. name: string;
  68199. shader: string;
  68200. };
  68201. }
  68202. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68203. import { Nullable } from "babylonjs/types";
  68204. import { Camera } from "babylonjs/Cameras/camera";
  68205. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68206. import { Scene } from "babylonjs/scene";
  68207. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68208. import "babylonjs/Animations/animatable";
  68209. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68210. import "babylonjs/Shaders/motionBlur.fragment";
  68211. import { Engine } from "babylonjs/Engines/engine";
  68212. /**
  68213. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68214. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  68215. * As an example, all you have to do is to create the post-process:
  68216. * var mb = new BABYLON.MotionBlurPostProcess(
  68217. * 'mb', // The name of the effect.
  68218. * scene, // The scene containing the objects to blur according to their velocity.
  68219. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  68220. * camera // The camera to apply the render pass to.
  68221. * );
  68222. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  68223. */
  68224. export class MotionBlurPostProcess extends PostProcess {
  68225. /**
  68226. * Defines how much the image is blurred by the movement. Default value is equal to 1
  68227. */
  68228. motionStrength: number;
  68229. /**
  68230. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  68231. */
  68232. get motionBlurSamples(): number;
  68233. /**
  68234. * Sets the number of iterations to be used for motion blur quality
  68235. */
  68236. set motionBlurSamples(samples: number);
  68237. private _motionBlurSamples;
  68238. private _geometryBufferRenderer;
  68239. /**
  68240. * Creates a new instance MotionBlurPostProcess
  68241. * @param name The name of the effect.
  68242. * @param scene The scene containing the objects to blur according to their velocity.
  68243. * @param options The required width/height ratio to downsize to before computing the render pass.
  68244. * @param camera The camera to apply the render pass to.
  68245. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68246. * @param engine The engine which the post process will be applied. (default: current engine)
  68247. * @param reusable If the post process can be reused on the same frame. (default: false)
  68248. * @param textureType Type of textures used when performing the post process. (default: 0)
  68249. * @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)
  68250. */
  68251. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68252. /**
  68253. * Excludes the given skinned mesh from computing bones velocities.
  68254. * 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.
  68255. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  68256. */
  68257. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68258. /**
  68259. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  68260. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  68261. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  68262. */
  68263. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  68264. /**
  68265. * Disposes the post process.
  68266. * @param camera The camera to dispose the post process on.
  68267. */
  68268. dispose(camera?: Camera): void;
  68269. }
  68270. }
  68271. declare module "babylonjs/Shaders/refraction.fragment" {
  68272. /** @hidden */
  68273. export var refractionPixelShader: {
  68274. name: string;
  68275. shader: string;
  68276. };
  68277. }
  68278. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  68279. import { Color3 } from "babylonjs/Maths/math.color";
  68280. import { Camera } from "babylonjs/Cameras/camera";
  68281. import { Texture } from "babylonjs/Materials/Textures/texture";
  68282. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68283. import { Engine } from "babylonjs/Engines/engine";
  68284. import "babylonjs/Shaders/refraction.fragment";
  68285. /**
  68286. * Post process which applies a refractin texture
  68287. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68288. */
  68289. export class RefractionPostProcess extends PostProcess {
  68290. /** the base color of the refraction (used to taint the rendering) */
  68291. color: Color3;
  68292. /** simulated refraction depth */
  68293. depth: number;
  68294. /** the coefficient of the base color (0 to remove base color tainting) */
  68295. colorLevel: number;
  68296. private _refTexture;
  68297. private _ownRefractionTexture;
  68298. /**
  68299. * Gets or sets the refraction texture
  68300. * Please note that you are responsible for disposing the texture if you set it manually
  68301. */
  68302. get refractionTexture(): Texture;
  68303. set refractionTexture(value: Texture);
  68304. /**
  68305. * Initializes the RefractionPostProcess
  68306. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  68307. * @param name The name of the effect.
  68308. * @param refractionTextureUrl Url of the refraction texture to use
  68309. * @param color the base color of the refraction (used to taint the rendering)
  68310. * @param depth simulated refraction depth
  68311. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  68312. * @param camera The camera to apply the render pass to.
  68313. * @param options The required width/height ratio to downsize to before computing the render pass.
  68314. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68315. * @param engine The engine which the post process will be applied. (default: current engine)
  68316. * @param reusable If the post process can be reused on the same frame. (default: false)
  68317. */
  68318. constructor(name: string, refractionTextureUrl: string,
  68319. /** the base color of the refraction (used to taint the rendering) */
  68320. color: Color3,
  68321. /** simulated refraction depth */
  68322. depth: number,
  68323. /** the coefficient of the base color (0 to remove base color tainting) */
  68324. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68325. /**
  68326. * Disposes of the post process
  68327. * @param camera Camera to dispose post process on
  68328. */
  68329. dispose(camera: Camera): void;
  68330. }
  68331. }
  68332. declare module "babylonjs/Shaders/sharpen.fragment" {
  68333. /** @hidden */
  68334. export var sharpenPixelShader: {
  68335. name: string;
  68336. shader: string;
  68337. };
  68338. }
  68339. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  68340. import { Nullable } from "babylonjs/types";
  68341. import { Camera } from "babylonjs/Cameras/camera";
  68342. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68343. import "babylonjs/Shaders/sharpen.fragment";
  68344. import { Engine } from "babylonjs/Engines/engine";
  68345. /**
  68346. * The SharpenPostProcess applies a sharpen kernel to every pixel
  68347. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68348. */
  68349. export class SharpenPostProcess extends PostProcess {
  68350. /**
  68351. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  68352. */
  68353. colorAmount: number;
  68354. /**
  68355. * How much sharpness should be applied (default: 0.3)
  68356. */
  68357. edgeAmount: number;
  68358. /**
  68359. * Creates a new instance ConvolutionPostProcess
  68360. * @param name The name of the effect.
  68361. * @param options The required width/height ratio to downsize to before computing the render pass.
  68362. * @param camera The camera to apply the render pass to.
  68363. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68364. * @param engine The engine which the post process will be applied. (default: current engine)
  68365. * @param reusable If the post process can be reused on the same frame. (default: false)
  68366. * @param textureType Type of textures used when performing the post process. (default: 0)
  68367. * @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)
  68368. */
  68369. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68370. }
  68371. }
  68372. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  68373. import { Nullable } from "babylonjs/types";
  68374. import { Camera } from "babylonjs/Cameras/camera";
  68375. import { Engine } from "babylonjs/Engines/engine";
  68376. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68377. import { IInspectable } from "babylonjs/Misc/iInspectable";
  68378. /**
  68379. * PostProcessRenderPipeline
  68380. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68381. */
  68382. export class PostProcessRenderPipeline {
  68383. private engine;
  68384. private _renderEffects;
  68385. private _renderEffectsForIsolatedPass;
  68386. /**
  68387. * List of inspectable custom properties (used by the Inspector)
  68388. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  68389. */
  68390. inspectableCustomProperties: IInspectable[];
  68391. /**
  68392. * @hidden
  68393. */
  68394. protected _cameras: Camera[];
  68395. /** @hidden */
  68396. _name: string;
  68397. /**
  68398. * Gets pipeline name
  68399. */
  68400. get name(): string;
  68401. /** Gets the list of attached cameras */
  68402. get cameras(): Camera[];
  68403. /**
  68404. * Initializes a PostProcessRenderPipeline
  68405. * @param engine engine to add the pipeline to
  68406. * @param name name of the pipeline
  68407. */
  68408. constructor(engine: Engine, name: string);
  68409. /**
  68410. * Gets the class name
  68411. * @returns "PostProcessRenderPipeline"
  68412. */
  68413. getClassName(): string;
  68414. /**
  68415. * If all the render effects in the pipeline are supported
  68416. */
  68417. get isSupported(): boolean;
  68418. /**
  68419. * Adds an effect to the pipeline
  68420. * @param renderEffect the effect to add
  68421. */
  68422. addEffect(renderEffect: PostProcessRenderEffect): void;
  68423. /** @hidden */
  68424. _rebuild(): void;
  68425. /** @hidden */
  68426. _enableEffect(renderEffectName: string, cameras: Camera): void;
  68427. /** @hidden */
  68428. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  68429. /** @hidden */
  68430. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68431. /** @hidden */
  68432. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  68433. /** @hidden */
  68434. _attachCameras(cameras: Camera, unique: boolean): void;
  68435. /** @hidden */
  68436. _attachCameras(cameras: Camera[], unique: boolean): void;
  68437. /** @hidden */
  68438. _detachCameras(cameras: Camera): void;
  68439. /** @hidden */
  68440. _detachCameras(cameras: Nullable<Camera[]>): void;
  68441. /** @hidden */
  68442. _update(): void;
  68443. /** @hidden */
  68444. _reset(): void;
  68445. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  68446. /**
  68447. * Disposes of the pipeline
  68448. */
  68449. dispose(): void;
  68450. }
  68451. }
  68452. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  68453. import { Camera } from "babylonjs/Cameras/camera";
  68454. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68455. /**
  68456. * PostProcessRenderPipelineManager class
  68457. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68458. */
  68459. export class PostProcessRenderPipelineManager {
  68460. private _renderPipelines;
  68461. /**
  68462. * Initializes a PostProcessRenderPipelineManager
  68463. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68464. */
  68465. constructor();
  68466. /**
  68467. * Gets the list of supported render pipelines
  68468. */
  68469. get supportedPipelines(): PostProcessRenderPipeline[];
  68470. /**
  68471. * Adds a pipeline to the manager
  68472. * @param renderPipeline The pipeline to add
  68473. */
  68474. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  68475. /**
  68476. * Attaches a camera to the pipeline
  68477. * @param renderPipelineName The name of the pipeline to attach to
  68478. * @param cameras the camera to attach
  68479. * @param unique if the camera can be attached multiple times to the pipeline
  68480. */
  68481. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  68482. /**
  68483. * Detaches a camera from the pipeline
  68484. * @param renderPipelineName The name of the pipeline to detach from
  68485. * @param cameras the camera to detach
  68486. */
  68487. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  68488. /**
  68489. * Enables an effect by name on a pipeline
  68490. * @param renderPipelineName the name of the pipeline to enable the effect in
  68491. * @param renderEffectName the name of the effect to enable
  68492. * @param cameras the cameras that the effect should be enabled on
  68493. */
  68494. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68495. /**
  68496. * Disables an effect by name on a pipeline
  68497. * @param renderPipelineName the name of the pipeline to disable the effect in
  68498. * @param renderEffectName the name of the effect to disable
  68499. * @param cameras the cameras that the effect should be disabled on
  68500. */
  68501. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  68502. /**
  68503. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  68504. */
  68505. update(): void;
  68506. /** @hidden */
  68507. _rebuild(): void;
  68508. /**
  68509. * Disposes of the manager and pipelines
  68510. */
  68511. dispose(): void;
  68512. }
  68513. }
  68514. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  68515. import { ISceneComponent } from "babylonjs/sceneComponent";
  68516. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  68517. import { Scene } from "babylonjs/scene";
  68518. module "babylonjs/scene" {
  68519. interface Scene {
  68520. /** @hidden (Backing field) */
  68521. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68522. /**
  68523. * Gets the postprocess render pipeline manager
  68524. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  68525. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68526. */
  68527. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  68528. }
  68529. }
  68530. /**
  68531. * Defines the Render Pipeline scene component responsible to rendering pipelines
  68532. */
  68533. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  68534. /**
  68535. * The component name helpfull to identify the component in the list of scene components.
  68536. */
  68537. readonly name: string;
  68538. /**
  68539. * The scene the component belongs to.
  68540. */
  68541. scene: Scene;
  68542. /**
  68543. * Creates a new instance of the component for the given scene
  68544. * @param scene Defines the scene to register the component in
  68545. */
  68546. constructor(scene: Scene);
  68547. /**
  68548. * Registers the component in a given scene
  68549. */
  68550. register(): void;
  68551. /**
  68552. * Rebuilds the elements related to this component in case of
  68553. * context lost for instance.
  68554. */
  68555. rebuild(): void;
  68556. /**
  68557. * Disposes the component and the associated ressources
  68558. */
  68559. dispose(): void;
  68560. private _gatherRenderTargets;
  68561. }
  68562. }
  68563. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  68564. import { Nullable } from "babylonjs/types";
  68565. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  68566. import { Camera } from "babylonjs/Cameras/camera";
  68567. import { IDisposable } from "babylonjs/scene";
  68568. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  68569. import { Scene } from "babylonjs/scene";
  68570. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  68571. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  68572. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  68573. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  68574. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  68575. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68576. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  68577. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68578. import { Animation } from "babylonjs/Animations/animation";
  68579. /**
  68580. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  68581. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  68582. */
  68583. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  68584. private _scene;
  68585. private _camerasToBeAttached;
  68586. /**
  68587. * ID of the sharpen post process,
  68588. */
  68589. private readonly SharpenPostProcessId;
  68590. /**
  68591. * @ignore
  68592. * ID of the image processing post process;
  68593. */
  68594. readonly ImageProcessingPostProcessId: string;
  68595. /**
  68596. * @ignore
  68597. * ID of the Fast Approximate Anti-Aliasing post process;
  68598. */
  68599. readonly FxaaPostProcessId: string;
  68600. /**
  68601. * ID of the chromatic aberration post process,
  68602. */
  68603. private readonly ChromaticAberrationPostProcessId;
  68604. /**
  68605. * ID of the grain post process
  68606. */
  68607. private readonly GrainPostProcessId;
  68608. /**
  68609. * Sharpen post process which will apply a sharpen convolution to enhance edges
  68610. */
  68611. sharpen: SharpenPostProcess;
  68612. private _sharpenEffect;
  68613. private bloom;
  68614. /**
  68615. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  68616. */
  68617. depthOfField: DepthOfFieldEffect;
  68618. /**
  68619. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  68620. */
  68621. fxaa: FxaaPostProcess;
  68622. /**
  68623. * Image post processing pass used to perform operations such as tone mapping or color grading.
  68624. */
  68625. imageProcessing: ImageProcessingPostProcess;
  68626. /**
  68627. * Chromatic aberration post process which will shift rgb colors in the image
  68628. */
  68629. chromaticAberration: ChromaticAberrationPostProcess;
  68630. private _chromaticAberrationEffect;
  68631. /**
  68632. * Grain post process which add noise to the image
  68633. */
  68634. grain: GrainPostProcess;
  68635. private _grainEffect;
  68636. /**
  68637. * Glow post process which adds a glow to emissive areas of the image
  68638. */
  68639. private _glowLayer;
  68640. /**
  68641. * Animations which can be used to tweak settings over a period of time
  68642. */
  68643. animations: Animation[];
  68644. private _imageProcessingConfigurationObserver;
  68645. private _sharpenEnabled;
  68646. private _bloomEnabled;
  68647. private _depthOfFieldEnabled;
  68648. private _depthOfFieldBlurLevel;
  68649. private _fxaaEnabled;
  68650. private _imageProcessingEnabled;
  68651. private _defaultPipelineTextureType;
  68652. private _bloomScale;
  68653. private _chromaticAberrationEnabled;
  68654. private _grainEnabled;
  68655. private _buildAllowed;
  68656. /**
  68657. * Gets active scene
  68658. */
  68659. get scene(): Scene;
  68660. /**
  68661. * Enable or disable the sharpen process from the pipeline
  68662. */
  68663. set sharpenEnabled(enabled: boolean);
  68664. get sharpenEnabled(): boolean;
  68665. private _resizeObserver;
  68666. private _hardwareScaleLevel;
  68667. private _bloomKernel;
  68668. /**
  68669. * Specifies the size of the bloom blur kernel, relative to the final output size
  68670. */
  68671. get bloomKernel(): number;
  68672. set bloomKernel(value: number);
  68673. /**
  68674. * Specifies the weight of the bloom in the final rendering
  68675. */
  68676. private _bloomWeight;
  68677. /**
  68678. * Specifies the luma threshold for the area that will be blurred by the bloom
  68679. */
  68680. private _bloomThreshold;
  68681. private _hdr;
  68682. /**
  68683. * The strength of the bloom.
  68684. */
  68685. set bloomWeight(value: number);
  68686. get bloomWeight(): number;
  68687. /**
  68688. * The strength of the bloom.
  68689. */
  68690. set bloomThreshold(value: number);
  68691. get bloomThreshold(): number;
  68692. /**
  68693. * The scale of the bloom, lower value will provide better performance.
  68694. */
  68695. set bloomScale(value: number);
  68696. get bloomScale(): number;
  68697. /**
  68698. * Enable or disable the bloom from the pipeline
  68699. */
  68700. set bloomEnabled(enabled: boolean);
  68701. get bloomEnabled(): boolean;
  68702. private _rebuildBloom;
  68703. /**
  68704. * If the depth of field is enabled.
  68705. */
  68706. get depthOfFieldEnabled(): boolean;
  68707. set depthOfFieldEnabled(enabled: boolean);
  68708. /**
  68709. * Blur level of the depth of field effect. (Higher blur will effect performance)
  68710. */
  68711. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  68712. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  68713. /**
  68714. * If the anti aliasing is enabled.
  68715. */
  68716. set fxaaEnabled(enabled: boolean);
  68717. get fxaaEnabled(): boolean;
  68718. private _samples;
  68719. /**
  68720. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  68721. */
  68722. set samples(sampleCount: number);
  68723. get samples(): number;
  68724. /**
  68725. * If image processing is enabled.
  68726. */
  68727. set imageProcessingEnabled(enabled: boolean);
  68728. get imageProcessingEnabled(): boolean;
  68729. /**
  68730. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  68731. */
  68732. set glowLayerEnabled(enabled: boolean);
  68733. get glowLayerEnabled(): boolean;
  68734. /**
  68735. * Gets the glow layer (or null if not defined)
  68736. */
  68737. get glowLayer(): Nullable<GlowLayer>;
  68738. /**
  68739. * Enable or disable the chromaticAberration process from the pipeline
  68740. */
  68741. set chromaticAberrationEnabled(enabled: boolean);
  68742. get chromaticAberrationEnabled(): boolean;
  68743. /**
  68744. * Enable or disable the grain process from the pipeline
  68745. */
  68746. set grainEnabled(enabled: boolean);
  68747. get grainEnabled(): boolean;
  68748. /**
  68749. * @constructor
  68750. * @param name - The rendering pipeline name (default: "")
  68751. * @param hdr - If high dynamic range textures should be used (default: true)
  68752. * @param scene - The scene linked to this pipeline (default: the last created scene)
  68753. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  68754. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  68755. */
  68756. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  68757. /**
  68758. * Get the class name
  68759. * @returns "DefaultRenderingPipeline"
  68760. */
  68761. getClassName(): string;
  68762. /**
  68763. * Force the compilation of the entire pipeline.
  68764. */
  68765. prepare(): void;
  68766. private _hasCleared;
  68767. private _prevPostProcess;
  68768. private _prevPrevPostProcess;
  68769. private _setAutoClearAndTextureSharing;
  68770. private _depthOfFieldSceneObserver;
  68771. private _buildPipeline;
  68772. private _disposePostProcesses;
  68773. /**
  68774. * Adds a camera to the pipeline
  68775. * @param camera the camera to be added
  68776. */
  68777. addCamera(camera: Camera): void;
  68778. /**
  68779. * Removes a camera from the pipeline
  68780. * @param camera the camera to remove
  68781. */
  68782. removeCamera(camera: Camera): void;
  68783. /**
  68784. * Dispose of the pipeline and stop all post processes
  68785. */
  68786. dispose(): void;
  68787. /**
  68788. * Serialize the rendering pipeline (Used when exporting)
  68789. * @returns the serialized object
  68790. */
  68791. serialize(): any;
  68792. /**
  68793. * Parse the serialized pipeline
  68794. * @param source Source pipeline.
  68795. * @param scene The scene to load the pipeline to.
  68796. * @param rootUrl The URL of the serialized pipeline.
  68797. * @returns An instantiated pipeline from the serialized object.
  68798. */
  68799. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  68800. }
  68801. }
  68802. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  68803. /** @hidden */
  68804. export var lensHighlightsPixelShader: {
  68805. name: string;
  68806. shader: string;
  68807. };
  68808. }
  68809. declare module "babylonjs/Shaders/depthOfField.fragment" {
  68810. /** @hidden */
  68811. export var depthOfFieldPixelShader: {
  68812. name: string;
  68813. shader: string;
  68814. };
  68815. }
  68816. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  68817. import { Camera } from "babylonjs/Cameras/camera";
  68818. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  68819. import { Scene } from "babylonjs/scene";
  68820. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  68821. import "babylonjs/Shaders/chromaticAberration.fragment";
  68822. import "babylonjs/Shaders/lensHighlights.fragment";
  68823. import "babylonjs/Shaders/depthOfField.fragment";
  68824. /**
  68825. * BABYLON.JS Chromatic Aberration GLSL Shader
  68826. * Author: Olivier Guyot
  68827. * Separates very slightly R, G and B colors on the edges of the screen
  68828. * Inspired by Francois Tarlier & Martins Upitis
  68829. */
  68830. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  68831. /**
  68832. * @ignore
  68833. * The chromatic aberration PostProcess id in the pipeline
  68834. */
  68835. LensChromaticAberrationEffect: string;
  68836. /**
  68837. * @ignore
  68838. * The highlights enhancing PostProcess id in the pipeline
  68839. */
  68840. HighlightsEnhancingEffect: string;
  68841. /**
  68842. * @ignore
  68843. * The depth-of-field PostProcess id in the pipeline
  68844. */
  68845. LensDepthOfFieldEffect: string;
  68846. private _scene;
  68847. private _depthTexture;
  68848. private _grainTexture;
  68849. private _chromaticAberrationPostProcess;
  68850. private _highlightsPostProcess;
  68851. private _depthOfFieldPostProcess;
  68852. private _edgeBlur;
  68853. private _grainAmount;
  68854. private _chromaticAberration;
  68855. private _distortion;
  68856. private _highlightsGain;
  68857. private _highlightsThreshold;
  68858. private _dofDistance;
  68859. private _dofAperture;
  68860. private _dofDarken;
  68861. private _dofPentagon;
  68862. private _blurNoise;
  68863. /**
  68864. * @constructor
  68865. *
  68866. * Effect parameters are as follow:
  68867. * {
  68868. * chromatic_aberration: number; // from 0 to x (1 for realism)
  68869. * edge_blur: number; // from 0 to x (1 for realism)
  68870. * distortion: number; // from 0 to x (1 for realism)
  68871. * grain_amount: number; // from 0 to 1
  68872. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  68873. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  68874. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  68875. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  68876. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  68877. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  68878. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  68879. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  68880. * }
  68881. * Note: if an effect parameter is unset, effect is disabled
  68882. *
  68883. * @param name The rendering pipeline name
  68884. * @param parameters - An object containing all parameters (see above)
  68885. * @param scene The scene linked to this pipeline
  68886. * @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)
  68887. * @param cameras The array of cameras that the rendering pipeline will be attached to
  68888. */
  68889. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  68890. /**
  68891. * Get the class name
  68892. * @returns "LensRenderingPipeline"
  68893. */
  68894. getClassName(): string;
  68895. /**
  68896. * Gets associated scene
  68897. */
  68898. get scene(): Scene;
  68899. /**
  68900. * Gets or sets the edge blur
  68901. */
  68902. get edgeBlur(): number;
  68903. set edgeBlur(value: number);
  68904. /**
  68905. * Gets or sets the grain amount
  68906. */
  68907. get grainAmount(): number;
  68908. set grainAmount(value: number);
  68909. /**
  68910. * Gets or sets the chromatic aberration amount
  68911. */
  68912. get chromaticAberration(): number;
  68913. set chromaticAberration(value: number);
  68914. /**
  68915. * Gets or sets the depth of field aperture
  68916. */
  68917. get dofAperture(): number;
  68918. set dofAperture(value: number);
  68919. /**
  68920. * Gets or sets the edge distortion
  68921. */
  68922. get edgeDistortion(): number;
  68923. set edgeDistortion(value: number);
  68924. /**
  68925. * Gets or sets the depth of field distortion
  68926. */
  68927. get dofDistortion(): number;
  68928. set dofDistortion(value: number);
  68929. /**
  68930. * Gets or sets the darken out of focus amount
  68931. */
  68932. get darkenOutOfFocus(): number;
  68933. set darkenOutOfFocus(value: number);
  68934. /**
  68935. * Gets or sets a boolean indicating if blur noise is enabled
  68936. */
  68937. get blurNoise(): boolean;
  68938. set blurNoise(value: boolean);
  68939. /**
  68940. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  68941. */
  68942. get pentagonBokeh(): boolean;
  68943. set pentagonBokeh(value: boolean);
  68944. /**
  68945. * Gets or sets the highlight grain amount
  68946. */
  68947. get highlightsGain(): number;
  68948. set highlightsGain(value: number);
  68949. /**
  68950. * Gets or sets the highlight threshold
  68951. */
  68952. get highlightsThreshold(): number;
  68953. set highlightsThreshold(value: number);
  68954. /**
  68955. * Sets the amount of blur at the edges
  68956. * @param amount blur amount
  68957. */
  68958. setEdgeBlur(amount: number): void;
  68959. /**
  68960. * Sets edge blur to 0
  68961. */
  68962. disableEdgeBlur(): void;
  68963. /**
  68964. * Sets the amout of grain
  68965. * @param amount Amount of grain
  68966. */
  68967. setGrainAmount(amount: number): void;
  68968. /**
  68969. * Set grain amount to 0
  68970. */
  68971. disableGrain(): void;
  68972. /**
  68973. * Sets the chromatic aberration amount
  68974. * @param amount amount of chromatic aberration
  68975. */
  68976. setChromaticAberration(amount: number): void;
  68977. /**
  68978. * Sets chromatic aberration amount to 0
  68979. */
  68980. disableChromaticAberration(): void;
  68981. /**
  68982. * Sets the EdgeDistortion amount
  68983. * @param amount amount of EdgeDistortion
  68984. */
  68985. setEdgeDistortion(amount: number): void;
  68986. /**
  68987. * Sets edge distortion to 0
  68988. */
  68989. disableEdgeDistortion(): void;
  68990. /**
  68991. * Sets the FocusDistance amount
  68992. * @param amount amount of FocusDistance
  68993. */
  68994. setFocusDistance(amount: number): void;
  68995. /**
  68996. * Disables depth of field
  68997. */
  68998. disableDepthOfField(): void;
  68999. /**
  69000. * Sets the Aperture amount
  69001. * @param amount amount of Aperture
  69002. */
  69003. setAperture(amount: number): void;
  69004. /**
  69005. * Sets the DarkenOutOfFocus amount
  69006. * @param amount amount of DarkenOutOfFocus
  69007. */
  69008. setDarkenOutOfFocus(amount: number): void;
  69009. private _pentagonBokehIsEnabled;
  69010. /**
  69011. * Creates a pentagon bokeh effect
  69012. */
  69013. enablePentagonBokeh(): void;
  69014. /**
  69015. * Disables the pentagon bokeh effect
  69016. */
  69017. disablePentagonBokeh(): void;
  69018. /**
  69019. * Enables noise blur
  69020. */
  69021. enableNoiseBlur(): void;
  69022. /**
  69023. * Disables noise blur
  69024. */
  69025. disableNoiseBlur(): void;
  69026. /**
  69027. * Sets the HighlightsGain amount
  69028. * @param amount amount of HighlightsGain
  69029. */
  69030. setHighlightsGain(amount: number): void;
  69031. /**
  69032. * Sets the HighlightsThreshold amount
  69033. * @param amount amount of HighlightsThreshold
  69034. */
  69035. setHighlightsThreshold(amount: number): void;
  69036. /**
  69037. * Disables highlights
  69038. */
  69039. disableHighlights(): void;
  69040. /**
  69041. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69042. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69043. */
  69044. dispose(disableDepthRender?: boolean): void;
  69045. private _createChromaticAberrationPostProcess;
  69046. private _createHighlightsPostProcess;
  69047. private _createDepthOfFieldPostProcess;
  69048. private _createGrainTexture;
  69049. }
  69050. }
  69051. declare module "babylonjs/Shaders/ssao2.fragment" {
  69052. /** @hidden */
  69053. export var ssao2PixelShader: {
  69054. name: string;
  69055. shader: string;
  69056. };
  69057. }
  69058. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69059. /** @hidden */
  69060. export var ssaoCombinePixelShader: {
  69061. name: string;
  69062. shader: string;
  69063. };
  69064. }
  69065. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69066. import { Camera } from "babylonjs/Cameras/camera";
  69067. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69068. import { Scene } from "babylonjs/scene";
  69069. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69070. import "babylonjs/Shaders/ssao2.fragment";
  69071. import "babylonjs/Shaders/ssaoCombine.fragment";
  69072. /**
  69073. * Render pipeline to produce ssao effect
  69074. */
  69075. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69076. /**
  69077. * @ignore
  69078. * The PassPostProcess id in the pipeline that contains the original scene color
  69079. */
  69080. SSAOOriginalSceneColorEffect: string;
  69081. /**
  69082. * @ignore
  69083. * The SSAO PostProcess id in the pipeline
  69084. */
  69085. SSAORenderEffect: string;
  69086. /**
  69087. * @ignore
  69088. * The horizontal blur PostProcess id in the pipeline
  69089. */
  69090. SSAOBlurHRenderEffect: string;
  69091. /**
  69092. * @ignore
  69093. * The vertical blur PostProcess id in the pipeline
  69094. */
  69095. SSAOBlurVRenderEffect: string;
  69096. /**
  69097. * @ignore
  69098. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69099. */
  69100. SSAOCombineRenderEffect: string;
  69101. /**
  69102. * The output strength of the SSAO post-process. Default value is 1.0.
  69103. */
  69104. totalStrength: number;
  69105. /**
  69106. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69107. */
  69108. maxZ: number;
  69109. /**
  69110. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69111. */
  69112. minZAspect: number;
  69113. private _samples;
  69114. /**
  69115. * Number of samples used for the SSAO calculations. Default value is 8
  69116. */
  69117. set samples(n: number);
  69118. get samples(): number;
  69119. private _textureSamples;
  69120. /**
  69121. * Number of samples to use for antialiasing
  69122. */
  69123. set textureSamples(n: number);
  69124. get textureSamples(): number;
  69125. /**
  69126. * Ratio object used for SSAO ratio and blur ratio
  69127. */
  69128. private _ratio;
  69129. /**
  69130. * Dynamically generated sphere sampler.
  69131. */
  69132. private _sampleSphere;
  69133. /**
  69134. * Blur filter offsets
  69135. */
  69136. private _samplerOffsets;
  69137. private _expensiveBlur;
  69138. /**
  69139. * If bilateral blur should be used
  69140. */
  69141. set expensiveBlur(b: boolean);
  69142. get expensiveBlur(): boolean;
  69143. /**
  69144. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69145. */
  69146. radius: number;
  69147. /**
  69148. * The base color of the SSAO post-process
  69149. * The final result is "base + ssao" between [0, 1]
  69150. */
  69151. base: number;
  69152. /**
  69153. * Support test.
  69154. */
  69155. static get IsSupported(): boolean;
  69156. private _scene;
  69157. private _depthTexture;
  69158. private _normalTexture;
  69159. private _randomTexture;
  69160. private _originalColorPostProcess;
  69161. private _ssaoPostProcess;
  69162. private _blurHPostProcess;
  69163. private _blurVPostProcess;
  69164. private _ssaoCombinePostProcess;
  69165. /**
  69166. * Gets active scene
  69167. */
  69168. get scene(): Scene;
  69169. /**
  69170. * @constructor
  69171. * @param name The rendering pipeline name
  69172. * @param scene The scene linked to this pipeline
  69173. * @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 }
  69174. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69175. */
  69176. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69177. /**
  69178. * Get the class name
  69179. * @returns "SSAO2RenderingPipeline"
  69180. */
  69181. getClassName(): string;
  69182. /**
  69183. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69184. */
  69185. dispose(disableGeometryBufferRenderer?: boolean): void;
  69186. private _createBlurPostProcess;
  69187. /** @hidden */
  69188. _rebuild(): void;
  69189. private _bits;
  69190. private _radicalInverse_VdC;
  69191. private _hammersley;
  69192. private _hemisphereSample_uniform;
  69193. private _generateHemisphere;
  69194. private _createSSAOPostProcess;
  69195. private _createSSAOCombinePostProcess;
  69196. private _createRandomTexture;
  69197. /**
  69198. * Serialize the rendering pipeline (Used when exporting)
  69199. * @returns the serialized object
  69200. */
  69201. serialize(): any;
  69202. /**
  69203. * Parse the serialized pipeline
  69204. * @param source Source pipeline.
  69205. * @param scene The scene to load the pipeline to.
  69206. * @param rootUrl The URL of the serialized pipeline.
  69207. * @returns An instantiated pipeline from the serialized object.
  69208. */
  69209. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69210. }
  69211. }
  69212. declare module "babylonjs/Shaders/ssao.fragment" {
  69213. /** @hidden */
  69214. export var ssaoPixelShader: {
  69215. name: string;
  69216. shader: string;
  69217. };
  69218. }
  69219. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  69220. import { Camera } from "babylonjs/Cameras/camera";
  69221. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69222. import { Scene } from "babylonjs/scene";
  69223. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69224. import "babylonjs/Shaders/ssao.fragment";
  69225. import "babylonjs/Shaders/ssaoCombine.fragment";
  69226. /**
  69227. * Render pipeline to produce ssao effect
  69228. */
  69229. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  69230. /**
  69231. * @ignore
  69232. * The PassPostProcess id in the pipeline that contains the original scene color
  69233. */
  69234. SSAOOriginalSceneColorEffect: string;
  69235. /**
  69236. * @ignore
  69237. * The SSAO PostProcess id in the pipeline
  69238. */
  69239. SSAORenderEffect: string;
  69240. /**
  69241. * @ignore
  69242. * The horizontal blur PostProcess id in the pipeline
  69243. */
  69244. SSAOBlurHRenderEffect: string;
  69245. /**
  69246. * @ignore
  69247. * The vertical blur PostProcess id in the pipeline
  69248. */
  69249. SSAOBlurVRenderEffect: string;
  69250. /**
  69251. * @ignore
  69252. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69253. */
  69254. SSAOCombineRenderEffect: string;
  69255. /**
  69256. * The output strength of the SSAO post-process. Default value is 1.0.
  69257. */
  69258. totalStrength: number;
  69259. /**
  69260. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  69261. */
  69262. radius: number;
  69263. /**
  69264. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  69265. * Must not be equal to fallOff and superior to fallOff.
  69266. * Default value is 0.0075
  69267. */
  69268. area: number;
  69269. /**
  69270. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  69271. * Must not be equal to area and inferior to area.
  69272. * Default value is 0.000001
  69273. */
  69274. fallOff: number;
  69275. /**
  69276. * The base color of the SSAO post-process
  69277. * The final result is "base + ssao" between [0, 1]
  69278. */
  69279. base: number;
  69280. private _scene;
  69281. private _depthTexture;
  69282. private _randomTexture;
  69283. private _originalColorPostProcess;
  69284. private _ssaoPostProcess;
  69285. private _blurHPostProcess;
  69286. private _blurVPostProcess;
  69287. private _ssaoCombinePostProcess;
  69288. private _firstUpdate;
  69289. /**
  69290. * Gets active scene
  69291. */
  69292. get scene(): Scene;
  69293. /**
  69294. * @constructor
  69295. * @param name - The rendering pipeline name
  69296. * @param scene - The scene linked to this pipeline
  69297. * @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 }
  69298. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  69299. */
  69300. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69301. /**
  69302. * Get the class name
  69303. * @returns "SSAORenderingPipeline"
  69304. */
  69305. getClassName(): string;
  69306. /**
  69307. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69308. */
  69309. dispose(disableDepthRender?: boolean): void;
  69310. private _createBlurPostProcess;
  69311. /** @hidden */
  69312. _rebuild(): void;
  69313. private _createSSAOPostProcess;
  69314. private _createSSAOCombinePostProcess;
  69315. private _createRandomTexture;
  69316. }
  69317. }
  69318. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  69319. /** @hidden */
  69320. export var screenSpaceReflectionPixelShader: {
  69321. name: string;
  69322. shader: string;
  69323. };
  69324. }
  69325. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  69326. import { Nullable } from "babylonjs/types";
  69327. import { Camera } from "babylonjs/Cameras/camera";
  69328. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69329. import { Scene } from "babylonjs/scene";
  69330. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  69331. import { Engine } from "babylonjs/Engines/engine";
  69332. /**
  69333. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  69334. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  69335. */
  69336. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  69337. /**
  69338. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  69339. */
  69340. threshold: number;
  69341. /**
  69342. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  69343. */
  69344. strength: number;
  69345. /**
  69346. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  69347. */
  69348. reflectionSpecularFalloffExponent: number;
  69349. /**
  69350. * 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]
  69351. */
  69352. step: number;
  69353. /**
  69354. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  69355. */
  69356. roughnessFactor: number;
  69357. private _geometryBufferRenderer;
  69358. private _enableSmoothReflections;
  69359. private _reflectionSamples;
  69360. private _smoothSteps;
  69361. /**
  69362. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  69363. * @param name The name of the effect.
  69364. * @param scene The scene containing the objects to calculate reflections.
  69365. * @param options The required width/height ratio to downsize to before computing the render pass.
  69366. * @param camera The camera to apply the render pass to.
  69367. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69368. * @param engine The engine which the post process will be applied. (default: current engine)
  69369. * @param reusable If the post process can be reused on the same frame. (default: false)
  69370. * @param textureType Type of textures used when performing the post process. (default: 0)
  69371. * @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)
  69372. */
  69373. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69374. /**
  69375. * Gets wether or not smoothing reflections is enabled.
  69376. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69377. */
  69378. get enableSmoothReflections(): boolean;
  69379. /**
  69380. * Sets wether or not smoothing reflections is enabled.
  69381. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  69382. */
  69383. set enableSmoothReflections(enabled: boolean);
  69384. /**
  69385. * Gets the number of samples taken while computing reflections. More samples count is high,
  69386. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69387. */
  69388. get reflectionSamples(): number;
  69389. /**
  69390. * Sets the number of samples taken while computing reflections. More samples count is high,
  69391. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  69392. */
  69393. set reflectionSamples(samples: number);
  69394. /**
  69395. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  69396. * more the post-process will require GPU power and can generate a drop in FPS.
  69397. * Default value (5.0) work pretty well in all cases but can be adjusted.
  69398. */
  69399. get smoothSteps(): number;
  69400. set smoothSteps(steps: number);
  69401. private _updateEffectDefines;
  69402. }
  69403. }
  69404. declare module "babylonjs/Shaders/standard.fragment" {
  69405. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  69406. /** @hidden */
  69407. export var standardPixelShader: {
  69408. name: string;
  69409. shader: string;
  69410. };
  69411. }
  69412. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  69413. import { Nullable } from "babylonjs/types";
  69414. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69415. import { Camera } from "babylonjs/Cameras/camera";
  69416. import { Texture } from "babylonjs/Materials/Textures/texture";
  69417. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69418. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69419. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  69420. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69421. import { IDisposable } from "babylonjs/scene";
  69422. import { SpotLight } from "babylonjs/Lights/spotLight";
  69423. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  69424. import { Scene } from "babylonjs/scene";
  69425. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  69426. import { Animation } from "babylonjs/Animations/animation";
  69427. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69428. import "babylonjs/Shaders/standard.fragment";
  69429. /**
  69430. * Standard rendering pipeline
  69431. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69432. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  69433. */
  69434. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69435. /**
  69436. * Public members
  69437. */
  69438. /**
  69439. * Post-process which contains the original scene color before the pipeline applies all the effects
  69440. */
  69441. originalPostProcess: Nullable<PostProcess>;
  69442. /**
  69443. * Post-process used to down scale an image x4
  69444. */
  69445. downSampleX4PostProcess: Nullable<PostProcess>;
  69446. /**
  69447. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  69448. */
  69449. brightPassPostProcess: Nullable<PostProcess>;
  69450. /**
  69451. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  69452. */
  69453. blurHPostProcesses: PostProcess[];
  69454. /**
  69455. * Post-process array storing all the vertical blur post-processes used by the pipeline
  69456. */
  69457. blurVPostProcesses: PostProcess[];
  69458. /**
  69459. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  69460. */
  69461. textureAdderPostProcess: Nullable<PostProcess>;
  69462. /**
  69463. * Post-process used to create volumetric lighting effect
  69464. */
  69465. volumetricLightPostProcess: Nullable<PostProcess>;
  69466. /**
  69467. * Post-process used to smooth the previous volumetric light post-process on the X axis
  69468. */
  69469. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  69470. /**
  69471. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  69472. */
  69473. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  69474. /**
  69475. * Post-process used to merge the volumetric light effect and the real scene color
  69476. */
  69477. volumetricLightMergePostProces: Nullable<PostProcess>;
  69478. /**
  69479. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  69480. */
  69481. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  69482. /**
  69483. * Base post-process used to calculate the average luminance of the final image for HDR
  69484. */
  69485. luminancePostProcess: Nullable<PostProcess>;
  69486. /**
  69487. * Post-processes used to create down sample post-processes in order to get
  69488. * the average luminance of the final image for HDR
  69489. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  69490. */
  69491. luminanceDownSamplePostProcesses: PostProcess[];
  69492. /**
  69493. * Post-process used to create a HDR effect (light adaptation)
  69494. */
  69495. hdrPostProcess: Nullable<PostProcess>;
  69496. /**
  69497. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  69498. */
  69499. textureAdderFinalPostProcess: Nullable<PostProcess>;
  69500. /**
  69501. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  69502. */
  69503. lensFlareFinalPostProcess: Nullable<PostProcess>;
  69504. /**
  69505. * Post-process used to merge the final HDR post-process and the real scene color
  69506. */
  69507. hdrFinalPostProcess: Nullable<PostProcess>;
  69508. /**
  69509. * Post-process used to create a lens flare effect
  69510. */
  69511. lensFlarePostProcess: Nullable<PostProcess>;
  69512. /**
  69513. * Post-process that merges the result of the lens flare post-process and the real scene color
  69514. */
  69515. lensFlareComposePostProcess: Nullable<PostProcess>;
  69516. /**
  69517. * Post-process used to create a motion blur effect
  69518. */
  69519. motionBlurPostProcess: Nullable<PostProcess>;
  69520. /**
  69521. * Post-process used to create a depth of field effect
  69522. */
  69523. depthOfFieldPostProcess: Nullable<PostProcess>;
  69524. /**
  69525. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69526. */
  69527. fxaaPostProcess: Nullable<FxaaPostProcess>;
  69528. /**
  69529. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  69530. */
  69531. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  69532. /**
  69533. * Represents the brightness threshold in order to configure the illuminated surfaces
  69534. */
  69535. brightThreshold: number;
  69536. /**
  69537. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  69538. */
  69539. blurWidth: number;
  69540. /**
  69541. * Sets if the blur for highlighted surfaces must be only horizontal
  69542. */
  69543. horizontalBlur: boolean;
  69544. /**
  69545. * Gets the overall exposure used by the pipeline
  69546. */
  69547. get exposure(): number;
  69548. /**
  69549. * Sets the overall exposure used by the pipeline
  69550. */
  69551. set exposure(value: number);
  69552. /**
  69553. * Texture used typically to simulate "dirty" on camera lens
  69554. */
  69555. lensTexture: Nullable<Texture>;
  69556. /**
  69557. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  69558. */
  69559. volumetricLightCoefficient: number;
  69560. /**
  69561. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  69562. */
  69563. volumetricLightPower: number;
  69564. /**
  69565. * Used the set the blur intensity to smooth the volumetric lights
  69566. */
  69567. volumetricLightBlurScale: number;
  69568. /**
  69569. * Light (spot or directional) used to generate the volumetric lights rays
  69570. * The source light must have a shadow generate so the pipeline can get its
  69571. * depth map
  69572. */
  69573. sourceLight: Nullable<SpotLight | DirectionalLight>;
  69574. /**
  69575. * For eye adaptation, represents the minimum luminance the eye can see
  69576. */
  69577. hdrMinimumLuminance: number;
  69578. /**
  69579. * For eye adaptation, represents the decrease luminance speed
  69580. */
  69581. hdrDecreaseRate: number;
  69582. /**
  69583. * For eye adaptation, represents the increase luminance speed
  69584. */
  69585. hdrIncreaseRate: number;
  69586. /**
  69587. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69588. */
  69589. get hdrAutoExposure(): boolean;
  69590. /**
  69591. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  69592. */
  69593. set hdrAutoExposure(value: boolean);
  69594. /**
  69595. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  69596. */
  69597. lensColorTexture: Nullable<Texture>;
  69598. /**
  69599. * The overall strengh for the lens flare effect
  69600. */
  69601. lensFlareStrength: number;
  69602. /**
  69603. * Dispersion coefficient for lens flare ghosts
  69604. */
  69605. lensFlareGhostDispersal: number;
  69606. /**
  69607. * Main lens flare halo width
  69608. */
  69609. lensFlareHaloWidth: number;
  69610. /**
  69611. * Based on the lens distortion effect, defines how much the lens flare result
  69612. * is distorted
  69613. */
  69614. lensFlareDistortionStrength: number;
  69615. /**
  69616. * Configures the blur intensity used for for lens flare (halo)
  69617. */
  69618. lensFlareBlurWidth: number;
  69619. /**
  69620. * Lens star texture must be used to simulate rays on the flares and is available
  69621. * in the documentation
  69622. */
  69623. lensStarTexture: Nullable<Texture>;
  69624. /**
  69625. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  69626. * flare effect by taking account of the dirt texture
  69627. */
  69628. lensFlareDirtTexture: Nullable<Texture>;
  69629. /**
  69630. * Represents the focal length for the depth of field effect
  69631. */
  69632. depthOfFieldDistance: number;
  69633. /**
  69634. * Represents the blur intensity for the blurred part of the depth of field effect
  69635. */
  69636. depthOfFieldBlurWidth: number;
  69637. /**
  69638. * Gets how much the image is blurred by the movement while using the motion blur post-process
  69639. */
  69640. get motionStrength(): number;
  69641. /**
  69642. * Sets how much the image is blurred by the movement while using the motion blur post-process
  69643. */
  69644. set motionStrength(strength: number);
  69645. /**
  69646. * Gets wether or not the motion blur post-process is object based or screen based.
  69647. */
  69648. get objectBasedMotionBlur(): boolean;
  69649. /**
  69650. * Sets wether or not the motion blur post-process should be object based or screen based
  69651. */
  69652. set objectBasedMotionBlur(value: boolean);
  69653. /**
  69654. * List of animations for the pipeline (IAnimatable implementation)
  69655. */
  69656. animations: Animation[];
  69657. /**
  69658. * Private members
  69659. */
  69660. private _scene;
  69661. private _currentDepthOfFieldSource;
  69662. private _basePostProcess;
  69663. private _fixedExposure;
  69664. private _currentExposure;
  69665. private _hdrAutoExposure;
  69666. private _hdrCurrentLuminance;
  69667. private _motionStrength;
  69668. private _isObjectBasedMotionBlur;
  69669. private _floatTextureType;
  69670. private _camerasToBeAttached;
  69671. private _ratio;
  69672. private _bloomEnabled;
  69673. private _depthOfFieldEnabled;
  69674. private _vlsEnabled;
  69675. private _lensFlareEnabled;
  69676. private _hdrEnabled;
  69677. private _motionBlurEnabled;
  69678. private _fxaaEnabled;
  69679. private _screenSpaceReflectionsEnabled;
  69680. private _motionBlurSamples;
  69681. private _volumetricLightStepsCount;
  69682. private _samples;
  69683. /**
  69684. * @ignore
  69685. * Specifies if the bloom pipeline is enabled
  69686. */
  69687. get BloomEnabled(): boolean;
  69688. set BloomEnabled(enabled: boolean);
  69689. /**
  69690. * @ignore
  69691. * Specifies if the depth of field pipeline is enabed
  69692. */
  69693. get DepthOfFieldEnabled(): boolean;
  69694. set DepthOfFieldEnabled(enabled: boolean);
  69695. /**
  69696. * @ignore
  69697. * Specifies if the lens flare pipeline is enabed
  69698. */
  69699. get LensFlareEnabled(): boolean;
  69700. set LensFlareEnabled(enabled: boolean);
  69701. /**
  69702. * @ignore
  69703. * Specifies if the HDR pipeline is enabled
  69704. */
  69705. get HDREnabled(): boolean;
  69706. set HDREnabled(enabled: boolean);
  69707. /**
  69708. * @ignore
  69709. * Specifies if the volumetric lights scattering effect is enabled
  69710. */
  69711. get VLSEnabled(): boolean;
  69712. set VLSEnabled(enabled: boolean);
  69713. /**
  69714. * @ignore
  69715. * Specifies if the motion blur effect is enabled
  69716. */
  69717. get MotionBlurEnabled(): boolean;
  69718. set MotionBlurEnabled(enabled: boolean);
  69719. /**
  69720. * Specifies if anti-aliasing is enabled
  69721. */
  69722. get fxaaEnabled(): boolean;
  69723. set fxaaEnabled(enabled: boolean);
  69724. /**
  69725. * Specifies if screen space reflections are enabled.
  69726. */
  69727. get screenSpaceReflectionsEnabled(): boolean;
  69728. set screenSpaceReflectionsEnabled(enabled: boolean);
  69729. /**
  69730. * Specifies the number of steps used to calculate the volumetric lights
  69731. * Typically in interval [50, 200]
  69732. */
  69733. get volumetricLightStepsCount(): number;
  69734. set volumetricLightStepsCount(count: number);
  69735. /**
  69736. * Specifies the number of samples used for the motion blur effect
  69737. * Typically in interval [16, 64]
  69738. */
  69739. get motionBlurSamples(): number;
  69740. set motionBlurSamples(samples: number);
  69741. /**
  69742. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69743. */
  69744. get samples(): number;
  69745. set samples(sampleCount: number);
  69746. /**
  69747. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  69748. * @constructor
  69749. * @param name The rendering pipeline name
  69750. * @param scene The scene linked to this pipeline
  69751. * @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)
  69752. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  69753. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69754. */
  69755. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  69756. private _buildPipeline;
  69757. private _createDownSampleX4PostProcess;
  69758. private _createBrightPassPostProcess;
  69759. private _createBlurPostProcesses;
  69760. private _createTextureAdderPostProcess;
  69761. private _createVolumetricLightPostProcess;
  69762. private _createLuminancePostProcesses;
  69763. private _createHdrPostProcess;
  69764. private _createLensFlarePostProcess;
  69765. private _createDepthOfFieldPostProcess;
  69766. private _createMotionBlurPostProcess;
  69767. private _getDepthTexture;
  69768. private _disposePostProcesses;
  69769. /**
  69770. * Dispose of the pipeline and stop all post processes
  69771. */
  69772. dispose(): void;
  69773. /**
  69774. * Serialize the rendering pipeline (Used when exporting)
  69775. * @returns the serialized object
  69776. */
  69777. serialize(): any;
  69778. /**
  69779. * Parse the serialized pipeline
  69780. * @param source Source pipeline.
  69781. * @param scene The scene to load the pipeline to.
  69782. * @param rootUrl The URL of the serialized pipeline.
  69783. * @returns An instantiated pipeline from the serialized object.
  69784. */
  69785. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  69786. /**
  69787. * Luminance steps
  69788. */
  69789. static LuminanceSteps: number;
  69790. }
  69791. }
  69792. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  69793. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  69794. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  69795. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  69796. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  69797. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  69798. }
  69799. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  69800. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  69801. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69802. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69803. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69804. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69805. }
  69806. declare module "babylonjs/Shaders/tonemap.fragment" {
  69807. /** @hidden */
  69808. export var tonemapPixelShader: {
  69809. name: string;
  69810. shader: string;
  69811. };
  69812. }
  69813. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  69814. import { Camera } from "babylonjs/Cameras/camera";
  69815. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69816. import "babylonjs/Shaders/tonemap.fragment";
  69817. import { Engine } from "babylonjs/Engines/engine";
  69818. /** Defines operator used for tonemapping */
  69819. export enum TonemappingOperator {
  69820. /** Hable */
  69821. Hable = 0,
  69822. /** Reinhard */
  69823. Reinhard = 1,
  69824. /** HejiDawson */
  69825. HejiDawson = 2,
  69826. /** Photographic */
  69827. Photographic = 3
  69828. }
  69829. /**
  69830. * Defines a post process to apply tone mapping
  69831. */
  69832. export class TonemapPostProcess extends PostProcess {
  69833. private _operator;
  69834. /** Defines the required exposure adjustement */
  69835. exposureAdjustment: number;
  69836. /**
  69837. * Creates a new TonemapPostProcess
  69838. * @param name defines the name of the postprocess
  69839. * @param _operator defines the operator to use
  69840. * @param exposureAdjustment defines the required exposure adjustement
  69841. * @param camera defines the camera to use (can be null)
  69842. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  69843. * @param engine defines the hosting engine (can be ignore if camera is set)
  69844. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  69845. */
  69846. constructor(name: string, _operator: TonemappingOperator,
  69847. /** Defines the required exposure adjustement */
  69848. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  69849. }
  69850. }
  69851. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  69852. /** @hidden */
  69853. export var volumetricLightScatteringPixelShader: {
  69854. name: string;
  69855. shader: string;
  69856. };
  69857. }
  69858. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  69859. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  69860. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  69861. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  69862. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  69863. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  69864. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  69865. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  69866. /** @hidden */
  69867. export var volumetricLightScatteringPassVertexShader: {
  69868. name: string;
  69869. shader: string;
  69870. };
  69871. }
  69872. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  69873. /** @hidden */
  69874. export var volumetricLightScatteringPassPixelShader: {
  69875. name: string;
  69876. shader: string;
  69877. };
  69878. }
  69879. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  69880. import { Vector3 } from "babylonjs/Maths/math.vector";
  69881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69882. import { Mesh } from "babylonjs/Meshes/mesh";
  69883. import { Camera } from "babylonjs/Cameras/camera";
  69884. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  69885. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  69886. import { Scene } from "babylonjs/scene";
  69887. import "babylonjs/Meshes/Builders/planeBuilder";
  69888. import "babylonjs/Shaders/depth.vertex";
  69889. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  69890. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  69891. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  69892. import { Engine } from "babylonjs/Engines/engine";
  69893. /**
  69894. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  69895. */
  69896. export class VolumetricLightScatteringPostProcess extends PostProcess {
  69897. private _volumetricLightScatteringPass;
  69898. private _volumetricLightScatteringRTT;
  69899. private _viewPort;
  69900. private _screenCoordinates;
  69901. private _cachedDefines;
  69902. /**
  69903. * If not undefined, the mesh position is computed from the attached node position
  69904. */
  69905. attachedNode: {
  69906. position: Vector3;
  69907. };
  69908. /**
  69909. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  69910. */
  69911. customMeshPosition: Vector3;
  69912. /**
  69913. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  69914. */
  69915. useCustomMeshPosition: boolean;
  69916. /**
  69917. * If the post-process should inverse the light scattering direction
  69918. */
  69919. invert: boolean;
  69920. /**
  69921. * The internal mesh used by the post-process
  69922. */
  69923. mesh: Mesh;
  69924. /**
  69925. * @hidden
  69926. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  69927. */
  69928. get useDiffuseColor(): boolean;
  69929. set useDiffuseColor(useDiffuseColor: boolean);
  69930. /**
  69931. * Array containing the excluded meshes not rendered in the internal pass
  69932. */
  69933. excludedMeshes: AbstractMesh[];
  69934. /**
  69935. * Controls the overall intensity of the post-process
  69936. */
  69937. exposure: number;
  69938. /**
  69939. * Dissipates each sample's contribution in range [0, 1]
  69940. */
  69941. decay: number;
  69942. /**
  69943. * Controls the overall intensity of each sample
  69944. */
  69945. weight: number;
  69946. /**
  69947. * Controls the density of each sample
  69948. */
  69949. density: number;
  69950. /**
  69951. * @constructor
  69952. * @param name The post-process name
  69953. * @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)
  69954. * @param camera The camera that the post-process will be attached to
  69955. * @param mesh The mesh used to create the light scattering
  69956. * @param samples The post-process quality, default 100
  69957. * @param samplingModeThe post-process filtering mode
  69958. * @param engine The babylon engine
  69959. * @param reusable If the post-process is reusable
  69960. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  69961. */
  69962. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  69963. /**
  69964. * Returns the string "VolumetricLightScatteringPostProcess"
  69965. * @returns "VolumetricLightScatteringPostProcess"
  69966. */
  69967. getClassName(): string;
  69968. private _isReady;
  69969. /**
  69970. * Sets the new light position for light scattering effect
  69971. * @param position The new custom light position
  69972. */
  69973. setCustomMeshPosition(position: Vector3): void;
  69974. /**
  69975. * Returns the light position for light scattering effect
  69976. * @return Vector3 The custom light position
  69977. */
  69978. getCustomMeshPosition(): Vector3;
  69979. /**
  69980. * Disposes the internal assets and detaches the post-process from the camera
  69981. */
  69982. dispose(camera: Camera): void;
  69983. /**
  69984. * Returns the render target texture used by the post-process
  69985. * @return the render target texture used by the post-process
  69986. */
  69987. getPass(): RenderTargetTexture;
  69988. private _meshExcluded;
  69989. private _createPass;
  69990. private _updateMeshScreenCoordinates;
  69991. /**
  69992. * Creates a default mesh for the Volumeric Light Scattering post-process
  69993. * @param name The mesh name
  69994. * @param scene The scene where to create the mesh
  69995. * @return the default mesh
  69996. */
  69997. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  69998. }
  69999. }
  70000. declare module "babylonjs/PostProcesses/index" {
  70001. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  70002. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  70003. export * from "babylonjs/PostProcesses/bloomEffect";
  70004. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  70005. export * from "babylonjs/PostProcesses/blurPostProcess";
  70006. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  70007. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  70008. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  70009. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  70010. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  70011. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  70012. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  70013. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  70014. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  70015. export * from "babylonjs/PostProcesses/filterPostProcess";
  70016. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  70017. export * from "babylonjs/PostProcesses/grainPostProcess";
  70018. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  70019. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  70020. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  70021. export * from "babylonjs/PostProcesses/passPostProcess";
  70022. export * from "babylonjs/PostProcesses/postProcess";
  70023. export * from "babylonjs/PostProcesses/postProcessManager";
  70024. export * from "babylonjs/PostProcesses/refractionPostProcess";
  70025. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  70026. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  70027. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  70028. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  70029. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  70030. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  70031. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  70032. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70033. }
  70034. declare module "babylonjs/Probes/index" {
  70035. export * from "babylonjs/Probes/reflectionProbe";
  70036. }
  70037. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  70038. import { Scene } from "babylonjs/scene";
  70039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70040. import { SmartArray } from "babylonjs/Misc/smartArray";
  70041. import { ISceneComponent } from "babylonjs/sceneComponent";
  70042. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  70043. import "babylonjs/Meshes/Builders/boxBuilder";
  70044. import "babylonjs/Shaders/color.fragment";
  70045. import "babylonjs/Shaders/color.vertex";
  70046. import { Color3 } from "babylonjs/Maths/math.color";
  70047. module "babylonjs/scene" {
  70048. interface Scene {
  70049. /** @hidden (Backing field) */
  70050. _boundingBoxRenderer: BoundingBoxRenderer;
  70051. /** @hidden (Backing field) */
  70052. _forceShowBoundingBoxes: boolean;
  70053. /**
  70054. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70055. */
  70056. forceShowBoundingBoxes: boolean;
  70057. /**
  70058. * Gets the bounding box renderer associated with the scene
  70059. * @returns a BoundingBoxRenderer
  70060. */
  70061. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70062. }
  70063. }
  70064. module "babylonjs/Meshes/abstractMesh" {
  70065. interface AbstractMesh {
  70066. /** @hidden (Backing field) */
  70067. _showBoundingBox: boolean;
  70068. /**
  70069. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70070. */
  70071. showBoundingBox: boolean;
  70072. }
  70073. }
  70074. /**
  70075. * Component responsible of rendering the bounding box of the meshes in a scene.
  70076. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70077. */
  70078. export class BoundingBoxRenderer implements ISceneComponent {
  70079. /**
  70080. * The component name helpfull to identify the component in the list of scene components.
  70081. */
  70082. readonly name: string;
  70083. /**
  70084. * The scene the component belongs to.
  70085. */
  70086. scene: Scene;
  70087. /**
  70088. * Color of the bounding box lines placed in front of an object
  70089. */
  70090. frontColor: Color3;
  70091. /**
  70092. * Color of the bounding box lines placed behind an object
  70093. */
  70094. backColor: Color3;
  70095. /**
  70096. * Defines if the renderer should show the back lines or not
  70097. */
  70098. showBackLines: boolean;
  70099. /**
  70100. * @hidden
  70101. */
  70102. renderList: SmartArray<BoundingBox>;
  70103. private _colorShader;
  70104. private _vertexBuffers;
  70105. private _indexBuffer;
  70106. private _fillIndexBuffer;
  70107. private _fillIndexData;
  70108. /**
  70109. * Instantiates a new bounding box renderer in a scene.
  70110. * @param scene the scene the renderer renders in
  70111. */
  70112. constructor(scene: Scene);
  70113. /**
  70114. * Registers the component in a given scene
  70115. */
  70116. register(): void;
  70117. private _evaluateSubMesh;
  70118. private _activeMesh;
  70119. private _prepareRessources;
  70120. private _createIndexBuffer;
  70121. /**
  70122. * Rebuilds the elements related to this component in case of
  70123. * context lost for instance.
  70124. */
  70125. rebuild(): void;
  70126. /**
  70127. * @hidden
  70128. */
  70129. reset(): void;
  70130. /**
  70131. * Render the bounding boxes of a specific rendering group
  70132. * @param renderingGroupId defines the rendering group to render
  70133. */
  70134. render(renderingGroupId: number): void;
  70135. /**
  70136. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70137. * @param mesh Define the mesh to render the occlusion bounding box for
  70138. */
  70139. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70140. /**
  70141. * Dispose and release the resources attached to this renderer.
  70142. */
  70143. dispose(): void;
  70144. }
  70145. }
  70146. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70147. import { Nullable } from "babylonjs/types";
  70148. import { Scene } from "babylonjs/scene";
  70149. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70150. import { Camera } from "babylonjs/Cameras/camera";
  70151. import { ISceneComponent } from "babylonjs/sceneComponent";
  70152. module "babylonjs/scene" {
  70153. interface Scene {
  70154. /** @hidden (Backing field) */
  70155. _depthRenderer: {
  70156. [id: string]: DepthRenderer;
  70157. };
  70158. /**
  70159. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70160. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70161. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70162. * @returns the created depth renderer
  70163. */
  70164. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70165. /**
  70166. * Disables a depth renderer for a given camera
  70167. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70168. */
  70169. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70170. }
  70171. }
  70172. /**
  70173. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70174. * in several rendering techniques.
  70175. */
  70176. export class DepthRendererSceneComponent implements ISceneComponent {
  70177. /**
  70178. * The component name helpfull to identify the component in the list of scene components.
  70179. */
  70180. readonly name: string;
  70181. /**
  70182. * The scene the component belongs to.
  70183. */
  70184. scene: Scene;
  70185. /**
  70186. * Creates a new instance of the component for the given scene
  70187. * @param scene Defines the scene to register the component in
  70188. */
  70189. constructor(scene: Scene);
  70190. /**
  70191. * Registers the component in a given scene
  70192. */
  70193. register(): void;
  70194. /**
  70195. * Rebuilds the elements related to this component in case of
  70196. * context lost for instance.
  70197. */
  70198. rebuild(): void;
  70199. /**
  70200. * Disposes the component and the associated ressources
  70201. */
  70202. dispose(): void;
  70203. private _gatherRenderTargets;
  70204. private _gatherActiveCameraRenderTargets;
  70205. }
  70206. }
  70207. declare module "babylonjs/Shaders/outline.fragment" {
  70208. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70209. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70210. /** @hidden */
  70211. export var outlinePixelShader: {
  70212. name: string;
  70213. shader: string;
  70214. };
  70215. }
  70216. declare module "babylonjs/Shaders/outline.vertex" {
  70217. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70218. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70219. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70220. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70221. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70222. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70223. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70224. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70225. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  70226. /** @hidden */
  70227. export var outlineVertexShader: {
  70228. name: string;
  70229. shader: string;
  70230. };
  70231. }
  70232. declare module "babylonjs/Rendering/outlineRenderer" {
  70233. import { SubMesh } from "babylonjs/Meshes/subMesh";
  70234. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  70235. import { Scene } from "babylonjs/scene";
  70236. import { ISceneComponent } from "babylonjs/sceneComponent";
  70237. import "babylonjs/Shaders/outline.fragment";
  70238. import "babylonjs/Shaders/outline.vertex";
  70239. module "babylonjs/scene" {
  70240. interface Scene {
  70241. /** @hidden */
  70242. _outlineRenderer: OutlineRenderer;
  70243. /**
  70244. * Gets the outline renderer associated with the scene
  70245. * @returns a OutlineRenderer
  70246. */
  70247. getOutlineRenderer(): OutlineRenderer;
  70248. }
  70249. }
  70250. module "babylonjs/Meshes/abstractMesh" {
  70251. interface AbstractMesh {
  70252. /** @hidden (Backing field) */
  70253. _renderOutline: boolean;
  70254. /**
  70255. * Gets or sets a boolean indicating if the outline must be rendered as well
  70256. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  70257. */
  70258. renderOutline: boolean;
  70259. /** @hidden (Backing field) */
  70260. _renderOverlay: boolean;
  70261. /**
  70262. * Gets or sets a boolean indicating if the overlay must be rendered as well
  70263. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  70264. */
  70265. renderOverlay: boolean;
  70266. }
  70267. }
  70268. /**
  70269. * This class is responsible to draw bothe outline/overlay of meshes.
  70270. * It should not be used directly but through the available method on mesh.
  70271. */
  70272. export class OutlineRenderer implements ISceneComponent {
  70273. /**
  70274. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  70275. */
  70276. private static _StencilReference;
  70277. /**
  70278. * The name of the component. Each component must have a unique name.
  70279. */
  70280. name: string;
  70281. /**
  70282. * The scene the component belongs to.
  70283. */
  70284. scene: Scene;
  70285. /**
  70286. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  70287. */
  70288. zOffset: number;
  70289. private _engine;
  70290. private _effect;
  70291. private _cachedDefines;
  70292. private _savedDepthWrite;
  70293. /**
  70294. * Instantiates a new outline renderer. (There could be only one per scene).
  70295. * @param scene Defines the scene it belongs to
  70296. */
  70297. constructor(scene: Scene);
  70298. /**
  70299. * Register the component to one instance of a scene.
  70300. */
  70301. register(): void;
  70302. /**
  70303. * Rebuilds the elements related to this component in case of
  70304. * context lost for instance.
  70305. */
  70306. rebuild(): void;
  70307. /**
  70308. * Disposes the component and the associated ressources.
  70309. */
  70310. dispose(): void;
  70311. /**
  70312. * Renders the outline in the canvas.
  70313. * @param subMesh Defines the sumesh to render
  70314. * @param batch Defines the batch of meshes in case of instances
  70315. * @param useOverlay Defines if the rendering is for the overlay or the outline
  70316. */
  70317. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  70318. /**
  70319. * Returns whether or not the outline renderer is ready for a given submesh.
  70320. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  70321. * @param subMesh Defines the submesh to check readyness for
  70322. * @param useInstances Defines wheter wee are trying to render instances or not
  70323. * @returns true if ready otherwise false
  70324. */
  70325. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  70326. private _beforeRenderingMesh;
  70327. private _afterRenderingMesh;
  70328. }
  70329. }
  70330. declare module "babylonjs/Rendering/index" {
  70331. export * from "babylonjs/Rendering/boundingBoxRenderer";
  70332. export * from "babylonjs/Rendering/depthRenderer";
  70333. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  70334. export * from "babylonjs/Rendering/edgesRenderer";
  70335. export * from "babylonjs/Rendering/geometryBufferRenderer";
  70336. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  70337. export * from "babylonjs/Rendering/outlineRenderer";
  70338. export * from "babylonjs/Rendering/renderingGroup";
  70339. export * from "babylonjs/Rendering/renderingManager";
  70340. export * from "babylonjs/Rendering/utilityLayerRenderer";
  70341. }
  70342. declare module "babylonjs/Sprites/ISprites" {
  70343. /**
  70344. * Defines the basic options interface of a Sprite Frame Source Size.
  70345. */
  70346. export interface ISpriteJSONSpriteSourceSize {
  70347. /**
  70348. * number of the original width of the Frame
  70349. */
  70350. w: number;
  70351. /**
  70352. * number of the original height of the Frame
  70353. */
  70354. h: number;
  70355. }
  70356. /**
  70357. * Defines the basic options interface of a Sprite Frame Data.
  70358. */
  70359. export interface ISpriteJSONSpriteFrameData {
  70360. /**
  70361. * number of the x offset of the Frame
  70362. */
  70363. x: number;
  70364. /**
  70365. * number of the y offset of the Frame
  70366. */
  70367. y: number;
  70368. /**
  70369. * number of the width of the Frame
  70370. */
  70371. w: number;
  70372. /**
  70373. * number of the height of the Frame
  70374. */
  70375. h: number;
  70376. }
  70377. /**
  70378. * Defines the basic options interface of a JSON Sprite.
  70379. */
  70380. export interface ISpriteJSONSprite {
  70381. /**
  70382. * string name of the Frame
  70383. */
  70384. filename: string;
  70385. /**
  70386. * ISpriteJSONSpriteFrame basic object of the frame data
  70387. */
  70388. frame: ISpriteJSONSpriteFrameData;
  70389. /**
  70390. * boolean to flag is the frame was rotated.
  70391. */
  70392. rotated: boolean;
  70393. /**
  70394. * boolean to flag is the frame was trimmed.
  70395. */
  70396. trimmed: boolean;
  70397. /**
  70398. * ISpriteJSONSpriteFrame basic object of the source data
  70399. */
  70400. spriteSourceSize: ISpriteJSONSpriteFrameData;
  70401. /**
  70402. * ISpriteJSONSpriteFrame basic object of the source data
  70403. */
  70404. sourceSize: ISpriteJSONSpriteSourceSize;
  70405. }
  70406. /**
  70407. * Defines the basic options interface of a JSON atlas.
  70408. */
  70409. export interface ISpriteJSONAtlas {
  70410. /**
  70411. * Array of objects that contain the frame data.
  70412. */
  70413. frames: Array<ISpriteJSONSprite>;
  70414. /**
  70415. * object basic object containing the sprite meta data.
  70416. */
  70417. meta?: object;
  70418. }
  70419. }
  70420. declare module "babylonjs/Shaders/spriteMap.fragment" {
  70421. /** @hidden */
  70422. export var spriteMapPixelShader: {
  70423. name: string;
  70424. shader: string;
  70425. };
  70426. }
  70427. declare module "babylonjs/Shaders/spriteMap.vertex" {
  70428. /** @hidden */
  70429. export var spriteMapVertexShader: {
  70430. name: string;
  70431. shader: string;
  70432. };
  70433. }
  70434. declare module "babylonjs/Sprites/spriteMap" {
  70435. import { IDisposable, Scene } from "babylonjs/scene";
  70436. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  70437. import { Texture } from "babylonjs/Materials/Textures/texture";
  70438. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  70439. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  70440. import "babylonjs/Meshes/Builders/planeBuilder";
  70441. import "babylonjs/Shaders/spriteMap.fragment";
  70442. import "babylonjs/Shaders/spriteMap.vertex";
  70443. /**
  70444. * Defines the basic options interface of a SpriteMap
  70445. */
  70446. export interface ISpriteMapOptions {
  70447. /**
  70448. * Vector2 of the number of cells in the grid.
  70449. */
  70450. stageSize?: Vector2;
  70451. /**
  70452. * Vector2 of the size of the output plane in World Units.
  70453. */
  70454. outputSize?: Vector2;
  70455. /**
  70456. * Vector3 of the position of the output plane in World Units.
  70457. */
  70458. outputPosition?: Vector3;
  70459. /**
  70460. * Vector3 of the rotation of the output plane.
  70461. */
  70462. outputRotation?: Vector3;
  70463. /**
  70464. * number of layers that the system will reserve in resources.
  70465. */
  70466. layerCount?: number;
  70467. /**
  70468. * number of max animation frames a single cell will reserve in resources.
  70469. */
  70470. maxAnimationFrames?: number;
  70471. /**
  70472. * number cell index of the base tile when the system compiles.
  70473. */
  70474. baseTile?: number;
  70475. /**
  70476. * boolean flip the sprite after its been repositioned by the framing data.
  70477. */
  70478. flipU?: boolean;
  70479. /**
  70480. * Vector3 scalar of the global RGB values of the SpriteMap.
  70481. */
  70482. colorMultiply?: Vector3;
  70483. }
  70484. /**
  70485. * Defines the IDisposable interface in order to be cleanable from resources.
  70486. */
  70487. export interface ISpriteMap extends IDisposable {
  70488. /**
  70489. * String name of the SpriteMap.
  70490. */
  70491. name: string;
  70492. /**
  70493. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  70494. */
  70495. atlasJSON: ISpriteJSONAtlas;
  70496. /**
  70497. * Texture of the SpriteMap.
  70498. */
  70499. spriteSheet: Texture;
  70500. /**
  70501. * The parameters to initialize the SpriteMap with.
  70502. */
  70503. options: ISpriteMapOptions;
  70504. }
  70505. /**
  70506. * Class used to manage a grid restricted sprite deployment on an Output plane.
  70507. */
  70508. export class SpriteMap implements ISpriteMap {
  70509. /** The Name of the spriteMap */
  70510. name: string;
  70511. /** The JSON file with the frame and meta data */
  70512. atlasJSON: ISpriteJSONAtlas;
  70513. /** The systems Sprite Sheet Texture */
  70514. spriteSheet: Texture;
  70515. /** Arguments passed with the Constructor */
  70516. options: ISpriteMapOptions;
  70517. /** Public Sprite Storage array, parsed from atlasJSON */
  70518. sprites: Array<ISpriteJSONSprite>;
  70519. /** Returns the Number of Sprites in the System */
  70520. get spriteCount(): number;
  70521. /** Returns the Position of Output Plane*/
  70522. get position(): Vector3;
  70523. /** Returns the Position of Output Plane*/
  70524. set position(v: Vector3);
  70525. /** Returns the Rotation of Output Plane*/
  70526. get rotation(): Vector3;
  70527. /** Returns the Rotation of Output Plane*/
  70528. set rotation(v: Vector3);
  70529. /** Sets the AnimationMap*/
  70530. get animationMap(): RawTexture;
  70531. /** Sets the AnimationMap*/
  70532. set animationMap(v: RawTexture);
  70533. /** Scene that the SpriteMap was created in */
  70534. private _scene;
  70535. /** Texture Buffer of Float32 that holds tile frame data*/
  70536. private _frameMap;
  70537. /** Texture Buffers of Float32 that holds tileMap data*/
  70538. private _tileMaps;
  70539. /** Texture Buffer of Float32 that holds Animation Data*/
  70540. private _animationMap;
  70541. /** Custom ShaderMaterial Central to the System*/
  70542. private _material;
  70543. /** Custom ShaderMaterial Central to the System*/
  70544. private _output;
  70545. /** Systems Time Ticker*/
  70546. private _time;
  70547. /**
  70548. * Creates a new SpriteMap
  70549. * @param name defines the SpriteMaps Name
  70550. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  70551. * @param spriteSheet is the Texture that the Sprites are on.
  70552. * @param options a basic deployment configuration
  70553. * @param scene The Scene that the map is deployed on
  70554. */
  70555. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  70556. /**
  70557. * Returns tileID location
  70558. * @returns Vector2 the cell position ID
  70559. */
  70560. getTileID(): Vector2;
  70561. /**
  70562. * Gets the UV location of the mouse over the SpriteMap.
  70563. * @returns Vector2 the UV position of the mouse interaction
  70564. */
  70565. getMousePosition(): Vector2;
  70566. /**
  70567. * Creates the "frame" texture Buffer
  70568. * -------------------------------------
  70569. * Structure of frames
  70570. * "filename": "Falling-Water-2.png",
  70571. * "frame": {"x":69,"y":103,"w":24,"h":32},
  70572. * "rotated": true,
  70573. * "trimmed": true,
  70574. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  70575. * "sourceSize": {"w":32,"h":32}
  70576. * @returns RawTexture of the frameMap
  70577. */
  70578. private _createFrameBuffer;
  70579. /**
  70580. * Creates the tileMap texture Buffer
  70581. * @param buffer normally and array of numbers, or a false to generate from scratch
  70582. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  70583. * @returns RawTexture of the tileMap
  70584. */
  70585. private _createTileBuffer;
  70586. /**
  70587. * Modifies the data of the tileMaps
  70588. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  70589. * @param pos is the iVector2 Coordinates of the Tile
  70590. * @param tile The SpriteIndex of the new Tile
  70591. */
  70592. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  70593. /**
  70594. * Creates the animationMap texture Buffer
  70595. * @param buffer normally and array of numbers, or a false to generate from scratch
  70596. * @returns RawTexture of the animationMap
  70597. */
  70598. private _createTileAnimationBuffer;
  70599. /**
  70600. * Modifies the data of the animationMap
  70601. * @param cellID is the Index of the Sprite
  70602. * @param _frame is the target Animation frame
  70603. * @param toCell is the Target Index of the next frame of the animation
  70604. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  70605. * @param speed is a global scalar of the time variable on the map.
  70606. */
  70607. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  70608. /**
  70609. * Exports the .tilemaps file
  70610. */
  70611. saveTileMaps(): void;
  70612. /**
  70613. * Imports the .tilemaps file
  70614. * @param url of the .tilemaps file
  70615. */
  70616. loadTileMaps(url: string): void;
  70617. /**
  70618. * Release associated resources
  70619. */
  70620. dispose(): void;
  70621. }
  70622. }
  70623. declare module "babylonjs/Sprites/spritePackedManager" {
  70624. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  70625. import { Scene } from "babylonjs/scene";
  70626. /**
  70627. * Class used to manage multiple sprites of different sizes on the same spritesheet
  70628. * @see http://doc.babylonjs.com/babylon101/sprites
  70629. */
  70630. export class SpritePackedManager extends SpriteManager {
  70631. /** defines the packed manager's name */
  70632. name: string;
  70633. /**
  70634. * Creates a new sprite manager from a packed sprite sheet
  70635. * @param name defines the manager's name
  70636. * @param imgUrl defines the sprite sheet url
  70637. * @param capacity defines the maximum allowed number of sprites
  70638. * @param scene defines the hosting scene
  70639. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  70640. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  70641. * @param samplingMode defines the smapling mode to use with spritesheet
  70642. * @param fromPacked set to true; do not alter
  70643. */
  70644. constructor(
  70645. /** defines the packed manager's name */
  70646. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  70647. }
  70648. }
  70649. declare module "babylonjs/Sprites/index" {
  70650. export * from "babylonjs/Sprites/sprite";
  70651. export * from "babylonjs/Sprites/ISprites";
  70652. export * from "babylonjs/Sprites/spriteManager";
  70653. export * from "babylonjs/Sprites/spriteMap";
  70654. export * from "babylonjs/Sprites/spritePackedManager";
  70655. export * from "babylonjs/Sprites/spriteSceneComponent";
  70656. }
  70657. declare module "babylonjs/States/index" {
  70658. export * from "babylonjs/States/alphaCullingState";
  70659. export * from "babylonjs/States/depthCullingState";
  70660. export * from "babylonjs/States/stencilState";
  70661. }
  70662. declare module "babylonjs/Misc/assetsManager" {
  70663. import { Scene } from "babylonjs/scene";
  70664. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70665. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  70666. import { Skeleton } from "babylonjs/Bones/skeleton";
  70667. import { Observable } from "babylonjs/Misc/observable";
  70668. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  70669. import { Texture } from "babylonjs/Materials/Textures/texture";
  70670. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  70671. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  70672. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  70673. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  70674. /**
  70675. * Defines the list of states available for a task inside a AssetsManager
  70676. */
  70677. export enum AssetTaskState {
  70678. /**
  70679. * Initialization
  70680. */
  70681. INIT = 0,
  70682. /**
  70683. * Running
  70684. */
  70685. RUNNING = 1,
  70686. /**
  70687. * Done
  70688. */
  70689. DONE = 2,
  70690. /**
  70691. * Error
  70692. */
  70693. ERROR = 3
  70694. }
  70695. /**
  70696. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  70697. */
  70698. export abstract class AbstractAssetTask {
  70699. /**
  70700. * Task name
  70701. */ name: string;
  70702. /**
  70703. * Callback called when the task is successful
  70704. */
  70705. onSuccess: (task: any) => void;
  70706. /**
  70707. * Callback called when the task is not successful
  70708. */
  70709. onError: (task: any, message?: string, exception?: any) => void;
  70710. /**
  70711. * Creates a new AssetsManager
  70712. * @param name defines the name of the task
  70713. */
  70714. constructor(
  70715. /**
  70716. * Task name
  70717. */ name: string);
  70718. private _isCompleted;
  70719. private _taskState;
  70720. private _errorObject;
  70721. /**
  70722. * Get if the task is completed
  70723. */
  70724. get isCompleted(): boolean;
  70725. /**
  70726. * Gets the current state of the task
  70727. */
  70728. get taskState(): AssetTaskState;
  70729. /**
  70730. * Gets the current error object (if task is in error)
  70731. */
  70732. get errorObject(): {
  70733. message?: string;
  70734. exception?: any;
  70735. };
  70736. /**
  70737. * Internal only
  70738. * @hidden
  70739. */
  70740. _setErrorObject(message?: string, exception?: any): void;
  70741. /**
  70742. * Execute the current task
  70743. * @param scene defines the scene where you want your assets to be loaded
  70744. * @param onSuccess is a callback called when the task is successfully executed
  70745. * @param onError is a callback called if an error occurs
  70746. */
  70747. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70748. /**
  70749. * Execute the current task
  70750. * @param scene defines the scene where you want your assets to be loaded
  70751. * @param onSuccess is a callback called when the task is successfully executed
  70752. * @param onError is a callback called if an error occurs
  70753. */
  70754. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70755. /**
  70756. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  70757. * This can be used with failed tasks that have the reason for failure fixed.
  70758. */
  70759. reset(): void;
  70760. private onErrorCallback;
  70761. private onDoneCallback;
  70762. }
  70763. /**
  70764. * Define the interface used by progress events raised during assets loading
  70765. */
  70766. export interface IAssetsProgressEvent {
  70767. /**
  70768. * Defines the number of remaining tasks to process
  70769. */
  70770. remainingCount: number;
  70771. /**
  70772. * Defines the total number of tasks
  70773. */
  70774. totalCount: number;
  70775. /**
  70776. * Defines the task that was just processed
  70777. */
  70778. task: AbstractAssetTask;
  70779. }
  70780. /**
  70781. * Class used to share progress information about assets loading
  70782. */
  70783. export class AssetsProgressEvent implements IAssetsProgressEvent {
  70784. /**
  70785. * Defines the number of remaining tasks to process
  70786. */
  70787. remainingCount: number;
  70788. /**
  70789. * Defines the total number of tasks
  70790. */
  70791. totalCount: number;
  70792. /**
  70793. * Defines the task that was just processed
  70794. */
  70795. task: AbstractAssetTask;
  70796. /**
  70797. * Creates a AssetsProgressEvent
  70798. * @param remainingCount defines the number of remaining tasks to process
  70799. * @param totalCount defines the total number of tasks
  70800. * @param task defines the task that was just processed
  70801. */
  70802. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  70803. }
  70804. /**
  70805. * Define a task used by AssetsManager to load meshes
  70806. */
  70807. export class MeshAssetTask extends AbstractAssetTask {
  70808. /**
  70809. * Defines the name of the task
  70810. */
  70811. name: string;
  70812. /**
  70813. * Defines the list of mesh's names you want to load
  70814. */
  70815. meshesNames: any;
  70816. /**
  70817. * Defines the root url to use as a base to load your meshes and associated resources
  70818. */
  70819. rootUrl: string;
  70820. /**
  70821. * Defines the filename of the scene to load from
  70822. */
  70823. sceneFilename: string;
  70824. /**
  70825. * Gets the list of loaded meshes
  70826. */
  70827. loadedMeshes: Array<AbstractMesh>;
  70828. /**
  70829. * Gets the list of loaded particle systems
  70830. */
  70831. loadedParticleSystems: Array<IParticleSystem>;
  70832. /**
  70833. * Gets the list of loaded skeletons
  70834. */
  70835. loadedSkeletons: Array<Skeleton>;
  70836. /**
  70837. * Gets the list of loaded animation groups
  70838. */
  70839. loadedAnimationGroups: Array<AnimationGroup>;
  70840. /**
  70841. * Callback called when the task is successful
  70842. */
  70843. onSuccess: (task: MeshAssetTask) => void;
  70844. /**
  70845. * Callback called when the task is successful
  70846. */
  70847. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  70848. /**
  70849. * Creates a new MeshAssetTask
  70850. * @param name defines the name of the task
  70851. * @param meshesNames defines the list of mesh's names you want to load
  70852. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  70853. * @param sceneFilename defines the filename of the scene to load from
  70854. */
  70855. constructor(
  70856. /**
  70857. * Defines the name of the task
  70858. */
  70859. name: string,
  70860. /**
  70861. * Defines the list of mesh's names you want to load
  70862. */
  70863. meshesNames: any,
  70864. /**
  70865. * Defines the root url to use as a base to load your meshes and associated resources
  70866. */
  70867. rootUrl: string,
  70868. /**
  70869. * Defines the filename of the scene to load from
  70870. */
  70871. sceneFilename: string);
  70872. /**
  70873. * Execute the current task
  70874. * @param scene defines the scene where you want your assets to be loaded
  70875. * @param onSuccess is a callback called when the task is successfully executed
  70876. * @param onError is a callback called if an error occurs
  70877. */
  70878. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70879. }
  70880. /**
  70881. * Define a task used by AssetsManager to load text content
  70882. */
  70883. export class TextFileAssetTask extends AbstractAssetTask {
  70884. /**
  70885. * Defines the name of the task
  70886. */
  70887. name: string;
  70888. /**
  70889. * Defines the location of the file to load
  70890. */
  70891. url: string;
  70892. /**
  70893. * Gets the loaded text string
  70894. */
  70895. text: string;
  70896. /**
  70897. * Callback called when the task is successful
  70898. */
  70899. onSuccess: (task: TextFileAssetTask) => void;
  70900. /**
  70901. * Callback called when the task is successful
  70902. */
  70903. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  70904. /**
  70905. * Creates a new TextFileAssetTask object
  70906. * @param name defines the name of the task
  70907. * @param url defines the location of the file to load
  70908. */
  70909. constructor(
  70910. /**
  70911. * Defines the name of the task
  70912. */
  70913. name: string,
  70914. /**
  70915. * Defines the location of the file to load
  70916. */
  70917. url: string);
  70918. /**
  70919. * Execute the current task
  70920. * @param scene defines the scene where you want your assets to be loaded
  70921. * @param onSuccess is a callback called when the task is successfully executed
  70922. * @param onError is a callback called if an error occurs
  70923. */
  70924. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70925. }
  70926. /**
  70927. * Define a task used by AssetsManager to load binary data
  70928. */
  70929. export class BinaryFileAssetTask extends AbstractAssetTask {
  70930. /**
  70931. * Defines the name of the task
  70932. */
  70933. name: string;
  70934. /**
  70935. * Defines the location of the file to load
  70936. */
  70937. url: string;
  70938. /**
  70939. * Gets the lodaded data (as an array buffer)
  70940. */
  70941. data: ArrayBuffer;
  70942. /**
  70943. * Callback called when the task is successful
  70944. */
  70945. onSuccess: (task: BinaryFileAssetTask) => void;
  70946. /**
  70947. * Callback called when the task is successful
  70948. */
  70949. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  70950. /**
  70951. * Creates a new BinaryFileAssetTask object
  70952. * @param name defines the name of the new task
  70953. * @param url defines the location of the file to load
  70954. */
  70955. constructor(
  70956. /**
  70957. * Defines the name of the task
  70958. */
  70959. name: string,
  70960. /**
  70961. * Defines the location of the file to load
  70962. */
  70963. url: string);
  70964. /**
  70965. * Execute the current task
  70966. * @param scene defines the scene where you want your assets to be loaded
  70967. * @param onSuccess is a callback called when the task is successfully executed
  70968. * @param onError is a callback called if an error occurs
  70969. */
  70970. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  70971. }
  70972. /**
  70973. * Define a task used by AssetsManager to load images
  70974. */
  70975. export class ImageAssetTask extends AbstractAssetTask {
  70976. /**
  70977. * Defines the name of the task
  70978. */
  70979. name: string;
  70980. /**
  70981. * Defines the location of the image to load
  70982. */
  70983. url: string;
  70984. /**
  70985. * Gets the loaded images
  70986. */
  70987. image: HTMLImageElement;
  70988. /**
  70989. * Callback called when the task is successful
  70990. */
  70991. onSuccess: (task: ImageAssetTask) => void;
  70992. /**
  70993. * Callback called when the task is successful
  70994. */
  70995. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  70996. /**
  70997. * Creates a new ImageAssetTask
  70998. * @param name defines the name of the task
  70999. * @param url defines the location of the image to load
  71000. */
  71001. constructor(
  71002. /**
  71003. * Defines the name of the task
  71004. */
  71005. name: string,
  71006. /**
  71007. * Defines the location of the image to load
  71008. */
  71009. url: string);
  71010. /**
  71011. * Execute the current task
  71012. * @param scene defines the scene where you want your assets to be loaded
  71013. * @param onSuccess is a callback called when the task is successfully executed
  71014. * @param onError is a callback called if an error occurs
  71015. */
  71016. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71017. }
  71018. /**
  71019. * Defines the interface used by texture loading tasks
  71020. */
  71021. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71022. /**
  71023. * Gets the loaded texture
  71024. */
  71025. texture: TEX;
  71026. }
  71027. /**
  71028. * Define a task used by AssetsManager to load 2D textures
  71029. */
  71030. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71031. /**
  71032. * Defines the name of the task
  71033. */
  71034. name: string;
  71035. /**
  71036. * Defines the location of the file to load
  71037. */
  71038. url: string;
  71039. /**
  71040. * Defines if mipmap should not be generated (default is false)
  71041. */
  71042. noMipmap?: boolean | undefined;
  71043. /**
  71044. * Defines if texture must be inverted on Y axis (default is false)
  71045. */
  71046. invertY?: boolean | undefined;
  71047. /**
  71048. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71049. */
  71050. samplingMode: number;
  71051. /**
  71052. * Gets the loaded texture
  71053. */
  71054. texture: Texture;
  71055. /**
  71056. * Callback called when the task is successful
  71057. */
  71058. onSuccess: (task: TextureAssetTask) => void;
  71059. /**
  71060. * Callback called when the task is successful
  71061. */
  71062. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71063. /**
  71064. * Creates a new TextureAssetTask object
  71065. * @param name defines the name of the task
  71066. * @param url defines the location of the file to load
  71067. * @param noMipmap defines if mipmap should not be generated (default is false)
  71068. * @param invertY defines if texture must be inverted on Y axis (default is false)
  71069. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71070. */
  71071. constructor(
  71072. /**
  71073. * Defines the name of the task
  71074. */
  71075. name: string,
  71076. /**
  71077. * Defines the location of the file to load
  71078. */
  71079. url: string,
  71080. /**
  71081. * Defines if mipmap should not be generated (default is false)
  71082. */
  71083. noMipmap?: boolean | undefined,
  71084. /**
  71085. * Defines if texture must be inverted on Y axis (default is false)
  71086. */
  71087. invertY?: boolean | undefined,
  71088. /**
  71089. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71090. */
  71091. samplingMode?: number);
  71092. /**
  71093. * Execute the current task
  71094. * @param scene defines the scene where you want your assets to be loaded
  71095. * @param onSuccess is a callback called when the task is successfully executed
  71096. * @param onError is a callback called if an error occurs
  71097. */
  71098. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71099. }
  71100. /**
  71101. * Define a task used by AssetsManager to load cube textures
  71102. */
  71103. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71104. /**
  71105. * Defines the name of the task
  71106. */
  71107. name: string;
  71108. /**
  71109. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71110. */
  71111. url: string;
  71112. /**
  71113. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71114. */
  71115. extensions?: string[] | undefined;
  71116. /**
  71117. * Defines if mipmaps should not be generated (default is false)
  71118. */
  71119. noMipmap?: boolean | undefined;
  71120. /**
  71121. * Defines the explicit list of files (undefined by default)
  71122. */
  71123. files?: string[] | undefined;
  71124. /**
  71125. * Gets the loaded texture
  71126. */
  71127. texture: CubeTexture;
  71128. /**
  71129. * Callback called when the task is successful
  71130. */
  71131. onSuccess: (task: CubeTextureAssetTask) => void;
  71132. /**
  71133. * Callback called when the task is successful
  71134. */
  71135. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71136. /**
  71137. * Creates a new CubeTextureAssetTask
  71138. * @param name defines the name of the task
  71139. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71140. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71141. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71142. * @param files defines the explicit list of files (undefined by default)
  71143. */
  71144. constructor(
  71145. /**
  71146. * Defines the name of the task
  71147. */
  71148. name: string,
  71149. /**
  71150. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71151. */
  71152. url: string,
  71153. /**
  71154. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71155. */
  71156. extensions?: string[] | undefined,
  71157. /**
  71158. * Defines if mipmaps should not be generated (default is false)
  71159. */
  71160. noMipmap?: boolean | undefined,
  71161. /**
  71162. * Defines the explicit list of files (undefined by default)
  71163. */
  71164. files?: string[] | undefined);
  71165. /**
  71166. * Execute the current task
  71167. * @param scene defines the scene where you want your assets to be loaded
  71168. * @param onSuccess is a callback called when the task is successfully executed
  71169. * @param onError is a callback called if an error occurs
  71170. */
  71171. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71172. }
  71173. /**
  71174. * Define a task used by AssetsManager to load HDR cube textures
  71175. */
  71176. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71177. /**
  71178. * Defines the name of the task
  71179. */
  71180. name: string;
  71181. /**
  71182. * Defines the location of the file to load
  71183. */
  71184. url: string;
  71185. /**
  71186. * Defines the desired size (the more it increases the longer the generation will be)
  71187. */
  71188. size: number;
  71189. /**
  71190. * Defines if mipmaps should not be generated (default is false)
  71191. */
  71192. noMipmap: boolean;
  71193. /**
  71194. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71195. */
  71196. generateHarmonics: boolean;
  71197. /**
  71198. * 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)
  71199. */
  71200. gammaSpace: boolean;
  71201. /**
  71202. * Internal Use Only
  71203. */
  71204. reserved: boolean;
  71205. /**
  71206. * Gets the loaded texture
  71207. */
  71208. texture: HDRCubeTexture;
  71209. /**
  71210. * Callback called when the task is successful
  71211. */
  71212. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71213. /**
  71214. * Callback called when the task is successful
  71215. */
  71216. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  71217. /**
  71218. * Creates a new HDRCubeTextureAssetTask object
  71219. * @param name defines the name of the task
  71220. * @param url defines the location of the file to load
  71221. * @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.
  71222. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71223. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71224. * @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)
  71225. * @param reserved Internal use only
  71226. */
  71227. constructor(
  71228. /**
  71229. * Defines the name of the task
  71230. */
  71231. name: string,
  71232. /**
  71233. * Defines the location of the file to load
  71234. */
  71235. url: string,
  71236. /**
  71237. * Defines the desired size (the more it increases the longer the generation will be)
  71238. */
  71239. size: number,
  71240. /**
  71241. * Defines if mipmaps should not be generated (default is false)
  71242. */
  71243. noMipmap?: boolean,
  71244. /**
  71245. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71246. */
  71247. generateHarmonics?: boolean,
  71248. /**
  71249. * 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)
  71250. */
  71251. gammaSpace?: boolean,
  71252. /**
  71253. * Internal Use Only
  71254. */
  71255. reserved?: boolean);
  71256. /**
  71257. * Execute the current task
  71258. * @param scene defines the scene where you want your assets to be loaded
  71259. * @param onSuccess is a callback called when the task is successfully executed
  71260. * @param onError is a callback called if an error occurs
  71261. */
  71262. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71263. }
  71264. /**
  71265. * Define a task used by AssetsManager to load Equirectangular cube textures
  71266. */
  71267. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  71268. /**
  71269. * Defines the name of the task
  71270. */
  71271. name: string;
  71272. /**
  71273. * Defines the location of the file to load
  71274. */
  71275. url: string;
  71276. /**
  71277. * Defines the desired size (the more it increases the longer the generation will be)
  71278. */
  71279. size: number;
  71280. /**
  71281. * Defines if mipmaps should not be generated (default is false)
  71282. */
  71283. noMipmap: boolean;
  71284. /**
  71285. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71286. * but the standard material would require them in Gamma space) (default is true)
  71287. */
  71288. gammaSpace: boolean;
  71289. /**
  71290. * Gets the loaded texture
  71291. */
  71292. texture: EquiRectangularCubeTexture;
  71293. /**
  71294. * Callback called when the task is successful
  71295. */
  71296. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  71297. /**
  71298. * Callback called when the task is successful
  71299. */
  71300. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  71301. /**
  71302. * Creates a new EquiRectangularCubeTextureAssetTask object
  71303. * @param name defines the name of the task
  71304. * @param url defines the location of the file to load
  71305. * @param size defines the desired size (the more it increases the longer the generation will be)
  71306. * If the size is omitted this implies you are using a preprocessed cubemap.
  71307. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71308. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  71309. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  71310. * (default is true)
  71311. */
  71312. constructor(
  71313. /**
  71314. * Defines the name of the task
  71315. */
  71316. name: string,
  71317. /**
  71318. * Defines the location of the file to load
  71319. */
  71320. url: string,
  71321. /**
  71322. * Defines the desired size (the more it increases the longer the generation will be)
  71323. */
  71324. size: number,
  71325. /**
  71326. * Defines if mipmaps should not be generated (default is false)
  71327. */
  71328. noMipmap?: boolean,
  71329. /**
  71330. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  71331. * but the standard material would require them in Gamma space) (default is true)
  71332. */
  71333. gammaSpace?: boolean);
  71334. /**
  71335. * Execute the current task
  71336. * @param scene defines the scene where you want your assets to be loaded
  71337. * @param onSuccess is a callback called when the task is successfully executed
  71338. * @param onError is a callback called if an error occurs
  71339. */
  71340. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71341. }
  71342. /**
  71343. * This class can be used to easily import assets into a scene
  71344. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  71345. */
  71346. export class AssetsManager {
  71347. private _scene;
  71348. private _isLoading;
  71349. protected _tasks: AbstractAssetTask[];
  71350. protected _waitingTasksCount: number;
  71351. protected _totalTasksCount: number;
  71352. /**
  71353. * Callback called when all tasks are processed
  71354. */
  71355. onFinish: (tasks: AbstractAssetTask[]) => void;
  71356. /**
  71357. * Callback called when a task is successful
  71358. */
  71359. onTaskSuccess: (task: AbstractAssetTask) => void;
  71360. /**
  71361. * Callback called when a task had an error
  71362. */
  71363. onTaskError: (task: AbstractAssetTask) => void;
  71364. /**
  71365. * Callback called when a task is done (whatever the result is)
  71366. */
  71367. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  71368. /**
  71369. * Observable called when all tasks are processed
  71370. */
  71371. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  71372. /**
  71373. * Observable called when a task had an error
  71374. */
  71375. onTaskErrorObservable: Observable<AbstractAssetTask>;
  71376. /**
  71377. * Observable called when all tasks were executed
  71378. */
  71379. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  71380. /**
  71381. * Observable called when a task is done (whatever the result is)
  71382. */
  71383. onProgressObservable: Observable<IAssetsProgressEvent>;
  71384. /**
  71385. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  71386. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  71387. */
  71388. useDefaultLoadingScreen: boolean;
  71389. /**
  71390. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  71391. * when all assets have been downloaded.
  71392. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  71393. */
  71394. autoHideLoadingUI: boolean;
  71395. /**
  71396. * Creates a new AssetsManager
  71397. * @param scene defines the scene to work on
  71398. */
  71399. constructor(scene: Scene);
  71400. /**
  71401. * Add a MeshAssetTask to the list of active tasks
  71402. * @param taskName defines the name of the new task
  71403. * @param meshesNames defines the name of meshes to load
  71404. * @param rootUrl defines the root url to use to locate files
  71405. * @param sceneFilename defines the filename of the scene file
  71406. * @returns a new MeshAssetTask object
  71407. */
  71408. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  71409. /**
  71410. * Add a TextFileAssetTask to the list of active tasks
  71411. * @param taskName defines the name of the new task
  71412. * @param url defines the url of the file to load
  71413. * @returns a new TextFileAssetTask object
  71414. */
  71415. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  71416. /**
  71417. * Add a BinaryFileAssetTask to the list of active tasks
  71418. * @param taskName defines the name of the new task
  71419. * @param url defines the url of the file to load
  71420. * @returns a new BinaryFileAssetTask object
  71421. */
  71422. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  71423. /**
  71424. * Add a ImageAssetTask to the list of active tasks
  71425. * @param taskName defines the name of the new task
  71426. * @param url defines the url of the file to load
  71427. * @returns a new ImageAssetTask object
  71428. */
  71429. addImageTask(taskName: string, url: string): ImageAssetTask;
  71430. /**
  71431. * Add a TextureAssetTask to the list of active tasks
  71432. * @param taskName defines the name of the new task
  71433. * @param url defines the url of the file to load
  71434. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71435. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  71436. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  71437. * @returns a new TextureAssetTask object
  71438. */
  71439. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  71440. /**
  71441. * Add a CubeTextureAssetTask to the list of active tasks
  71442. * @param taskName defines the name of the new task
  71443. * @param url defines the url of the file to load
  71444. * @param extensions defines the extension to use to load the cube map (can be null)
  71445. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71446. * @param files defines the list of files to load (can be null)
  71447. * @returns a new CubeTextureAssetTask object
  71448. */
  71449. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  71450. /**
  71451. *
  71452. * Add a HDRCubeTextureAssetTask to the list of active tasks
  71453. * @param taskName defines the name of the new task
  71454. * @param url defines the url of the file to load
  71455. * @param size defines the size you want for the cubemap (can be null)
  71456. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71457. * @param generateHarmonics defines if you want to automatically generate (true by default)
  71458. * @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)
  71459. * @param reserved Internal use only
  71460. * @returns a new HDRCubeTextureAssetTask object
  71461. */
  71462. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  71463. /**
  71464. *
  71465. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  71466. * @param taskName defines the name of the new task
  71467. * @param url defines the url of the file to load
  71468. * @param size defines the size you want for the cubemap (can be null)
  71469. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  71470. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  71471. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  71472. * @returns a new EquiRectangularCubeTextureAssetTask object
  71473. */
  71474. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  71475. /**
  71476. * Remove a task from the assets manager.
  71477. * @param task the task to remove
  71478. */
  71479. removeTask(task: AbstractAssetTask): void;
  71480. private _decreaseWaitingTasksCount;
  71481. private _runTask;
  71482. /**
  71483. * Reset the AssetsManager and remove all tasks
  71484. * @return the current instance of the AssetsManager
  71485. */
  71486. reset(): AssetsManager;
  71487. /**
  71488. * Start the loading process
  71489. * @return the current instance of the AssetsManager
  71490. */
  71491. load(): AssetsManager;
  71492. /**
  71493. * Start the loading process as an async operation
  71494. * @return a promise returning the list of failed tasks
  71495. */
  71496. loadAsync(): Promise<void>;
  71497. }
  71498. }
  71499. declare module "babylonjs/Misc/deferred" {
  71500. /**
  71501. * Wrapper class for promise with external resolve and reject.
  71502. */
  71503. export class Deferred<T> {
  71504. /**
  71505. * The promise associated with this deferred object.
  71506. */
  71507. readonly promise: Promise<T>;
  71508. private _resolve;
  71509. private _reject;
  71510. /**
  71511. * The resolve method of the promise associated with this deferred object.
  71512. */
  71513. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  71514. /**
  71515. * The reject method of the promise associated with this deferred object.
  71516. */
  71517. get reject(): (reason?: any) => void;
  71518. /**
  71519. * Constructor for this deferred object.
  71520. */
  71521. constructor();
  71522. }
  71523. }
  71524. declare module "babylonjs/Misc/meshExploder" {
  71525. import { Mesh } from "babylonjs/Meshes/mesh";
  71526. /**
  71527. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  71528. */
  71529. export class MeshExploder {
  71530. private _centerMesh;
  71531. private _meshes;
  71532. private _meshesOrigins;
  71533. private _toCenterVectors;
  71534. private _scaledDirection;
  71535. private _newPosition;
  71536. private _centerPosition;
  71537. /**
  71538. * Explodes meshes from a center mesh.
  71539. * @param meshes The meshes to explode.
  71540. * @param centerMesh The mesh to be center of explosion.
  71541. */
  71542. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  71543. private _setCenterMesh;
  71544. /**
  71545. * Get class name
  71546. * @returns "MeshExploder"
  71547. */
  71548. getClassName(): string;
  71549. /**
  71550. * "Exploded meshes"
  71551. * @returns Array of meshes with the centerMesh at index 0.
  71552. */
  71553. getMeshes(): Array<Mesh>;
  71554. /**
  71555. * Explodes meshes giving a specific direction
  71556. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  71557. */
  71558. explode(direction?: number): void;
  71559. }
  71560. }
  71561. declare module "babylonjs/Misc/filesInput" {
  71562. import { Engine } from "babylonjs/Engines/engine";
  71563. import { Scene } from "babylonjs/scene";
  71564. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  71565. /**
  71566. * Class used to help managing file picking and drag'n'drop
  71567. */
  71568. export class FilesInput {
  71569. /**
  71570. * List of files ready to be loaded
  71571. */
  71572. static get FilesToLoad(): {
  71573. [key: string]: File;
  71574. };
  71575. /**
  71576. * Callback called when a file is processed
  71577. */
  71578. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  71579. private _engine;
  71580. private _currentScene;
  71581. private _sceneLoadedCallback;
  71582. private _progressCallback;
  71583. private _additionalRenderLoopLogicCallback;
  71584. private _textureLoadingCallback;
  71585. private _startingProcessingFilesCallback;
  71586. private _onReloadCallback;
  71587. private _errorCallback;
  71588. private _elementToMonitor;
  71589. private _sceneFileToLoad;
  71590. private _filesToLoad;
  71591. /**
  71592. * Creates a new FilesInput
  71593. * @param engine defines the rendering engine
  71594. * @param scene defines the hosting scene
  71595. * @param sceneLoadedCallback callback called when scene is loaded
  71596. * @param progressCallback callback called to track progress
  71597. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  71598. * @param textureLoadingCallback callback called when a texture is loading
  71599. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  71600. * @param onReloadCallback callback called when a reload is requested
  71601. * @param errorCallback callback call if an error occurs
  71602. */
  71603. 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);
  71604. private _dragEnterHandler;
  71605. private _dragOverHandler;
  71606. private _dropHandler;
  71607. /**
  71608. * Calls this function to listen to drag'n'drop events on a specific DOM element
  71609. * @param elementToMonitor defines the DOM element to track
  71610. */
  71611. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  71612. /**
  71613. * Release all associated resources
  71614. */
  71615. dispose(): void;
  71616. private renderFunction;
  71617. private drag;
  71618. private drop;
  71619. private _traverseFolder;
  71620. private _processFiles;
  71621. /**
  71622. * Load files from a drop event
  71623. * @param event defines the drop event to use as source
  71624. */
  71625. loadFiles(event: any): void;
  71626. private _processReload;
  71627. /**
  71628. * Reload the current scene from the loaded files
  71629. */
  71630. reload(): void;
  71631. }
  71632. }
  71633. declare module "babylonjs/Misc/HighDynamicRange/index" {
  71634. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  71635. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  71636. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  71637. }
  71638. declare module "babylonjs/Misc/sceneOptimizer" {
  71639. import { Scene, IDisposable } from "babylonjs/scene";
  71640. import { Observable } from "babylonjs/Misc/observable";
  71641. /**
  71642. * Defines the root class used to create scene optimization to use with SceneOptimizer
  71643. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71644. */
  71645. export class SceneOptimization {
  71646. /**
  71647. * Defines the priority of this optimization (0 by default which means first in the list)
  71648. */
  71649. priority: number;
  71650. /**
  71651. * Gets a string describing the action executed by the current optimization
  71652. * @returns description string
  71653. */
  71654. getDescription(): string;
  71655. /**
  71656. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71657. * @param scene defines the current scene where to apply this optimization
  71658. * @param optimizer defines the current optimizer
  71659. * @returns true if everything that can be done was applied
  71660. */
  71661. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71662. /**
  71663. * Creates the SceneOptimization object
  71664. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71665. * @param desc defines the description associated with the optimization
  71666. */
  71667. constructor(
  71668. /**
  71669. * Defines the priority of this optimization (0 by default which means first in the list)
  71670. */
  71671. priority?: number);
  71672. }
  71673. /**
  71674. * Defines an optimization used to reduce the size of render target textures
  71675. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71676. */
  71677. export class TextureOptimization extends SceneOptimization {
  71678. /**
  71679. * Defines the priority of this optimization (0 by default which means first in the list)
  71680. */
  71681. priority: number;
  71682. /**
  71683. * 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
  71684. */
  71685. maximumSize: number;
  71686. /**
  71687. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71688. */
  71689. step: number;
  71690. /**
  71691. * Gets a string describing the action executed by the current optimization
  71692. * @returns description string
  71693. */
  71694. getDescription(): string;
  71695. /**
  71696. * Creates the TextureOptimization object
  71697. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71698. * @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
  71699. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71700. */
  71701. constructor(
  71702. /**
  71703. * Defines the priority of this optimization (0 by default which means first in the list)
  71704. */
  71705. priority?: number,
  71706. /**
  71707. * 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
  71708. */
  71709. maximumSize?: number,
  71710. /**
  71711. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  71712. */
  71713. step?: number);
  71714. /**
  71715. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71716. * @param scene defines the current scene where to apply this optimization
  71717. * @param optimizer defines the current optimizer
  71718. * @returns true if everything that can be done was applied
  71719. */
  71720. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71721. }
  71722. /**
  71723. * Defines an optimization used to increase or decrease the rendering resolution
  71724. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71725. */
  71726. export class HardwareScalingOptimization extends SceneOptimization {
  71727. /**
  71728. * Defines the priority of this optimization (0 by default which means first in the list)
  71729. */
  71730. priority: number;
  71731. /**
  71732. * Defines the maximum scale to use (2 by default)
  71733. */
  71734. maximumScale: number;
  71735. /**
  71736. * Defines the step to use between two passes (0.5 by default)
  71737. */
  71738. step: number;
  71739. private _currentScale;
  71740. private _directionOffset;
  71741. /**
  71742. * Gets a string describing the action executed by the current optimization
  71743. * @return description string
  71744. */
  71745. getDescription(): string;
  71746. /**
  71747. * Creates the HardwareScalingOptimization object
  71748. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71749. * @param maximumScale defines the maximum scale to use (2 by default)
  71750. * @param step defines the step to use between two passes (0.5 by default)
  71751. */
  71752. constructor(
  71753. /**
  71754. * Defines the priority of this optimization (0 by default which means first in the list)
  71755. */
  71756. priority?: number,
  71757. /**
  71758. * Defines the maximum scale to use (2 by default)
  71759. */
  71760. maximumScale?: number,
  71761. /**
  71762. * Defines the step to use between two passes (0.5 by default)
  71763. */
  71764. step?: number);
  71765. /**
  71766. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71767. * @param scene defines the current scene where to apply this optimization
  71768. * @param optimizer defines the current optimizer
  71769. * @returns true if everything that can be done was applied
  71770. */
  71771. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71772. }
  71773. /**
  71774. * Defines an optimization used to remove shadows
  71775. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71776. */
  71777. export class ShadowsOptimization extends SceneOptimization {
  71778. /**
  71779. * Gets a string describing the action executed by the current optimization
  71780. * @return description string
  71781. */
  71782. getDescription(): string;
  71783. /**
  71784. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71785. * @param scene defines the current scene where to apply this optimization
  71786. * @param optimizer defines the current optimizer
  71787. * @returns true if everything that can be done was applied
  71788. */
  71789. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71790. }
  71791. /**
  71792. * Defines an optimization used to turn post-processes off
  71793. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71794. */
  71795. export class PostProcessesOptimization extends SceneOptimization {
  71796. /**
  71797. * Gets a string describing the action executed by the current optimization
  71798. * @return description string
  71799. */
  71800. getDescription(): string;
  71801. /**
  71802. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71803. * @param scene defines the current scene where to apply this optimization
  71804. * @param optimizer defines the current optimizer
  71805. * @returns true if everything that can be done was applied
  71806. */
  71807. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71808. }
  71809. /**
  71810. * Defines an optimization used to turn lens flares off
  71811. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71812. */
  71813. export class LensFlaresOptimization extends SceneOptimization {
  71814. /**
  71815. * Gets a string describing the action executed by the current optimization
  71816. * @return description string
  71817. */
  71818. getDescription(): string;
  71819. /**
  71820. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71821. * @param scene defines the current scene where to apply this optimization
  71822. * @param optimizer defines the current optimizer
  71823. * @returns true if everything that can be done was applied
  71824. */
  71825. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71826. }
  71827. /**
  71828. * Defines an optimization based on user defined callback.
  71829. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71830. */
  71831. export class CustomOptimization extends SceneOptimization {
  71832. /**
  71833. * Callback called to apply the custom optimization.
  71834. */
  71835. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  71836. /**
  71837. * Callback called to get custom description
  71838. */
  71839. onGetDescription: () => string;
  71840. /**
  71841. * Gets a string describing the action executed by the current optimization
  71842. * @returns description string
  71843. */
  71844. getDescription(): string;
  71845. /**
  71846. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71847. * @param scene defines the current scene where to apply this optimization
  71848. * @param optimizer defines the current optimizer
  71849. * @returns true if everything that can be done was applied
  71850. */
  71851. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71852. }
  71853. /**
  71854. * Defines an optimization used to turn particles off
  71855. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71856. */
  71857. export class ParticlesOptimization extends SceneOptimization {
  71858. /**
  71859. * Gets a string describing the action executed by the current optimization
  71860. * @return description string
  71861. */
  71862. getDescription(): string;
  71863. /**
  71864. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71865. * @param scene defines the current scene where to apply this optimization
  71866. * @param optimizer defines the current optimizer
  71867. * @returns true if everything that can be done was applied
  71868. */
  71869. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71870. }
  71871. /**
  71872. * Defines an optimization used to turn render targets off
  71873. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71874. */
  71875. export class RenderTargetsOptimization extends SceneOptimization {
  71876. /**
  71877. * Gets a string describing the action executed by the current optimization
  71878. * @return description string
  71879. */
  71880. getDescription(): string;
  71881. /**
  71882. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71883. * @param scene defines the current scene where to apply this optimization
  71884. * @param optimizer defines the current optimizer
  71885. * @returns true if everything that can be done was applied
  71886. */
  71887. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  71888. }
  71889. /**
  71890. * Defines an optimization used to merge meshes with compatible materials
  71891. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71892. */
  71893. export class MergeMeshesOptimization extends SceneOptimization {
  71894. private static _UpdateSelectionTree;
  71895. /**
  71896. * Gets or sets a boolean which defines if optimization octree has to be updated
  71897. */
  71898. static get UpdateSelectionTree(): boolean;
  71899. /**
  71900. * Gets or sets a boolean which defines if optimization octree has to be updated
  71901. */
  71902. static set UpdateSelectionTree(value: boolean);
  71903. /**
  71904. * Gets a string describing the action executed by the current optimization
  71905. * @return description string
  71906. */
  71907. getDescription(): string;
  71908. private _canBeMerged;
  71909. /**
  71910. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  71911. * @param scene defines the current scene where to apply this optimization
  71912. * @param optimizer defines the current optimizer
  71913. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  71914. * @returns true if everything that can be done was applied
  71915. */
  71916. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  71917. }
  71918. /**
  71919. * Defines a list of options used by SceneOptimizer
  71920. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71921. */
  71922. export class SceneOptimizerOptions {
  71923. /**
  71924. * Defines the target frame rate to reach (60 by default)
  71925. */
  71926. targetFrameRate: number;
  71927. /**
  71928. * Defines the interval between two checkes (2000ms by default)
  71929. */
  71930. trackerDuration: number;
  71931. /**
  71932. * Gets the list of optimizations to apply
  71933. */
  71934. optimizations: SceneOptimization[];
  71935. /**
  71936. * Creates a new list of options used by SceneOptimizer
  71937. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  71938. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  71939. */
  71940. constructor(
  71941. /**
  71942. * Defines the target frame rate to reach (60 by default)
  71943. */
  71944. targetFrameRate?: number,
  71945. /**
  71946. * Defines the interval between two checkes (2000ms by default)
  71947. */
  71948. trackerDuration?: number);
  71949. /**
  71950. * Add a new optimization
  71951. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  71952. * @returns the current SceneOptimizerOptions
  71953. */
  71954. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  71955. /**
  71956. * Add a new custom optimization
  71957. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  71958. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  71959. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  71960. * @returns the current SceneOptimizerOptions
  71961. */
  71962. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  71963. /**
  71964. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  71965. * @param targetFrameRate defines the target frame rate (60 by default)
  71966. * @returns a SceneOptimizerOptions object
  71967. */
  71968. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71969. /**
  71970. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  71971. * @param targetFrameRate defines the target frame rate (60 by default)
  71972. * @returns a SceneOptimizerOptions object
  71973. */
  71974. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71975. /**
  71976. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  71977. * @param targetFrameRate defines the target frame rate (60 by default)
  71978. * @returns a SceneOptimizerOptions object
  71979. */
  71980. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  71981. }
  71982. /**
  71983. * Class used to run optimizations in order to reach a target frame rate
  71984. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  71985. */
  71986. export class SceneOptimizer implements IDisposable {
  71987. private _isRunning;
  71988. private _options;
  71989. private _scene;
  71990. private _currentPriorityLevel;
  71991. private _targetFrameRate;
  71992. private _trackerDuration;
  71993. private _currentFrameRate;
  71994. private _sceneDisposeObserver;
  71995. private _improvementMode;
  71996. /**
  71997. * Defines an observable called when the optimizer reaches the target frame rate
  71998. */
  71999. onSuccessObservable: Observable<SceneOptimizer>;
  72000. /**
  72001. * Defines an observable called when the optimizer enables an optimization
  72002. */
  72003. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72004. /**
  72005. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72006. */
  72007. onFailureObservable: Observable<SceneOptimizer>;
  72008. /**
  72009. * Gets a boolean indicating if the optimizer is in improvement mode
  72010. */
  72011. get isInImprovementMode(): boolean;
  72012. /**
  72013. * Gets the current priority level (0 at start)
  72014. */
  72015. get currentPriorityLevel(): number;
  72016. /**
  72017. * Gets the current frame rate checked by the SceneOptimizer
  72018. */
  72019. get currentFrameRate(): number;
  72020. /**
  72021. * Gets or sets the current target frame rate (60 by default)
  72022. */
  72023. get targetFrameRate(): number;
  72024. /**
  72025. * Gets or sets the current target frame rate (60 by default)
  72026. */
  72027. set targetFrameRate(value: number);
  72028. /**
  72029. * Gets or sets the current interval between two checks (every 2000ms by default)
  72030. */
  72031. get trackerDuration(): number;
  72032. /**
  72033. * Gets or sets the current interval between two checks (every 2000ms by default)
  72034. */
  72035. set trackerDuration(value: number);
  72036. /**
  72037. * Gets the list of active optimizations
  72038. */
  72039. get optimizations(): SceneOptimization[];
  72040. /**
  72041. * Creates a new SceneOptimizer
  72042. * @param scene defines the scene to work on
  72043. * @param options defines the options to use with the SceneOptimizer
  72044. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72045. * @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)
  72046. */
  72047. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72048. /**
  72049. * Stops the current optimizer
  72050. */
  72051. stop(): void;
  72052. /**
  72053. * Reset the optimizer to initial step (current priority level = 0)
  72054. */
  72055. reset(): void;
  72056. /**
  72057. * Start the optimizer. By default it will try to reach a specific framerate
  72058. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72059. */
  72060. start(): void;
  72061. private _checkCurrentState;
  72062. /**
  72063. * Release all resources
  72064. */
  72065. dispose(): void;
  72066. /**
  72067. * Helper function to create a SceneOptimizer with one single line of code
  72068. * @param scene defines the scene to work on
  72069. * @param options defines the options to use with the SceneOptimizer
  72070. * @param onSuccess defines a callback to call on success
  72071. * @param onFailure defines a callback to call on failure
  72072. * @returns the new SceneOptimizer object
  72073. */
  72074. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72075. }
  72076. }
  72077. declare module "babylonjs/Misc/sceneSerializer" {
  72078. import { Scene } from "babylonjs/scene";
  72079. /**
  72080. * Class used to serialize a scene into a string
  72081. */
  72082. export class SceneSerializer {
  72083. /**
  72084. * Clear cache used by a previous serialization
  72085. */
  72086. static ClearCache(): void;
  72087. /**
  72088. * Serialize a scene into a JSON compatible object
  72089. * @param scene defines the scene to serialize
  72090. * @returns a JSON compatible object
  72091. */
  72092. static Serialize(scene: Scene): any;
  72093. /**
  72094. * Serialize a mesh into a JSON compatible object
  72095. * @param toSerialize defines the mesh to serialize
  72096. * @param withParents defines if parents must be serialized as well
  72097. * @param withChildren defines if children must be serialized as well
  72098. * @returns a JSON compatible object
  72099. */
  72100. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72101. }
  72102. }
  72103. declare module "babylonjs/Misc/textureTools" {
  72104. import { Texture } from "babylonjs/Materials/Textures/texture";
  72105. /**
  72106. * Class used to host texture specific utilities
  72107. */
  72108. export class TextureTools {
  72109. /**
  72110. * Uses the GPU to create a copy texture rescaled at a given size
  72111. * @param texture Texture to copy from
  72112. * @param width defines the desired width
  72113. * @param height defines the desired height
  72114. * @param useBilinearMode defines if bilinear mode has to be used
  72115. * @return the generated texture
  72116. */
  72117. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72118. }
  72119. }
  72120. declare module "babylonjs/Misc/videoRecorder" {
  72121. import { Nullable } from "babylonjs/types";
  72122. import { Engine } from "babylonjs/Engines/engine";
  72123. /**
  72124. * This represents the different options available for the video capture.
  72125. */
  72126. export interface VideoRecorderOptions {
  72127. /** Defines the mime type of the video. */
  72128. mimeType: string;
  72129. /** Defines the FPS the video should be recorded at. */
  72130. fps: number;
  72131. /** Defines the chunk size for the recording data. */
  72132. recordChunckSize: number;
  72133. /** The audio tracks to attach to the recording. */
  72134. audioTracks?: MediaStreamTrack[];
  72135. }
  72136. /**
  72137. * This can help with recording videos from BabylonJS.
  72138. * This is based on the available WebRTC functionalities of the browser.
  72139. *
  72140. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72141. */
  72142. export class VideoRecorder {
  72143. private static readonly _defaultOptions;
  72144. /**
  72145. * Returns whether or not the VideoRecorder is available in your browser.
  72146. * @param engine Defines the Babylon Engine.
  72147. * @returns true if supported otherwise false.
  72148. */
  72149. static IsSupported(engine: Engine): boolean;
  72150. private readonly _options;
  72151. private _canvas;
  72152. private _mediaRecorder;
  72153. private _recordedChunks;
  72154. private _fileName;
  72155. private _resolve;
  72156. private _reject;
  72157. /**
  72158. * True when a recording is already in progress.
  72159. */
  72160. get isRecording(): boolean;
  72161. /**
  72162. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72163. * @param engine Defines the BabylonJS Engine you wish to record.
  72164. * @param options Defines options that can be used to customize the capture.
  72165. */
  72166. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72167. /**
  72168. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72169. */
  72170. stopRecording(): void;
  72171. /**
  72172. * Starts recording the canvas for a max duration specified in parameters.
  72173. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72174. * If null no automatic download will start and you can rely on the promise to get the data back.
  72175. * @param maxDuration Defines the maximum recording time in seconds.
  72176. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72177. * @return A promise callback at the end of the recording with the video data in Blob.
  72178. */
  72179. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72180. /**
  72181. * Releases internal resources used during the recording.
  72182. */
  72183. dispose(): void;
  72184. private _handleDataAvailable;
  72185. private _handleError;
  72186. private _handleStop;
  72187. }
  72188. }
  72189. declare module "babylonjs/Misc/screenshotTools" {
  72190. import { Camera } from "babylonjs/Cameras/camera";
  72191. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72192. import { Engine } from "babylonjs/Engines/engine";
  72193. /**
  72194. * Class containing a set of static utilities functions for screenshots
  72195. */
  72196. export class ScreenshotTools {
  72197. /**
  72198. * Captures a screenshot of the current rendering
  72199. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72200. * @param engine defines the rendering engine
  72201. * @param camera defines the source camera
  72202. * @param size This parameter can be set to a single number or to an object with the
  72203. * following (optional) properties: precision, width, height. If a single number is passed,
  72204. * it will be used for both width and height. If an object is passed, the screenshot size
  72205. * will be derived from the parameters. The precision property is a multiplier allowing
  72206. * rendering at a higher or lower resolution
  72207. * @param successCallback defines the callback receives a single parameter which contains the
  72208. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72209. * src parameter of an <img> to display it
  72210. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72211. * Check your browser for supported MIME types
  72212. */
  72213. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72214. /**
  72215. * Captures a screenshot of the current rendering
  72216. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72217. * @param engine defines the rendering engine
  72218. * @param camera defines the source camera
  72219. * @param size This parameter can be set to a single number or to an object with the
  72220. * following (optional) properties: precision, width, height. If a single number is passed,
  72221. * it will be used for both width and height. If an object is passed, the screenshot size
  72222. * will be derived from the parameters. The precision property is a multiplier allowing
  72223. * rendering at a higher or lower resolution
  72224. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72225. * Check your browser for supported MIME types
  72226. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72227. * to the src parameter of an <img> to display it
  72228. */
  72229. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  72230. /**
  72231. * Generates an image screenshot from the specified camera.
  72232. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72233. * @param engine The engine to use for rendering
  72234. * @param camera The camera to use for rendering
  72235. * @param size This parameter can be set to a single number or to an object with the
  72236. * following (optional) properties: precision, width, height. If a single number is passed,
  72237. * it will be used for both width and height. If an object is passed, the screenshot size
  72238. * will be derived from the parameters. The precision property is a multiplier allowing
  72239. * rendering at a higher or lower resolution
  72240. * @param successCallback The callback receives a single parameter which contains the
  72241. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72242. * src parameter of an <img> to display it
  72243. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72244. * Check your browser for supported MIME types
  72245. * @param samples Texture samples (default: 1)
  72246. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72247. * @param fileName A name for for the downloaded file.
  72248. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72249. */
  72250. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  72251. /**
  72252. * Generates an image screenshot from the specified camera.
  72253. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72254. * @param engine The engine to use for rendering
  72255. * @param camera The camera to use for rendering
  72256. * @param size This parameter can be set to a single number or to an object with the
  72257. * following (optional) properties: precision, width, height. If a single number is passed,
  72258. * it will be used for both width and height. If an object is passed, the screenshot size
  72259. * will be derived from the parameters. The precision property is a multiplier allowing
  72260. * rendering at a higher or lower resolution
  72261. * @param mimeType The MIME type of the screenshot image (default: image/png).
  72262. * Check your browser for supported MIME types
  72263. * @param samples Texture samples (default: 1)
  72264. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  72265. * @param fileName A name for for the downloaded file.
  72266. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  72267. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  72268. * to the src parameter of an <img> to display it
  72269. */
  72270. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  72271. /**
  72272. * Gets height and width for screenshot size
  72273. * @private
  72274. */
  72275. private static _getScreenshotSize;
  72276. }
  72277. }
  72278. declare module "babylonjs/Misc/dataReader" {
  72279. /**
  72280. * Interface for a data buffer
  72281. */
  72282. export interface IDataBuffer {
  72283. /**
  72284. * Reads bytes from the data buffer.
  72285. * @param byteOffset The byte offset to read
  72286. * @param byteLength The byte length to read
  72287. * @returns A promise that resolves when the bytes are read
  72288. */
  72289. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  72290. /**
  72291. * The byte length of the buffer.
  72292. */
  72293. readonly byteLength: number;
  72294. }
  72295. /**
  72296. * Utility class for reading from a data buffer
  72297. */
  72298. export class DataReader {
  72299. /**
  72300. * The data buffer associated with this data reader.
  72301. */
  72302. readonly buffer: IDataBuffer;
  72303. /**
  72304. * The current byte offset from the beginning of the data buffer.
  72305. */
  72306. byteOffset: number;
  72307. private _dataView;
  72308. private _dataByteOffset;
  72309. /**
  72310. * Constructor
  72311. * @param buffer The buffer to read
  72312. */
  72313. constructor(buffer: IDataBuffer);
  72314. /**
  72315. * Loads the given byte length.
  72316. * @param byteLength The byte length to load
  72317. * @returns A promise that resolves when the load is complete
  72318. */
  72319. loadAsync(byteLength: number): Promise<void>;
  72320. /**
  72321. * Read a unsigned 32-bit integer from the currently loaded data range.
  72322. * @returns The 32-bit integer read
  72323. */
  72324. readUint32(): number;
  72325. /**
  72326. * Read a byte array from the currently loaded data range.
  72327. * @param byteLength The byte length to read
  72328. * @returns The byte array read
  72329. */
  72330. readUint8Array(byteLength: number): Uint8Array;
  72331. /**
  72332. * Read a string from the currently loaded data range.
  72333. * @param byteLength The byte length to read
  72334. * @returns The string read
  72335. */
  72336. readString(byteLength: number): string;
  72337. /**
  72338. * Skips the given byte length the currently loaded data range.
  72339. * @param byteLength The byte length to skip
  72340. */
  72341. skipBytes(byteLength: number): void;
  72342. }
  72343. }
  72344. declare module "babylonjs/Misc/index" {
  72345. export * from "babylonjs/Misc/andOrNotEvaluator";
  72346. export * from "babylonjs/Misc/assetsManager";
  72347. export * from "babylonjs/Misc/basis";
  72348. export * from "babylonjs/Misc/dds";
  72349. export * from "babylonjs/Misc/decorators";
  72350. export * from "babylonjs/Misc/deferred";
  72351. export * from "babylonjs/Misc/environmentTextureTools";
  72352. export * from "babylonjs/Misc/meshExploder";
  72353. export * from "babylonjs/Misc/filesInput";
  72354. export * from "babylonjs/Misc/HighDynamicRange/index";
  72355. export * from "babylonjs/Misc/khronosTextureContainer";
  72356. export * from "babylonjs/Misc/observable";
  72357. export * from "babylonjs/Misc/performanceMonitor";
  72358. export * from "babylonjs/Misc/promise";
  72359. export * from "babylonjs/Misc/sceneOptimizer";
  72360. export * from "babylonjs/Misc/sceneSerializer";
  72361. export * from "babylonjs/Misc/smartArray";
  72362. export * from "babylonjs/Misc/stringDictionary";
  72363. export * from "babylonjs/Misc/tags";
  72364. export * from "babylonjs/Misc/textureTools";
  72365. export * from "babylonjs/Misc/tga";
  72366. export * from "babylonjs/Misc/tools";
  72367. export * from "babylonjs/Misc/videoRecorder";
  72368. export * from "babylonjs/Misc/virtualJoystick";
  72369. export * from "babylonjs/Misc/workerPool";
  72370. export * from "babylonjs/Misc/logger";
  72371. export * from "babylonjs/Misc/typeStore";
  72372. export * from "babylonjs/Misc/filesInputStore";
  72373. export * from "babylonjs/Misc/deepCopier";
  72374. export * from "babylonjs/Misc/pivotTools";
  72375. export * from "babylonjs/Misc/precisionDate";
  72376. export * from "babylonjs/Misc/screenshotTools";
  72377. export * from "babylonjs/Misc/typeStore";
  72378. export * from "babylonjs/Misc/webRequest";
  72379. export * from "babylonjs/Misc/iInspectable";
  72380. export * from "babylonjs/Misc/brdfTextureTools";
  72381. export * from "babylonjs/Misc/rgbdTextureTools";
  72382. export * from "babylonjs/Misc/gradients";
  72383. export * from "babylonjs/Misc/perfCounter";
  72384. export * from "babylonjs/Misc/fileRequest";
  72385. export * from "babylonjs/Misc/customAnimationFrameRequester";
  72386. export * from "babylonjs/Misc/retryStrategy";
  72387. export * from "babylonjs/Misc/interfaces/screenshotSize";
  72388. export * from "babylonjs/Misc/canvasGenerator";
  72389. export * from "babylonjs/Misc/fileTools";
  72390. export * from "babylonjs/Misc/stringTools";
  72391. export * from "babylonjs/Misc/dataReader";
  72392. export * from "babylonjs/Misc/minMaxReducer";
  72393. export * from "babylonjs/Misc/depthReducer";
  72394. }
  72395. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  72396. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72397. import { Observable } from "babylonjs/Misc/observable";
  72398. import { Matrix } from "babylonjs/Maths/math.vector";
  72399. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72400. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72401. /**
  72402. * Options used for hit testing
  72403. */
  72404. export interface IWebXRHitTestOptions {
  72405. /**
  72406. * Only test when user interacted with the scene. Default - hit test every frame
  72407. */
  72408. testOnPointerDownOnly?: boolean;
  72409. /**
  72410. * The node to use to transform the local results to world coordinates
  72411. */
  72412. worldParentNode?: TransformNode;
  72413. }
  72414. /**
  72415. * Interface defining the babylon result of raycasting/hit-test
  72416. */
  72417. export interface IWebXRHitResult {
  72418. /**
  72419. * The native hit test result
  72420. */
  72421. xrHitResult: XRHitResult;
  72422. /**
  72423. * Transformation matrix that can be applied to a node that will put it in the hit point location
  72424. */
  72425. transformationMatrix: Matrix;
  72426. }
  72427. /**
  72428. * The currently-working hit-test module.
  72429. * Hit test (or raycasting) is used to interact with the real world.
  72430. * For further information read here - https://github.com/immersive-web/hit-test
  72431. */
  72432. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  72433. /**
  72434. * options to use when constructing this feature
  72435. */
  72436. readonly options: IWebXRHitTestOptions;
  72437. /**
  72438. * The module's name
  72439. */
  72440. static readonly Name: string;
  72441. /**
  72442. * The (Babylon) version of this module.
  72443. * This is an integer representing the implementation version.
  72444. * This number does not correspond to the webxr specs version
  72445. */
  72446. static readonly Version: number;
  72447. /**
  72448. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  72449. * @param event the (select) event to use to select with
  72450. * @param referenceSpace the reference space to use for this hit test
  72451. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72452. */
  72453. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  72454. /**
  72455. * execute a hit test with an XR Ray
  72456. *
  72457. * @param xrSession a native xrSession that will execute this hit test
  72458. * @param xrRay the ray (position and direction) to use for raycasting
  72459. * @param referenceSpace native XR reference space to use for the hit-test
  72460. * @param filter filter function that will filter the results
  72461. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  72462. */
  72463. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  72464. /**
  72465. * Triggered when new babylon (transformed) hit test results are available
  72466. */
  72467. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  72468. private _onSelectEnabled;
  72469. /**
  72470. * Creates a new instance of the (legacy version) hit test feature
  72471. * @param _xrSessionManager an instance of WebXRSessionManager
  72472. * @param options options to use when constructing this feature
  72473. */
  72474. constructor(_xrSessionManager: WebXRSessionManager,
  72475. /**
  72476. * options to use when constructing this feature
  72477. */
  72478. options?: IWebXRHitTestOptions);
  72479. /**
  72480. * Populated with the last native XR Hit Results
  72481. */
  72482. lastNativeXRHitResults: XRHitResult[];
  72483. /**
  72484. * attach this feature
  72485. * Will usually be called by the features manager
  72486. *
  72487. * @returns true if successful.
  72488. */
  72489. attach(): boolean;
  72490. /**
  72491. * detach this feature.
  72492. * Will usually be called by the features manager
  72493. *
  72494. * @returns true if successful.
  72495. */
  72496. detach(): boolean;
  72497. private _onHitTestResults;
  72498. private _origin;
  72499. private _direction;
  72500. private _mat;
  72501. protected _onXRFrame(frame: XRFrame): void;
  72502. private _onSelect;
  72503. /**
  72504. * Dispose this feature and all of the resources attached
  72505. */
  72506. dispose(): void;
  72507. }
  72508. }
  72509. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  72510. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72511. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72512. import { Observable } from "babylonjs/Misc/observable";
  72513. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  72514. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72515. /**
  72516. * Options used in the plane detector module
  72517. */
  72518. export interface IWebXRPlaneDetectorOptions {
  72519. /**
  72520. * The node to use to transform the local results to world coordinates
  72521. */
  72522. worldParentNode?: TransformNode;
  72523. }
  72524. /**
  72525. * A babylon interface for a webxr plane.
  72526. * A Plane is actually a polygon, built from N points in space
  72527. *
  72528. * Supported in chrome 79, not supported in canary 81 ATM
  72529. */
  72530. export interface IWebXRPlane {
  72531. /**
  72532. * a babylon-assigned ID for this polygon
  72533. */
  72534. id: number;
  72535. /**
  72536. * the native xr-plane object
  72537. */
  72538. xrPlane: XRPlane;
  72539. /**
  72540. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  72541. */
  72542. polygonDefinition: Array<Vector3>;
  72543. /**
  72544. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  72545. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  72546. */
  72547. transformationMatrix: Matrix;
  72548. }
  72549. /**
  72550. * The plane detector is used to detect planes in the real world when in AR
  72551. * For more information see https://github.com/immersive-web/real-world-geometry/
  72552. */
  72553. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  72554. private _options;
  72555. /**
  72556. * The module's name
  72557. */
  72558. static readonly Name: string;
  72559. /**
  72560. * The (Babylon) version of this module.
  72561. * This is an integer representing the implementation version.
  72562. * This number does not correspond to the webxr specs version
  72563. */
  72564. static readonly Version: number;
  72565. /**
  72566. * Observers registered here will be executed when a new plane was added to the session
  72567. */
  72568. onPlaneAddedObservable: Observable<IWebXRPlane>;
  72569. /**
  72570. * Observers registered here will be executed when a plane is no longer detected in the session
  72571. */
  72572. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  72573. /**
  72574. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  72575. * This can execute N times every frame
  72576. */
  72577. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  72578. private _enabled;
  72579. private _detectedPlanes;
  72580. private _lastFrameDetected;
  72581. /**
  72582. * construct a new Plane Detector
  72583. * @param _xrSessionManager an instance of xr Session manager
  72584. * @param _options configuration to use when constructing this feature
  72585. */
  72586. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  72587. private _init;
  72588. protected _onXRFrame(frame: XRFrame): void;
  72589. /**
  72590. * Dispose this feature and all of the resources attached
  72591. */
  72592. dispose(): void;
  72593. private _updatePlaneWithXRPlane;
  72594. /**
  72595. * avoiding using Array.find for global support.
  72596. * @param xrPlane the plane to find in the array
  72597. */
  72598. private findIndexInPlaneArray;
  72599. }
  72600. }
  72601. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  72602. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72603. import { Observable } from "babylonjs/Misc/observable";
  72604. import { Matrix } from "babylonjs/Maths/math.vector";
  72605. import { TransformNode } from "babylonjs/Meshes/transformNode";
  72606. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  72607. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  72608. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72609. /**
  72610. * Configuration options of the anchor system
  72611. */
  72612. export interface IWebXRAnchorSystemOptions {
  72613. /**
  72614. * a node that will be used to convert local to world coordinates
  72615. */
  72616. worldParentNode?: TransformNode;
  72617. /**
  72618. * should the anchor system use plane detection.
  72619. * If set to true, the plane-detection feature should be set using setPlaneDetector
  72620. */
  72621. usePlaneDetection?: boolean;
  72622. /**
  72623. * Should a new anchor be added every time a select event is triggered
  72624. */
  72625. addAnchorOnSelect?: boolean;
  72626. }
  72627. /**
  72628. * A babylon container for an XR Anchor
  72629. */
  72630. export interface IWebXRAnchor {
  72631. /**
  72632. * A babylon-assigned ID for this anchor
  72633. */
  72634. id: number;
  72635. /**
  72636. * The native anchor object
  72637. */
  72638. xrAnchor: XRAnchor;
  72639. /**
  72640. * Transformation matrix to apply to an object attached to this anchor
  72641. */
  72642. transformationMatrix: Matrix;
  72643. }
  72644. /**
  72645. * An implementation of the anchor system of WebXR.
  72646. * Note that the current documented implementation is not available in any browser. Future implementations
  72647. * will use the frame to create an anchor and not the session or a detected plane
  72648. * For further information see https://github.com/immersive-web/anchors/
  72649. */
  72650. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  72651. private _options;
  72652. /**
  72653. * The module's name
  72654. */
  72655. static readonly Name: string;
  72656. /**
  72657. * The (Babylon) version of this module.
  72658. * This is an integer representing the implementation version.
  72659. * This number does not correspond to the webxr specs version
  72660. */
  72661. static readonly Version: number;
  72662. /**
  72663. * Observers registered here will be executed when a new anchor was added to the session
  72664. */
  72665. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  72666. /**
  72667. * Observers registered here will be executed when an existing anchor updates
  72668. * This can execute N times every frame
  72669. */
  72670. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  72671. /**
  72672. * Observers registered here will be executed when an anchor was removed from the session
  72673. */
  72674. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  72675. private _planeDetector;
  72676. private _hitTestModule;
  72677. private _enabled;
  72678. private _trackedAnchors;
  72679. private _lastFrameDetected;
  72680. /**
  72681. * constructs a new anchor system
  72682. * @param _xrSessionManager an instance of WebXRSessionManager
  72683. * @param _options configuration object for this feature
  72684. */
  72685. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  72686. /**
  72687. * set the plane detector to use in order to create anchors from frames
  72688. * @param planeDetector the plane-detector module to use
  72689. * @param enable enable plane-anchors. default is true
  72690. */
  72691. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  72692. /**
  72693. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  72694. * @param hitTestModule the hit-test module to use.
  72695. */
  72696. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  72697. /**
  72698. * attach this feature
  72699. * Will usually be called by the features manager
  72700. *
  72701. * @returns true if successful.
  72702. */
  72703. attach(): boolean;
  72704. /**
  72705. * detach this feature.
  72706. * Will usually be called by the features manager
  72707. *
  72708. * @returns true if successful.
  72709. */
  72710. detach(): boolean;
  72711. /**
  72712. * Dispose this feature and all of the resources attached
  72713. */
  72714. dispose(): void;
  72715. protected _onXRFrame(frame: XRFrame): void;
  72716. private _onSelect;
  72717. /**
  72718. * Add anchor at a specific XR point.
  72719. *
  72720. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  72721. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  72722. * @returns a promise the fulfills when the anchor was created
  72723. */
  72724. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  72725. private _updateAnchorWithXRFrame;
  72726. /**
  72727. * avoiding using Array.find for global support.
  72728. * @param xrAnchor the plane to find in the array
  72729. */
  72730. private _findIndexInAnchorArray;
  72731. }
  72732. }
  72733. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  72734. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72735. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72736. import { Observable } from "babylonjs/Misc/observable";
  72737. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72738. /**
  72739. * Options interface for the background remover plugin
  72740. */
  72741. export interface IWebXRBackgroundRemoverOptions {
  72742. /**
  72743. * don't disable the environment helper
  72744. */
  72745. ignoreEnvironmentHelper?: boolean;
  72746. /**
  72747. * flags to configure the removal of the environment helper.
  72748. * If not set, the entire background will be removed. If set, flags should be set as well.
  72749. */
  72750. environmentHelperRemovalFlags?: {
  72751. /**
  72752. * Should the skybox be removed (default false)
  72753. */
  72754. skyBox?: boolean;
  72755. /**
  72756. * Should the ground be removed (default false)
  72757. */
  72758. ground?: boolean;
  72759. };
  72760. /**
  72761. * Further background meshes to disable when entering AR
  72762. */
  72763. backgroundMeshes?: AbstractMesh[];
  72764. }
  72765. /**
  72766. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  72767. */
  72768. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  72769. /**
  72770. * read-only options to be used in this module
  72771. */
  72772. readonly options: IWebXRBackgroundRemoverOptions;
  72773. /**
  72774. * The module's name
  72775. */
  72776. static readonly Name: string;
  72777. /**
  72778. * The (Babylon) version of this module.
  72779. * This is an integer representing the implementation version.
  72780. * This number does not correspond to the webxr specs version
  72781. */
  72782. static readonly Version: number;
  72783. /**
  72784. * registered observers will be triggered when the background state changes
  72785. */
  72786. onBackgroundStateChangedObservable: Observable<boolean>;
  72787. /**
  72788. * constructs a new background remover module
  72789. * @param _xrSessionManager the session manager for this module
  72790. * @param options read-only options to be used in this module
  72791. */
  72792. constructor(_xrSessionManager: WebXRSessionManager,
  72793. /**
  72794. * read-only options to be used in this module
  72795. */
  72796. options?: IWebXRBackgroundRemoverOptions);
  72797. /**
  72798. * attach this feature
  72799. * Will usually be called by the features manager
  72800. *
  72801. * @returns true if successful.
  72802. */
  72803. attach(): boolean;
  72804. /**
  72805. * detach this feature.
  72806. * Will usually be called by the features manager
  72807. *
  72808. * @returns true if successful.
  72809. */
  72810. detach(): boolean;
  72811. private _setBackgroundState;
  72812. /**
  72813. * Dispose this feature and all of the resources attached
  72814. */
  72815. dispose(): void;
  72816. protected _onXRFrame(_xrFrame: XRFrame): void;
  72817. }
  72818. }
  72819. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  72820. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  72821. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  72822. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72823. import { WebXRInput } from "babylonjs/XR/webXRInput";
  72824. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  72825. import { Nullable } from "babylonjs/types";
  72826. /**
  72827. * Options for the controller physics feature
  72828. */
  72829. export class IWebXRControllerPhysicsOptions {
  72830. /**
  72831. * the xr input to use with this pointer selection
  72832. */
  72833. xrInput: WebXRInput;
  72834. /**
  72835. * The physics properties of the future impostors
  72836. */
  72837. physicsProperties?: {
  72838. /**
  72839. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  72840. * Note that this requires a physics engine that supports mesh impostors!
  72841. */
  72842. useControllerMesh?: boolean;
  72843. /**
  72844. * The type of impostor to create. Default is sphere
  72845. */
  72846. impostorType?: number;
  72847. /**
  72848. * the size of the impostor. Defaults to 10cm
  72849. */
  72850. impostorSize?: number | {
  72851. width: number;
  72852. height: number;
  72853. depth: number;
  72854. };
  72855. /**
  72856. * Friction definitions
  72857. */
  72858. friction?: number;
  72859. /**
  72860. * Restitution
  72861. */
  72862. restitution?: number;
  72863. };
  72864. /**
  72865. * Should the headset get its own impostor
  72866. */
  72867. enableHeadsetImpostor?: boolean;
  72868. /**
  72869. * Optional parameters for the headset impostor
  72870. */
  72871. headsetImpostorParams?: {
  72872. /**
  72873. * The type of impostor to create. Default is sphere
  72874. */
  72875. impostorType: number;
  72876. /**
  72877. * the size of the impostor. Defaults to 10cm
  72878. */
  72879. impostorSize?: number | {
  72880. width: number;
  72881. height: number;
  72882. depth: number;
  72883. };
  72884. /**
  72885. * Friction definitions
  72886. */
  72887. friction?: number;
  72888. /**
  72889. * Restitution
  72890. */
  72891. restitution?: number;
  72892. };
  72893. }
  72894. /**
  72895. * Add physics impostor to your webxr controllers,
  72896. * including naive calculation of their linear and angular velocity
  72897. */
  72898. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  72899. private readonly _options;
  72900. /**
  72901. * The module's name
  72902. */
  72903. static readonly Name: string;
  72904. /**
  72905. * The (Babylon) version of this module.
  72906. * This is an integer representing the implementation version.
  72907. * This number does not correspond to the webxr specs version
  72908. */
  72909. static readonly Version: number;
  72910. private _lastTimestamp;
  72911. private _delta;
  72912. private _controllers;
  72913. private _headsetImpostor?;
  72914. private _headsetMesh?;
  72915. private _tmpVector;
  72916. private _tmpQuaternion;
  72917. /**
  72918. * Construct a new Controller Physics Feature
  72919. * @param _xrSessionManager the corresponding xr session manager
  72920. * @param _options options to create this feature with
  72921. */
  72922. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  72923. /**
  72924. * Update the physics properties provided in the constructor
  72925. * @param newProperties the new properties object
  72926. */
  72927. setPhysicsProperties(newProperties: {
  72928. impostorType?: number;
  72929. impostorSize?: number | {
  72930. width: number;
  72931. height: number;
  72932. depth: number;
  72933. };
  72934. friction?: number;
  72935. restitution?: number;
  72936. }): void;
  72937. /**
  72938. * Get the physics impostor of a specific controller.
  72939. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  72940. * @param controller the controller or the controller id of which to get the impostor
  72941. * @returns the impostor or null
  72942. */
  72943. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  72944. /**
  72945. * Get the headset impostor, if enabled
  72946. * @returns the impostor
  72947. */
  72948. getHeadsetImpostor(): PhysicsImpostor | undefined;
  72949. /**
  72950. * attach this feature
  72951. * Will usually be called by the features manager
  72952. *
  72953. * @returns true if successful.
  72954. */
  72955. attach(): boolean;
  72956. /**
  72957. * detach this feature.
  72958. * Will usually be called by the features manager
  72959. *
  72960. * @returns true if successful.
  72961. */
  72962. detach(): boolean;
  72963. /**
  72964. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  72965. * @param xrController the controller to add
  72966. */
  72967. addController(xrController: WebXRInputSource): void;
  72968. private _debugMode;
  72969. /**
  72970. * @hidden
  72971. * enable debugging - will show console outputs and the impostor mesh
  72972. */
  72973. _enablePhysicsDebug(): void;
  72974. private _attachController;
  72975. private _detachController;
  72976. protected _onXRFrame(_xrFrame: any): void;
  72977. }
  72978. }
  72979. declare module "babylonjs/XR/features/index" {
  72980. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  72981. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  72982. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  72983. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  72984. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  72985. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  72986. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  72987. }
  72988. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  72989. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  72990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  72991. import { Scene } from "babylonjs/scene";
  72992. /**
  72993. * The motion controller class for all microsoft mixed reality controllers
  72994. */
  72995. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  72996. /**
  72997. * The base url used to load the left and right controller models
  72998. */
  72999. static MODEL_BASE_URL: string;
  73000. /**
  73001. * The name of the left controller model file
  73002. */
  73003. static MODEL_LEFT_FILENAME: string;
  73004. /**
  73005. * The name of the right controller model file
  73006. */
  73007. static MODEL_RIGHT_FILENAME: string;
  73008. profileId: string;
  73009. protected readonly _mapping: {
  73010. defaultButton: {
  73011. "valueNodeName": string;
  73012. "unpressedNodeName": string;
  73013. "pressedNodeName": string;
  73014. };
  73015. defaultAxis: {
  73016. "valueNodeName": string;
  73017. "minNodeName": string;
  73018. "maxNodeName": string;
  73019. };
  73020. buttons: {
  73021. "xr-standard-trigger": {
  73022. "rootNodeName": string;
  73023. "componentProperty": string;
  73024. "states": string[];
  73025. };
  73026. "xr-standard-squeeze": {
  73027. "rootNodeName": string;
  73028. "componentProperty": string;
  73029. "states": string[];
  73030. };
  73031. "xr-standard-touchpad": {
  73032. "rootNodeName": string;
  73033. "labelAnchorNodeName": string;
  73034. "touchPointNodeName": string;
  73035. };
  73036. "xr-standard-thumbstick": {
  73037. "rootNodeName": string;
  73038. "componentProperty": string;
  73039. "states": string[];
  73040. };
  73041. };
  73042. axes: {
  73043. "xr-standard-touchpad": {
  73044. "x-axis": {
  73045. "rootNodeName": string;
  73046. };
  73047. "y-axis": {
  73048. "rootNodeName": string;
  73049. };
  73050. };
  73051. "xr-standard-thumbstick": {
  73052. "x-axis": {
  73053. "rootNodeName": string;
  73054. };
  73055. "y-axis": {
  73056. "rootNodeName": string;
  73057. };
  73058. };
  73059. };
  73060. };
  73061. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73062. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73063. protected _getFilenameAndPath(): {
  73064. filename: string;
  73065. path: string;
  73066. };
  73067. protected _updateModel(): void;
  73068. protected _getModelLoadingConstraints(): boolean;
  73069. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73070. }
  73071. }
  73072. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  73073. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73074. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73075. import { Scene } from "babylonjs/scene";
  73076. /**
  73077. * The motion controller class for oculus touch (quest, rift).
  73078. * This class supports legacy mapping as well the standard xr mapping
  73079. */
  73080. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  73081. private _forceLegacyControllers;
  73082. /**
  73083. * The base url used to load the left and right controller models
  73084. */
  73085. static MODEL_BASE_URL: string;
  73086. /**
  73087. * The name of the left controller model file
  73088. */
  73089. static MODEL_LEFT_FILENAME: string;
  73090. /**
  73091. * The name of the right controller model file
  73092. */
  73093. static MODEL_RIGHT_FILENAME: string;
  73094. /**
  73095. * Base Url for the Quest controller model.
  73096. */
  73097. static QUEST_MODEL_BASE_URL: string;
  73098. profileId: string;
  73099. private _modelRootNode;
  73100. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  73101. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73102. protected _getFilenameAndPath(): {
  73103. filename: string;
  73104. path: string;
  73105. };
  73106. /**
  73107. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  73108. * between the touch and touch 2.
  73109. */
  73110. private _isQuest;
  73111. protected _updateModel(): void;
  73112. protected _getModelLoadingConstraints(): boolean;
  73113. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73114. }
  73115. }
  73116. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  73117. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73118. import { Scene } from "babylonjs/scene";
  73119. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73120. /**
  73121. * The motion controller class for the standard HTC-Vive controllers
  73122. */
  73123. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  73124. /**
  73125. * The base url used to load the left and right controller models
  73126. */
  73127. static MODEL_BASE_URL: string;
  73128. /**
  73129. * File name for the controller model.
  73130. */
  73131. static MODEL_FILENAME: string;
  73132. profileId: string;
  73133. private _modelRootNode;
  73134. /**
  73135. * Create a new Vive motion controller object
  73136. * @param scene the scene to use to create this controller
  73137. * @param gamepadObject the corresponding gamepad object
  73138. * @param handness the handness of the controller
  73139. */
  73140. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  73141. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  73142. protected _getFilenameAndPath(): {
  73143. filename: string;
  73144. path: string;
  73145. };
  73146. protected _updateModel(): void;
  73147. protected _getModelLoadingConstraints(): boolean;
  73148. protected _setRootMesh(meshes: AbstractMesh[]): void;
  73149. }
  73150. }
  73151. declare module "babylonjs/XR/motionController/index" {
  73152. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73153. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  73154. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  73155. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  73156. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  73157. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  73158. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  73159. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  73160. }
  73161. declare module "babylonjs/XR/index" {
  73162. export * from "babylonjs/XR/webXRCamera";
  73163. export * from "babylonjs/XR/webXREnterExitUI";
  73164. export * from "babylonjs/XR/webXRExperienceHelper";
  73165. export * from "babylonjs/XR/webXRInput";
  73166. export * from "babylonjs/XR/webXRInputSource";
  73167. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  73168. export * from "babylonjs/XR/webXRTypes";
  73169. export * from "babylonjs/XR/webXRSessionManager";
  73170. export * from "babylonjs/XR/webXRDefaultExperience";
  73171. export * from "babylonjs/XR/webXRFeaturesManager";
  73172. export * from "babylonjs/XR/features/index";
  73173. export * from "babylonjs/XR/motionController/index";
  73174. }
  73175. declare module "babylonjs/index" {
  73176. export * from "babylonjs/abstractScene";
  73177. export * from "babylonjs/Actions/index";
  73178. export * from "babylonjs/Animations/index";
  73179. export * from "babylonjs/assetContainer";
  73180. export * from "babylonjs/Audio/index";
  73181. export * from "babylonjs/Behaviors/index";
  73182. export * from "babylonjs/Bones/index";
  73183. export * from "babylonjs/Cameras/index";
  73184. export * from "babylonjs/Collisions/index";
  73185. export * from "babylonjs/Culling/index";
  73186. export * from "babylonjs/Debug/index";
  73187. export * from "babylonjs/Engines/index";
  73188. export * from "babylonjs/Events/index";
  73189. export * from "babylonjs/Gamepads/index";
  73190. export * from "babylonjs/Gizmos/index";
  73191. export * from "babylonjs/Helpers/index";
  73192. export * from "babylonjs/Instrumentation/index";
  73193. export * from "babylonjs/Layers/index";
  73194. export * from "babylonjs/LensFlares/index";
  73195. export * from "babylonjs/Lights/index";
  73196. export * from "babylonjs/Loading/index";
  73197. export * from "babylonjs/Materials/index";
  73198. export * from "babylonjs/Maths/index";
  73199. export * from "babylonjs/Meshes/index";
  73200. export * from "babylonjs/Morph/index";
  73201. export * from "babylonjs/Navigation/index";
  73202. export * from "babylonjs/node";
  73203. export * from "babylonjs/Offline/index";
  73204. export * from "babylonjs/Particles/index";
  73205. export * from "babylonjs/Physics/index";
  73206. export * from "babylonjs/PostProcesses/index";
  73207. export * from "babylonjs/Probes/index";
  73208. export * from "babylonjs/Rendering/index";
  73209. export * from "babylonjs/scene";
  73210. export * from "babylonjs/sceneComponent";
  73211. export * from "babylonjs/Sprites/index";
  73212. export * from "babylonjs/States/index";
  73213. export * from "babylonjs/Misc/index";
  73214. export * from "babylonjs/XR/index";
  73215. export * from "babylonjs/types";
  73216. }
  73217. declare module "babylonjs/Animations/pathCursor" {
  73218. import { Vector3 } from "babylonjs/Maths/math.vector";
  73219. import { Path2 } from "babylonjs/Maths/math.path";
  73220. /**
  73221. * A cursor which tracks a point on a path
  73222. */
  73223. export class PathCursor {
  73224. private path;
  73225. /**
  73226. * Stores path cursor callbacks for when an onchange event is triggered
  73227. */
  73228. private _onchange;
  73229. /**
  73230. * The value of the path cursor
  73231. */
  73232. value: number;
  73233. /**
  73234. * The animation array of the path cursor
  73235. */
  73236. animations: Animation[];
  73237. /**
  73238. * Initializes the path cursor
  73239. * @param path The path to track
  73240. */
  73241. constructor(path: Path2);
  73242. /**
  73243. * Gets the cursor point on the path
  73244. * @returns A point on the path cursor at the cursor location
  73245. */
  73246. getPoint(): Vector3;
  73247. /**
  73248. * Moves the cursor ahead by the step amount
  73249. * @param step The amount to move the cursor forward
  73250. * @returns This path cursor
  73251. */
  73252. moveAhead(step?: number): PathCursor;
  73253. /**
  73254. * Moves the cursor behind by the step amount
  73255. * @param step The amount to move the cursor back
  73256. * @returns This path cursor
  73257. */
  73258. moveBack(step?: number): PathCursor;
  73259. /**
  73260. * Moves the cursor by the step amount
  73261. * If the step amount is greater than one, an exception is thrown
  73262. * @param step The amount to move the cursor
  73263. * @returns This path cursor
  73264. */
  73265. move(step: number): PathCursor;
  73266. /**
  73267. * Ensures that the value is limited between zero and one
  73268. * @returns This path cursor
  73269. */
  73270. private ensureLimits;
  73271. /**
  73272. * Runs onchange callbacks on change (used by the animation engine)
  73273. * @returns This path cursor
  73274. */
  73275. private raiseOnChange;
  73276. /**
  73277. * Executes a function on change
  73278. * @param f A path cursor onchange callback
  73279. * @returns This path cursor
  73280. */
  73281. onchange(f: (cursor: PathCursor) => void): PathCursor;
  73282. }
  73283. }
  73284. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  73285. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  73286. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  73287. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  73288. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  73289. }
  73290. declare module "babylonjs/Engines/Processors/Expressions/index" {
  73291. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  73292. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  73293. }
  73294. declare module "babylonjs/Engines/Processors/index" {
  73295. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  73296. export * from "babylonjs/Engines/Processors/Expressions/index";
  73297. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  73298. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  73299. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  73300. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  73301. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  73302. export * from "babylonjs/Engines/Processors/shaderProcessor";
  73303. }
  73304. declare module "babylonjs/Legacy/legacy" {
  73305. import * as Babylon from "babylonjs/index";
  73306. export * from "babylonjs/index";
  73307. }
  73308. declare module "babylonjs/Shaders/blur.fragment" {
  73309. /** @hidden */
  73310. export var blurPixelShader: {
  73311. name: string;
  73312. shader: string;
  73313. };
  73314. }
  73315. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  73316. /** @hidden */
  73317. export var pointCloudVertexDeclaration: {
  73318. name: string;
  73319. shader: string;
  73320. };
  73321. }
  73322. declare module "babylonjs" {
  73323. export * from "babylonjs/Legacy/legacy";
  73324. }
  73325. declare module BABYLON {
  73326. /** Alias type for value that can be null */
  73327. export type Nullable<T> = T | null;
  73328. /**
  73329. * Alias type for number that are floats
  73330. * @ignorenaming
  73331. */
  73332. export type float = number;
  73333. /**
  73334. * Alias type for number that are doubles.
  73335. * @ignorenaming
  73336. */
  73337. export type double = number;
  73338. /**
  73339. * Alias type for number that are integer
  73340. * @ignorenaming
  73341. */
  73342. export type int = number;
  73343. /** Alias type for number array or Float32Array */
  73344. export type FloatArray = number[] | Float32Array;
  73345. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  73346. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  73347. /**
  73348. * Alias for types that can be used by a Buffer or VertexBuffer.
  73349. */
  73350. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  73351. /**
  73352. * Alias type for primitive types
  73353. * @ignorenaming
  73354. */
  73355. type Primitive = undefined | null | boolean | string | number | Function;
  73356. /**
  73357. * Type modifier to make all the properties of an object Readonly
  73358. */
  73359. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  73360. /**
  73361. * Type modifier to make all the properties of an object Readonly recursively
  73362. */
  73363. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  73364. /**
  73365. * Type modifier to make object properties readonly.
  73366. */
  73367. export type DeepImmutableObject<T> = {
  73368. readonly [K in keyof T]: DeepImmutable<T[K]>;
  73369. };
  73370. /** @hidden */
  73371. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  73372. }
  73373. }
  73374. declare module BABYLON {
  73375. /**
  73376. * A class serves as a medium between the observable and its observers
  73377. */
  73378. export class EventState {
  73379. /**
  73380. * Create a new EventState
  73381. * @param mask defines the mask associated with this state
  73382. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73383. * @param target defines the original target of the state
  73384. * @param currentTarget defines the current target of the state
  73385. */
  73386. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  73387. /**
  73388. * Initialize the current event state
  73389. * @param mask defines the mask associated with this state
  73390. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  73391. * @param target defines the original target of the state
  73392. * @param currentTarget defines the current target of the state
  73393. * @returns the current event state
  73394. */
  73395. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73396. /**
  73397. * An Observer can set this property to true to prevent subsequent observers of being notified
  73398. */
  73399. skipNextObservers: boolean;
  73400. /**
  73401. * Get the mask value that were used to trigger the event corresponding to this EventState object
  73402. */
  73403. mask: number;
  73404. /**
  73405. * The object that originally notified the event
  73406. */
  73407. target?: any;
  73408. /**
  73409. * The current object in the bubbling phase
  73410. */
  73411. currentTarget?: any;
  73412. /**
  73413. * This will be populated with the return value of the last function that was executed.
  73414. * If it is the first function in the callback chain it will be the event data.
  73415. */
  73416. lastReturnValue?: any;
  73417. }
  73418. /**
  73419. * Represent an Observer registered to a given Observable object.
  73420. */
  73421. export class Observer<T> {
  73422. /**
  73423. * Defines the callback to call when the observer is notified
  73424. */
  73425. callback: (eventData: T, eventState: EventState) => void;
  73426. /**
  73427. * Defines the mask of the observer (used to filter notifications)
  73428. */
  73429. mask: number;
  73430. /**
  73431. * Defines the current scope used to restore the JS context
  73432. */
  73433. scope: any;
  73434. /** @hidden */
  73435. _willBeUnregistered: boolean;
  73436. /**
  73437. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  73438. */
  73439. unregisterOnNextCall: boolean;
  73440. /**
  73441. * Creates a new observer
  73442. * @param callback defines the callback to call when the observer is notified
  73443. * @param mask defines the mask of the observer (used to filter notifications)
  73444. * @param scope defines the current scope used to restore the JS context
  73445. */
  73446. constructor(
  73447. /**
  73448. * Defines the callback to call when the observer is notified
  73449. */
  73450. callback: (eventData: T, eventState: EventState) => void,
  73451. /**
  73452. * Defines the mask of the observer (used to filter notifications)
  73453. */
  73454. mask: number,
  73455. /**
  73456. * Defines the current scope used to restore the JS context
  73457. */
  73458. scope?: any);
  73459. }
  73460. /**
  73461. * Represent a list of observers registered to multiple Observables object.
  73462. */
  73463. export class MultiObserver<T> {
  73464. private _observers;
  73465. private _observables;
  73466. /**
  73467. * Release associated resources
  73468. */
  73469. dispose(): void;
  73470. /**
  73471. * Raise a callback when one of the observable will notify
  73472. * @param observables defines a list of observables to watch
  73473. * @param callback defines the callback to call on notification
  73474. * @param mask defines the mask used to filter notifications
  73475. * @param scope defines the current scope used to restore the JS context
  73476. * @returns the new MultiObserver
  73477. */
  73478. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  73479. }
  73480. /**
  73481. * The Observable class is a simple implementation of the Observable pattern.
  73482. *
  73483. * 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.
  73484. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  73485. * 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).
  73486. * 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.
  73487. */
  73488. export class Observable<T> {
  73489. private _observers;
  73490. private _eventState;
  73491. private _onObserverAdded;
  73492. /**
  73493. * Gets the list of observers
  73494. */
  73495. get observers(): Array<Observer<T>>;
  73496. /**
  73497. * Creates a new observable
  73498. * @param onObserverAdded defines a callback to call when a new observer is added
  73499. */
  73500. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  73501. /**
  73502. * Create a new Observer with the specified callback
  73503. * @param callback the callback that will be executed for that Observer
  73504. * @param mask the mask used to filter observers
  73505. * @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.
  73506. * @param scope optional scope for the callback to be called from
  73507. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  73508. * @returns the new observer created for the callback
  73509. */
  73510. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  73511. /**
  73512. * Create a new Observer with the specified callback and unregisters after the next notification
  73513. * @param callback the callback that will be executed for that Observer
  73514. * @returns the new observer created for the callback
  73515. */
  73516. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  73517. /**
  73518. * Remove an Observer from the Observable object
  73519. * @param observer the instance of the Observer to remove
  73520. * @returns false if it doesn't belong to this Observable
  73521. */
  73522. remove(observer: Nullable<Observer<T>>): boolean;
  73523. /**
  73524. * Remove a callback from the Observable object
  73525. * @param callback the callback to remove
  73526. * @param scope optional scope. If used only the callbacks with this scope will be removed
  73527. * @returns false if it doesn't belong to this Observable
  73528. */
  73529. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  73530. private _deferUnregister;
  73531. private _remove;
  73532. /**
  73533. * Moves the observable to the top of the observer list making it get called first when notified
  73534. * @param observer the observer to move
  73535. */
  73536. makeObserverTopPriority(observer: Observer<T>): void;
  73537. /**
  73538. * Moves the observable to the bottom of the observer list making it get called last when notified
  73539. * @param observer the observer to move
  73540. */
  73541. makeObserverBottomPriority(observer: Observer<T>): void;
  73542. /**
  73543. * Notify all Observers by calling their respective callback with the given data
  73544. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  73545. * @param eventData defines the data to send to all observers
  73546. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  73547. * @param target defines the original target of the state
  73548. * @param currentTarget defines the current target of the state
  73549. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  73550. */
  73551. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  73552. /**
  73553. * Calling this will execute each callback, expecting it to be a promise or return a value.
  73554. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  73555. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  73556. * and it is crucial that all callbacks will be executed.
  73557. * The order of the callbacks is kept, callbacks are not executed parallel.
  73558. *
  73559. * @param eventData The data to be sent to each callback
  73560. * @param mask is used to filter observers defaults to -1
  73561. * @param target defines the callback target (see EventState)
  73562. * @param currentTarget defines he current object in the bubbling phase
  73563. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  73564. */
  73565. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  73566. /**
  73567. * Notify a specific observer
  73568. * @param observer defines the observer to notify
  73569. * @param eventData defines the data to be sent to each callback
  73570. * @param mask is used to filter observers defaults to -1
  73571. */
  73572. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  73573. /**
  73574. * Gets a boolean indicating if the observable has at least one observer
  73575. * @returns true is the Observable has at least one Observer registered
  73576. */
  73577. hasObservers(): boolean;
  73578. /**
  73579. * Clear the list of observers
  73580. */
  73581. clear(): void;
  73582. /**
  73583. * Clone the current observable
  73584. * @returns a new observable
  73585. */
  73586. clone(): Observable<T>;
  73587. /**
  73588. * Does this observable handles observer registered with a given mask
  73589. * @param mask defines the mask to be tested
  73590. * @return whether or not one observer registered with the given mask is handeled
  73591. **/
  73592. hasSpecificMask(mask?: number): boolean;
  73593. }
  73594. }
  73595. declare module BABYLON {
  73596. /**
  73597. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  73598. * Babylon.js
  73599. */
  73600. export class DomManagement {
  73601. /**
  73602. * Checks if the window object exists
  73603. * @returns true if the window object exists
  73604. */
  73605. static IsWindowObjectExist(): boolean;
  73606. /**
  73607. * Checks if the navigator object exists
  73608. * @returns true if the navigator object exists
  73609. */
  73610. static IsNavigatorAvailable(): boolean;
  73611. /**
  73612. * Extracts text content from a DOM element hierarchy
  73613. * @param element defines the root element
  73614. * @returns a string
  73615. */
  73616. static GetDOMTextContent(element: HTMLElement): string;
  73617. }
  73618. }
  73619. declare module BABYLON {
  73620. /**
  73621. * Logger used througouht the application to allow configuration of
  73622. * the log level required for the messages.
  73623. */
  73624. export class Logger {
  73625. /**
  73626. * No log
  73627. */
  73628. static readonly NoneLogLevel: number;
  73629. /**
  73630. * Only message logs
  73631. */
  73632. static readonly MessageLogLevel: number;
  73633. /**
  73634. * Only warning logs
  73635. */
  73636. static readonly WarningLogLevel: number;
  73637. /**
  73638. * Only error logs
  73639. */
  73640. static readonly ErrorLogLevel: number;
  73641. /**
  73642. * All logs
  73643. */
  73644. static readonly AllLogLevel: number;
  73645. private static _LogCache;
  73646. /**
  73647. * Gets a value indicating the number of loading errors
  73648. * @ignorenaming
  73649. */
  73650. static errorsCount: number;
  73651. /**
  73652. * Callback called when a new log is added
  73653. */
  73654. static OnNewCacheEntry: (entry: string) => void;
  73655. private static _AddLogEntry;
  73656. private static _FormatMessage;
  73657. private static _LogDisabled;
  73658. private static _LogEnabled;
  73659. private static _WarnDisabled;
  73660. private static _WarnEnabled;
  73661. private static _ErrorDisabled;
  73662. private static _ErrorEnabled;
  73663. /**
  73664. * Log a message to the console
  73665. */
  73666. static Log: (message: string) => void;
  73667. /**
  73668. * Write a warning message to the console
  73669. */
  73670. static Warn: (message: string) => void;
  73671. /**
  73672. * Write an error message to the console
  73673. */
  73674. static Error: (message: string) => void;
  73675. /**
  73676. * Gets current log cache (list of logs)
  73677. */
  73678. static get LogCache(): string;
  73679. /**
  73680. * Clears the log cache
  73681. */
  73682. static ClearLogCache(): void;
  73683. /**
  73684. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  73685. */
  73686. static set LogLevels(level: number);
  73687. }
  73688. }
  73689. declare module BABYLON {
  73690. /** @hidden */
  73691. export class _TypeStore {
  73692. /** @hidden */
  73693. static RegisteredTypes: {
  73694. [key: string]: Object;
  73695. };
  73696. /** @hidden */
  73697. static GetClass(fqdn: string): any;
  73698. }
  73699. }
  73700. declare module BABYLON {
  73701. /**
  73702. * Helper to manipulate strings
  73703. */
  73704. export class StringTools {
  73705. /**
  73706. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  73707. * @param str Source string
  73708. * @param suffix Suffix to search for in the source string
  73709. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73710. */
  73711. static EndsWith(str: string, suffix: string): boolean;
  73712. /**
  73713. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  73714. * @param str Source string
  73715. * @param suffix Suffix to search for in the source string
  73716. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  73717. */
  73718. static StartsWith(str: string, suffix: string): boolean;
  73719. /**
  73720. * Decodes a buffer into a string
  73721. * @param buffer The buffer to decode
  73722. * @returns The decoded string
  73723. */
  73724. static Decode(buffer: Uint8Array | Uint16Array): string;
  73725. /**
  73726. * Encode a buffer to a base64 string
  73727. * @param buffer defines the buffer to encode
  73728. * @returns the encoded string
  73729. */
  73730. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  73731. }
  73732. }
  73733. declare module BABYLON {
  73734. /**
  73735. * Class containing a set of static utilities functions for deep copy.
  73736. */
  73737. export class DeepCopier {
  73738. /**
  73739. * Tries to copy an object by duplicating every property
  73740. * @param source defines the source object
  73741. * @param destination defines the target object
  73742. * @param doNotCopyList defines a list of properties to avoid
  73743. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  73744. */
  73745. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  73746. }
  73747. }
  73748. declare module BABYLON {
  73749. /**
  73750. * Class containing a set of static utilities functions for precision date
  73751. */
  73752. export class PrecisionDate {
  73753. /**
  73754. * Gets either window.performance.now() if supported or Date.now() else
  73755. */
  73756. static get Now(): number;
  73757. }
  73758. }
  73759. declare module BABYLON {
  73760. /** @hidden */
  73761. export class _DevTools {
  73762. static WarnImport(name: string): string;
  73763. }
  73764. }
  73765. declare module BABYLON {
  73766. /**
  73767. * Interface used to define the mechanism to get data from the network
  73768. */
  73769. export interface IWebRequest {
  73770. /**
  73771. * Returns client's response url
  73772. */
  73773. responseURL: string;
  73774. /**
  73775. * Returns client's status
  73776. */
  73777. status: number;
  73778. /**
  73779. * Returns client's status as a text
  73780. */
  73781. statusText: string;
  73782. }
  73783. }
  73784. declare module BABYLON {
  73785. /**
  73786. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  73787. */
  73788. export class WebRequest implements IWebRequest {
  73789. private _xhr;
  73790. /**
  73791. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  73792. * i.e. when loading files, where the server/service expects an Authorization header
  73793. */
  73794. static CustomRequestHeaders: {
  73795. [key: string]: string;
  73796. };
  73797. /**
  73798. * Add callback functions in this array to update all the requests before they get sent to the network
  73799. */
  73800. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  73801. private _injectCustomRequestHeaders;
  73802. /**
  73803. * Gets or sets a function to be called when loading progress changes
  73804. */
  73805. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  73806. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  73807. /**
  73808. * Returns client's state
  73809. */
  73810. get readyState(): number;
  73811. /**
  73812. * Returns client's status
  73813. */
  73814. get status(): number;
  73815. /**
  73816. * Returns client's status as a text
  73817. */
  73818. get statusText(): string;
  73819. /**
  73820. * Returns client's response
  73821. */
  73822. get response(): any;
  73823. /**
  73824. * Returns client's response url
  73825. */
  73826. get responseURL(): string;
  73827. /**
  73828. * Returns client's response as text
  73829. */
  73830. get responseText(): string;
  73831. /**
  73832. * Gets or sets the expected response type
  73833. */
  73834. get responseType(): XMLHttpRequestResponseType;
  73835. set responseType(value: XMLHttpRequestResponseType);
  73836. /** @hidden */
  73837. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  73838. /** @hidden */
  73839. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  73840. /**
  73841. * Cancels any network activity
  73842. */
  73843. abort(): void;
  73844. /**
  73845. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  73846. * @param body defines an optional request body
  73847. */
  73848. send(body?: Document | BodyInit | null): void;
  73849. /**
  73850. * Sets the request method, request URL
  73851. * @param method defines the method to use (GET, POST, etc..)
  73852. * @param url defines the url to connect with
  73853. */
  73854. open(method: string, url: string): void;
  73855. /**
  73856. * Sets the value of a request header.
  73857. * @param name The name of the header whose value is to be set
  73858. * @param value The value to set as the body of the header
  73859. */
  73860. setRequestHeader(name: string, value: string): void;
  73861. /**
  73862. * Get the string containing the text of a particular header's value.
  73863. * @param name The name of the header
  73864. * @returns The string containing the text of the given header name
  73865. */
  73866. getResponseHeader(name: string): Nullable<string>;
  73867. }
  73868. }
  73869. declare module BABYLON {
  73870. /**
  73871. * File request interface
  73872. */
  73873. export interface IFileRequest {
  73874. /**
  73875. * Raised when the request is complete (success or error).
  73876. */
  73877. onCompleteObservable: Observable<IFileRequest>;
  73878. /**
  73879. * Aborts the request for a file.
  73880. */
  73881. abort: () => void;
  73882. }
  73883. }
  73884. declare module BABYLON {
  73885. /**
  73886. * Define options used to create a render target texture
  73887. */
  73888. export class RenderTargetCreationOptions {
  73889. /**
  73890. * Specifies is mipmaps must be generated
  73891. */
  73892. generateMipMaps?: boolean;
  73893. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  73894. generateDepthBuffer?: boolean;
  73895. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  73896. generateStencilBuffer?: boolean;
  73897. /** Defines texture type (int by default) */
  73898. type?: number;
  73899. /** Defines sampling mode (trilinear by default) */
  73900. samplingMode?: number;
  73901. /** Defines format (RGBA by default) */
  73902. format?: number;
  73903. }
  73904. }
  73905. declare module BABYLON {
  73906. /** Defines the cross module used constants to avoid circular dependncies */
  73907. export class Constants {
  73908. /** Defines that alpha blending is disabled */
  73909. static readonly ALPHA_DISABLE: number;
  73910. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  73911. static readonly ALPHA_ADD: number;
  73912. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  73913. static readonly ALPHA_COMBINE: number;
  73914. /** Defines that alpha blending is DEST - SRC * DEST */
  73915. static readonly ALPHA_SUBTRACT: number;
  73916. /** Defines that alpha blending is SRC * DEST */
  73917. static readonly ALPHA_MULTIPLY: number;
  73918. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  73919. static readonly ALPHA_MAXIMIZED: number;
  73920. /** Defines that alpha blending is SRC + DEST */
  73921. static readonly ALPHA_ONEONE: number;
  73922. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  73923. static readonly ALPHA_PREMULTIPLIED: number;
  73924. /**
  73925. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  73926. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  73927. */
  73928. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  73929. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  73930. static readonly ALPHA_INTERPOLATE: number;
  73931. /**
  73932. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  73933. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  73934. */
  73935. static readonly ALPHA_SCREENMODE: number;
  73936. /**
  73937. * Defines that alpha blending is SRC + DST
  73938. * Alpha will be set to SRC ALPHA + DST ALPHA
  73939. */
  73940. static readonly ALPHA_ONEONE_ONEONE: number;
  73941. /**
  73942. * Defines that alpha blending is SRC * DST ALPHA + DST
  73943. * Alpha will be set to 0
  73944. */
  73945. static readonly ALPHA_ALPHATOCOLOR: number;
  73946. /**
  73947. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73948. */
  73949. static readonly ALPHA_REVERSEONEMINUS: number;
  73950. /**
  73951. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  73952. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  73953. */
  73954. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  73955. /**
  73956. * Defines that alpha blending is SRC + DST
  73957. * Alpha will be set to SRC ALPHA
  73958. */
  73959. static readonly ALPHA_ONEONE_ONEZERO: number;
  73960. /**
  73961. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  73962. * Alpha will be set to DST ALPHA
  73963. */
  73964. static readonly ALPHA_EXCLUSION: number;
  73965. /** Defines that alpha blending equation a SUM */
  73966. static readonly ALPHA_EQUATION_ADD: number;
  73967. /** Defines that alpha blending equation a SUBSTRACTION */
  73968. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  73969. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  73970. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  73971. /** Defines that alpha blending equation a MAX operation */
  73972. static readonly ALPHA_EQUATION_MAX: number;
  73973. /** Defines that alpha blending equation a MIN operation */
  73974. static readonly ALPHA_EQUATION_MIN: number;
  73975. /**
  73976. * Defines that alpha blending equation a DARKEN operation:
  73977. * It takes the min of the src and sums the alpha channels.
  73978. */
  73979. static readonly ALPHA_EQUATION_DARKEN: number;
  73980. /** Defines that the ressource is not delayed*/
  73981. static readonly DELAYLOADSTATE_NONE: number;
  73982. /** Defines that the ressource was successfully delay loaded */
  73983. static readonly DELAYLOADSTATE_LOADED: number;
  73984. /** Defines that the ressource is currently delay loading */
  73985. static readonly DELAYLOADSTATE_LOADING: number;
  73986. /** Defines that the ressource is delayed and has not started loading */
  73987. static readonly DELAYLOADSTATE_NOTLOADED: number;
  73988. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  73989. static readonly NEVER: number;
  73990. /** 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 */
  73991. static readonly ALWAYS: number;
  73992. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  73993. static readonly LESS: number;
  73994. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  73995. static readonly EQUAL: number;
  73996. /** 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 */
  73997. static readonly LEQUAL: number;
  73998. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  73999. static readonly GREATER: number;
  74000. /** 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 */
  74001. static readonly GEQUAL: number;
  74002. /** 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 */
  74003. static readonly NOTEQUAL: number;
  74004. /** Passed to stencilOperation to specify that stencil value must be kept */
  74005. static readonly KEEP: number;
  74006. /** Passed to stencilOperation to specify that stencil value must be replaced */
  74007. static readonly REPLACE: number;
  74008. /** Passed to stencilOperation to specify that stencil value must be incremented */
  74009. static readonly INCR: number;
  74010. /** Passed to stencilOperation to specify that stencil value must be decremented */
  74011. static readonly DECR: number;
  74012. /** Passed to stencilOperation to specify that stencil value must be inverted */
  74013. static readonly INVERT: number;
  74014. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  74015. static readonly INCR_WRAP: number;
  74016. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  74017. static readonly DECR_WRAP: number;
  74018. /** Texture is not repeating outside of 0..1 UVs */
  74019. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  74020. /** Texture is repeating outside of 0..1 UVs */
  74021. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  74022. /** Texture is repeating and mirrored */
  74023. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  74024. /** ALPHA */
  74025. static readonly TEXTUREFORMAT_ALPHA: number;
  74026. /** LUMINANCE */
  74027. static readonly TEXTUREFORMAT_LUMINANCE: number;
  74028. /** LUMINANCE_ALPHA */
  74029. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  74030. /** RGB */
  74031. static readonly TEXTUREFORMAT_RGB: number;
  74032. /** RGBA */
  74033. static readonly TEXTUREFORMAT_RGBA: number;
  74034. /** RED */
  74035. static readonly TEXTUREFORMAT_RED: number;
  74036. /** RED (2nd reference) */
  74037. static readonly TEXTUREFORMAT_R: number;
  74038. /** RG */
  74039. static readonly TEXTUREFORMAT_RG: number;
  74040. /** RED_INTEGER */
  74041. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  74042. /** RED_INTEGER (2nd reference) */
  74043. static readonly TEXTUREFORMAT_R_INTEGER: number;
  74044. /** RG_INTEGER */
  74045. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  74046. /** RGB_INTEGER */
  74047. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  74048. /** RGBA_INTEGER */
  74049. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  74050. /** UNSIGNED_BYTE */
  74051. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  74052. /** UNSIGNED_BYTE (2nd reference) */
  74053. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  74054. /** FLOAT */
  74055. static readonly TEXTURETYPE_FLOAT: number;
  74056. /** HALF_FLOAT */
  74057. static readonly TEXTURETYPE_HALF_FLOAT: number;
  74058. /** BYTE */
  74059. static readonly TEXTURETYPE_BYTE: number;
  74060. /** SHORT */
  74061. static readonly TEXTURETYPE_SHORT: number;
  74062. /** UNSIGNED_SHORT */
  74063. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  74064. /** INT */
  74065. static readonly TEXTURETYPE_INT: number;
  74066. /** UNSIGNED_INT */
  74067. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  74068. /** UNSIGNED_SHORT_4_4_4_4 */
  74069. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  74070. /** UNSIGNED_SHORT_5_5_5_1 */
  74071. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  74072. /** UNSIGNED_SHORT_5_6_5 */
  74073. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  74074. /** UNSIGNED_INT_2_10_10_10_REV */
  74075. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  74076. /** UNSIGNED_INT_24_8 */
  74077. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  74078. /** UNSIGNED_INT_10F_11F_11F_REV */
  74079. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  74080. /** UNSIGNED_INT_5_9_9_9_REV */
  74081. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  74082. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  74083. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  74084. /** nearest is mag = nearest and min = nearest and no mip */
  74085. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  74086. /** mag = nearest and min = nearest and mip = none */
  74087. static readonly TEXTURE_NEAREST_NEAREST: number;
  74088. /** Bilinear is mag = linear and min = linear and no mip */
  74089. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  74090. /** mag = linear and min = linear and mip = none */
  74091. static readonly TEXTURE_LINEAR_LINEAR: number;
  74092. /** Trilinear is mag = linear and min = linear and mip = linear */
  74093. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  74094. /** Trilinear is mag = linear and min = linear and mip = linear */
  74095. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  74096. /** mag = nearest and min = nearest and mip = nearest */
  74097. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  74098. /** mag = nearest and min = linear and mip = nearest */
  74099. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  74100. /** mag = nearest and min = linear and mip = linear */
  74101. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  74102. /** mag = nearest and min = linear and mip = none */
  74103. static readonly TEXTURE_NEAREST_LINEAR: number;
  74104. /** nearest is mag = nearest and min = nearest and mip = linear */
  74105. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  74106. /** mag = linear and min = nearest and mip = nearest */
  74107. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  74108. /** mag = linear and min = nearest and mip = linear */
  74109. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  74110. /** Bilinear is mag = linear and min = linear and mip = nearest */
  74111. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  74112. /** mag = linear and min = nearest and mip = none */
  74113. static readonly TEXTURE_LINEAR_NEAREST: number;
  74114. /** Explicit coordinates mode */
  74115. static readonly TEXTURE_EXPLICIT_MODE: number;
  74116. /** Spherical coordinates mode */
  74117. static readonly TEXTURE_SPHERICAL_MODE: number;
  74118. /** Planar coordinates mode */
  74119. static readonly TEXTURE_PLANAR_MODE: number;
  74120. /** Cubic coordinates mode */
  74121. static readonly TEXTURE_CUBIC_MODE: number;
  74122. /** Projection coordinates mode */
  74123. static readonly TEXTURE_PROJECTION_MODE: number;
  74124. /** Skybox coordinates mode */
  74125. static readonly TEXTURE_SKYBOX_MODE: number;
  74126. /** Inverse Cubic coordinates mode */
  74127. static readonly TEXTURE_INVCUBIC_MODE: number;
  74128. /** Equirectangular coordinates mode */
  74129. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  74130. /** Equirectangular Fixed coordinates mode */
  74131. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  74132. /** Equirectangular Fixed Mirrored coordinates mode */
  74133. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  74134. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  74135. static readonly SCALEMODE_FLOOR: number;
  74136. /** Defines that texture rescaling will look for the nearest power of 2 size */
  74137. static readonly SCALEMODE_NEAREST: number;
  74138. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  74139. static readonly SCALEMODE_CEILING: number;
  74140. /**
  74141. * The dirty texture flag value
  74142. */
  74143. static readonly MATERIAL_TextureDirtyFlag: number;
  74144. /**
  74145. * The dirty light flag value
  74146. */
  74147. static readonly MATERIAL_LightDirtyFlag: number;
  74148. /**
  74149. * The dirty fresnel flag value
  74150. */
  74151. static readonly MATERIAL_FresnelDirtyFlag: number;
  74152. /**
  74153. * The dirty attribute flag value
  74154. */
  74155. static readonly MATERIAL_AttributesDirtyFlag: number;
  74156. /**
  74157. * The dirty misc flag value
  74158. */
  74159. static readonly MATERIAL_MiscDirtyFlag: number;
  74160. /**
  74161. * The all dirty flag value
  74162. */
  74163. static readonly MATERIAL_AllDirtyFlag: number;
  74164. /**
  74165. * Returns the triangle fill mode
  74166. */
  74167. static readonly MATERIAL_TriangleFillMode: number;
  74168. /**
  74169. * Returns the wireframe mode
  74170. */
  74171. static readonly MATERIAL_WireFrameFillMode: number;
  74172. /**
  74173. * Returns the point fill mode
  74174. */
  74175. static readonly MATERIAL_PointFillMode: number;
  74176. /**
  74177. * Returns the point list draw mode
  74178. */
  74179. static readonly MATERIAL_PointListDrawMode: number;
  74180. /**
  74181. * Returns the line list draw mode
  74182. */
  74183. static readonly MATERIAL_LineListDrawMode: number;
  74184. /**
  74185. * Returns the line loop draw mode
  74186. */
  74187. static readonly MATERIAL_LineLoopDrawMode: number;
  74188. /**
  74189. * Returns the line strip draw mode
  74190. */
  74191. static readonly MATERIAL_LineStripDrawMode: number;
  74192. /**
  74193. * Returns the triangle strip draw mode
  74194. */
  74195. static readonly MATERIAL_TriangleStripDrawMode: number;
  74196. /**
  74197. * Returns the triangle fan draw mode
  74198. */
  74199. static readonly MATERIAL_TriangleFanDrawMode: number;
  74200. /**
  74201. * Stores the clock-wise side orientation
  74202. */
  74203. static readonly MATERIAL_ClockWiseSideOrientation: number;
  74204. /**
  74205. * Stores the counter clock-wise side orientation
  74206. */
  74207. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  74208. /**
  74209. * Nothing
  74210. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74211. */
  74212. static readonly ACTION_NothingTrigger: number;
  74213. /**
  74214. * On pick
  74215. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74216. */
  74217. static readonly ACTION_OnPickTrigger: number;
  74218. /**
  74219. * On left pick
  74220. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74221. */
  74222. static readonly ACTION_OnLeftPickTrigger: number;
  74223. /**
  74224. * On right pick
  74225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74226. */
  74227. static readonly ACTION_OnRightPickTrigger: number;
  74228. /**
  74229. * On center pick
  74230. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74231. */
  74232. static readonly ACTION_OnCenterPickTrigger: number;
  74233. /**
  74234. * On pick down
  74235. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74236. */
  74237. static readonly ACTION_OnPickDownTrigger: number;
  74238. /**
  74239. * On double pick
  74240. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74241. */
  74242. static readonly ACTION_OnDoublePickTrigger: number;
  74243. /**
  74244. * On pick up
  74245. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74246. */
  74247. static readonly ACTION_OnPickUpTrigger: number;
  74248. /**
  74249. * On pick out.
  74250. * This trigger will only be raised if you also declared a OnPickDown
  74251. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74252. */
  74253. static readonly ACTION_OnPickOutTrigger: number;
  74254. /**
  74255. * On long press
  74256. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74257. */
  74258. static readonly ACTION_OnLongPressTrigger: number;
  74259. /**
  74260. * On pointer over
  74261. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74262. */
  74263. static readonly ACTION_OnPointerOverTrigger: number;
  74264. /**
  74265. * On pointer out
  74266. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74267. */
  74268. static readonly ACTION_OnPointerOutTrigger: number;
  74269. /**
  74270. * On every frame
  74271. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74272. */
  74273. static readonly ACTION_OnEveryFrameTrigger: number;
  74274. /**
  74275. * On intersection enter
  74276. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74277. */
  74278. static readonly ACTION_OnIntersectionEnterTrigger: number;
  74279. /**
  74280. * On intersection exit
  74281. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74282. */
  74283. static readonly ACTION_OnIntersectionExitTrigger: number;
  74284. /**
  74285. * On key down
  74286. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74287. */
  74288. static readonly ACTION_OnKeyDownTrigger: number;
  74289. /**
  74290. * On key up
  74291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  74292. */
  74293. static readonly ACTION_OnKeyUpTrigger: number;
  74294. /**
  74295. * Billboard mode will only apply to Y axis
  74296. */
  74297. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  74298. /**
  74299. * Billboard mode will apply to all axes
  74300. */
  74301. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  74302. /**
  74303. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74304. */
  74305. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  74306. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  74307. * Test order :
  74308. * Is the bounding sphere outside the frustum ?
  74309. * If not, are the bounding box vertices outside the frustum ?
  74310. * It not, then the cullable object is in the frustum.
  74311. */
  74312. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  74313. /** Culling strategy : Bounding Sphere Only.
  74314. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  74315. * It's also less accurate than the standard because some not visible objects can still be selected.
  74316. * Test : is the bounding sphere outside the frustum ?
  74317. * If not, then the cullable object is in the frustum.
  74318. */
  74319. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  74320. /** Culling strategy : Optimistic Inclusion.
  74321. * This in an inclusion test first, then the standard exclusion test.
  74322. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  74323. * 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.
  74324. * Anyway, it's as accurate as the standard strategy.
  74325. * Test :
  74326. * Is the cullable object bounding sphere center in the frustum ?
  74327. * If not, apply the default culling strategy.
  74328. */
  74329. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  74330. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  74331. * This in an inclusion test first, then the bounding sphere only exclusion test.
  74332. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  74333. * 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.
  74334. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  74335. * Test :
  74336. * Is the cullable object bounding sphere center in the frustum ?
  74337. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  74338. */
  74339. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  74340. /**
  74341. * No logging while loading
  74342. */
  74343. static readonly SCENELOADER_NO_LOGGING: number;
  74344. /**
  74345. * Minimal logging while loading
  74346. */
  74347. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  74348. /**
  74349. * Summary logging while loading
  74350. */
  74351. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  74352. /**
  74353. * Detailled logging while loading
  74354. */
  74355. static readonly SCENELOADER_DETAILED_LOGGING: number;
  74356. }
  74357. }
  74358. declare module BABYLON {
  74359. /**
  74360. * This represents the required contract to create a new type of texture loader.
  74361. */
  74362. export interface IInternalTextureLoader {
  74363. /**
  74364. * Defines wether the loader supports cascade loading the different faces.
  74365. */
  74366. supportCascades: boolean;
  74367. /**
  74368. * This returns if the loader support the current file information.
  74369. * @param extension defines the file extension of the file being loaded
  74370. * @param textureFormatInUse defines the current compressed format in use iun the engine
  74371. * @param fallback defines the fallback internal texture if any
  74372. * @param isBase64 defines whether the texture is encoded as a base64
  74373. * @param isBuffer defines whether the texture data are stored as a buffer
  74374. * @returns true if the loader can load the specified file
  74375. */
  74376. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  74377. /**
  74378. * Transform the url before loading if required.
  74379. * @param rootUrl the url of the texture
  74380. * @param textureFormatInUse defines the current compressed format in use iun the engine
  74381. * @returns the transformed texture
  74382. */
  74383. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  74384. /**
  74385. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  74386. * @param rootUrl the url of the texture
  74387. * @param textureFormatInUse defines the current compressed format in use iun the engine
  74388. * @returns the fallback texture
  74389. */
  74390. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  74391. /**
  74392. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  74393. * @param data contains the texture data
  74394. * @param texture defines the BabylonJS internal texture
  74395. * @param createPolynomials will be true if polynomials have been requested
  74396. * @param onLoad defines the callback to trigger once the texture is ready
  74397. * @param onError defines the callback to trigger in case of error
  74398. */
  74399. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  74400. /**
  74401. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  74402. * @param data contains the texture data
  74403. * @param texture defines the BabylonJS internal texture
  74404. * @param callback defines the method to call once ready to upload
  74405. */
  74406. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  74407. }
  74408. }
  74409. declare module BABYLON {
  74410. /**
  74411. * Class used to store and describe the pipeline context associated with an effect
  74412. */
  74413. export interface IPipelineContext {
  74414. /**
  74415. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  74416. */
  74417. isAsync: boolean;
  74418. /**
  74419. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  74420. */
  74421. isReady: boolean;
  74422. /** @hidden */
  74423. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  74424. }
  74425. }
  74426. declare module BABYLON {
  74427. /**
  74428. * Class used to store gfx data (like WebGLBuffer)
  74429. */
  74430. export class DataBuffer {
  74431. /**
  74432. * Gets or sets the number of objects referencing this buffer
  74433. */
  74434. references: number;
  74435. /** Gets or sets the size of the underlying buffer */
  74436. capacity: number;
  74437. /**
  74438. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  74439. */
  74440. is32Bits: boolean;
  74441. /**
  74442. * Gets the underlying buffer
  74443. */
  74444. get underlyingResource(): any;
  74445. }
  74446. }
  74447. declare module BABYLON {
  74448. /** @hidden */
  74449. export interface IShaderProcessor {
  74450. attributeProcessor?: (attribute: string) => string;
  74451. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  74452. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  74453. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  74454. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  74455. lineProcessor?: (line: string, isFragment: boolean) => string;
  74456. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74457. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  74458. }
  74459. }
  74460. declare module BABYLON {
  74461. /** @hidden */
  74462. export interface ProcessingOptions {
  74463. defines: string[];
  74464. indexParameters: any;
  74465. isFragment: boolean;
  74466. shouldUseHighPrecisionShader: boolean;
  74467. supportsUniformBuffers: boolean;
  74468. shadersRepository: string;
  74469. includesShadersStore: {
  74470. [key: string]: string;
  74471. };
  74472. processor?: IShaderProcessor;
  74473. version: string;
  74474. platformName: string;
  74475. lookForClosingBracketForUniformBuffer?: boolean;
  74476. }
  74477. }
  74478. declare module BABYLON {
  74479. /** @hidden */
  74480. export class ShaderCodeNode {
  74481. line: string;
  74482. children: ShaderCodeNode[];
  74483. additionalDefineKey?: string;
  74484. additionalDefineValue?: string;
  74485. isValid(preprocessors: {
  74486. [key: string]: string;
  74487. }): boolean;
  74488. process(preprocessors: {
  74489. [key: string]: string;
  74490. }, options: ProcessingOptions): string;
  74491. }
  74492. }
  74493. declare module BABYLON {
  74494. /** @hidden */
  74495. export class ShaderCodeCursor {
  74496. private _lines;
  74497. lineIndex: number;
  74498. get currentLine(): string;
  74499. get canRead(): boolean;
  74500. set lines(value: string[]);
  74501. }
  74502. }
  74503. declare module BABYLON {
  74504. /** @hidden */
  74505. export class ShaderCodeConditionNode extends ShaderCodeNode {
  74506. process(preprocessors: {
  74507. [key: string]: string;
  74508. }, options: ProcessingOptions): string;
  74509. }
  74510. }
  74511. declare module BABYLON {
  74512. /** @hidden */
  74513. export class ShaderDefineExpression {
  74514. isTrue(preprocessors: {
  74515. [key: string]: string;
  74516. }): boolean;
  74517. }
  74518. }
  74519. declare module BABYLON {
  74520. /** @hidden */
  74521. export class ShaderCodeTestNode extends ShaderCodeNode {
  74522. testExpression: ShaderDefineExpression;
  74523. isValid(preprocessors: {
  74524. [key: string]: string;
  74525. }): boolean;
  74526. }
  74527. }
  74528. declare module BABYLON {
  74529. /** @hidden */
  74530. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  74531. define: string;
  74532. not: boolean;
  74533. constructor(define: string, not?: boolean);
  74534. isTrue(preprocessors: {
  74535. [key: string]: string;
  74536. }): boolean;
  74537. }
  74538. }
  74539. declare module BABYLON {
  74540. /** @hidden */
  74541. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  74542. leftOperand: ShaderDefineExpression;
  74543. rightOperand: ShaderDefineExpression;
  74544. isTrue(preprocessors: {
  74545. [key: string]: string;
  74546. }): boolean;
  74547. }
  74548. }
  74549. declare module BABYLON {
  74550. /** @hidden */
  74551. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  74552. leftOperand: ShaderDefineExpression;
  74553. rightOperand: ShaderDefineExpression;
  74554. isTrue(preprocessors: {
  74555. [key: string]: string;
  74556. }): boolean;
  74557. }
  74558. }
  74559. declare module BABYLON {
  74560. /** @hidden */
  74561. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  74562. define: string;
  74563. operand: string;
  74564. testValue: string;
  74565. constructor(define: string, operand: string, testValue: string);
  74566. isTrue(preprocessors: {
  74567. [key: string]: string;
  74568. }): boolean;
  74569. }
  74570. }
  74571. declare module BABYLON {
  74572. /**
  74573. * Class used to enable access to offline support
  74574. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  74575. */
  74576. export interface IOfflineProvider {
  74577. /**
  74578. * Gets a boolean indicating if scene must be saved in the database
  74579. */
  74580. enableSceneOffline: boolean;
  74581. /**
  74582. * Gets a boolean indicating if textures must be saved in the database
  74583. */
  74584. enableTexturesOffline: boolean;
  74585. /**
  74586. * Open the offline support and make it available
  74587. * @param successCallback defines the callback to call on success
  74588. * @param errorCallback defines the callback to call on error
  74589. */
  74590. open(successCallback: () => void, errorCallback: () => void): void;
  74591. /**
  74592. * Loads an image from the offline support
  74593. * @param url defines the url to load from
  74594. * @param image defines the target DOM image
  74595. */
  74596. loadImage(url: string, image: HTMLImageElement): void;
  74597. /**
  74598. * Loads a file from offline support
  74599. * @param url defines the URL to load from
  74600. * @param sceneLoaded defines a callback to call on success
  74601. * @param progressCallBack defines a callback to call when progress changed
  74602. * @param errorCallback defines a callback to call on error
  74603. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  74604. */
  74605. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  74606. }
  74607. }
  74608. declare module BABYLON {
  74609. /**
  74610. * Class used to help managing file picking and drag'n'drop
  74611. * File Storage
  74612. */
  74613. export class FilesInputStore {
  74614. /**
  74615. * List of files ready to be loaded
  74616. */
  74617. static FilesToLoad: {
  74618. [key: string]: File;
  74619. };
  74620. }
  74621. }
  74622. declare module BABYLON {
  74623. /**
  74624. * Class used to define a retry strategy when error happens while loading assets
  74625. */
  74626. export class RetryStrategy {
  74627. /**
  74628. * Function used to defines an exponential back off strategy
  74629. * @param maxRetries defines the maximum number of retries (3 by default)
  74630. * @param baseInterval defines the interval between retries
  74631. * @returns the strategy function to use
  74632. */
  74633. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  74634. }
  74635. }
  74636. declare module BABYLON {
  74637. /**
  74638. * @ignore
  74639. * Application error to support additional information when loading a file
  74640. */
  74641. export abstract class BaseError extends Error {
  74642. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  74643. }
  74644. }
  74645. declare module BABYLON {
  74646. /** @ignore */
  74647. export class LoadFileError extends BaseError {
  74648. request?: WebRequest;
  74649. file?: File;
  74650. /**
  74651. * Creates a new LoadFileError
  74652. * @param message defines the message of the error
  74653. * @param request defines the optional web request
  74654. * @param file defines the optional file
  74655. */
  74656. constructor(message: string, object?: WebRequest | File);
  74657. }
  74658. /** @ignore */
  74659. export class RequestFileError extends BaseError {
  74660. request: WebRequest;
  74661. /**
  74662. * Creates a new LoadFileError
  74663. * @param message defines the message of the error
  74664. * @param request defines the optional web request
  74665. */
  74666. constructor(message: string, request: WebRequest);
  74667. }
  74668. /** @ignore */
  74669. export class ReadFileError extends BaseError {
  74670. file: File;
  74671. /**
  74672. * Creates a new ReadFileError
  74673. * @param message defines the message of the error
  74674. * @param file defines the optional file
  74675. */
  74676. constructor(message: string, file: File);
  74677. }
  74678. /**
  74679. * @hidden
  74680. */
  74681. export class FileTools {
  74682. /**
  74683. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  74684. */
  74685. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  74686. /**
  74687. * Gets or sets the base URL to use to load assets
  74688. */
  74689. static BaseUrl: string;
  74690. /**
  74691. * Default behaviour for cors in the application.
  74692. * It can be a string if the expected behavior is identical in the entire app.
  74693. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  74694. */
  74695. static CorsBehavior: string | ((url: string | string[]) => string);
  74696. /**
  74697. * Gets or sets a function used to pre-process url before using them to load assets
  74698. */
  74699. static PreprocessUrl: (url: string) => string;
  74700. /**
  74701. * Removes unwanted characters from an url
  74702. * @param url defines the url to clean
  74703. * @returns the cleaned url
  74704. */
  74705. private static _CleanUrl;
  74706. /**
  74707. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  74708. * @param url define the url we are trying
  74709. * @param element define the dom element where to configure the cors policy
  74710. */
  74711. static SetCorsBehavior(url: string | string[], element: {
  74712. crossOrigin: string | null;
  74713. }): void;
  74714. /**
  74715. * Loads an image as an HTMLImageElement.
  74716. * @param input url string, ArrayBuffer, or Blob to load
  74717. * @param onLoad callback called when the image successfully loads
  74718. * @param onError callback called when the image fails to load
  74719. * @param offlineProvider offline provider for caching
  74720. * @param mimeType optional mime type
  74721. * @returns the HTMLImageElement of the loaded image
  74722. */
  74723. 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>;
  74724. /**
  74725. * Reads a file from a File object
  74726. * @param file defines the file to load
  74727. * @param onSuccess defines the callback to call when data is loaded
  74728. * @param onProgress defines the callback to call during loading process
  74729. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  74730. * @param onError defines the callback to call when an error occurs
  74731. * @returns a file request object
  74732. */
  74733. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  74734. /**
  74735. * Loads a file from a url
  74736. * @param url url to load
  74737. * @param onSuccess callback called when the file successfully loads
  74738. * @param onProgress callback called while file is loading (if the server supports this mode)
  74739. * @param offlineProvider defines the offline provider for caching
  74740. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74741. * @param onError callback called when the file fails to load
  74742. * @returns a file request object
  74743. */
  74744. 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;
  74745. /**
  74746. * Loads a file
  74747. * @param url url to load
  74748. * @param onSuccess callback called when the file successfully loads
  74749. * @param onProgress callback called while file is loading (if the server supports this mode)
  74750. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74751. * @param onError callback called when the file fails to load
  74752. * @param onOpened callback called when the web request is opened
  74753. * @returns a file request object
  74754. */
  74755. 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;
  74756. /**
  74757. * Checks if the loaded document was accessed via `file:`-Protocol.
  74758. * @returns boolean
  74759. */
  74760. static IsFileURL(): boolean;
  74761. }
  74762. }
  74763. declare module BABYLON {
  74764. /** @hidden */
  74765. export class ShaderProcessor {
  74766. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  74767. private static _ProcessPrecision;
  74768. private static _ExtractOperation;
  74769. private static _BuildSubExpression;
  74770. private static _BuildExpression;
  74771. private static _MoveCursorWithinIf;
  74772. private static _MoveCursor;
  74773. private static _EvaluatePreProcessors;
  74774. private static _PreparePreProcessors;
  74775. private static _ProcessShaderConversion;
  74776. private static _ProcessIncludes;
  74777. /**
  74778. * Loads a file from a url
  74779. * @param url url to load
  74780. * @param onSuccess callback called when the file successfully loads
  74781. * @param onProgress callback called while file is loading (if the server supports this mode)
  74782. * @param offlineProvider defines the offline provider for caching
  74783. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  74784. * @param onError callback called when the file fails to load
  74785. * @returns a file request object
  74786. * @hidden
  74787. */
  74788. 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;
  74789. }
  74790. }
  74791. declare module BABYLON {
  74792. /**
  74793. * @hidden
  74794. */
  74795. export interface IColor4Like {
  74796. r: float;
  74797. g: float;
  74798. b: float;
  74799. a: float;
  74800. }
  74801. /**
  74802. * @hidden
  74803. */
  74804. export interface IColor3Like {
  74805. r: float;
  74806. g: float;
  74807. b: float;
  74808. }
  74809. /**
  74810. * @hidden
  74811. */
  74812. export interface IVector4Like {
  74813. x: float;
  74814. y: float;
  74815. z: float;
  74816. w: float;
  74817. }
  74818. /**
  74819. * @hidden
  74820. */
  74821. export interface IVector3Like {
  74822. x: float;
  74823. y: float;
  74824. z: float;
  74825. }
  74826. /**
  74827. * @hidden
  74828. */
  74829. export interface IVector2Like {
  74830. x: float;
  74831. y: float;
  74832. }
  74833. /**
  74834. * @hidden
  74835. */
  74836. export interface IMatrixLike {
  74837. toArray(): DeepImmutable<Float32Array>;
  74838. updateFlag: int;
  74839. }
  74840. /**
  74841. * @hidden
  74842. */
  74843. export interface IViewportLike {
  74844. x: float;
  74845. y: float;
  74846. width: float;
  74847. height: float;
  74848. }
  74849. /**
  74850. * @hidden
  74851. */
  74852. export interface IPlaneLike {
  74853. normal: IVector3Like;
  74854. d: float;
  74855. normalize(): void;
  74856. }
  74857. }
  74858. declare module BABYLON {
  74859. /**
  74860. * Interface used to define common properties for effect fallbacks
  74861. */
  74862. export interface IEffectFallbacks {
  74863. /**
  74864. * Removes the defines that should be removed when falling back.
  74865. * @param currentDefines defines the current define statements for the shader.
  74866. * @param effect defines the current effect we try to compile
  74867. * @returns The resulting defines with defines of the current rank removed.
  74868. */
  74869. reduce(currentDefines: string, effect: Effect): string;
  74870. /**
  74871. * Removes the fallback from the bound mesh.
  74872. */
  74873. unBindMesh(): void;
  74874. /**
  74875. * Checks to see if more fallbacks are still availible.
  74876. */
  74877. hasMoreFallbacks: boolean;
  74878. }
  74879. }
  74880. declare module BABYLON {
  74881. /**
  74882. * Class used to evalaute queries containing `and` and `or` operators
  74883. */
  74884. export class AndOrNotEvaluator {
  74885. /**
  74886. * Evaluate a query
  74887. * @param query defines the query to evaluate
  74888. * @param evaluateCallback defines the callback used to filter result
  74889. * @returns true if the query matches
  74890. */
  74891. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  74892. private static _HandleParenthesisContent;
  74893. private static _SimplifyNegation;
  74894. }
  74895. }
  74896. declare module BABYLON {
  74897. /**
  74898. * Class used to store custom tags
  74899. */
  74900. export class Tags {
  74901. /**
  74902. * Adds support for tags on the given object
  74903. * @param obj defines the object to use
  74904. */
  74905. static EnableFor(obj: any): void;
  74906. /**
  74907. * Removes tags support
  74908. * @param obj defines the object to use
  74909. */
  74910. static DisableFor(obj: any): void;
  74911. /**
  74912. * Gets a boolean indicating if the given object has tags
  74913. * @param obj defines the object to use
  74914. * @returns a boolean
  74915. */
  74916. static HasTags(obj: any): boolean;
  74917. /**
  74918. * Gets the tags available on a given object
  74919. * @param obj defines the object to use
  74920. * @param asString defines if the tags must be returned as a string instead of an array of strings
  74921. * @returns the tags
  74922. */
  74923. static GetTags(obj: any, asString?: boolean): any;
  74924. /**
  74925. * Adds tags to an object
  74926. * @param obj defines the object to use
  74927. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  74928. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  74929. */
  74930. static AddTagsTo(obj: any, tagsString: string): void;
  74931. /**
  74932. * @hidden
  74933. */
  74934. static _AddTagTo(obj: any, tag: string): void;
  74935. /**
  74936. * Removes specific tags from a specific object
  74937. * @param obj defines the object to use
  74938. * @param tagsString defines the tags to remove
  74939. */
  74940. static RemoveTagsFrom(obj: any, tagsString: string): void;
  74941. /**
  74942. * @hidden
  74943. */
  74944. static _RemoveTagFrom(obj: any, tag: string): void;
  74945. /**
  74946. * Defines if tags hosted on an object match a given query
  74947. * @param obj defines the object to use
  74948. * @param tagsQuery defines the tag query
  74949. * @returns a boolean
  74950. */
  74951. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  74952. }
  74953. }
  74954. declare module BABYLON {
  74955. /**
  74956. * Scalar computation library
  74957. */
  74958. export class Scalar {
  74959. /**
  74960. * Two pi constants convenient for computation.
  74961. */
  74962. static TwoPi: number;
  74963. /**
  74964. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74965. * @param a number
  74966. * @param b number
  74967. * @param epsilon (default = 1.401298E-45)
  74968. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74969. */
  74970. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  74971. /**
  74972. * Returns a string : the upper case translation of the number i to hexadecimal.
  74973. * @param i number
  74974. * @returns the upper case translation of the number i to hexadecimal.
  74975. */
  74976. static ToHex(i: number): string;
  74977. /**
  74978. * Returns -1 if value is negative and +1 is value is positive.
  74979. * @param value the value
  74980. * @returns the value itself if it's equal to zero.
  74981. */
  74982. static Sign(value: number): number;
  74983. /**
  74984. * Returns the value itself if it's between min and max.
  74985. * Returns min if the value is lower than min.
  74986. * Returns max if the value is greater than max.
  74987. * @param value the value to clmap
  74988. * @param min the min value to clamp to (default: 0)
  74989. * @param max the max value to clamp to (default: 1)
  74990. * @returns the clamped value
  74991. */
  74992. static Clamp(value: number, min?: number, max?: number): number;
  74993. /**
  74994. * the log2 of value.
  74995. * @param value the value to compute log2 of
  74996. * @returns the log2 of value.
  74997. */
  74998. static Log2(value: number): number;
  74999. /**
  75000. * Loops the value, so that it is never larger than length and never smaller than 0.
  75001. *
  75002. * This is similar to the modulo operator but it works with floating point numbers.
  75003. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  75004. * With t = 5 and length = 2.5, the result would be 0.0.
  75005. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  75006. * @param value the value
  75007. * @param length the length
  75008. * @returns the looped value
  75009. */
  75010. static Repeat(value: number, length: number): number;
  75011. /**
  75012. * Normalize the value between 0.0 and 1.0 using min and max values
  75013. * @param value value to normalize
  75014. * @param min max to normalize between
  75015. * @param max min to normalize between
  75016. * @returns the normalized value
  75017. */
  75018. static Normalize(value: number, min: number, max: number): number;
  75019. /**
  75020. * Denormalize the value from 0.0 and 1.0 using min and max values
  75021. * @param normalized value to denormalize
  75022. * @param min max to denormalize between
  75023. * @param max min to denormalize between
  75024. * @returns the denormalized value
  75025. */
  75026. static Denormalize(normalized: number, min: number, max: number): number;
  75027. /**
  75028. * Calculates the shortest difference between two given angles given in degrees.
  75029. * @param current current angle in degrees
  75030. * @param target target angle in degrees
  75031. * @returns the delta
  75032. */
  75033. static DeltaAngle(current: number, target: number): number;
  75034. /**
  75035. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  75036. * @param tx value
  75037. * @param length length
  75038. * @returns The returned value will move back and forth between 0 and length
  75039. */
  75040. static PingPong(tx: number, length: number): number;
  75041. /**
  75042. * Interpolates between min and max with smoothing at the limits.
  75043. *
  75044. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  75045. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  75046. * @param from from
  75047. * @param to to
  75048. * @param tx value
  75049. * @returns the smooth stepped value
  75050. */
  75051. static SmoothStep(from: number, to: number, tx: number): number;
  75052. /**
  75053. * Moves a value current towards target.
  75054. *
  75055. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  75056. * Negative values of maxDelta pushes the value away from target.
  75057. * @param current current value
  75058. * @param target target value
  75059. * @param maxDelta max distance to move
  75060. * @returns resulting value
  75061. */
  75062. static MoveTowards(current: number, target: number, maxDelta: number): number;
  75063. /**
  75064. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75065. *
  75066. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  75067. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  75068. * @param current current value
  75069. * @param target target value
  75070. * @param maxDelta max distance to move
  75071. * @returns resulting angle
  75072. */
  75073. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  75074. /**
  75075. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  75076. * @param start start value
  75077. * @param end target value
  75078. * @param amount amount to lerp between
  75079. * @returns the lerped value
  75080. */
  75081. static Lerp(start: number, end: number, amount: number): number;
  75082. /**
  75083. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  75084. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  75085. * @param start start value
  75086. * @param end target value
  75087. * @param amount amount to lerp between
  75088. * @returns the lerped value
  75089. */
  75090. static LerpAngle(start: number, end: number, amount: number): number;
  75091. /**
  75092. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  75093. * @param a start value
  75094. * @param b target value
  75095. * @param value value between a and b
  75096. * @returns the inverseLerp value
  75097. */
  75098. static InverseLerp(a: number, b: number, value: number): number;
  75099. /**
  75100. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  75101. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  75102. * @param value1 spline value
  75103. * @param tangent1 spline value
  75104. * @param value2 spline value
  75105. * @param tangent2 spline value
  75106. * @param amount input value
  75107. * @returns hermite result
  75108. */
  75109. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  75110. /**
  75111. * Returns a random float number between and min and max values
  75112. * @param min min value of random
  75113. * @param max max value of random
  75114. * @returns random value
  75115. */
  75116. static RandomRange(min: number, max: number): number;
  75117. /**
  75118. * This function returns percentage of a number in a given range.
  75119. *
  75120. * RangeToPercent(40,20,60) will return 0.5 (50%)
  75121. * RangeToPercent(34,0,100) will return 0.34 (34%)
  75122. * @param number to convert to percentage
  75123. * @param min min range
  75124. * @param max max range
  75125. * @returns the percentage
  75126. */
  75127. static RangeToPercent(number: number, min: number, max: number): number;
  75128. /**
  75129. * This function returns number that corresponds to the percentage in a given range.
  75130. *
  75131. * PercentToRange(0.34,0,100) will return 34.
  75132. * @param percent to convert to number
  75133. * @param min min range
  75134. * @param max max range
  75135. * @returns the number
  75136. */
  75137. static PercentToRange(percent: number, min: number, max: number): number;
  75138. /**
  75139. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  75140. * @param angle The angle to normalize in radian.
  75141. * @return The converted angle.
  75142. */
  75143. static NormalizeRadians(angle: number): number;
  75144. }
  75145. }
  75146. declare module BABYLON {
  75147. /**
  75148. * Constant used to convert a value to gamma space
  75149. * @ignorenaming
  75150. */
  75151. export const ToGammaSpace: number;
  75152. /**
  75153. * Constant used to convert a value to linear space
  75154. * @ignorenaming
  75155. */
  75156. export const ToLinearSpace = 2.2;
  75157. /**
  75158. * Constant used to define the minimal number value in Babylon.js
  75159. * @ignorenaming
  75160. */
  75161. let Epsilon: number;
  75162. }
  75163. declare module BABYLON {
  75164. /**
  75165. * Class used to represent a viewport on screen
  75166. */
  75167. export class Viewport {
  75168. /** viewport left coordinate */
  75169. x: number;
  75170. /** viewport top coordinate */
  75171. y: number;
  75172. /**viewport width */
  75173. width: number;
  75174. /** viewport height */
  75175. height: number;
  75176. /**
  75177. * Creates a Viewport object located at (x, y) and sized (width, height)
  75178. * @param x defines viewport left coordinate
  75179. * @param y defines viewport top coordinate
  75180. * @param width defines the viewport width
  75181. * @param height defines the viewport height
  75182. */
  75183. constructor(
  75184. /** viewport left coordinate */
  75185. x: number,
  75186. /** viewport top coordinate */
  75187. y: number,
  75188. /**viewport width */
  75189. width: number,
  75190. /** viewport height */
  75191. height: number);
  75192. /**
  75193. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  75194. * @param renderWidth defines the rendering width
  75195. * @param renderHeight defines the rendering height
  75196. * @returns a new Viewport
  75197. */
  75198. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  75199. /**
  75200. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  75201. * @param renderWidth defines the rendering width
  75202. * @param renderHeight defines the rendering height
  75203. * @param ref defines the target viewport
  75204. * @returns the current viewport
  75205. */
  75206. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  75207. /**
  75208. * Returns a new Viewport copied from the current one
  75209. * @returns a new Viewport
  75210. */
  75211. clone(): Viewport;
  75212. }
  75213. }
  75214. declare module BABYLON {
  75215. /**
  75216. * Class containing a set of static utilities functions for arrays.
  75217. */
  75218. export class ArrayTools {
  75219. /**
  75220. * Returns an array of the given size filled with element built from the given constructor and the paramters
  75221. * @param size the number of element to construct and put in the array
  75222. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  75223. * @returns a new array filled with new objects
  75224. */
  75225. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  75226. }
  75227. }
  75228. declare module BABYLON {
  75229. /**
  75230. * Class representing a vector containing 2 coordinates
  75231. */
  75232. export class Vector2 {
  75233. /** defines the first coordinate */
  75234. x: number;
  75235. /** defines the second coordinate */
  75236. y: number;
  75237. /**
  75238. * Creates a new Vector2 from the given x and y coordinates
  75239. * @param x defines the first coordinate
  75240. * @param y defines the second coordinate
  75241. */
  75242. constructor(
  75243. /** defines the first coordinate */
  75244. x?: number,
  75245. /** defines the second coordinate */
  75246. y?: number);
  75247. /**
  75248. * Gets a string with the Vector2 coordinates
  75249. * @returns a string with the Vector2 coordinates
  75250. */
  75251. toString(): string;
  75252. /**
  75253. * Gets class name
  75254. * @returns the string "Vector2"
  75255. */
  75256. getClassName(): string;
  75257. /**
  75258. * Gets current vector hash code
  75259. * @returns the Vector2 hash code as a number
  75260. */
  75261. getHashCode(): number;
  75262. /**
  75263. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  75264. * @param array defines the source array
  75265. * @param index defines the offset in source array
  75266. * @returns the current Vector2
  75267. */
  75268. toArray(array: FloatArray, index?: number): Vector2;
  75269. /**
  75270. * Copy the current vector to an array
  75271. * @returns a new array with 2 elements: the Vector2 coordinates.
  75272. */
  75273. asArray(): number[];
  75274. /**
  75275. * Sets the Vector2 coordinates with the given Vector2 coordinates
  75276. * @param source defines the source Vector2
  75277. * @returns the current updated Vector2
  75278. */
  75279. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  75280. /**
  75281. * Sets the Vector2 coordinates with the given floats
  75282. * @param x defines the first coordinate
  75283. * @param y defines the second coordinate
  75284. * @returns the current updated Vector2
  75285. */
  75286. copyFromFloats(x: number, y: number): Vector2;
  75287. /**
  75288. * Sets the Vector2 coordinates with the given floats
  75289. * @param x defines the first coordinate
  75290. * @param y defines the second coordinate
  75291. * @returns the current updated Vector2
  75292. */
  75293. set(x: number, y: number): Vector2;
  75294. /**
  75295. * Add another vector with the current one
  75296. * @param otherVector defines the other vector
  75297. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  75298. */
  75299. add(otherVector: DeepImmutable<Vector2>): Vector2;
  75300. /**
  75301. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  75302. * @param otherVector defines the other vector
  75303. * @param result defines the target vector
  75304. * @returns the unmodified current Vector2
  75305. */
  75306. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75307. /**
  75308. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  75309. * @param otherVector defines the other vector
  75310. * @returns the current updated Vector2
  75311. */
  75312. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75313. /**
  75314. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  75315. * @param otherVector defines the other vector
  75316. * @returns a new Vector2
  75317. */
  75318. addVector3(otherVector: Vector3): Vector2;
  75319. /**
  75320. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  75321. * @param otherVector defines the other vector
  75322. * @returns a new Vector2
  75323. */
  75324. subtract(otherVector: Vector2): Vector2;
  75325. /**
  75326. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  75327. * @param otherVector defines the other vector
  75328. * @param result defines the target vector
  75329. * @returns the unmodified current Vector2
  75330. */
  75331. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75332. /**
  75333. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  75334. * @param otherVector defines the other vector
  75335. * @returns the current updated Vector2
  75336. */
  75337. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75338. /**
  75339. * Multiplies in place the current Vector2 coordinates by the given ones
  75340. * @param otherVector defines the other vector
  75341. * @returns the current updated Vector2
  75342. */
  75343. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75344. /**
  75345. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  75346. * @param otherVector defines the other vector
  75347. * @returns a new Vector2
  75348. */
  75349. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  75350. /**
  75351. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  75352. * @param otherVector defines the other vector
  75353. * @param result defines the target vector
  75354. * @returns the unmodified current Vector2
  75355. */
  75356. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75357. /**
  75358. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  75359. * @param x defines the first coordinate
  75360. * @param y defines the second coordinate
  75361. * @returns a new Vector2
  75362. */
  75363. multiplyByFloats(x: number, y: number): Vector2;
  75364. /**
  75365. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  75366. * @param otherVector defines the other vector
  75367. * @returns a new Vector2
  75368. */
  75369. divide(otherVector: Vector2): Vector2;
  75370. /**
  75371. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  75372. * @param otherVector defines the other vector
  75373. * @param result defines the target vector
  75374. * @returns the unmodified current Vector2
  75375. */
  75376. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  75377. /**
  75378. * Divides the current Vector2 coordinates by the given ones
  75379. * @param otherVector defines the other vector
  75380. * @returns the current updated Vector2
  75381. */
  75382. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  75383. /**
  75384. * Gets a new Vector2 with current Vector2 negated coordinates
  75385. * @returns a new Vector2
  75386. */
  75387. negate(): Vector2;
  75388. /**
  75389. * Negate this vector in place
  75390. * @returns this
  75391. */
  75392. negateInPlace(): Vector2;
  75393. /**
  75394. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  75395. * @param result defines the Vector3 object where to store the result
  75396. * @returns the current Vector2
  75397. */
  75398. negateToRef(result: Vector2): Vector2;
  75399. /**
  75400. * Multiply the Vector2 coordinates by scale
  75401. * @param scale defines the scaling factor
  75402. * @returns the current updated Vector2
  75403. */
  75404. scaleInPlace(scale: number): Vector2;
  75405. /**
  75406. * Returns a new Vector2 scaled by "scale" from the current Vector2
  75407. * @param scale defines the scaling factor
  75408. * @returns a new Vector2
  75409. */
  75410. scale(scale: number): Vector2;
  75411. /**
  75412. * Scale the current Vector2 values by a factor to a given Vector2
  75413. * @param scale defines the scale factor
  75414. * @param result defines the Vector2 object where to store the result
  75415. * @returns the unmodified current Vector2
  75416. */
  75417. scaleToRef(scale: number, result: Vector2): Vector2;
  75418. /**
  75419. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  75420. * @param scale defines the scale factor
  75421. * @param result defines the Vector2 object where to store the result
  75422. * @returns the unmodified current Vector2
  75423. */
  75424. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  75425. /**
  75426. * Gets a boolean if two vectors are equals
  75427. * @param otherVector defines the other vector
  75428. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  75429. */
  75430. equals(otherVector: DeepImmutable<Vector2>): boolean;
  75431. /**
  75432. * Gets a boolean if two vectors are equals (using an epsilon value)
  75433. * @param otherVector defines the other vector
  75434. * @param epsilon defines the minimal distance to consider equality
  75435. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  75436. */
  75437. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  75438. /**
  75439. * Gets a new Vector2 from current Vector2 floored values
  75440. * @returns a new Vector2
  75441. */
  75442. floor(): Vector2;
  75443. /**
  75444. * Gets a new Vector2 from current Vector2 floored values
  75445. * @returns a new Vector2
  75446. */
  75447. fract(): Vector2;
  75448. /**
  75449. * Gets the length of the vector
  75450. * @returns the vector length (float)
  75451. */
  75452. length(): number;
  75453. /**
  75454. * Gets the vector squared length
  75455. * @returns the vector squared length (float)
  75456. */
  75457. lengthSquared(): number;
  75458. /**
  75459. * Normalize the vector
  75460. * @returns the current updated Vector2
  75461. */
  75462. normalize(): Vector2;
  75463. /**
  75464. * Gets a new Vector2 copied from the Vector2
  75465. * @returns a new Vector2
  75466. */
  75467. clone(): Vector2;
  75468. /**
  75469. * Gets a new Vector2(0, 0)
  75470. * @returns a new Vector2
  75471. */
  75472. static Zero(): Vector2;
  75473. /**
  75474. * Gets a new Vector2(1, 1)
  75475. * @returns a new Vector2
  75476. */
  75477. static One(): Vector2;
  75478. /**
  75479. * Gets a new Vector2 set from the given index element of the given array
  75480. * @param array defines the data source
  75481. * @param offset defines the offset in the data source
  75482. * @returns a new Vector2
  75483. */
  75484. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  75485. /**
  75486. * Sets "result" from the given index element of the given array
  75487. * @param array defines the data source
  75488. * @param offset defines the offset in the data source
  75489. * @param result defines the target vector
  75490. */
  75491. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  75492. /**
  75493. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  75494. * @param value1 defines 1st point of control
  75495. * @param value2 defines 2nd point of control
  75496. * @param value3 defines 3rd point of control
  75497. * @param value4 defines 4th point of control
  75498. * @param amount defines the interpolation factor
  75499. * @returns a new Vector2
  75500. */
  75501. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  75502. /**
  75503. * 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".
  75504. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  75505. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  75506. * @param value defines the value to clamp
  75507. * @param min defines the lower limit
  75508. * @param max defines the upper limit
  75509. * @returns a new Vector2
  75510. */
  75511. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  75512. /**
  75513. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  75514. * @param value1 defines the 1st control point
  75515. * @param tangent1 defines the outgoing tangent
  75516. * @param value2 defines the 2nd control point
  75517. * @param tangent2 defines the incoming tangent
  75518. * @param amount defines the interpolation factor
  75519. * @returns a new Vector2
  75520. */
  75521. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  75522. /**
  75523. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  75524. * @param start defines the start vector
  75525. * @param end defines the end vector
  75526. * @param amount defines the interpolation factor
  75527. * @returns a new Vector2
  75528. */
  75529. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  75530. /**
  75531. * Gets the dot product of the vector "left" and the vector "right"
  75532. * @param left defines first vector
  75533. * @param right defines second vector
  75534. * @returns the dot product (float)
  75535. */
  75536. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  75537. /**
  75538. * Returns a new Vector2 equal to the normalized given vector
  75539. * @param vector defines the vector to normalize
  75540. * @returns a new Vector2
  75541. */
  75542. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  75543. /**
  75544. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  75545. * @param left defines 1st vector
  75546. * @param right defines 2nd vector
  75547. * @returns a new Vector2
  75548. */
  75549. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75550. /**
  75551. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  75552. * @param left defines 1st vector
  75553. * @param right defines 2nd vector
  75554. * @returns a new Vector2
  75555. */
  75556. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  75557. /**
  75558. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  75559. * @param vector defines the vector to transform
  75560. * @param transformation defines the matrix to apply
  75561. * @returns a new Vector2
  75562. */
  75563. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  75564. /**
  75565. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  75566. * @param vector defines the vector to transform
  75567. * @param transformation defines the matrix to apply
  75568. * @param result defines the target vector
  75569. */
  75570. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  75571. /**
  75572. * Determines if a given vector is included in a triangle
  75573. * @param p defines the vector to test
  75574. * @param p0 defines 1st triangle point
  75575. * @param p1 defines 2nd triangle point
  75576. * @param p2 defines 3rd triangle point
  75577. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  75578. */
  75579. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  75580. /**
  75581. * Gets the distance between the vectors "value1" and "value2"
  75582. * @param value1 defines first vector
  75583. * @param value2 defines second vector
  75584. * @returns the distance between vectors
  75585. */
  75586. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75587. /**
  75588. * Returns the squared distance between the vectors "value1" and "value2"
  75589. * @param value1 defines first vector
  75590. * @param value2 defines second vector
  75591. * @returns the squared distance between vectors
  75592. */
  75593. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  75594. /**
  75595. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  75596. * @param value1 defines first vector
  75597. * @param value2 defines second vector
  75598. * @returns a new Vector2
  75599. */
  75600. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  75601. /**
  75602. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  75603. * @param p defines the middle point
  75604. * @param segA defines one point of the segment
  75605. * @param segB defines the other point of the segment
  75606. * @returns the shortest distance
  75607. */
  75608. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  75609. }
  75610. /**
  75611. * Class used to store (x,y,z) vector representation
  75612. * A Vector3 is the main object used in 3D geometry
  75613. * It can represent etiher the coordinates of a point the space, either a direction
  75614. * Reminder: js uses a left handed forward facing system
  75615. */
  75616. export class Vector3 {
  75617. /**
  75618. * Defines the first coordinates (on X axis)
  75619. */
  75620. x: number;
  75621. /**
  75622. * Defines the second coordinates (on Y axis)
  75623. */
  75624. y: number;
  75625. /**
  75626. * Defines the third coordinates (on Z axis)
  75627. */
  75628. z: number;
  75629. private static _UpReadOnly;
  75630. private static _ZeroReadOnly;
  75631. /**
  75632. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  75633. * @param x defines the first coordinates (on X axis)
  75634. * @param y defines the second coordinates (on Y axis)
  75635. * @param z defines the third coordinates (on Z axis)
  75636. */
  75637. constructor(
  75638. /**
  75639. * Defines the first coordinates (on X axis)
  75640. */
  75641. x?: number,
  75642. /**
  75643. * Defines the second coordinates (on Y axis)
  75644. */
  75645. y?: number,
  75646. /**
  75647. * Defines the third coordinates (on Z axis)
  75648. */
  75649. z?: number);
  75650. /**
  75651. * Creates a string representation of the Vector3
  75652. * @returns a string with the Vector3 coordinates.
  75653. */
  75654. toString(): string;
  75655. /**
  75656. * Gets the class name
  75657. * @returns the string "Vector3"
  75658. */
  75659. getClassName(): string;
  75660. /**
  75661. * Creates the Vector3 hash code
  75662. * @returns a number which tends to be unique between Vector3 instances
  75663. */
  75664. getHashCode(): number;
  75665. /**
  75666. * Creates an array containing three elements : the coordinates of the Vector3
  75667. * @returns a new array of numbers
  75668. */
  75669. asArray(): number[];
  75670. /**
  75671. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  75672. * @param array defines the destination array
  75673. * @param index defines the offset in the destination array
  75674. * @returns the current Vector3
  75675. */
  75676. toArray(array: FloatArray, index?: number): Vector3;
  75677. /**
  75678. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  75679. * @returns a new Quaternion object, computed from the Vector3 coordinates
  75680. */
  75681. toQuaternion(): Quaternion;
  75682. /**
  75683. * Adds the given vector to the current Vector3
  75684. * @param otherVector defines the second operand
  75685. * @returns the current updated Vector3
  75686. */
  75687. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75688. /**
  75689. * Adds the given coordinates to the current Vector3
  75690. * @param x defines the x coordinate of the operand
  75691. * @param y defines the y coordinate of the operand
  75692. * @param z defines the z coordinate of the operand
  75693. * @returns the current updated Vector3
  75694. */
  75695. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75696. /**
  75697. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  75698. * @param otherVector defines the second operand
  75699. * @returns the resulting Vector3
  75700. */
  75701. add(otherVector: DeepImmutable<Vector3>): Vector3;
  75702. /**
  75703. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  75704. * @param otherVector defines the second operand
  75705. * @param result defines the Vector3 object where to store the result
  75706. * @returns the current Vector3
  75707. */
  75708. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75709. /**
  75710. * Subtract the given vector from the current Vector3
  75711. * @param otherVector defines the second operand
  75712. * @returns the current updated Vector3
  75713. */
  75714. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75715. /**
  75716. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  75717. * @param otherVector defines the second operand
  75718. * @returns the resulting Vector3
  75719. */
  75720. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  75721. /**
  75722. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  75723. * @param otherVector defines the second operand
  75724. * @param result defines the Vector3 object where to store the result
  75725. * @returns the current Vector3
  75726. */
  75727. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75728. /**
  75729. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  75730. * @param x defines the x coordinate of the operand
  75731. * @param y defines the y coordinate of the operand
  75732. * @param z defines the z coordinate of the operand
  75733. * @returns the resulting Vector3
  75734. */
  75735. subtractFromFloats(x: number, y: number, z: number): Vector3;
  75736. /**
  75737. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  75738. * @param x defines the x coordinate of the operand
  75739. * @param y defines the y coordinate of the operand
  75740. * @param z defines the z coordinate of the operand
  75741. * @param result defines the Vector3 object where to store the result
  75742. * @returns the current Vector3
  75743. */
  75744. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  75745. /**
  75746. * Gets a new Vector3 set with the current Vector3 negated coordinates
  75747. * @returns a new Vector3
  75748. */
  75749. negate(): Vector3;
  75750. /**
  75751. * Negate this vector in place
  75752. * @returns this
  75753. */
  75754. negateInPlace(): Vector3;
  75755. /**
  75756. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  75757. * @param result defines the Vector3 object where to store the result
  75758. * @returns the current Vector3
  75759. */
  75760. negateToRef(result: Vector3): Vector3;
  75761. /**
  75762. * Multiplies the Vector3 coordinates by the float "scale"
  75763. * @param scale defines the multiplier factor
  75764. * @returns the current updated Vector3
  75765. */
  75766. scaleInPlace(scale: number): Vector3;
  75767. /**
  75768. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  75769. * @param scale defines the multiplier factor
  75770. * @returns a new Vector3
  75771. */
  75772. scale(scale: number): Vector3;
  75773. /**
  75774. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  75775. * @param scale defines the multiplier factor
  75776. * @param result defines the Vector3 object where to store the result
  75777. * @returns the current Vector3
  75778. */
  75779. scaleToRef(scale: number, result: Vector3): Vector3;
  75780. /**
  75781. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  75782. * @param scale defines the scale factor
  75783. * @param result defines the Vector3 object where to store the result
  75784. * @returns the unmodified current Vector3
  75785. */
  75786. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  75787. /**
  75788. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  75789. * @param otherVector defines the second operand
  75790. * @returns true if both vectors are equals
  75791. */
  75792. equals(otherVector: DeepImmutable<Vector3>): boolean;
  75793. /**
  75794. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  75795. * @param otherVector defines the second operand
  75796. * @param epsilon defines the minimal distance to define values as equals
  75797. * @returns true if both vectors are distant less than epsilon
  75798. */
  75799. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  75800. /**
  75801. * Returns true if the current Vector3 coordinates equals the given floats
  75802. * @param x defines the x coordinate of the operand
  75803. * @param y defines the y coordinate of the operand
  75804. * @param z defines the z coordinate of the operand
  75805. * @returns true if both vectors are equals
  75806. */
  75807. equalsToFloats(x: number, y: number, z: number): boolean;
  75808. /**
  75809. * Multiplies the current Vector3 coordinates by the given ones
  75810. * @param otherVector defines the second operand
  75811. * @returns the current updated Vector3
  75812. */
  75813. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  75814. /**
  75815. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  75816. * @param otherVector defines the second operand
  75817. * @returns the new Vector3
  75818. */
  75819. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  75820. /**
  75821. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  75822. * @param otherVector defines the second operand
  75823. * @param result defines the Vector3 object where to store the result
  75824. * @returns the current Vector3
  75825. */
  75826. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75827. /**
  75828. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  75829. * @param x defines the x coordinate of the operand
  75830. * @param y defines the y coordinate of the operand
  75831. * @param z defines the z coordinate of the operand
  75832. * @returns the new Vector3
  75833. */
  75834. multiplyByFloats(x: number, y: number, z: number): Vector3;
  75835. /**
  75836. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  75837. * @param otherVector defines the second operand
  75838. * @returns the new Vector3
  75839. */
  75840. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  75841. /**
  75842. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  75843. * @param otherVector defines the second operand
  75844. * @param result defines the Vector3 object where to store the result
  75845. * @returns the current Vector3
  75846. */
  75847. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  75848. /**
  75849. * Divides the current Vector3 coordinates by the given ones.
  75850. * @param otherVector defines the second operand
  75851. * @returns the current updated Vector3
  75852. */
  75853. divideInPlace(otherVector: Vector3): Vector3;
  75854. /**
  75855. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  75856. * @param other defines the second operand
  75857. * @returns the current updated Vector3
  75858. */
  75859. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75860. /**
  75861. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  75862. * @param other defines the second operand
  75863. * @returns the current updated Vector3
  75864. */
  75865. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  75866. /**
  75867. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  75868. * @param x defines the x coordinate of the operand
  75869. * @param y defines the y coordinate of the operand
  75870. * @param z defines the z coordinate of the operand
  75871. * @returns the current updated Vector3
  75872. */
  75873. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75874. /**
  75875. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  75876. * @param x defines the x coordinate of the operand
  75877. * @param y defines the y coordinate of the operand
  75878. * @param z defines the z coordinate of the operand
  75879. * @returns the current updated Vector3
  75880. */
  75881. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  75882. /**
  75883. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  75884. * Check if is non uniform within a certain amount of decimal places to account for this
  75885. * @param epsilon the amount the values can differ
  75886. * @returns if the the vector is non uniform to a certain number of decimal places
  75887. */
  75888. isNonUniformWithinEpsilon(epsilon: number): boolean;
  75889. /**
  75890. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  75891. */
  75892. get isNonUniform(): boolean;
  75893. /**
  75894. * Gets a new Vector3 from current Vector3 floored values
  75895. * @returns a new Vector3
  75896. */
  75897. floor(): Vector3;
  75898. /**
  75899. * Gets a new Vector3 from current Vector3 floored values
  75900. * @returns a new Vector3
  75901. */
  75902. fract(): Vector3;
  75903. /**
  75904. * Gets the length of the Vector3
  75905. * @returns the length of the Vector3
  75906. */
  75907. length(): number;
  75908. /**
  75909. * Gets the squared length of the Vector3
  75910. * @returns squared length of the Vector3
  75911. */
  75912. lengthSquared(): number;
  75913. /**
  75914. * Normalize the current Vector3.
  75915. * Please note that this is an in place operation.
  75916. * @returns the current updated Vector3
  75917. */
  75918. normalize(): Vector3;
  75919. /**
  75920. * Reorders the x y z properties of the vector in place
  75921. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  75922. * @returns the current updated vector
  75923. */
  75924. reorderInPlace(order: string): this;
  75925. /**
  75926. * Rotates the vector around 0,0,0 by a quaternion
  75927. * @param quaternion the rotation quaternion
  75928. * @param result vector to store the result
  75929. * @returns the resulting vector
  75930. */
  75931. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  75932. /**
  75933. * Rotates a vector around a given point
  75934. * @param quaternion the rotation quaternion
  75935. * @param point the point to rotate around
  75936. * @param result vector to store the result
  75937. * @returns the resulting vector
  75938. */
  75939. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  75940. /**
  75941. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  75942. * The cross product is then orthogonal to both current and "other"
  75943. * @param other defines the right operand
  75944. * @returns the cross product
  75945. */
  75946. cross(other: Vector3): Vector3;
  75947. /**
  75948. * Normalize the current Vector3 with the given input length.
  75949. * Please note that this is an in place operation.
  75950. * @param len the length of the vector
  75951. * @returns the current updated Vector3
  75952. */
  75953. normalizeFromLength(len: number): Vector3;
  75954. /**
  75955. * Normalize the current Vector3 to a new vector
  75956. * @returns the new Vector3
  75957. */
  75958. normalizeToNew(): Vector3;
  75959. /**
  75960. * Normalize the current Vector3 to the reference
  75961. * @param reference define the Vector3 to update
  75962. * @returns the updated Vector3
  75963. */
  75964. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  75965. /**
  75966. * Creates a new Vector3 copied from the current Vector3
  75967. * @returns the new Vector3
  75968. */
  75969. clone(): Vector3;
  75970. /**
  75971. * Copies the given vector coordinates to the current Vector3 ones
  75972. * @param source defines the source Vector3
  75973. * @returns the current updated Vector3
  75974. */
  75975. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  75976. /**
  75977. * Copies the given floats to the current Vector3 coordinates
  75978. * @param x defines the x coordinate of the operand
  75979. * @param y defines the y coordinate of the operand
  75980. * @param z defines the z coordinate of the operand
  75981. * @returns the current updated Vector3
  75982. */
  75983. copyFromFloats(x: number, y: number, z: number): Vector3;
  75984. /**
  75985. * Copies the given floats to the current Vector3 coordinates
  75986. * @param x defines the x coordinate of the operand
  75987. * @param y defines the y coordinate of the operand
  75988. * @param z defines the z coordinate of the operand
  75989. * @returns the current updated Vector3
  75990. */
  75991. set(x: number, y: number, z: number): Vector3;
  75992. /**
  75993. * Copies the given float to the current Vector3 coordinates
  75994. * @param v defines the x, y and z coordinates of the operand
  75995. * @returns the current updated Vector3
  75996. */
  75997. setAll(v: number): Vector3;
  75998. /**
  75999. * Get the clip factor between two vectors
  76000. * @param vector0 defines the first operand
  76001. * @param vector1 defines the second operand
  76002. * @param axis defines the axis to use
  76003. * @param size defines the size along the axis
  76004. * @returns the clip factor
  76005. */
  76006. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  76007. /**
  76008. * Get angle between two vectors
  76009. * @param vector0 angle between vector0 and vector1
  76010. * @param vector1 angle between vector0 and vector1
  76011. * @param normal direction of the normal
  76012. * @return the angle between vector0 and vector1
  76013. */
  76014. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  76015. /**
  76016. * Returns a new Vector3 set from the index "offset" of the given array
  76017. * @param array defines the source array
  76018. * @param offset defines the offset in the source array
  76019. * @returns the new Vector3
  76020. */
  76021. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  76022. /**
  76023. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  76024. * @param array defines the source array
  76025. * @param offset defines the offset in the source array
  76026. * @returns the new Vector3
  76027. * @deprecated Please use FromArray instead.
  76028. */
  76029. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  76030. /**
  76031. * Sets the given vector "result" with the element values from the index "offset" of the given array
  76032. * @param array defines the source array
  76033. * @param offset defines the offset in the source array
  76034. * @param result defines the Vector3 where to store the result
  76035. */
  76036. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  76037. /**
  76038. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  76039. * @param array defines the source array
  76040. * @param offset defines the offset in the source array
  76041. * @param result defines the Vector3 where to store the result
  76042. * @deprecated Please use FromArrayToRef instead.
  76043. */
  76044. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  76045. /**
  76046. * Sets the given vector "result" with the given floats.
  76047. * @param x defines the x coordinate of the source
  76048. * @param y defines the y coordinate of the source
  76049. * @param z defines the z coordinate of the source
  76050. * @param result defines the Vector3 where to store the result
  76051. */
  76052. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  76053. /**
  76054. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  76055. * @returns a new empty Vector3
  76056. */
  76057. static Zero(): Vector3;
  76058. /**
  76059. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  76060. * @returns a new unit Vector3
  76061. */
  76062. static One(): Vector3;
  76063. /**
  76064. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  76065. * @returns a new up Vector3
  76066. */
  76067. static Up(): Vector3;
  76068. /**
  76069. * Gets a up Vector3 that must not be updated
  76070. */
  76071. static get UpReadOnly(): DeepImmutable<Vector3>;
  76072. /**
  76073. * Gets a zero Vector3 that must not be updated
  76074. */
  76075. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  76076. /**
  76077. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  76078. * @returns a new down Vector3
  76079. */
  76080. static Down(): Vector3;
  76081. /**
  76082. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  76083. * @returns a new forward Vector3
  76084. */
  76085. static Forward(): Vector3;
  76086. /**
  76087. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  76088. * @returns a new forward Vector3
  76089. */
  76090. static Backward(): Vector3;
  76091. /**
  76092. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  76093. * @returns a new right Vector3
  76094. */
  76095. static Right(): Vector3;
  76096. /**
  76097. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  76098. * @returns a new left Vector3
  76099. */
  76100. static Left(): Vector3;
  76101. /**
  76102. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  76103. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76104. * @param vector defines the Vector3 to transform
  76105. * @param transformation defines the transformation matrix
  76106. * @returns the transformed Vector3
  76107. */
  76108. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76109. /**
  76110. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  76111. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  76112. * @param vector defines the Vector3 to transform
  76113. * @param transformation defines the transformation matrix
  76114. * @param result defines the Vector3 where to store the result
  76115. */
  76116. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76117. /**
  76118. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  76119. * This method computes tranformed coordinates only, not transformed direction vectors
  76120. * @param x define the x coordinate of the source vector
  76121. * @param y define the y coordinate of the source vector
  76122. * @param z define the z coordinate of the source vector
  76123. * @param transformation defines the transformation matrix
  76124. * @param result defines the Vector3 where to store the result
  76125. */
  76126. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76127. /**
  76128. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  76129. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76130. * @param vector defines the Vector3 to transform
  76131. * @param transformation defines the transformation matrix
  76132. * @returns the new Vector3
  76133. */
  76134. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  76135. /**
  76136. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  76137. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76138. * @param vector defines the Vector3 to transform
  76139. * @param transformation defines the transformation matrix
  76140. * @param result defines the Vector3 where to store the result
  76141. */
  76142. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76143. /**
  76144. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  76145. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  76146. * @param x define the x coordinate of the source vector
  76147. * @param y define the y coordinate of the source vector
  76148. * @param z define the z coordinate of the source vector
  76149. * @param transformation defines the transformation matrix
  76150. * @param result defines the Vector3 where to store the result
  76151. */
  76152. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  76153. /**
  76154. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  76155. * @param value1 defines the first control point
  76156. * @param value2 defines the second control point
  76157. * @param value3 defines the third control point
  76158. * @param value4 defines the fourth control point
  76159. * @param amount defines the amount on the spline to use
  76160. * @returns the new Vector3
  76161. */
  76162. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  76163. /**
  76164. * 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"
  76165. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76166. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76167. * @param value defines the current value
  76168. * @param min defines the lower range value
  76169. * @param max defines the upper range value
  76170. * @returns the new Vector3
  76171. */
  76172. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  76173. /**
  76174. * 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"
  76175. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  76176. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  76177. * @param value defines the current value
  76178. * @param min defines the lower range value
  76179. * @param max defines the upper range value
  76180. * @param result defines the Vector3 where to store the result
  76181. */
  76182. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  76183. /**
  76184. * Checks if a given vector is inside a specific range
  76185. * @param v defines the vector to test
  76186. * @param min defines the minimum range
  76187. * @param max defines the maximum range
  76188. */
  76189. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  76190. /**
  76191. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  76192. * @param value1 defines the first control point
  76193. * @param tangent1 defines the first tangent vector
  76194. * @param value2 defines the second control point
  76195. * @param tangent2 defines the second tangent vector
  76196. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  76197. * @returns the new Vector3
  76198. */
  76199. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  76200. /**
  76201. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  76202. * @param start defines the start value
  76203. * @param end defines the end value
  76204. * @param amount max defines amount between both (between 0 and 1)
  76205. * @returns the new Vector3
  76206. */
  76207. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  76208. /**
  76209. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  76210. * @param start defines the start value
  76211. * @param end defines the end value
  76212. * @param amount max defines amount between both (between 0 and 1)
  76213. * @param result defines the Vector3 where to store the result
  76214. */
  76215. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  76216. /**
  76217. * Returns the dot product (float) between the vectors "left" and "right"
  76218. * @param left defines the left operand
  76219. * @param right defines the right operand
  76220. * @returns the dot product
  76221. */
  76222. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  76223. /**
  76224. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  76225. * The cross product is then orthogonal to both "left" and "right"
  76226. * @param left defines the left operand
  76227. * @param right defines the right operand
  76228. * @returns the cross product
  76229. */
  76230. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76231. /**
  76232. * Sets the given vector "result" with the cross product of "left" and "right"
  76233. * The cross product is then orthogonal to both "left" and "right"
  76234. * @param left defines the left operand
  76235. * @param right defines the right operand
  76236. * @param result defines the Vector3 where to store the result
  76237. */
  76238. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  76239. /**
  76240. * Returns a new Vector3 as the normalization of the given vector
  76241. * @param vector defines the Vector3 to normalize
  76242. * @returns the new Vector3
  76243. */
  76244. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  76245. /**
  76246. * Sets the given vector "result" with the normalization of the given first vector
  76247. * @param vector defines the Vector3 to normalize
  76248. * @param result defines the Vector3 where to store the result
  76249. */
  76250. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  76251. /**
  76252. * Project a Vector3 onto screen space
  76253. * @param vector defines the Vector3 to project
  76254. * @param world defines the world matrix to use
  76255. * @param transform defines the transform (view x projection) matrix to use
  76256. * @param viewport defines the screen viewport to use
  76257. * @returns the new Vector3
  76258. */
  76259. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  76260. /** @hidden */
  76261. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  76262. /**
  76263. * Unproject from screen space to object space
  76264. * @param source defines the screen space Vector3 to use
  76265. * @param viewportWidth defines the current width of the viewport
  76266. * @param viewportHeight defines the current height of the viewport
  76267. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76268. * @param transform defines the transform (view x projection) matrix to use
  76269. * @returns the new Vector3
  76270. */
  76271. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  76272. /**
  76273. * Unproject from screen space to object space
  76274. * @param source defines the screen space Vector3 to use
  76275. * @param viewportWidth defines the current width of the viewport
  76276. * @param viewportHeight defines the current height of the viewport
  76277. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76278. * @param view defines the view matrix to use
  76279. * @param projection defines the projection matrix to use
  76280. * @returns the new Vector3
  76281. */
  76282. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  76283. /**
  76284. * Unproject from screen space to object space
  76285. * @param source defines the screen space Vector3 to use
  76286. * @param viewportWidth defines the current width of the viewport
  76287. * @param viewportHeight defines the current height of the viewport
  76288. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76289. * @param view defines the view matrix to use
  76290. * @param projection defines the projection matrix to use
  76291. * @param result defines the Vector3 where to store the result
  76292. */
  76293. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76294. /**
  76295. * Unproject from screen space to object space
  76296. * @param sourceX defines the screen space x coordinate to use
  76297. * @param sourceY defines the screen space y coordinate to use
  76298. * @param sourceZ defines the screen space z coordinate to use
  76299. * @param viewportWidth defines the current width of the viewport
  76300. * @param viewportHeight defines the current height of the viewport
  76301. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  76302. * @param view defines the view matrix to use
  76303. * @param projection defines the projection matrix to use
  76304. * @param result defines the Vector3 where to store the result
  76305. */
  76306. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  76307. /**
  76308. * Gets the minimal coordinate values between two Vector3
  76309. * @param left defines the first operand
  76310. * @param right defines the second operand
  76311. * @returns the new Vector3
  76312. */
  76313. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76314. /**
  76315. * Gets the maximal coordinate values between two Vector3
  76316. * @param left defines the first operand
  76317. * @param right defines the second operand
  76318. * @returns the new Vector3
  76319. */
  76320. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  76321. /**
  76322. * Returns the distance between the vectors "value1" and "value2"
  76323. * @param value1 defines the first operand
  76324. * @param value2 defines the second operand
  76325. * @returns the distance
  76326. */
  76327. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76328. /**
  76329. * Returns the squared distance between the vectors "value1" and "value2"
  76330. * @param value1 defines the first operand
  76331. * @param value2 defines the second operand
  76332. * @returns the squared distance
  76333. */
  76334. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  76335. /**
  76336. * Returns a new Vector3 located at the center between "value1" and "value2"
  76337. * @param value1 defines the first operand
  76338. * @param value2 defines the second operand
  76339. * @returns the new Vector3
  76340. */
  76341. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  76342. /**
  76343. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  76344. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  76345. * to something in order to rotate it from its local system to the given target system
  76346. * Note: axis1, axis2 and axis3 are normalized during this operation
  76347. * @param axis1 defines the first axis
  76348. * @param axis2 defines the second axis
  76349. * @param axis3 defines the third axis
  76350. * @returns a new Vector3
  76351. */
  76352. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  76353. /**
  76354. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  76355. * @param axis1 defines the first axis
  76356. * @param axis2 defines the second axis
  76357. * @param axis3 defines the third axis
  76358. * @param ref defines the Vector3 where to store the result
  76359. */
  76360. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  76361. }
  76362. /**
  76363. * Vector4 class created for EulerAngle class conversion to Quaternion
  76364. */
  76365. export class Vector4 {
  76366. /** x value of the vector */
  76367. x: number;
  76368. /** y value of the vector */
  76369. y: number;
  76370. /** z value of the vector */
  76371. z: number;
  76372. /** w value of the vector */
  76373. w: number;
  76374. /**
  76375. * Creates a Vector4 object from the given floats.
  76376. * @param x x value of the vector
  76377. * @param y y value of the vector
  76378. * @param z z value of the vector
  76379. * @param w w value of the vector
  76380. */
  76381. constructor(
  76382. /** x value of the vector */
  76383. x: number,
  76384. /** y value of the vector */
  76385. y: number,
  76386. /** z value of the vector */
  76387. z: number,
  76388. /** w value of the vector */
  76389. w: number);
  76390. /**
  76391. * Returns the string with the Vector4 coordinates.
  76392. * @returns a string containing all the vector values
  76393. */
  76394. toString(): string;
  76395. /**
  76396. * Returns the string "Vector4".
  76397. * @returns "Vector4"
  76398. */
  76399. getClassName(): string;
  76400. /**
  76401. * Returns the Vector4 hash code.
  76402. * @returns a unique hash code
  76403. */
  76404. getHashCode(): number;
  76405. /**
  76406. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  76407. * @returns the resulting array
  76408. */
  76409. asArray(): number[];
  76410. /**
  76411. * Populates the given array from the given index with the Vector4 coordinates.
  76412. * @param array array to populate
  76413. * @param index index of the array to start at (default: 0)
  76414. * @returns the Vector4.
  76415. */
  76416. toArray(array: FloatArray, index?: number): Vector4;
  76417. /**
  76418. * Adds the given vector to the current Vector4.
  76419. * @param otherVector the vector to add
  76420. * @returns the updated Vector4.
  76421. */
  76422. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76423. /**
  76424. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  76425. * @param otherVector the vector to add
  76426. * @returns the resulting vector
  76427. */
  76428. add(otherVector: DeepImmutable<Vector4>): Vector4;
  76429. /**
  76430. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  76431. * @param otherVector the vector to add
  76432. * @param result the vector to store the result
  76433. * @returns the current Vector4.
  76434. */
  76435. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76436. /**
  76437. * Subtract in place the given vector from the current Vector4.
  76438. * @param otherVector the vector to subtract
  76439. * @returns the updated Vector4.
  76440. */
  76441. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76442. /**
  76443. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  76444. * @param otherVector the vector to add
  76445. * @returns the new vector with the result
  76446. */
  76447. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  76448. /**
  76449. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  76450. * @param otherVector the vector to subtract
  76451. * @param result the vector to store the result
  76452. * @returns the current Vector4.
  76453. */
  76454. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76455. /**
  76456. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76457. */
  76458. /**
  76459. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76460. * @param x value to subtract
  76461. * @param y value to subtract
  76462. * @param z value to subtract
  76463. * @param w value to subtract
  76464. * @returns new vector containing the result
  76465. */
  76466. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76467. /**
  76468. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  76469. * @param x value to subtract
  76470. * @param y value to subtract
  76471. * @param z value to subtract
  76472. * @param w value to subtract
  76473. * @param result the vector to store the result in
  76474. * @returns the current Vector4.
  76475. */
  76476. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  76477. /**
  76478. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  76479. * @returns a new vector with the negated values
  76480. */
  76481. negate(): Vector4;
  76482. /**
  76483. * Negate this vector in place
  76484. * @returns this
  76485. */
  76486. negateInPlace(): Vector4;
  76487. /**
  76488. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  76489. * @param result defines the Vector3 object where to store the result
  76490. * @returns the current Vector4
  76491. */
  76492. negateToRef(result: Vector4): Vector4;
  76493. /**
  76494. * Multiplies the current Vector4 coordinates by scale (float).
  76495. * @param scale the number to scale with
  76496. * @returns the updated Vector4.
  76497. */
  76498. scaleInPlace(scale: number): Vector4;
  76499. /**
  76500. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  76501. * @param scale the number to scale with
  76502. * @returns a new vector with the result
  76503. */
  76504. scale(scale: number): Vector4;
  76505. /**
  76506. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  76507. * @param scale the number to scale with
  76508. * @param result a vector to store the result in
  76509. * @returns the current Vector4.
  76510. */
  76511. scaleToRef(scale: number, result: Vector4): Vector4;
  76512. /**
  76513. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  76514. * @param scale defines the scale factor
  76515. * @param result defines the Vector4 object where to store the result
  76516. * @returns the unmodified current Vector4
  76517. */
  76518. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  76519. /**
  76520. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  76521. * @param otherVector the vector to compare against
  76522. * @returns true if they are equal
  76523. */
  76524. equals(otherVector: DeepImmutable<Vector4>): boolean;
  76525. /**
  76526. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  76527. * @param otherVector vector to compare against
  76528. * @param epsilon (Default: very small number)
  76529. * @returns true if they are equal
  76530. */
  76531. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  76532. /**
  76533. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  76534. * @param x x value to compare against
  76535. * @param y y value to compare against
  76536. * @param z z value to compare against
  76537. * @param w w value to compare against
  76538. * @returns true if equal
  76539. */
  76540. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  76541. /**
  76542. * Multiplies in place the current Vector4 by the given one.
  76543. * @param otherVector vector to multiple with
  76544. * @returns the updated Vector4.
  76545. */
  76546. multiplyInPlace(otherVector: Vector4): Vector4;
  76547. /**
  76548. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  76549. * @param otherVector vector to multiple with
  76550. * @returns resulting new vector
  76551. */
  76552. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  76553. /**
  76554. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  76555. * @param otherVector vector to multiple with
  76556. * @param result vector to store the result
  76557. * @returns the current Vector4.
  76558. */
  76559. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76560. /**
  76561. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  76562. * @param x x value multiply with
  76563. * @param y y value multiply with
  76564. * @param z z value multiply with
  76565. * @param w w value multiply with
  76566. * @returns resulting new vector
  76567. */
  76568. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  76569. /**
  76570. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  76571. * @param otherVector vector to devide with
  76572. * @returns resulting new vector
  76573. */
  76574. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  76575. /**
  76576. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  76577. * @param otherVector vector to devide with
  76578. * @param result vector to store the result
  76579. * @returns the current Vector4.
  76580. */
  76581. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  76582. /**
  76583. * Divides the current Vector3 coordinates by the given ones.
  76584. * @param otherVector vector to devide with
  76585. * @returns the updated Vector3.
  76586. */
  76587. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  76588. /**
  76589. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  76590. * @param other defines the second operand
  76591. * @returns the current updated Vector4
  76592. */
  76593. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76594. /**
  76595. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  76596. * @param other defines the second operand
  76597. * @returns the current updated Vector4
  76598. */
  76599. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  76600. /**
  76601. * Gets a new Vector4 from current Vector4 floored values
  76602. * @returns a new Vector4
  76603. */
  76604. floor(): Vector4;
  76605. /**
  76606. * Gets a new Vector4 from current Vector3 floored values
  76607. * @returns a new Vector4
  76608. */
  76609. fract(): Vector4;
  76610. /**
  76611. * Returns the Vector4 length (float).
  76612. * @returns the length
  76613. */
  76614. length(): number;
  76615. /**
  76616. * Returns the Vector4 squared length (float).
  76617. * @returns the length squared
  76618. */
  76619. lengthSquared(): number;
  76620. /**
  76621. * Normalizes in place the Vector4.
  76622. * @returns the updated Vector4.
  76623. */
  76624. normalize(): Vector4;
  76625. /**
  76626. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  76627. * @returns this converted to a new vector3
  76628. */
  76629. toVector3(): Vector3;
  76630. /**
  76631. * Returns a new Vector4 copied from the current one.
  76632. * @returns the new cloned vector
  76633. */
  76634. clone(): Vector4;
  76635. /**
  76636. * Updates the current Vector4 with the given one coordinates.
  76637. * @param source the source vector to copy from
  76638. * @returns the updated Vector4.
  76639. */
  76640. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  76641. /**
  76642. * Updates the current Vector4 coordinates with the given floats.
  76643. * @param x float to copy from
  76644. * @param y float to copy from
  76645. * @param z float to copy from
  76646. * @param w float to copy from
  76647. * @returns the updated Vector4.
  76648. */
  76649. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  76650. /**
  76651. * Updates the current Vector4 coordinates with the given floats.
  76652. * @param x float to set from
  76653. * @param y float to set from
  76654. * @param z float to set from
  76655. * @param w float to set from
  76656. * @returns the updated Vector4.
  76657. */
  76658. set(x: number, y: number, z: number, w: number): Vector4;
  76659. /**
  76660. * Copies the given float to the current Vector3 coordinates
  76661. * @param v defines the x, y, z and w coordinates of the operand
  76662. * @returns the current updated Vector3
  76663. */
  76664. setAll(v: number): Vector4;
  76665. /**
  76666. * Returns a new Vector4 set from the starting index of the given array.
  76667. * @param array the array to pull values from
  76668. * @param offset the offset into the array to start at
  76669. * @returns the new vector
  76670. */
  76671. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  76672. /**
  76673. * Updates the given vector "result" from the starting index of the given array.
  76674. * @param array the array to pull values from
  76675. * @param offset the offset into the array to start at
  76676. * @param result the vector to store the result in
  76677. */
  76678. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  76679. /**
  76680. * Updates the given vector "result" from the starting index of the given Float32Array.
  76681. * @param array the array to pull values from
  76682. * @param offset the offset into the array to start at
  76683. * @param result the vector to store the result in
  76684. */
  76685. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  76686. /**
  76687. * Updates the given vector "result" coordinates from the given floats.
  76688. * @param x float to set from
  76689. * @param y float to set from
  76690. * @param z float to set from
  76691. * @param w float to set from
  76692. * @param result the vector to the floats in
  76693. */
  76694. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  76695. /**
  76696. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  76697. * @returns the new vector
  76698. */
  76699. static Zero(): Vector4;
  76700. /**
  76701. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  76702. * @returns the new vector
  76703. */
  76704. static One(): Vector4;
  76705. /**
  76706. * Returns a new normalized Vector4 from the given one.
  76707. * @param vector the vector to normalize
  76708. * @returns the vector
  76709. */
  76710. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  76711. /**
  76712. * Updates the given vector "result" from the normalization of the given one.
  76713. * @param vector the vector to normalize
  76714. * @param result the vector to store the result in
  76715. */
  76716. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  76717. /**
  76718. * Returns a vector with the minimum values from the left and right vectors
  76719. * @param left left vector to minimize
  76720. * @param right right vector to minimize
  76721. * @returns a new vector with the minimum of the left and right vector values
  76722. */
  76723. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76724. /**
  76725. * Returns a vector with the maximum values from the left and right vectors
  76726. * @param left left vector to maximize
  76727. * @param right right vector to maximize
  76728. * @returns a new vector with the maximum of the left and right vector values
  76729. */
  76730. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  76731. /**
  76732. * Returns the distance (float) between the vectors "value1" and "value2".
  76733. * @param value1 value to calulate the distance between
  76734. * @param value2 value to calulate the distance between
  76735. * @return the distance between the two vectors
  76736. */
  76737. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76738. /**
  76739. * Returns the squared distance (float) between the vectors "value1" and "value2".
  76740. * @param value1 value to calulate the distance between
  76741. * @param value2 value to calulate the distance between
  76742. * @return the distance between the two vectors squared
  76743. */
  76744. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  76745. /**
  76746. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  76747. * @param value1 value to calulate the center between
  76748. * @param value2 value to calulate the center between
  76749. * @return the center between the two vectors
  76750. */
  76751. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  76752. /**
  76753. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  76754. * This methods computes transformed normalized direction vectors only.
  76755. * @param vector the vector to transform
  76756. * @param transformation the transformation matrix to apply
  76757. * @returns the new vector
  76758. */
  76759. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  76760. /**
  76761. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  76762. * This methods computes transformed normalized direction vectors only.
  76763. * @param vector the vector to transform
  76764. * @param transformation the transformation matrix to apply
  76765. * @param result the vector to store the result in
  76766. */
  76767. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76768. /**
  76769. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  76770. * This methods computes transformed normalized direction vectors only.
  76771. * @param x value to transform
  76772. * @param y value to transform
  76773. * @param z value to transform
  76774. * @param w value to transform
  76775. * @param transformation the transformation matrix to apply
  76776. * @param result the vector to store the results in
  76777. */
  76778. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  76779. /**
  76780. * Creates a new Vector4 from a Vector3
  76781. * @param source defines the source data
  76782. * @param w defines the 4th component (default is 0)
  76783. * @returns a new Vector4
  76784. */
  76785. static FromVector3(source: Vector3, w?: number): Vector4;
  76786. }
  76787. /**
  76788. * Class used to store quaternion data
  76789. * @see https://en.wikipedia.org/wiki/Quaternion
  76790. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  76791. */
  76792. export class Quaternion {
  76793. /** defines the first component (0 by default) */
  76794. x: number;
  76795. /** defines the second component (0 by default) */
  76796. y: number;
  76797. /** defines the third component (0 by default) */
  76798. z: number;
  76799. /** defines the fourth component (1.0 by default) */
  76800. w: number;
  76801. /**
  76802. * Creates a new Quaternion from the given floats
  76803. * @param x defines the first component (0 by default)
  76804. * @param y defines the second component (0 by default)
  76805. * @param z defines the third component (0 by default)
  76806. * @param w defines the fourth component (1.0 by default)
  76807. */
  76808. constructor(
  76809. /** defines the first component (0 by default) */
  76810. x?: number,
  76811. /** defines the second component (0 by default) */
  76812. y?: number,
  76813. /** defines the third component (0 by default) */
  76814. z?: number,
  76815. /** defines the fourth component (1.0 by default) */
  76816. w?: number);
  76817. /**
  76818. * Gets a string representation for the current quaternion
  76819. * @returns a string with the Quaternion coordinates
  76820. */
  76821. toString(): string;
  76822. /**
  76823. * Gets the class name of the quaternion
  76824. * @returns the string "Quaternion"
  76825. */
  76826. getClassName(): string;
  76827. /**
  76828. * Gets a hash code for this quaternion
  76829. * @returns the quaternion hash code
  76830. */
  76831. getHashCode(): number;
  76832. /**
  76833. * Copy the quaternion to an array
  76834. * @returns a new array populated with 4 elements from the quaternion coordinates
  76835. */
  76836. asArray(): number[];
  76837. /**
  76838. * Check if two quaternions are equals
  76839. * @param otherQuaternion defines the second operand
  76840. * @return true if the current quaternion and the given one coordinates are strictly equals
  76841. */
  76842. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  76843. /**
  76844. * Gets a boolean if two quaternions are equals (using an epsilon value)
  76845. * @param otherQuaternion defines the other quaternion
  76846. * @param epsilon defines the minimal distance to consider equality
  76847. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  76848. */
  76849. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  76850. /**
  76851. * Clone the current quaternion
  76852. * @returns a new quaternion copied from the current one
  76853. */
  76854. clone(): Quaternion;
  76855. /**
  76856. * Copy a quaternion to the current one
  76857. * @param other defines the other quaternion
  76858. * @returns the updated current quaternion
  76859. */
  76860. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  76861. /**
  76862. * Updates the current quaternion with the given float coordinates
  76863. * @param x defines the x coordinate
  76864. * @param y defines the y coordinate
  76865. * @param z defines the z coordinate
  76866. * @param w defines the w coordinate
  76867. * @returns the updated current quaternion
  76868. */
  76869. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  76870. /**
  76871. * Updates the current quaternion from the given float coordinates
  76872. * @param x defines the x coordinate
  76873. * @param y defines the y coordinate
  76874. * @param z defines the z coordinate
  76875. * @param w defines the w coordinate
  76876. * @returns the updated current quaternion
  76877. */
  76878. set(x: number, y: number, z: number, w: number): Quaternion;
  76879. /**
  76880. * Adds two quaternions
  76881. * @param other defines the second operand
  76882. * @returns a new quaternion as the addition result of the given one and the current quaternion
  76883. */
  76884. add(other: DeepImmutable<Quaternion>): Quaternion;
  76885. /**
  76886. * Add a quaternion to the current one
  76887. * @param other defines the quaternion to add
  76888. * @returns the current quaternion
  76889. */
  76890. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  76891. /**
  76892. * Subtract two quaternions
  76893. * @param other defines the second operand
  76894. * @returns a new quaternion as the subtraction result of the given one from the current one
  76895. */
  76896. subtract(other: Quaternion): Quaternion;
  76897. /**
  76898. * Multiplies the current quaternion by a scale factor
  76899. * @param value defines the scale factor
  76900. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  76901. */
  76902. scale(value: number): Quaternion;
  76903. /**
  76904. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  76905. * @param scale defines the scale factor
  76906. * @param result defines the Quaternion object where to store the result
  76907. * @returns the unmodified current quaternion
  76908. */
  76909. scaleToRef(scale: number, result: Quaternion): Quaternion;
  76910. /**
  76911. * Multiplies in place the current quaternion by a scale factor
  76912. * @param value defines the scale factor
  76913. * @returns the current modified quaternion
  76914. */
  76915. scaleInPlace(value: number): Quaternion;
  76916. /**
  76917. * Scale the current quaternion values by a factor and add the result to a given quaternion
  76918. * @param scale defines the scale factor
  76919. * @param result defines the Quaternion object where to store the result
  76920. * @returns the unmodified current quaternion
  76921. */
  76922. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  76923. /**
  76924. * Multiplies two quaternions
  76925. * @param q1 defines the second operand
  76926. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  76927. */
  76928. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  76929. /**
  76930. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  76931. * @param q1 defines the second operand
  76932. * @param result defines the target quaternion
  76933. * @returns the current quaternion
  76934. */
  76935. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  76936. /**
  76937. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  76938. * @param q1 defines the second operand
  76939. * @returns the currentupdated quaternion
  76940. */
  76941. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  76942. /**
  76943. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  76944. * @param ref defines the target quaternion
  76945. * @returns the current quaternion
  76946. */
  76947. conjugateToRef(ref: Quaternion): Quaternion;
  76948. /**
  76949. * Conjugates in place (1-q) the current quaternion
  76950. * @returns the current updated quaternion
  76951. */
  76952. conjugateInPlace(): Quaternion;
  76953. /**
  76954. * Conjugates in place (1-q) the current quaternion
  76955. * @returns a new quaternion
  76956. */
  76957. conjugate(): Quaternion;
  76958. /**
  76959. * Gets length of current quaternion
  76960. * @returns the quaternion length (float)
  76961. */
  76962. length(): number;
  76963. /**
  76964. * Normalize in place the current quaternion
  76965. * @returns the current updated quaternion
  76966. */
  76967. normalize(): Quaternion;
  76968. /**
  76969. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  76970. * @param order is a reserved parameter and is ignore for now
  76971. * @returns a new Vector3 containing the Euler angles
  76972. */
  76973. toEulerAngles(order?: string): Vector3;
  76974. /**
  76975. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  76976. * @param result defines the vector which will be filled with the Euler angles
  76977. * @param order is a reserved parameter and is ignore for now
  76978. * @returns the current unchanged quaternion
  76979. */
  76980. toEulerAnglesToRef(result: Vector3): Quaternion;
  76981. /**
  76982. * Updates the given rotation matrix with the current quaternion values
  76983. * @param result defines the target matrix
  76984. * @returns the current unchanged quaternion
  76985. */
  76986. toRotationMatrix(result: Matrix): Quaternion;
  76987. /**
  76988. * Updates the current quaternion from the given rotation matrix values
  76989. * @param matrix defines the source matrix
  76990. * @returns the current updated quaternion
  76991. */
  76992. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76993. /**
  76994. * Creates a new quaternion from a rotation matrix
  76995. * @param matrix defines the source matrix
  76996. * @returns a new quaternion created from the given rotation matrix values
  76997. */
  76998. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  76999. /**
  77000. * Updates the given quaternion with the given rotation matrix values
  77001. * @param matrix defines the source matrix
  77002. * @param result defines the target quaternion
  77003. */
  77004. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  77005. /**
  77006. * Returns the dot product (float) between the quaternions "left" and "right"
  77007. * @param left defines the left operand
  77008. * @param right defines the right operand
  77009. * @returns the dot product
  77010. */
  77011. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  77012. /**
  77013. * Checks if the two quaternions are close to each other
  77014. * @param quat0 defines the first quaternion to check
  77015. * @param quat1 defines the second quaternion to check
  77016. * @returns true if the two quaternions are close to each other
  77017. */
  77018. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  77019. /**
  77020. * Creates an empty quaternion
  77021. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  77022. */
  77023. static Zero(): Quaternion;
  77024. /**
  77025. * Inverse a given quaternion
  77026. * @param q defines the source quaternion
  77027. * @returns a new quaternion as the inverted current quaternion
  77028. */
  77029. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  77030. /**
  77031. * Inverse a given quaternion
  77032. * @param q defines the source quaternion
  77033. * @param result the quaternion the result will be stored in
  77034. * @returns the result quaternion
  77035. */
  77036. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  77037. /**
  77038. * Creates an identity quaternion
  77039. * @returns the identity quaternion
  77040. */
  77041. static Identity(): Quaternion;
  77042. /**
  77043. * Gets a boolean indicating if the given quaternion is identity
  77044. * @param quaternion defines the quaternion to check
  77045. * @returns true if the quaternion is identity
  77046. */
  77047. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  77048. /**
  77049. * Creates a quaternion from a rotation around an axis
  77050. * @param axis defines the axis to use
  77051. * @param angle defines the angle to use
  77052. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  77053. */
  77054. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  77055. /**
  77056. * Creates a rotation around an axis and stores it into the given quaternion
  77057. * @param axis defines the axis to use
  77058. * @param angle defines the angle to use
  77059. * @param result defines the target quaternion
  77060. * @returns the target quaternion
  77061. */
  77062. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  77063. /**
  77064. * Creates a new quaternion from data stored into an array
  77065. * @param array defines the data source
  77066. * @param offset defines the offset in the source array where the data starts
  77067. * @returns a new quaternion
  77068. */
  77069. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  77070. /**
  77071. * Create a quaternion from Euler rotation angles
  77072. * @param x Pitch
  77073. * @param y Yaw
  77074. * @param z Roll
  77075. * @returns the new Quaternion
  77076. */
  77077. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  77078. /**
  77079. * Updates a quaternion from Euler rotation angles
  77080. * @param x Pitch
  77081. * @param y Yaw
  77082. * @param z Roll
  77083. * @param result the quaternion to store the result
  77084. * @returns the updated quaternion
  77085. */
  77086. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  77087. /**
  77088. * Create a quaternion from Euler rotation vector
  77089. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77090. * @returns the new Quaternion
  77091. */
  77092. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  77093. /**
  77094. * Updates a quaternion from Euler rotation vector
  77095. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  77096. * @param result the quaternion to store the result
  77097. * @returns the updated quaternion
  77098. */
  77099. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  77100. /**
  77101. * Creates a new quaternion from the given Euler float angles (y, x, z)
  77102. * @param yaw defines the rotation around Y axis
  77103. * @param pitch defines the rotation around X axis
  77104. * @param roll defines the rotation around Z axis
  77105. * @returns the new quaternion
  77106. */
  77107. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  77108. /**
  77109. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  77110. * @param yaw defines the rotation around Y axis
  77111. * @param pitch defines the rotation around X axis
  77112. * @param roll defines the rotation around Z axis
  77113. * @param result defines the target quaternion
  77114. */
  77115. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  77116. /**
  77117. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  77118. * @param alpha defines the rotation around first axis
  77119. * @param beta defines the rotation around second axis
  77120. * @param gamma defines the rotation around third axis
  77121. * @returns the new quaternion
  77122. */
  77123. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  77124. /**
  77125. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  77126. * @param alpha defines the rotation around first axis
  77127. * @param beta defines the rotation around second axis
  77128. * @param gamma defines the rotation around third axis
  77129. * @param result defines the target quaternion
  77130. */
  77131. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  77132. /**
  77133. * 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)
  77134. * @param axis1 defines the first axis
  77135. * @param axis2 defines the second axis
  77136. * @param axis3 defines the third axis
  77137. * @returns the new quaternion
  77138. */
  77139. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  77140. /**
  77141. * 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
  77142. * @param axis1 defines the first axis
  77143. * @param axis2 defines the second axis
  77144. * @param axis3 defines the third axis
  77145. * @param ref defines the target quaternion
  77146. */
  77147. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  77148. /**
  77149. * Interpolates between two quaternions
  77150. * @param left defines first quaternion
  77151. * @param right defines second quaternion
  77152. * @param amount defines the gradient to use
  77153. * @returns the new interpolated quaternion
  77154. */
  77155. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77156. /**
  77157. * Interpolates between two quaternions and stores it into a target quaternion
  77158. * @param left defines first quaternion
  77159. * @param right defines second quaternion
  77160. * @param amount defines the gradient to use
  77161. * @param result defines the target quaternion
  77162. */
  77163. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  77164. /**
  77165. * Interpolate between two quaternions using Hermite interpolation
  77166. * @param value1 defines first quaternion
  77167. * @param tangent1 defines the incoming tangent
  77168. * @param value2 defines second quaternion
  77169. * @param tangent2 defines the outgoing tangent
  77170. * @param amount defines the target quaternion
  77171. * @returns the new interpolated quaternion
  77172. */
  77173. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  77174. }
  77175. /**
  77176. * Class used to store matrix data (4x4)
  77177. */
  77178. export class Matrix {
  77179. private static _updateFlagSeed;
  77180. private static _identityReadOnly;
  77181. private _isIdentity;
  77182. private _isIdentityDirty;
  77183. private _isIdentity3x2;
  77184. private _isIdentity3x2Dirty;
  77185. /**
  77186. * Gets the update flag of the matrix which is an unique number for the matrix.
  77187. * It will be incremented every time the matrix data change.
  77188. * You can use it to speed the comparison between two versions of the same matrix.
  77189. */
  77190. updateFlag: number;
  77191. private readonly _m;
  77192. /**
  77193. * Gets the internal data of the matrix
  77194. */
  77195. get m(): DeepImmutable<Float32Array>;
  77196. /** @hidden */
  77197. _markAsUpdated(): void;
  77198. /** @hidden */
  77199. private _updateIdentityStatus;
  77200. /**
  77201. * Creates an empty matrix (filled with zeros)
  77202. */
  77203. constructor();
  77204. /**
  77205. * Check if the current matrix is identity
  77206. * @returns true is the matrix is the identity matrix
  77207. */
  77208. isIdentity(): boolean;
  77209. /**
  77210. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  77211. * @returns true is the matrix is the identity matrix
  77212. */
  77213. isIdentityAs3x2(): boolean;
  77214. /**
  77215. * Gets the determinant of the matrix
  77216. * @returns the matrix determinant
  77217. */
  77218. determinant(): number;
  77219. /**
  77220. * Returns the matrix as a Float32Array
  77221. * @returns the matrix underlying array
  77222. */
  77223. toArray(): DeepImmutable<Float32Array>;
  77224. /**
  77225. * Returns the matrix as a Float32Array
  77226. * @returns the matrix underlying array.
  77227. */
  77228. asArray(): DeepImmutable<Float32Array>;
  77229. /**
  77230. * Inverts the current matrix in place
  77231. * @returns the current inverted matrix
  77232. */
  77233. invert(): Matrix;
  77234. /**
  77235. * Sets all the matrix elements to zero
  77236. * @returns the current matrix
  77237. */
  77238. reset(): Matrix;
  77239. /**
  77240. * Adds the current matrix with a second one
  77241. * @param other defines the matrix to add
  77242. * @returns a new matrix as the addition of the current matrix and the given one
  77243. */
  77244. add(other: DeepImmutable<Matrix>): Matrix;
  77245. /**
  77246. * Sets the given matrix "result" to the addition of the current matrix and the given one
  77247. * @param other defines the matrix to add
  77248. * @param result defines the target matrix
  77249. * @returns the current matrix
  77250. */
  77251. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77252. /**
  77253. * Adds in place the given matrix to the current matrix
  77254. * @param other defines the second operand
  77255. * @returns the current updated matrix
  77256. */
  77257. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  77258. /**
  77259. * Sets the given matrix to the current inverted Matrix
  77260. * @param other defines the target matrix
  77261. * @returns the unmodified current matrix
  77262. */
  77263. invertToRef(other: Matrix): Matrix;
  77264. /**
  77265. * add a value at the specified position in the current Matrix
  77266. * @param index the index of the value within the matrix. between 0 and 15.
  77267. * @param value the value to be added
  77268. * @returns the current updated matrix
  77269. */
  77270. addAtIndex(index: number, value: number): Matrix;
  77271. /**
  77272. * mutiply the specified position in the current Matrix by a value
  77273. * @param index the index of the value within the matrix. between 0 and 15.
  77274. * @param value the value to be added
  77275. * @returns the current updated matrix
  77276. */
  77277. multiplyAtIndex(index: number, value: number): Matrix;
  77278. /**
  77279. * Inserts the translation vector (using 3 floats) in the current matrix
  77280. * @param x defines the 1st component of the translation
  77281. * @param y defines the 2nd component of the translation
  77282. * @param z defines the 3rd component of the translation
  77283. * @returns the current updated matrix
  77284. */
  77285. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77286. /**
  77287. * Adds the translation vector (using 3 floats) in the current matrix
  77288. * @param x defines the 1st component of the translation
  77289. * @param y defines the 2nd component of the translation
  77290. * @param z defines the 3rd component of the translation
  77291. * @returns the current updated matrix
  77292. */
  77293. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  77294. /**
  77295. * Inserts the translation vector in the current matrix
  77296. * @param vector3 defines the translation to insert
  77297. * @returns the current updated matrix
  77298. */
  77299. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  77300. /**
  77301. * Gets the translation value of the current matrix
  77302. * @returns a new Vector3 as the extracted translation from the matrix
  77303. */
  77304. getTranslation(): Vector3;
  77305. /**
  77306. * Fill a Vector3 with the extracted translation from the matrix
  77307. * @param result defines the Vector3 where to store the translation
  77308. * @returns the current matrix
  77309. */
  77310. getTranslationToRef(result: Vector3): Matrix;
  77311. /**
  77312. * Remove rotation and scaling part from the matrix
  77313. * @returns the updated matrix
  77314. */
  77315. removeRotationAndScaling(): Matrix;
  77316. /**
  77317. * Multiply two matrices
  77318. * @param other defines the second operand
  77319. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  77320. */
  77321. multiply(other: DeepImmutable<Matrix>): Matrix;
  77322. /**
  77323. * Copy the current matrix from the given one
  77324. * @param other defines the source matrix
  77325. * @returns the current updated matrix
  77326. */
  77327. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  77328. /**
  77329. * Populates the given array from the starting index with the current matrix values
  77330. * @param array defines the target array
  77331. * @param offset defines the offset in the target array where to start storing values
  77332. * @returns the current matrix
  77333. */
  77334. copyToArray(array: Float32Array, offset?: number): Matrix;
  77335. /**
  77336. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  77337. * @param other defines the second operand
  77338. * @param result defines the matrix where to store the multiplication
  77339. * @returns the current matrix
  77340. */
  77341. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  77342. /**
  77343. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  77344. * @param other defines the second operand
  77345. * @param result defines the array where to store the multiplication
  77346. * @param offset defines the offset in the target array where to start storing values
  77347. * @returns the current matrix
  77348. */
  77349. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  77350. /**
  77351. * Check equality between this matrix and a second one
  77352. * @param value defines the second matrix to compare
  77353. * @returns true is the current matrix and the given one values are strictly equal
  77354. */
  77355. equals(value: DeepImmutable<Matrix>): boolean;
  77356. /**
  77357. * Clone the current matrix
  77358. * @returns a new matrix from the current matrix
  77359. */
  77360. clone(): Matrix;
  77361. /**
  77362. * Returns the name of the current matrix class
  77363. * @returns the string "Matrix"
  77364. */
  77365. getClassName(): string;
  77366. /**
  77367. * Gets the hash code of the current matrix
  77368. * @returns the hash code
  77369. */
  77370. getHashCode(): number;
  77371. /**
  77372. * Decomposes the current Matrix into a translation, rotation and scaling components
  77373. * @param scale defines the scale vector3 given as a reference to update
  77374. * @param rotation defines the rotation quaternion given as a reference to update
  77375. * @param translation defines the translation vector3 given as a reference to update
  77376. * @returns true if operation was successful
  77377. */
  77378. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  77379. /**
  77380. * Gets specific row of the matrix
  77381. * @param index defines the number of the row to get
  77382. * @returns the index-th row of the current matrix as a new Vector4
  77383. */
  77384. getRow(index: number): Nullable<Vector4>;
  77385. /**
  77386. * Sets the index-th row of the current matrix to the vector4 values
  77387. * @param index defines the number of the row to set
  77388. * @param row defines the target vector4
  77389. * @returns the updated current matrix
  77390. */
  77391. setRow(index: number, row: Vector4): Matrix;
  77392. /**
  77393. * Compute the transpose of the matrix
  77394. * @returns the new transposed matrix
  77395. */
  77396. transpose(): Matrix;
  77397. /**
  77398. * Compute the transpose of the matrix and store it in a given matrix
  77399. * @param result defines the target matrix
  77400. * @returns the current matrix
  77401. */
  77402. transposeToRef(result: Matrix): Matrix;
  77403. /**
  77404. * Sets the index-th row of the current matrix with the given 4 x float values
  77405. * @param index defines the row index
  77406. * @param x defines the x component to set
  77407. * @param y defines the y component to set
  77408. * @param z defines the z component to set
  77409. * @param w defines the w component to set
  77410. * @returns the updated current matrix
  77411. */
  77412. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  77413. /**
  77414. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  77415. * @param scale defines the scale factor
  77416. * @returns a new matrix
  77417. */
  77418. scale(scale: number): Matrix;
  77419. /**
  77420. * Scale the current matrix values by a factor to a given result matrix
  77421. * @param scale defines the scale factor
  77422. * @param result defines the matrix to store the result
  77423. * @returns the current matrix
  77424. */
  77425. scaleToRef(scale: number, result: Matrix): Matrix;
  77426. /**
  77427. * Scale the current matrix values by a factor and add the result to a given matrix
  77428. * @param scale defines the scale factor
  77429. * @param result defines the Matrix to store the result
  77430. * @returns the current matrix
  77431. */
  77432. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  77433. /**
  77434. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  77435. * @param ref matrix to store the result
  77436. */
  77437. toNormalMatrix(ref: Matrix): void;
  77438. /**
  77439. * Gets only rotation part of the current matrix
  77440. * @returns a new matrix sets to the extracted rotation matrix from the current one
  77441. */
  77442. getRotationMatrix(): Matrix;
  77443. /**
  77444. * Extracts the rotation matrix from the current one and sets it as the given "result"
  77445. * @param result defines the target matrix to store data to
  77446. * @returns the current matrix
  77447. */
  77448. getRotationMatrixToRef(result: Matrix): Matrix;
  77449. /**
  77450. * Toggles model matrix from being right handed to left handed in place and vice versa
  77451. */
  77452. toggleModelMatrixHandInPlace(): void;
  77453. /**
  77454. * Toggles projection matrix from being right handed to left handed in place and vice versa
  77455. */
  77456. toggleProjectionMatrixHandInPlace(): void;
  77457. /**
  77458. * Creates a matrix from an array
  77459. * @param array defines the source array
  77460. * @param offset defines an offset in the source array
  77461. * @returns a new Matrix set from the starting index of the given array
  77462. */
  77463. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  77464. /**
  77465. * Copy the content of an array into a given matrix
  77466. * @param array defines the source array
  77467. * @param offset defines an offset in the source array
  77468. * @param result defines the target matrix
  77469. */
  77470. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  77471. /**
  77472. * Stores an array into a matrix after having multiplied each component by a given factor
  77473. * @param array defines the source array
  77474. * @param offset defines the offset in the source array
  77475. * @param scale defines the scaling factor
  77476. * @param result defines the target matrix
  77477. */
  77478. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  77479. /**
  77480. * Gets an identity matrix that must not be updated
  77481. */
  77482. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  77483. /**
  77484. * Stores a list of values (16) inside a given matrix
  77485. * @param initialM11 defines 1st value of 1st row
  77486. * @param initialM12 defines 2nd value of 1st row
  77487. * @param initialM13 defines 3rd value of 1st row
  77488. * @param initialM14 defines 4th value of 1st row
  77489. * @param initialM21 defines 1st value of 2nd row
  77490. * @param initialM22 defines 2nd value of 2nd row
  77491. * @param initialM23 defines 3rd value of 2nd row
  77492. * @param initialM24 defines 4th value of 2nd row
  77493. * @param initialM31 defines 1st value of 3rd row
  77494. * @param initialM32 defines 2nd value of 3rd row
  77495. * @param initialM33 defines 3rd value of 3rd row
  77496. * @param initialM34 defines 4th value of 3rd row
  77497. * @param initialM41 defines 1st value of 4th row
  77498. * @param initialM42 defines 2nd value of 4th row
  77499. * @param initialM43 defines 3rd value of 4th row
  77500. * @param initialM44 defines 4th value of 4th row
  77501. * @param result defines the target matrix
  77502. */
  77503. 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;
  77504. /**
  77505. * Creates new matrix from a list of values (16)
  77506. * @param initialM11 defines 1st value of 1st row
  77507. * @param initialM12 defines 2nd value of 1st row
  77508. * @param initialM13 defines 3rd value of 1st row
  77509. * @param initialM14 defines 4th value of 1st row
  77510. * @param initialM21 defines 1st value of 2nd row
  77511. * @param initialM22 defines 2nd value of 2nd row
  77512. * @param initialM23 defines 3rd value of 2nd row
  77513. * @param initialM24 defines 4th value of 2nd row
  77514. * @param initialM31 defines 1st value of 3rd row
  77515. * @param initialM32 defines 2nd value of 3rd row
  77516. * @param initialM33 defines 3rd value of 3rd row
  77517. * @param initialM34 defines 4th value of 3rd row
  77518. * @param initialM41 defines 1st value of 4th row
  77519. * @param initialM42 defines 2nd value of 4th row
  77520. * @param initialM43 defines 3rd value of 4th row
  77521. * @param initialM44 defines 4th value of 4th row
  77522. * @returns the new matrix
  77523. */
  77524. 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;
  77525. /**
  77526. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77527. * @param scale defines the scale vector3
  77528. * @param rotation defines the rotation quaternion
  77529. * @param translation defines the translation vector3
  77530. * @returns a new matrix
  77531. */
  77532. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  77533. /**
  77534. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  77535. * @param scale defines the scale vector3
  77536. * @param rotation defines the rotation quaternion
  77537. * @param translation defines the translation vector3
  77538. * @param result defines the target matrix
  77539. */
  77540. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  77541. /**
  77542. * Creates a new identity matrix
  77543. * @returns a new identity matrix
  77544. */
  77545. static Identity(): Matrix;
  77546. /**
  77547. * Creates a new identity matrix and stores the result in a given matrix
  77548. * @param result defines the target matrix
  77549. */
  77550. static IdentityToRef(result: Matrix): void;
  77551. /**
  77552. * Creates a new zero matrix
  77553. * @returns a new zero matrix
  77554. */
  77555. static Zero(): Matrix;
  77556. /**
  77557. * Creates a new rotation matrix for "angle" radians around the X axis
  77558. * @param angle defines the angle (in radians) to use
  77559. * @return the new matrix
  77560. */
  77561. static RotationX(angle: number): Matrix;
  77562. /**
  77563. * Creates a new matrix as the invert of a given matrix
  77564. * @param source defines the source matrix
  77565. * @returns the new matrix
  77566. */
  77567. static Invert(source: DeepImmutable<Matrix>): Matrix;
  77568. /**
  77569. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  77570. * @param angle defines the angle (in radians) to use
  77571. * @param result defines the target matrix
  77572. */
  77573. static RotationXToRef(angle: number, result: Matrix): void;
  77574. /**
  77575. * Creates a new rotation matrix for "angle" radians around the Y axis
  77576. * @param angle defines the angle (in radians) to use
  77577. * @return the new matrix
  77578. */
  77579. static RotationY(angle: number): Matrix;
  77580. /**
  77581. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  77582. * @param angle defines the angle (in radians) to use
  77583. * @param result defines the target matrix
  77584. */
  77585. static RotationYToRef(angle: number, result: Matrix): void;
  77586. /**
  77587. * Creates a new rotation matrix for "angle" radians around the Z axis
  77588. * @param angle defines the angle (in radians) to use
  77589. * @return the new matrix
  77590. */
  77591. static RotationZ(angle: number): Matrix;
  77592. /**
  77593. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  77594. * @param angle defines the angle (in radians) to use
  77595. * @param result defines the target matrix
  77596. */
  77597. static RotationZToRef(angle: number, result: Matrix): void;
  77598. /**
  77599. * Creates a new rotation matrix for "angle" radians around the given axis
  77600. * @param axis defines the axis to use
  77601. * @param angle defines the angle (in radians) to use
  77602. * @return the new matrix
  77603. */
  77604. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  77605. /**
  77606. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  77607. * @param axis defines the axis to use
  77608. * @param angle defines the angle (in radians) to use
  77609. * @param result defines the target matrix
  77610. */
  77611. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  77612. /**
  77613. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  77614. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  77615. * @param from defines the vector to align
  77616. * @param to defines the vector to align to
  77617. * @param result defines the target matrix
  77618. */
  77619. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  77620. /**
  77621. * Creates a rotation matrix
  77622. * @param yaw defines the yaw angle in radians (Y axis)
  77623. * @param pitch defines the pitch angle in radians (X axis)
  77624. * @param roll defines the roll angle in radians (X axis)
  77625. * @returns the new rotation matrix
  77626. */
  77627. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  77628. /**
  77629. * Creates a rotation matrix and stores it in a given matrix
  77630. * @param yaw defines the yaw angle in radians (Y axis)
  77631. * @param pitch defines the pitch angle in radians (X axis)
  77632. * @param roll defines the roll angle in radians (X axis)
  77633. * @param result defines the target matrix
  77634. */
  77635. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  77636. /**
  77637. * Creates a scaling matrix
  77638. * @param x defines the scale factor on X axis
  77639. * @param y defines the scale factor on Y axis
  77640. * @param z defines the scale factor on Z axis
  77641. * @returns the new matrix
  77642. */
  77643. static Scaling(x: number, y: number, z: number): Matrix;
  77644. /**
  77645. * Creates a scaling matrix and stores it in a given matrix
  77646. * @param x defines the scale factor on X axis
  77647. * @param y defines the scale factor on Y axis
  77648. * @param z defines the scale factor on Z axis
  77649. * @param result defines the target matrix
  77650. */
  77651. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  77652. /**
  77653. * Creates a translation matrix
  77654. * @param x defines the translation on X axis
  77655. * @param y defines the translation on Y axis
  77656. * @param z defines the translationon Z axis
  77657. * @returns the new matrix
  77658. */
  77659. static Translation(x: number, y: number, z: number): Matrix;
  77660. /**
  77661. * Creates a translation matrix and stores it in a given matrix
  77662. * @param x defines the translation on X axis
  77663. * @param y defines the translation on Y axis
  77664. * @param z defines the translationon Z axis
  77665. * @param result defines the target matrix
  77666. */
  77667. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  77668. /**
  77669. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77670. * @param startValue defines the start value
  77671. * @param endValue defines the end value
  77672. * @param gradient defines the gradient factor
  77673. * @returns the new matrix
  77674. */
  77675. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77676. /**
  77677. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  77678. * @param startValue defines the start value
  77679. * @param endValue defines the end value
  77680. * @param gradient defines the gradient factor
  77681. * @param result defines the Matrix object where to store data
  77682. */
  77683. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77684. /**
  77685. * Builds a new matrix whose values are computed by:
  77686. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77687. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77688. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77689. * @param startValue defines the first matrix
  77690. * @param endValue defines the second matrix
  77691. * @param gradient defines the gradient between the two matrices
  77692. * @returns the new matrix
  77693. */
  77694. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  77695. /**
  77696. * Update a matrix to values which are computed by:
  77697. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  77698. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  77699. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  77700. * @param startValue defines the first matrix
  77701. * @param endValue defines the second matrix
  77702. * @param gradient defines the gradient between the two matrices
  77703. * @param result defines the target matrix
  77704. */
  77705. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  77706. /**
  77707. * 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"
  77708. * This function works in left handed mode
  77709. * @param eye defines the final position of the entity
  77710. * @param target defines where the entity should look at
  77711. * @param up defines the up vector for the entity
  77712. * @returns the new matrix
  77713. */
  77714. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77715. /**
  77716. * 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".
  77717. * This function works in left handed mode
  77718. * @param eye defines the final position of the entity
  77719. * @param target defines where the entity should look at
  77720. * @param up defines the up vector for the entity
  77721. * @param result defines the target matrix
  77722. */
  77723. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77724. /**
  77725. * 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"
  77726. * This function works in right handed mode
  77727. * @param eye defines the final position of the entity
  77728. * @param target defines where the entity should look at
  77729. * @param up defines the up vector for the entity
  77730. * @returns the new matrix
  77731. */
  77732. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  77733. /**
  77734. * 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".
  77735. * This function works in right handed mode
  77736. * @param eye defines the final position of the entity
  77737. * @param target defines where the entity should look at
  77738. * @param up defines the up vector for the entity
  77739. * @param result defines the target matrix
  77740. */
  77741. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  77742. /**
  77743. * Create a left-handed orthographic projection matrix
  77744. * @param width defines the viewport width
  77745. * @param height defines the viewport height
  77746. * @param znear defines the near clip plane
  77747. * @param zfar defines the far clip plane
  77748. * @returns a new matrix as a left-handed orthographic projection matrix
  77749. */
  77750. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77751. /**
  77752. * Store a left-handed orthographic projection to a given matrix
  77753. * @param width defines the viewport width
  77754. * @param height defines the viewport height
  77755. * @param znear defines the near clip plane
  77756. * @param zfar defines the far clip plane
  77757. * @param result defines the target matrix
  77758. */
  77759. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  77760. /**
  77761. * Create a left-handed orthographic projection matrix
  77762. * @param left defines the viewport left coordinate
  77763. * @param right defines the viewport right coordinate
  77764. * @param bottom defines the viewport bottom coordinate
  77765. * @param top defines the viewport top coordinate
  77766. * @param znear defines the near clip plane
  77767. * @param zfar defines the far clip plane
  77768. * @returns a new matrix as a left-handed orthographic projection matrix
  77769. */
  77770. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77771. /**
  77772. * Stores a left-handed orthographic projection into a given matrix
  77773. * @param left defines the viewport left coordinate
  77774. * @param right defines the viewport right coordinate
  77775. * @param bottom defines the viewport bottom coordinate
  77776. * @param top defines the viewport top coordinate
  77777. * @param znear defines the near clip plane
  77778. * @param zfar defines the far clip plane
  77779. * @param result defines the target matrix
  77780. */
  77781. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77782. /**
  77783. * Creates a right-handed orthographic projection matrix
  77784. * @param left defines the viewport left coordinate
  77785. * @param right defines the viewport right coordinate
  77786. * @param bottom defines the viewport bottom coordinate
  77787. * @param top defines the viewport top coordinate
  77788. * @param znear defines the near clip plane
  77789. * @param zfar defines the far clip plane
  77790. * @returns a new matrix as a right-handed orthographic projection matrix
  77791. */
  77792. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  77793. /**
  77794. * Stores a right-handed orthographic projection into a given matrix
  77795. * @param left defines the viewport left coordinate
  77796. * @param right defines the viewport right coordinate
  77797. * @param bottom defines the viewport bottom coordinate
  77798. * @param top defines the viewport top coordinate
  77799. * @param znear defines the near clip plane
  77800. * @param zfar defines the far clip plane
  77801. * @param result defines the target matrix
  77802. */
  77803. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  77804. /**
  77805. * Creates a left-handed perspective projection matrix
  77806. * @param width defines the viewport width
  77807. * @param height defines the viewport height
  77808. * @param znear defines the near clip plane
  77809. * @param zfar defines the far clip plane
  77810. * @returns a new matrix as a left-handed perspective projection matrix
  77811. */
  77812. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  77813. /**
  77814. * Creates a left-handed perspective projection matrix
  77815. * @param fov defines the horizontal field of view
  77816. * @param aspect defines the aspect ratio
  77817. * @param znear defines the near clip plane
  77818. * @param zfar defines the far clip plane
  77819. * @returns a new matrix as a left-handed perspective projection matrix
  77820. */
  77821. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77822. /**
  77823. * Stores a left-handed perspective projection into a given matrix
  77824. * @param fov defines the horizontal field of view
  77825. * @param aspect defines the aspect ratio
  77826. * @param znear defines the near clip plane
  77827. * @param zfar defines the far clip plane
  77828. * @param result defines the target matrix
  77829. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77830. */
  77831. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77832. /**
  77833. * Stores a left-handed perspective projection into a given matrix with depth reversed
  77834. * @param fov defines the horizontal field of view
  77835. * @param aspect defines the aspect ratio
  77836. * @param znear defines the near clip plane
  77837. * @param zfar not used as infinity is used as far clip
  77838. * @param result defines the target matrix
  77839. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77840. */
  77841. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77842. /**
  77843. * Creates a right-handed perspective projection matrix
  77844. * @param fov defines the horizontal field of view
  77845. * @param aspect defines the aspect ratio
  77846. * @param znear defines the near clip plane
  77847. * @param zfar defines the far clip plane
  77848. * @returns a new matrix as a right-handed perspective projection matrix
  77849. */
  77850. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  77851. /**
  77852. * Stores a right-handed perspective projection into a given matrix
  77853. * @param fov defines the horizontal field of view
  77854. * @param aspect defines the aspect ratio
  77855. * @param znear defines the near clip plane
  77856. * @param zfar defines the far clip plane
  77857. * @param result defines the target matrix
  77858. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77859. */
  77860. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77861. /**
  77862. * Stores a right-handed perspective projection into a given matrix
  77863. * @param fov defines the horizontal field of view
  77864. * @param aspect defines the aspect ratio
  77865. * @param znear defines the near clip plane
  77866. * @param zfar not used as infinity is used as far clip
  77867. * @param result defines the target matrix
  77868. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  77869. */
  77870. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  77871. /**
  77872. * Stores a perspective projection for WebVR info a given matrix
  77873. * @param fov defines the field of view
  77874. * @param znear defines the near clip plane
  77875. * @param zfar defines the far clip plane
  77876. * @param result defines the target matrix
  77877. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  77878. */
  77879. static PerspectiveFovWebVRToRef(fov: {
  77880. upDegrees: number;
  77881. downDegrees: number;
  77882. leftDegrees: number;
  77883. rightDegrees: number;
  77884. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  77885. /**
  77886. * Computes a complete transformation matrix
  77887. * @param viewport defines the viewport to use
  77888. * @param world defines the world matrix
  77889. * @param view defines the view matrix
  77890. * @param projection defines the projection matrix
  77891. * @param zmin defines the near clip plane
  77892. * @param zmax defines the far clip plane
  77893. * @returns the transformation matrix
  77894. */
  77895. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  77896. /**
  77897. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  77898. * @param matrix defines the matrix to use
  77899. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  77900. */
  77901. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  77902. /**
  77903. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  77904. * @param matrix defines the matrix to use
  77905. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  77906. */
  77907. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  77908. /**
  77909. * Compute the transpose of a given matrix
  77910. * @param matrix defines the matrix to transpose
  77911. * @returns the new matrix
  77912. */
  77913. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  77914. /**
  77915. * Compute the transpose of a matrix and store it in a target matrix
  77916. * @param matrix defines the matrix to transpose
  77917. * @param result defines the target matrix
  77918. */
  77919. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  77920. /**
  77921. * Computes a reflection matrix from a plane
  77922. * @param plane defines the reflection plane
  77923. * @returns a new matrix
  77924. */
  77925. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  77926. /**
  77927. * Computes a reflection matrix from a plane
  77928. * @param plane defines the reflection plane
  77929. * @param result defines the target matrix
  77930. */
  77931. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  77932. /**
  77933. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  77934. * @param xaxis defines the value of the 1st axis
  77935. * @param yaxis defines the value of the 2nd axis
  77936. * @param zaxis defines the value of the 3rd axis
  77937. * @param result defines the target matrix
  77938. */
  77939. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  77940. /**
  77941. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  77942. * @param quat defines the quaternion to use
  77943. * @param result defines the target matrix
  77944. */
  77945. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  77946. }
  77947. /**
  77948. * @hidden
  77949. */
  77950. export class TmpVectors {
  77951. static Vector2: Vector2[];
  77952. static Vector3: Vector3[];
  77953. static Vector4: Vector4[];
  77954. static Quaternion: Quaternion[];
  77955. static Matrix: Matrix[];
  77956. }
  77957. }
  77958. declare module BABYLON {
  77959. /**
  77960. * Defines potential orientation for back face culling
  77961. */
  77962. export enum Orientation {
  77963. /**
  77964. * Clockwise
  77965. */
  77966. CW = 0,
  77967. /** Counter clockwise */
  77968. CCW = 1
  77969. }
  77970. /** Class used to represent a Bezier curve */
  77971. export class BezierCurve {
  77972. /**
  77973. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  77974. * @param t defines the time
  77975. * @param x1 defines the left coordinate on X axis
  77976. * @param y1 defines the left coordinate on Y axis
  77977. * @param x2 defines the right coordinate on X axis
  77978. * @param y2 defines the right coordinate on Y axis
  77979. * @returns the interpolated value
  77980. */
  77981. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  77982. }
  77983. /**
  77984. * Defines angle representation
  77985. */
  77986. export class Angle {
  77987. private _radians;
  77988. /**
  77989. * Creates an Angle object of "radians" radians (float).
  77990. * @param radians the angle in radians
  77991. */
  77992. constructor(radians: number);
  77993. /**
  77994. * Get value in degrees
  77995. * @returns the Angle value in degrees (float)
  77996. */
  77997. degrees(): number;
  77998. /**
  77999. * Get value in radians
  78000. * @returns the Angle value in radians (float)
  78001. */
  78002. radians(): number;
  78003. /**
  78004. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  78005. * @param a defines first vector
  78006. * @param b defines second vector
  78007. * @returns a new Angle
  78008. */
  78009. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  78010. /**
  78011. * Gets a new Angle object from the given float in radians
  78012. * @param radians defines the angle value in radians
  78013. * @returns a new Angle
  78014. */
  78015. static FromRadians(radians: number): Angle;
  78016. /**
  78017. * Gets a new Angle object from the given float in degrees
  78018. * @param degrees defines the angle value in degrees
  78019. * @returns a new Angle
  78020. */
  78021. static FromDegrees(degrees: number): Angle;
  78022. }
  78023. /**
  78024. * This represents an arc in a 2d space.
  78025. */
  78026. export class Arc2 {
  78027. /** Defines the start point of the arc */
  78028. startPoint: Vector2;
  78029. /** Defines the mid point of the arc */
  78030. midPoint: Vector2;
  78031. /** Defines the end point of the arc */
  78032. endPoint: Vector2;
  78033. /**
  78034. * Defines the center point of the arc.
  78035. */
  78036. centerPoint: Vector2;
  78037. /**
  78038. * Defines the radius of the arc.
  78039. */
  78040. radius: number;
  78041. /**
  78042. * Defines the angle of the arc (from mid point to end point).
  78043. */
  78044. angle: Angle;
  78045. /**
  78046. * Defines the start angle of the arc (from start point to middle point).
  78047. */
  78048. startAngle: Angle;
  78049. /**
  78050. * Defines the orientation of the arc (clock wise/counter clock wise).
  78051. */
  78052. orientation: Orientation;
  78053. /**
  78054. * Creates an Arc object from the three given points : start, middle and end.
  78055. * @param startPoint Defines the start point of the arc
  78056. * @param midPoint Defines the midlle point of the arc
  78057. * @param endPoint Defines the end point of the arc
  78058. */
  78059. constructor(
  78060. /** Defines the start point of the arc */
  78061. startPoint: Vector2,
  78062. /** Defines the mid point of the arc */
  78063. midPoint: Vector2,
  78064. /** Defines the end point of the arc */
  78065. endPoint: Vector2);
  78066. }
  78067. /**
  78068. * Represents a 2D path made up of multiple 2D points
  78069. */
  78070. export class Path2 {
  78071. private _points;
  78072. private _length;
  78073. /**
  78074. * If the path start and end point are the same
  78075. */
  78076. closed: boolean;
  78077. /**
  78078. * Creates a Path2 object from the starting 2D coordinates x and y.
  78079. * @param x the starting points x value
  78080. * @param y the starting points y value
  78081. */
  78082. constructor(x: number, y: number);
  78083. /**
  78084. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  78085. * @param x the added points x value
  78086. * @param y the added points y value
  78087. * @returns the updated Path2.
  78088. */
  78089. addLineTo(x: number, y: number): Path2;
  78090. /**
  78091. * 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.
  78092. * @param midX middle point x value
  78093. * @param midY middle point y value
  78094. * @param endX end point x value
  78095. * @param endY end point y value
  78096. * @param numberOfSegments (default: 36)
  78097. * @returns the updated Path2.
  78098. */
  78099. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  78100. /**
  78101. * Closes the Path2.
  78102. * @returns the Path2.
  78103. */
  78104. close(): Path2;
  78105. /**
  78106. * Gets the sum of the distance between each sequential point in the path
  78107. * @returns the Path2 total length (float).
  78108. */
  78109. length(): number;
  78110. /**
  78111. * Gets the points which construct the path
  78112. * @returns the Path2 internal array of points.
  78113. */
  78114. getPoints(): Vector2[];
  78115. /**
  78116. * Retreives the point at the distance aways from the starting point
  78117. * @param normalizedLengthPosition the length along the path to retreive the point from
  78118. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  78119. */
  78120. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  78121. /**
  78122. * Creates a new path starting from an x and y position
  78123. * @param x starting x value
  78124. * @param y starting y value
  78125. * @returns a new Path2 starting at the coordinates (x, y).
  78126. */
  78127. static StartingAt(x: number, y: number): Path2;
  78128. }
  78129. /**
  78130. * Represents a 3D path made up of multiple 3D points
  78131. */
  78132. export class Path3D {
  78133. /**
  78134. * an array of Vector3, the curve axis of the Path3D
  78135. */
  78136. path: Vector3[];
  78137. private _curve;
  78138. private _distances;
  78139. private _tangents;
  78140. private _normals;
  78141. private _binormals;
  78142. private _raw;
  78143. private _alignTangentsWithPath;
  78144. private readonly _pointAtData;
  78145. /**
  78146. * new Path3D(path, normal, raw)
  78147. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  78148. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  78149. * @param path an array of Vector3, the curve axis of the Path3D
  78150. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  78151. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  78152. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  78153. */
  78154. constructor(
  78155. /**
  78156. * an array of Vector3, the curve axis of the Path3D
  78157. */
  78158. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  78159. /**
  78160. * Returns the Path3D array of successive Vector3 designing its curve.
  78161. * @returns the Path3D array of successive Vector3 designing its curve.
  78162. */
  78163. getCurve(): Vector3[];
  78164. /**
  78165. * Returns the Path3D array of successive Vector3 designing its curve.
  78166. * @returns the Path3D array of successive Vector3 designing its curve.
  78167. */
  78168. getPoints(): Vector3[];
  78169. /**
  78170. * @returns the computed length (float) of the path.
  78171. */
  78172. length(): number;
  78173. /**
  78174. * Returns an array populated with tangent vectors on each Path3D curve point.
  78175. * @returns an array populated with tangent vectors on each Path3D curve point.
  78176. */
  78177. getTangents(): Vector3[];
  78178. /**
  78179. * Returns an array populated with normal vectors on each Path3D curve point.
  78180. * @returns an array populated with normal vectors on each Path3D curve point.
  78181. */
  78182. getNormals(): Vector3[];
  78183. /**
  78184. * Returns an array populated with binormal vectors on each Path3D curve point.
  78185. * @returns an array populated with binormal vectors on each Path3D curve point.
  78186. */
  78187. getBinormals(): Vector3[];
  78188. /**
  78189. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  78190. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  78191. */
  78192. getDistances(): number[];
  78193. /**
  78194. * Returns an interpolated point along this path
  78195. * @param position the position of the point along this path, from 0.0 to 1.0
  78196. * @returns a new Vector3 as the point
  78197. */
  78198. getPointAt(position: number): Vector3;
  78199. /**
  78200. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78201. * @param position the position of the point along this path, from 0.0 to 1.0
  78202. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  78203. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  78204. */
  78205. getTangentAt(position: number, interpolated?: boolean): Vector3;
  78206. /**
  78207. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  78208. * @param position the position of the point along this path, from 0.0 to 1.0
  78209. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  78210. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  78211. */
  78212. getNormalAt(position: number, interpolated?: boolean): Vector3;
  78213. /**
  78214. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  78215. * @param position the position of the point along this path, from 0.0 to 1.0
  78216. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  78217. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  78218. */
  78219. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  78220. /**
  78221. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  78222. * @param position the position of the point along this path, from 0.0 to 1.0
  78223. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  78224. */
  78225. getDistanceAt(position: number): number;
  78226. /**
  78227. * Returns the array index of the previous point of an interpolated point along this path
  78228. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78229. * @returns the array index
  78230. */
  78231. getPreviousPointIndexAt(position: number): number;
  78232. /**
  78233. * 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)
  78234. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  78235. * @returns the sub position
  78236. */
  78237. getSubPositionAt(position: number): number;
  78238. /**
  78239. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  78240. * @param target the vector of which to get the closest position to
  78241. * @returns the position of the closest virtual point on this path to the target vector
  78242. */
  78243. getClosestPositionTo(target: Vector3): number;
  78244. /**
  78245. * Returns a sub path (slice) of this path
  78246. * @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
  78247. * @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
  78248. * @returns a sub path (slice) of this path
  78249. */
  78250. slice(start?: number, end?: number): Path3D;
  78251. /**
  78252. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  78253. * @param path path which all values are copied into the curves points
  78254. * @param firstNormal which should be projected onto the curve
  78255. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  78256. * @returns the same object updated.
  78257. */
  78258. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  78259. private _compute;
  78260. private _getFirstNonNullVector;
  78261. private _getLastNonNullVector;
  78262. private _normalVector;
  78263. /**
  78264. * Updates the point at data for an interpolated point along this curve
  78265. * @param position the position of the point along this curve, from 0.0 to 1.0
  78266. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  78267. * @returns the (updated) point at data
  78268. */
  78269. private _updatePointAtData;
  78270. /**
  78271. * Updates the point at data from the specified parameters
  78272. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  78273. * @param point the interpolated point
  78274. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  78275. */
  78276. private _setPointAtData;
  78277. /**
  78278. * Updates the point at interpolation matrix for the tangents, normals and binormals
  78279. */
  78280. private _updateInterpolationMatrix;
  78281. }
  78282. /**
  78283. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78284. * A Curve3 is designed from a series of successive Vector3.
  78285. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  78286. */
  78287. export class Curve3 {
  78288. private _points;
  78289. private _length;
  78290. /**
  78291. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  78292. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  78293. * @param v1 (Vector3) the control point
  78294. * @param v2 (Vector3) the end point of the Quadratic Bezier
  78295. * @param nbPoints (integer) the wanted number of points in the curve
  78296. * @returns the created Curve3
  78297. */
  78298. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78299. /**
  78300. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  78301. * @param v0 (Vector3) the origin point of the Cubic Bezier
  78302. * @param v1 (Vector3) the first control point
  78303. * @param v2 (Vector3) the second control point
  78304. * @param v3 (Vector3) the end point of the Cubic Bezier
  78305. * @param nbPoints (integer) the wanted number of points in the curve
  78306. * @returns the created Curve3
  78307. */
  78308. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78309. /**
  78310. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  78311. * @param p1 (Vector3) the origin point of the Hermite Spline
  78312. * @param t1 (Vector3) the tangent vector at the origin point
  78313. * @param p2 (Vector3) the end point of the Hermite Spline
  78314. * @param t2 (Vector3) the tangent vector at the end point
  78315. * @param nbPoints (integer) the wanted number of points in the curve
  78316. * @returns the created Curve3
  78317. */
  78318. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  78319. /**
  78320. * Returns a Curve3 object along a CatmullRom Spline curve :
  78321. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  78322. * @param nbPoints (integer) the wanted number of points between each curve control points
  78323. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  78324. * @returns the created Curve3
  78325. */
  78326. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  78327. /**
  78328. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  78329. * A Curve3 is designed from a series of successive Vector3.
  78330. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  78331. * @param points points which make up the curve
  78332. */
  78333. constructor(points: Vector3[]);
  78334. /**
  78335. * @returns the Curve3 stored array of successive Vector3
  78336. */
  78337. getPoints(): Vector3[];
  78338. /**
  78339. * @returns the computed length (float) of the curve.
  78340. */
  78341. length(): number;
  78342. /**
  78343. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  78344. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  78345. * curveA and curveB keep unchanged.
  78346. * @param curve the curve to continue from this curve
  78347. * @returns the newly constructed curve
  78348. */
  78349. continue(curve: DeepImmutable<Curve3>): Curve3;
  78350. private _computeLength;
  78351. }
  78352. }
  78353. declare module BABYLON {
  78354. /**
  78355. * This represents the main contract an easing function should follow.
  78356. * Easing functions are used throughout the animation system.
  78357. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78358. */
  78359. export interface IEasingFunction {
  78360. /**
  78361. * Given an input gradient between 0 and 1, this returns the corrseponding value
  78362. * of the easing function.
  78363. * The link below provides some of the most common examples of easing functions.
  78364. * @see https://easings.net/
  78365. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78366. * @returns the corresponding value on the curve defined by the easing function
  78367. */
  78368. ease(gradient: number): number;
  78369. }
  78370. /**
  78371. * Base class used for every default easing function.
  78372. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78373. */
  78374. export class EasingFunction implements IEasingFunction {
  78375. /**
  78376. * Interpolation follows the mathematical formula associated with the easing function.
  78377. */
  78378. static readonly EASINGMODE_EASEIN: number;
  78379. /**
  78380. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  78381. */
  78382. static readonly EASINGMODE_EASEOUT: number;
  78383. /**
  78384. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  78385. */
  78386. static readonly EASINGMODE_EASEINOUT: number;
  78387. private _easingMode;
  78388. /**
  78389. * Sets the easing mode of the current function.
  78390. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  78391. */
  78392. setEasingMode(easingMode: number): void;
  78393. /**
  78394. * Gets the current easing mode.
  78395. * @returns the easing mode
  78396. */
  78397. getEasingMode(): number;
  78398. /**
  78399. * @hidden
  78400. */
  78401. easeInCore(gradient: number): number;
  78402. /**
  78403. * Given an input gradient between 0 and 1, this returns the corresponding value
  78404. * of the easing function.
  78405. * @param gradient Defines the value between 0 and 1 we want the easing value for
  78406. * @returns the corresponding value on the curve defined by the easing function
  78407. */
  78408. ease(gradient: number): number;
  78409. }
  78410. /**
  78411. * Easing function with a circle shape (see link below).
  78412. * @see https://easings.net/#easeInCirc
  78413. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78414. */
  78415. export class CircleEase extends EasingFunction implements IEasingFunction {
  78416. /** @hidden */
  78417. easeInCore(gradient: number): number;
  78418. }
  78419. /**
  78420. * Easing function with a ease back shape (see link below).
  78421. * @see https://easings.net/#easeInBack
  78422. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78423. */
  78424. export class BackEase extends EasingFunction implements IEasingFunction {
  78425. /** Defines the amplitude of the function */
  78426. amplitude: number;
  78427. /**
  78428. * Instantiates a back ease easing
  78429. * @see https://easings.net/#easeInBack
  78430. * @param amplitude Defines the amplitude of the function
  78431. */
  78432. constructor(
  78433. /** Defines the amplitude of the function */
  78434. amplitude?: number);
  78435. /** @hidden */
  78436. easeInCore(gradient: number): number;
  78437. }
  78438. /**
  78439. * Easing function with a bouncing shape (see link below).
  78440. * @see https://easings.net/#easeInBounce
  78441. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78442. */
  78443. export class BounceEase extends EasingFunction implements IEasingFunction {
  78444. /** Defines the number of bounces */
  78445. bounces: number;
  78446. /** Defines the amplitude of the bounce */
  78447. bounciness: number;
  78448. /**
  78449. * Instantiates a bounce easing
  78450. * @see https://easings.net/#easeInBounce
  78451. * @param bounces Defines the number of bounces
  78452. * @param bounciness Defines the amplitude of the bounce
  78453. */
  78454. constructor(
  78455. /** Defines the number of bounces */
  78456. bounces?: number,
  78457. /** Defines the amplitude of the bounce */
  78458. bounciness?: number);
  78459. /** @hidden */
  78460. easeInCore(gradient: number): number;
  78461. }
  78462. /**
  78463. * Easing function with a power of 3 shape (see link below).
  78464. * @see https://easings.net/#easeInCubic
  78465. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78466. */
  78467. export class CubicEase extends EasingFunction implements IEasingFunction {
  78468. /** @hidden */
  78469. easeInCore(gradient: number): number;
  78470. }
  78471. /**
  78472. * Easing function with an elastic shape (see link below).
  78473. * @see https://easings.net/#easeInElastic
  78474. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78475. */
  78476. export class ElasticEase extends EasingFunction implements IEasingFunction {
  78477. /** Defines the number of oscillations*/
  78478. oscillations: number;
  78479. /** Defines the amplitude of the oscillations*/
  78480. springiness: number;
  78481. /**
  78482. * Instantiates an elastic easing function
  78483. * @see https://easings.net/#easeInElastic
  78484. * @param oscillations Defines the number of oscillations
  78485. * @param springiness Defines the amplitude of the oscillations
  78486. */
  78487. constructor(
  78488. /** Defines the number of oscillations*/
  78489. oscillations?: number,
  78490. /** Defines the amplitude of the oscillations*/
  78491. springiness?: number);
  78492. /** @hidden */
  78493. easeInCore(gradient: number): number;
  78494. }
  78495. /**
  78496. * Easing function with an exponential shape (see link below).
  78497. * @see https://easings.net/#easeInExpo
  78498. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78499. */
  78500. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  78501. /** Defines the exponent of the function */
  78502. exponent: number;
  78503. /**
  78504. * Instantiates an exponential easing function
  78505. * @see https://easings.net/#easeInExpo
  78506. * @param exponent Defines the exponent of the function
  78507. */
  78508. constructor(
  78509. /** Defines the exponent of the function */
  78510. exponent?: number);
  78511. /** @hidden */
  78512. easeInCore(gradient: number): number;
  78513. }
  78514. /**
  78515. * Easing function with a power shape (see link below).
  78516. * @see https://easings.net/#easeInQuad
  78517. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78518. */
  78519. export class PowerEase extends EasingFunction implements IEasingFunction {
  78520. /** Defines the power of the function */
  78521. power: number;
  78522. /**
  78523. * Instantiates an power base easing function
  78524. * @see https://easings.net/#easeInQuad
  78525. * @param power Defines the power of the function
  78526. */
  78527. constructor(
  78528. /** Defines the power of the function */
  78529. power?: number);
  78530. /** @hidden */
  78531. easeInCore(gradient: number): number;
  78532. }
  78533. /**
  78534. * Easing function with a power of 2 shape (see link below).
  78535. * @see https://easings.net/#easeInQuad
  78536. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78537. */
  78538. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  78539. /** @hidden */
  78540. easeInCore(gradient: number): number;
  78541. }
  78542. /**
  78543. * Easing function with a power of 4 shape (see link below).
  78544. * @see https://easings.net/#easeInQuart
  78545. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78546. */
  78547. export class QuarticEase extends EasingFunction implements IEasingFunction {
  78548. /** @hidden */
  78549. easeInCore(gradient: number): number;
  78550. }
  78551. /**
  78552. * Easing function with a power of 5 shape (see link below).
  78553. * @see https://easings.net/#easeInQuint
  78554. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78555. */
  78556. export class QuinticEase extends EasingFunction implements IEasingFunction {
  78557. /** @hidden */
  78558. easeInCore(gradient: number): number;
  78559. }
  78560. /**
  78561. * Easing function with a sin shape (see link below).
  78562. * @see https://easings.net/#easeInSine
  78563. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78564. */
  78565. export class SineEase extends EasingFunction implements IEasingFunction {
  78566. /** @hidden */
  78567. easeInCore(gradient: number): number;
  78568. }
  78569. /**
  78570. * Easing function with a bezier shape (see link below).
  78571. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78572. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  78573. */
  78574. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  78575. /** Defines the x component of the start tangent in the bezier curve */
  78576. x1: number;
  78577. /** Defines the y component of the start tangent in the bezier curve */
  78578. y1: number;
  78579. /** Defines the x component of the end tangent in the bezier curve */
  78580. x2: number;
  78581. /** Defines the y component of the end tangent in the bezier curve */
  78582. y2: number;
  78583. /**
  78584. * Instantiates a bezier function
  78585. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  78586. * @param x1 Defines the x component of the start tangent in the bezier curve
  78587. * @param y1 Defines the y component of the start tangent in the bezier curve
  78588. * @param x2 Defines the x component of the end tangent in the bezier curve
  78589. * @param y2 Defines the y component of the end tangent in the bezier curve
  78590. */
  78591. constructor(
  78592. /** Defines the x component of the start tangent in the bezier curve */
  78593. x1?: number,
  78594. /** Defines the y component of the start tangent in the bezier curve */
  78595. y1?: number,
  78596. /** Defines the x component of the end tangent in the bezier curve */
  78597. x2?: number,
  78598. /** Defines the y component of the end tangent in the bezier curve */
  78599. y2?: number);
  78600. /** @hidden */
  78601. easeInCore(gradient: number): number;
  78602. }
  78603. }
  78604. declare module BABYLON {
  78605. /**
  78606. * Class used to hold a RBG color
  78607. */
  78608. export class Color3 {
  78609. /**
  78610. * Defines the red component (between 0 and 1, default is 0)
  78611. */
  78612. r: number;
  78613. /**
  78614. * Defines the green component (between 0 and 1, default is 0)
  78615. */
  78616. g: number;
  78617. /**
  78618. * Defines the blue component (between 0 and 1, default is 0)
  78619. */
  78620. b: number;
  78621. /**
  78622. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  78623. * @param r defines the red component (between 0 and 1, default is 0)
  78624. * @param g defines the green component (between 0 and 1, default is 0)
  78625. * @param b defines the blue component (between 0 and 1, default is 0)
  78626. */
  78627. constructor(
  78628. /**
  78629. * Defines the red component (between 0 and 1, default is 0)
  78630. */
  78631. r?: number,
  78632. /**
  78633. * Defines the green component (between 0 and 1, default is 0)
  78634. */
  78635. g?: number,
  78636. /**
  78637. * Defines the blue component (between 0 and 1, default is 0)
  78638. */
  78639. b?: number);
  78640. /**
  78641. * Creates a string with the Color3 current values
  78642. * @returns the string representation of the Color3 object
  78643. */
  78644. toString(): string;
  78645. /**
  78646. * Returns the string "Color3"
  78647. * @returns "Color3"
  78648. */
  78649. getClassName(): string;
  78650. /**
  78651. * Compute the Color3 hash code
  78652. * @returns an unique number that can be used to hash Color3 objects
  78653. */
  78654. getHashCode(): number;
  78655. /**
  78656. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  78657. * @param array defines the array where to store the r,g,b components
  78658. * @param index defines an optional index in the target array to define where to start storing values
  78659. * @returns the current Color3 object
  78660. */
  78661. toArray(array: FloatArray, index?: number): Color3;
  78662. /**
  78663. * Returns a new Color4 object from the current Color3 and the given alpha
  78664. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  78665. * @returns a new Color4 object
  78666. */
  78667. toColor4(alpha?: number): Color4;
  78668. /**
  78669. * Returns a new array populated with 3 numeric elements : red, green and blue values
  78670. * @returns the new array
  78671. */
  78672. asArray(): number[];
  78673. /**
  78674. * Returns the luminance value
  78675. * @returns a float value
  78676. */
  78677. toLuminance(): number;
  78678. /**
  78679. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  78680. * @param otherColor defines the second operand
  78681. * @returns the new Color3 object
  78682. */
  78683. multiply(otherColor: DeepImmutable<Color3>): Color3;
  78684. /**
  78685. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  78686. * @param otherColor defines the second operand
  78687. * @param result defines the Color3 object where to store the result
  78688. * @returns the current Color3
  78689. */
  78690. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78691. /**
  78692. * Determines equality between Color3 objects
  78693. * @param otherColor defines the second operand
  78694. * @returns true if the rgb values are equal to the given ones
  78695. */
  78696. equals(otherColor: DeepImmutable<Color3>): boolean;
  78697. /**
  78698. * Determines equality between the current Color3 object and a set of r,b,g values
  78699. * @param r defines the red component to check
  78700. * @param g defines the green component to check
  78701. * @param b defines the blue component to check
  78702. * @returns true if the rgb values are equal to the given ones
  78703. */
  78704. equalsFloats(r: number, g: number, b: number): boolean;
  78705. /**
  78706. * Multiplies in place each rgb value by scale
  78707. * @param scale defines the scaling factor
  78708. * @returns the updated Color3
  78709. */
  78710. scale(scale: number): Color3;
  78711. /**
  78712. * Multiplies the rgb values by scale and stores the result into "result"
  78713. * @param scale defines the scaling factor
  78714. * @param result defines the Color3 object where to store the result
  78715. * @returns the unmodified current Color3
  78716. */
  78717. scaleToRef(scale: number, result: Color3): Color3;
  78718. /**
  78719. * Scale the current Color3 values by a factor and add the result to a given Color3
  78720. * @param scale defines the scale factor
  78721. * @param result defines color to store the result into
  78722. * @returns the unmodified current Color3
  78723. */
  78724. scaleAndAddToRef(scale: number, result: Color3): Color3;
  78725. /**
  78726. * Clamps the rgb values by the min and max values and stores the result into "result"
  78727. * @param min defines minimum clamping value (default is 0)
  78728. * @param max defines maximum clamping value (default is 1)
  78729. * @param result defines color to store the result into
  78730. * @returns the original Color3
  78731. */
  78732. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  78733. /**
  78734. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  78735. * @param otherColor defines the second operand
  78736. * @returns the new Color3
  78737. */
  78738. add(otherColor: DeepImmutable<Color3>): Color3;
  78739. /**
  78740. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  78741. * @param otherColor defines the second operand
  78742. * @param result defines Color3 object to store the result into
  78743. * @returns the unmodified current Color3
  78744. */
  78745. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78746. /**
  78747. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  78748. * @param otherColor defines the second operand
  78749. * @returns the new Color3
  78750. */
  78751. subtract(otherColor: DeepImmutable<Color3>): Color3;
  78752. /**
  78753. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  78754. * @param otherColor defines the second operand
  78755. * @param result defines Color3 object to store the result into
  78756. * @returns the unmodified current Color3
  78757. */
  78758. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  78759. /**
  78760. * Copy the current object
  78761. * @returns a new Color3 copied the current one
  78762. */
  78763. clone(): Color3;
  78764. /**
  78765. * Copies the rgb values from the source in the current Color3
  78766. * @param source defines the source Color3 object
  78767. * @returns the updated Color3 object
  78768. */
  78769. copyFrom(source: DeepImmutable<Color3>): Color3;
  78770. /**
  78771. * Updates the Color3 rgb values from the given floats
  78772. * @param r defines the red component to read from
  78773. * @param g defines the green component to read from
  78774. * @param b defines the blue component to read from
  78775. * @returns the current Color3 object
  78776. */
  78777. copyFromFloats(r: number, g: number, b: number): Color3;
  78778. /**
  78779. * Updates the Color3 rgb values from the given floats
  78780. * @param r defines the red component to read from
  78781. * @param g defines the green component to read from
  78782. * @param b defines the blue component to read from
  78783. * @returns the current Color3 object
  78784. */
  78785. set(r: number, g: number, b: number): Color3;
  78786. /**
  78787. * Compute the Color3 hexadecimal code as a string
  78788. * @returns a string containing the hexadecimal representation of the Color3 object
  78789. */
  78790. toHexString(): string;
  78791. /**
  78792. * Computes a new Color3 converted from the current one to linear space
  78793. * @returns a new Color3 object
  78794. */
  78795. toLinearSpace(): Color3;
  78796. /**
  78797. * Converts current color in rgb space to HSV values
  78798. * @returns a new color3 representing the HSV values
  78799. */
  78800. toHSV(): Color3;
  78801. /**
  78802. * Converts current color in rgb space to HSV values
  78803. * @param result defines the Color3 where to store the HSV values
  78804. */
  78805. toHSVToRef(result: Color3): void;
  78806. /**
  78807. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  78808. * @param convertedColor defines the Color3 object where to store the linear space version
  78809. * @returns the unmodified Color3
  78810. */
  78811. toLinearSpaceToRef(convertedColor: Color3): Color3;
  78812. /**
  78813. * Computes a new Color3 converted from the current one to gamma space
  78814. * @returns a new Color3 object
  78815. */
  78816. toGammaSpace(): Color3;
  78817. /**
  78818. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  78819. * @param convertedColor defines the Color3 object where to store the gamma space version
  78820. * @returns the unmodified Color3
  78821. */
  78822. toGammaSpaceToRef(convertedColor: Color3): Color3;
  78823. private static _BlackReadOnly;
  78824. /**
  78825. * Convert Hue, saturation and value to a Color3 (RGB)
  78826. * @param hue defines the hue
  78827. * @param saturation defines the saturation
  78828. * @param value defines the value
  78829. * @param result defines the Color3 where to store the RGB values
  78830. */
  78831. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  78832. /**
  78833. * Creates a new Color3 from the string containing valid hexadecimal values
  78834. * @param hex defines a string containing valid hexadecimal values
  78835. * @returns a new Color3 object
  78836. */
  78837. static FromHexString(hex: string): Color3;
  78838. /**
  78839. * Creates a new Color3 from the starting index of the given array
  78840. * @param array defines the source array
  78841. * @param offset defines an offset in the source array
  78842. * @returns a new Color3 object
  78843. */
  78844. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  78845. /**
  78846. * Creates a new Color3 from integer values (< 256)
  78847. * @param r defines the red component to read from (value between 0 and 255)
  78848. * @param g defines the green component to read from (value between 0 and 255)
  78849. * @param b defines the blue component to read from (value between 0 and 255)
  78850. * @returns a new Color3 object
  78851. */
  78852. static FromInts(r: number, g: number, b: number): Color3;
  78853. /**
  78854. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78855. * @param start defines the start Color3 value
  78856. * @param end defines the end Color3 value
  78857. * @param amount defines the gradient value between start and end
  78858. * @returns a new Color3 object
  78859. */
  78860. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  78861. /**
  78862. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  78863. * @param left defines the start value
  78864. * @param right defines the end value
  78865. * @param amount defines the gradient factor
  78866. * @param result defines the Color3 object where to store the result
  78867. */
  78868. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  78869. /**
  78870. * Returns a Color3 value containing a red color
  78871. * @returns a new Color3 object
  78872. */
  78873. static Red(): Color3;
  78874. /**
  78875. * Returns a Color3 value containing a green color
  78876. * @returns a new Color3 object
  78877. */
  78878. static Green(): Color3;
  78879. /**
  78880. * Returns a Color3 value containing a blue color
  78881. * @returns a new Color3 object
  78882. */
  78883. static Blue(): Color3;
  78884. /**
  78885. * Returns a Color3 value containing a black color
  78886. * @returns a new Color3 object
  78887. */
  78888. static Black(): Color3;
  78889. /**
  78890. * Gets a Color3 value containing a black color that must not be updated
  78891. */
  78892. static get BlackReadOnly(): DeepImmutable<Color3>;
  78893. /**
  78894. * Returns a Color3 value containing a white color
  78895. * @returns a new Color3 object
  78896. */
  78897. static White(): Color3;
  78898. /**
  78899. * Returns a Color3 value containing a purple color
  78900. * @returns a new Color3 object
  78901. */
  78902. static Purple(): Color3;
  78903. /**
  78904. * Returns a Color3 value containing a magenta color
  78905. * @returns a new Color3 object
  78906. */
  78907. static Magenta(): Color3;
  78908. /**
  78909. * Returns a Color3 value containing a yellow color
  78910. * @returns a new Color3 object
  78911. */
  78912. static Yellow(): Color3;
  78913. /**
  78914. * Returns a Color3 value containing a gray color
  78915. * @returns a new Color3 object
  78916. */
  78917. static Gray(): Color3;
  78918. /**
  78919. * Returns a Color3 value containing a teal color
  78920. * @returns a new Color3 object
  78921. */
  78922. static Teal(): Color3;
  78923. /**
  78924. * Returns a Color3 value containing a random color
  78925. * @returns a new Color3 object
  78926. */
  78927. static Random(): Color3;
  78928. }
  78929. /**
  78930. * Class used to hold a RBGA color
  78931. */
  78932. export class Color4 {
  78933. /**
  78934. * Defines the red component (between 0 and 1, default is 0)
  78935. */
  78936. r: number;
  78937. /**
  78938. * Defines the green component (between 0 and 1, default is 0)
  78939. */
  78940. g: number;
  78941. /**
  78942. * Defines the blue component (between 0 and 1, default is 0)
  78943. */
  78944. b: number;
  78945. /**
  78946. * Defines the alpha component (between 0 and 1, default is 1)
  78947. */
  78948. a: number;
  78949. /**
  78950. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  78951. * @param r defines the red component (between 0 and 1, default is 0)
  78952. * @param g defines the green component (between 0 and 1, default is 0)
  78953. * @param b defines the blue component (between 0 and 1, default is 0)
  78954. * @param a defines the alpha component (between 0 and 1, default is 1)
  78955. */
  78956. constructor(
  78957. /**
  78958. * Defines the red component (between 0 and 1, default is 0)
  78959. */
  78960. r?: number,
  78961. /**
  78962. * Defines the green component (between 0 and 1, default is 0)
  78963. */
  78964. g?: number,
  78965. /**
  78966. * Defines the blue component (between 0 and 1, default is 0)
  78967. */
  78968. b?: number,
  78969. /**
  78970. * Defines the alpha component (between 0 and 1, default is 1)
  78971. */
  78972. a?: number);
  78973. /**
  78974. * Adds in place the given Color4 values to the current Color4 object
  78975. * @param right defines the second operand
  78976. * @returns the current updated Color4 object
  78977. */
  78978. addInPlace(right: DeepImmutable<Color4>): Color4;
  78979. /**
  78980. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  78981. * @returns the new array
  78982. */
  78983. asArray(): number[];
  78984. /**
  78985. * Stores from the starting index in the given array the Color4 successive values
  78986. * @param array defines the array where to store the r,g,b components
  78987. * @param index defines an optional index in the target array to define where to start storing values
  78988. * @returns the current Color4 object
  78989. */
  78990. toArray(array: number[], index?: number): Color4;
  78991. /**
  78992. * Determines equality between Color4 objects
  78993. * @param otherColor defines the second operand
  78994. * @returns true if the rgba values are equal to the given ones
  78995. */
  78996. equals(otherColor: DeepImmutable<Color4>): boolean;
  78997. /**
  78998. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  78999. * @param right defines the second operand
  79000. * @returns a new Color4 object
  79001. */
  79002. add(right: DeepImmutable<Color4>): Color4;
  79003. /**
  79004. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  79005. * @param right defines the second operand
  79006. * @returns a new Color4 object
  79007. */
  79008. subtract(right: DeepImmutable<Color4>): Color4;
  79009. /**
  79010. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  79011. * @param right defines the second operand
  79012. * @param result defines the Color4 object where to store the result
  79013. * @returns the current Color4 object
  79014. */
  79015. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  79016. /**
  79017. * Creates a new Color4 with the current Color4 values multiplied by scale
  79018. * @param scale defines the scaling factor to apply
  79019. * @returns a new Color4 object
  79020. */
  79021. scale(scale: number): Color4;
  79022. /**
  79023. * Multiplies the current Color4 values by scale and stores the result in "result"
  79024. * @param scale defines the scaling factor to apply
  79025. * @param result defines the Color4 object where to store the result
  79026. * @returns the current unmodified Color4
  79027. */
  79028. scaleToRef(scale: number, result: Color4): Color4;
  79029. /**
  79030. * Scale the current Color4 values by a factor and add the result to a given Color4
  79031. * @param scale defines the scale factor
  79032. * @param result defines the Color4 object where to store the result
  79033. * @returns the unmodified current Color4
  79034. */
  79035. scaleAndAddToRef(scale: number, result: Color4): Color4;
  79036. /**
  79037. * Clamps the rgb values by the min and max values and stores the result into "result"
  79038. * @param min defines minimum clamping value (default is 0)
  79039. * @param max defines maximum clamping value (default is 1)
  79040. * @param result defines color to store the result into.
  79041. * @returns the cuurent Color4
  79042. */
  79043. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  79044. /**
  79045. * Multipy an Color4 value by another and return a new Color4 object
  79046. * @param color defines the Color4 value to multiply by
  79047. * @returns a new Color4 object
  79048. */
  79049. multiply(color: Color4): Color4;
  79050. /**
  79051. * Multipy a Color4 value by another and push the result in a reference value
  79052. * @param color defines the Color4 value to multiply by
  79053. * @param result defines the Color4 to fill the result in
  79054. * @returns the result Color4
  79055. */
  79056. multiplyToRef(color: Color4, result: Color4): Color4;
  79057. /**
  79058. * Creates a string with the Color4 current values
  79059. * @returns the string representation of the Color4 object
  79060. */
  79061. toString(): string;
  79062. /**
  79063. * Returns the string "Color4"
  79064. * @returns "Color4"
  79065. */
  79066. getClassName(): string;
  79067. /**
  79068. * Compute the Color4 hash code
  79069. * @returns an unique number that can be used to hash Color4 objects
  79070. */
  79071. getHashCode(): number;
  79072. /**
  79073. * Creates a new Color4 copied from the current one
  79074. * @returns a new Color4 object
  79075. */
  79076. clone(): Color4;
  79077. /**
  79078. * Copies the given Color4 values into the current one
  79079. * @param source defines the source Color4 object
  79080. * @returns the current updated Color4 object
  79081. */
  79082. copyFrom(source: Color4): Color4;
  79083. /**
  79084. * Copies the given float values into the current one
  79085. * @param r defines the red component to read from
  79086. * @param g defines the green component to read from
  79087. * @param b defines the blue component to read from
  79088. * @param a defines the alpha component to read from
  79089. * @returns the current updated Color4 object
  79090. */
  79091. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  79092. /**
  79093. * Copies the given float values into the current one
  79094. * @param r defines the red component to read from
  79095. * @param g defines the green component to read from
  79096. * @param b defines the blue component to read from
  79097. * @param a defines the alpha component to read from
  79098. * @returns the current updated Color4 object
  79099. */
  79100. set(r: number, g: number, b: number, a: number): Color4;
  79101. /**
  79102. * Compute the Color4 hexadecimal code as a string
  79103. * @returns a string containing the hexadecimal representation of the Color4 object
  79104. */
  79105. toHexString(): string;
  79106. /**
  79107. * Computes a new Color4 converted from the current one to linear space
  79108. * @returns a new Color4 object
  79109. */
  79110. toLinearSpace(): Color4;
  79111. /**
  79112. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  79113. * @param convertedColor defines the Color4 object where to store the linear space version
  79114. * @returns the unmodified Color4
  79115. */
  79116. toLinearSpaceToRef(convertedColor: Color4): Color4;
  79117. /**
  79118. * Computes a new Color4 converted from the current one to gamma space
  79119. * @returns a new Color4 object
  79120. */
  79121. toGammaSpace(): Color4;
  79122. /**
  79123. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  79124. * @param convertedColor defines the Color4 object where to store the gamma space version
  79125. * @returns the unmodified Color4
  79126. */
  79127. toGammaSpaceToRef(convertedColor: Color4): Color4;
  79128. /**
  79129. * Creates a new Color4 from the string containing valid hexadecimal values
  79130. * @param hex defines a string containing valid hexadecimal values
  79131. * @returns a new Color4 object
  79132. */
  79133. static FromHexString(hex: string): Color4;
  79134. /**
  79135. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79136. * @param left defines the start value
  79137. * @param right defines the end value
  79138. * @param amount defines the gradient factor
  79139. * @returns a new Color4 object
  79140. */
  79141. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  79142. /**
  79143. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  79144. * @param left defines the start value
  79145. * @param right defines the end value
  79146. * @param amount defines the gradient factor
  79147. * @param result defines the Color4 object where to store data
  79148. */
  79149. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  79150. /**
  79151. * Creates a new Color4 from a Color3 and an alpha value
  79152. * @param color3 defines the source Color3 to read from
  79153. * @param alpha defines the alpha component (1.0 by default)
  79154. * @returns a new Color4 object
  79155. */
  79156. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  79157. /**
  79158. * Creates a new Color4 from the starting index element of the given array
  79159. * @param array defines the source array to read from
  79160. * @param offset defines the offset in the source array
  79161. * @returns a new Color4 object
  79162. */
  79163. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  79164. /**
  79165. * Creates a new Color3 from integer values (< 256)
  79166. * @param r defines the red component to read from (value between 0 and 255)
  79167. * @param g defines the green component to read from (value between 0 and 255)
  79168. * @param b defines the blue component to read from (value between 0 and 255)
  79169. * @param a defines the alpha component to read from (value between 0 and 255)
  79170. * @returns a new Color3 object
  79171. */
  79172. static FromInts(r: number, g: number, b: number, a: number): Color4;
  79173. /**
  79174. * Check the content of a given array and convert it to an array containing RGBA data
  79175. * If the original array was already containing count * 4 values then it is returned directly
  79176. * @param colors defines the array to check
  79177. * @param count defines the number of RGBA data to expect
  79178. * @returns an array containing count * 4 values (RGBA)
  79179. */
  79180. static CheckColors4(colors: number[], count: number): number[];
  79181. }
  79182. /**
  79183. * @hidden
  79184. */
  79185. export class TmpColors {
  79186. static Color3: Color3[];
  79187. static Color4: Color4[];
  79188. }
  79189. }
  79190. declare module BABYLON {
  79191. /**
  79192. * Defines an interface which represents an animation key frame
  79193. */
  79194. export interface IAnimationKey {
  79195. /**
  79196. * Frame of the key frame
  79197. */
  79198. frame: number;
  79199. /**
  79200. * Value at the specifies key frame
  79201. */
  79202. value: any;
  79203. /**
  79204. * The input tangent for the cubic hermite spline
  79205. */
  79206. inTangent?: any;
  79207. /**
  79208. * The output tangent for the cubic hermite spline
  79209. */
  79210. outTangent?: any;
  79211. /**
  79212. * The animation interpolation type
  79213. */
  79214. interpolation?: AnimationKeyInterpolation;
  79215. }
  79216. /**
  79217. * Enum for the animation key frame interpolation type
  79218. */
  79219. export enum AnimationKeyInterpolation {
  79220. /**
  79221. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  79222. */
  79223. STEP = 1
  79224. }
  79225. }
  79226. declare module BABYLON {
  79227. /**
  79228. * Represents the range of an animation
  79229. */
  79230. export class AnimationRange {
  79231. /**The name of the animation range**/
  79232. name: string;
  79233. /**The starting frame of the animation */
  79234. from: number;
  79235. /**The ending frame of the animation*/
  79236. to: number;
  79237. /**
  79238. * Initializes the range of an animation
  79239. * @param name The name of the animation range
  79240. * @param from The starting frame of the animation
  79241. * @param to The ending frame of the animation
  79242. */
  79243. constructor(
  79244. /**The name of the animation range**/
  79245. name: string,
  79246. /**The starting frame of the animation */
  79247. from: number,
  79248. /**The ending frame of the animation*/
  79249. to: number);
  79250. /**
  79251. * Makes a copy of the animation range
  79252. * @returns A copy of the animation range
  79253. */
  79254. clone(): AnimationRange;
  79255. }
  79256. }
  79257. declare module BABYLON {
  79258. /**
  79259. * Composed of a frame, and an action function
  79260. */
  79261. export class AnimationEvent {
  79262. /** The frame for which the event is triggered **/
  79263. frame: number;
  79264. /** The event to perform when triggered **/
  79265. action: (currentFrame: number) => void;
  79266. /** Specifies if the event should be triggered only once**/
  79267. onlyOnce?: boolean | undefined;
  79268. /**
  79269. * Specifies if the animation event is done
  79270. */
  79271. isDone: boolean;
  79272. /**
  79273. * Initializes the animation event
  79274. * @param frame The frame for which the event is triggered
  79275. * @param action The event to perform when triggered
  79276. * @param onlyOnce Specifies if the event should be triggered only once
  79277. */
  79278. constructor(
  79279. /** The frame for which the event is triggered **/
  79280. frame: number,
  79281. /** The event to perform when triggered **/
  79282. action: (currentFrame: number) => void,
  79283. /** Specifies if the event should be triggered only once**/
  79284. onlyOnce?: boolean | undefined);
  79285. /** @hidden */
  79286. _clone(): AnimationEvent;
  79287. }
  79288. }
  79289. declare module BABYLON {
  79290. /**
  79291. * Interface used to define a behavior
  79292. */
  79293. export interface Behavior<T> {
  79294. /** gets or sets behavior's name */
  79295. name: string;
  79296. /**
  79297. * Function called when the behavior needs to be initialized (after attaching it to a target)
  79298. */
  79299. init(): void;
  79300. /**
  79301. * Called when the behavior is attached to a target
  79302. * @param target defines the target where the behavior is attached to
  79303. */
  79304. attach(target: T): void;
  79305. /**
  79306. * Called when the behavior is detached from its target
  79307. */
  79308. detach(): void;
  79309. }
  79310. /**
  79311. * Interface implemented by classes supporting behaviors
  79312. */
  79313. export interface IBehaviorAware<T> {
  79314. /**
  79315. * Attach a behavior
  79316. * @param behavior defines the behavior to attach
  79317. * @returns the current host
  79318. */
  79319. addBehavior(behavior: Behavior<T>): T;
  79320. /**
  79321. * Remove a behavior from the current object
  79322. * @param behavior defines the behavior to detach
  79323. * @returns the current host
  79324. */
  79325. removeBehavior(behavior: Behavior<T>): T;
  79326. /**
  79327. * Gets a behavior using its name to search
  79328. * @param name defines the name to search
  79329. * @returns the behavior or null if not found
  79330. */
  79331. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  79332. }
  79333. }
  79334. declare module BABYLON {
  79335. /**
  79336. * Defines an array and its length.
  79337. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  79338. */
  79339. export interface ISmartArrayLike<T> {
  79340. /**
  79341. * The data of the array.
  79342. */
  79343. data: Array<T>;
  79344. /**
  79345. * The active length of the array.
  79346. */
  79347. length: number;
  79348. }
  79349. /**
  79350. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79351. */
  79352. export class SmartArray<T> implements ISmartArrayLike<T> {
  79353. /**
  79354. * The full set of data from the array.
  79355. */
  79356. data: Array<T>;
  79357. /**
  79358. * The active length of the array.
  79359. */
  79360. length: number;
  79361. protected _id: number;
  79362. /**
  79363. * Instantiates a Smart Array.
  79364. * @param capacity defines the default capacity of the array.
  79365. */
  79366. constructor(capacity: number);
  79367. /**
  79368. * Pushes a value at the end of the active data.
  79369. * @param value defines the object to push in the array.
  79370. */
  79371. push(value: T): void;
  79372. /**
  79373. * Iterates over the active data and apply the lambda to them.
  79374. * @param func defines the action to apply on each value.
  79375. */
  79376. forEach(func: (content: T) => void): void;
  79377. /**
  79378. * Sorts the full sets of data.
  79379. * @param compareFn defines the comparison function to apply.
  79380. */
  79381. sort(compareFn: (a: T, b: T) => number): void;
  79382. /**
  79383. * Resets the active data to an empty array.
  79384. */
  79385. reset(): void;
  79386. /**
  79387. * Releases all the data from the array as well as the array.
  79388. */
  79389. dispose(): void;
  79390. /**
  79391. * Concats the active data with a given array.
  79392. * @param array defines the data to concatenate with.
  79393. */
  79394. concat(array: any): void;
  79395. /**
  79396. * Returns the position of a value in the active data.
  79397. * @param value defines the value to find the index for
  79398. * @returns the index if found in the active data otherwise -1
  79399. */
  79400. indexOf(value: T): number;
  79401. /**
  79402. * Returns whether an element is part of the active data.
  79403. * @param value defines the value to look for
  79404. * @returns true if found in the active data otherwise false
  79405. */
  79406. contains(value: T): boolean;
  79407. private static _GlobalId;
  79408. }
  79409. /**
  79410. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  79411. * The data in this array can only be present once
  79412. */
  79413. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  79414. private _duplicateId;
  79415. /**
  79416. * Pushes a value at the end of the active data.
  79417. * THIS DOES NOT PREVENT DUPPLICATE DATA
  79418. * @param value defines the object to push in the array.
  79419. */
  79420. push(value: T): void;
  79421. /**
  79422. * Pushes a value at the end of the active data.
  79423. * If the data is already present, it won t be added again
  79424. * @param value defines the object to push in the array.
  79425. * @returns true if added false if it was already present
  79426. */
  79427. pushNoDuplicate(value: T): boolean;
  79428. /**
  79429. * Resets the active data to an empty array.
  79430. */
  79431. reset(): void;
  79432. /**
  79433. * Concats the active data with a given array.
  79434. * This ensures no dupplicate will be present in the result.
  79435. * @param array defines the data to concatenate with.
  79436. */
  79437. concatWithNoDuplicate(array: any): void;
  79438. }
  79439. }
  79440. declare module BABYLON {
  79441. /**
  79442. * @ignore
  79443. * This is a list of all the different input types that are available in the application.
  79444. * Fo instance: ArcRotateCameraGamepadInput...
  79445. */
  79446. export var CameraInputTypes: {};
  79447. /**
  79448. * This is the contract to implement in order to create a new input class.
  79449. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  79450. */
  79451. export interface ICameraInput<TCamera extends Camera> {
  79452. /**
  79453. * Defines the camera the input is attached to.
  79454. */
  79455. camera: Nullable<TCamera>;
  79456. /**
  79457. * Gets the class name of the current intput.
  79458. * @returns the class name
  79459. */
  79460. getClassName(): string;
  79461. /**
  79462. * Get the friendly name associated with the input class.
  79463. * @returns the input friendly name
  79464. */
  79465. getSimpleName(): string;
  79466. /**
  79467. * Attach the input controls to a specific dom element to get the input from.
  79468. * @param element Defines the element the controls should be listened from
  79469. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79470. */
  79471. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  79472. /**
  79473. * Detach the current controls from the specified dom element.
  79474. * @param element Defines the element to stop listening the inputs from
  79475. */
  79476. detachControl(element: Nullable<HTMLElement>): void;
  79477. /**
  79478. * Update the current camera state depending on the inputs that have been used this frame.
  79479. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79480. */
  79481. checkInputs?: () => void;
  79482. }
  79483. /**
  79484. * Represents a map of input types to input instance or input index to input instance.
  79485. */
  79486. export interface CameraInputsMap<TCamera extends Camera> {
  79487. /**
  79488. * Accessor to the input by input type.
  79489. */
  79490. [name: string]: ICameraInput<TCamera>;
  79491. /**
  79492. * Accessor to the input by input index.
  79493. */
  79494. [idx: number]: ICameraInput<TCamera>;
  79495. }
  79496. /**
  79497. * This represents the input manager used within a camera.
  79498. * It helps dealing with all the different kind of input attached to a camera.
  79499. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79500. */
  79501. export class CameraInputsManager<TCamera extends Camera> {
  79502. /**
  79503. * Defines the list of inputs attahed to the camera.
  79504. */
  79505. attached: CameraInputsMap<TCamera>;
  79506. /**
  79507. * Defines the dom element the camera is collecting inputs from.
  79508. * This is null if the controls have not been attached.
  79509. */
  79510. attachedElement: Nullable<HTMLElement>;
  79511. /**
  79512. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79513. */
  79514. noPreventDefault: boolean;
  79515. /**
  79516. * Defined the camera the input manager belongs to.
  79517. */
  79518. camera: TCamera;
  79519. /**
  79520. * Update the current camera state depending on the inputs that have been used this frame.
  79521. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  79522. */
  79523. checkInputs: () => void;
  79524. /**
  79525. * Instantiate a new Camera Input Manager.
  79526. * @param camera Defines the camera the input manager blongs to
  79527. */
  79528. constructor(camera: TCamera);
  79529. /**
  79530. * Add an input method to a camera
  79531. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  79532. * @param input camera input method
  79533. */
  79534. add(input: ICameraInput<TCamera>): void;
  79535. /**
  79536. * Remove a specific input method from a camera
  79537. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  79538. * @param inputToRemove camera input method
  79539. */
  79540. remove(inputToRemove: ICameraInput<TCamera>): void;
  79541. /**
  79542. * Remove a specific input type from a camera
  79543. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  79544. * @param inputType the type of the input to remove
  79545. */
  79546. removeByType(inputType: string): void;
  79547. private _addCheckInputs;
  79548. /**
  79549. * Attach the input controls to the currently attached dom element to listen the events from.
  79550. * @param input Defines the input to attach
  79551. */
  79552. attachInput(input: ICameraInput<TCamera>): void;
  79553. /**
  79554. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  79555. * @param element Defines the dom element to collect the events from
  79556. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  79557. */
  79558. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  79559. /**
  79560. * Detach the current manager inputs controls from a specific dom element.
  79561. * @param element Defines the dom element to collect the events from
  79562. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  79563. */
  79564. detachElement(element: HTMLElement, disconnect?: boolean): void;
  79565. /**
  79566. * Rebuild the dynamic inputCheck function from the current list of
  79567. * defined inputs in the manager.
  79568. */
  79569. rebuildInputCheck(): void;
  79570. /**
  79571. * Remove all attached input methods from a camera
  79572. */
  79573. clear(): void;
  79574. /**
  79575. * Serialize the current input manager attached to a camera.
  79576. * This ensures than once parsed,
  79577. * the input associated to the camera will be identical to the current ones
  79578. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  79579. */
  79580. serialize(serializedCamera: any): void;
  79581. /**
  79582. * Parses an input manager serialized JSON to restore the previous list of inputs
  79583. * and states associated to a camera.
  79584. * @param parsedCamera Defines the JSON to parse
  79585. */
  79586. parse(parsedCamera: any): void;
  79587. }
  79588. }
  79589. declare module BABYLON {
  79590. /**
  79591. * Class used to store data that will be store in GPU memory
  79592. */
  79593. export class Buffer {
  79594. private _engine;
  79595. private _buffer;
  79596. /** @hidden */
  79597. _data: Nullable<DataArray>;
  79598. private _updatable;
  79599. private _instanced;
  79600. private _divisor;
  79601. /**
  79602. * Gets the byte stride.
  79603. */
  79604. readonly byteStride: number;
  79605. /**
  79606. * Constructor
  79607. * @param engine the engine
  79608. * @param data the data to use for this buffer
  79609. * @param updatable whether the data is updatable
  79610. * @param stride the stride (optional)
  79611. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79612. * @param instanced whether the buffer is instanced (optional)
  79613. * @param useBytes set to true if the stride in in bytes (optional)
  79614. * @param divisor sets an optional divisor for instances (1 by default)
  79615. */
  79616. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  79617. /**
  79618. * Create a new VertexBuffer based on the current buffer
  79619. * @param kind defines the vertex buffer kind (position, normal, etc.)
  79620. * @param offset defines offset in the buffer (0 by default)
  79621. * @param size defines the size in floats of attributes (position is 3 for instance)
  79622. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  79623. * @param instanced defines if the vertex buffer contains indexed data
  79624. * @param useBytes defines if the offset and stride are in bytes *
  79625. * @param divisor sets an optional divisor for instances (1 by default)
  79626. * @returns the new vertex buffer
  79627. */
  79628. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  79629. /**
  79630. * Gets a boolean indicating if the Buffer is updatable?
  79631. * @returns true if the buffer is updatable
  79632. */
  79633. isUpdatable(): boolean;
  79634. /**
  79635. * Gets current buffer's data
  79636. * @returns a DataArray or null
  79637. */
  79638. getData(): Nullable<DataArray>;
  79639. /**
  79640. * Gets underlying native buffer
  79641. * @returns underlying native buffer
  79642. */
  79643. getBuffer(): Nullable<DataBuffer>;
  79644. /**
  79645. * Gets the stride in float32 units (i.e. byte stride / 4).
  79646. * May not be an integer if the byte stride is not divisible by 4.
  79647. * @returns the stride in float32 units
  79648. * @deprecated Please use byteStride instead.
  79649. */
  79650. getStrideSize(): number;
  79651. /**
  79652. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79653. * @param data defines the data to store
  79654. */
  79655. create(data?: Nullable<DataArray>): void;
  79656. /** @hidden */
  79657. _rebuild(): void;
  79658. /**
  79659. * Update current buffer data
  79660. * @param data defines the data to store
  79661. */
  79662. update(data: DataArray): void;
  79663. /**
  79664. * Updates the data directly.
  79665. * @param data the new data
  79666. * @param offset the new offset
  79667. * @param vertexCount the vertex count (optional)
  79668. * @param useBytes set to true if the offset is in bytes
  79669. */
  79670. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  79671. /**
  79672. * Release all resources
  79673. */
  79674. dispose(): void;
  79675. }
  79676. /**
  79677. * Specialized buffer used to store vertex data
  79678. */
  79679. export class VertexBuffer {
  79680. /** @hidden */
  79681. _buffer: Buffer;
  79682. private _kind;
  79683. private _size;
  79684. private _ownsBuffer;
  79685. private _instanced;
  79686. private _instanceDivisor;
  79687. /**
  79688. * The byte type.
  79689. */
  79690. static readonly BYTE: number;
  79691. /**
  79692. * The unsigned byte type.
  79693. */
  79694. static readonly UNSIGNED_BYTE: number;
  79695. /**
  79696. * The short type.
  79697. */
  79698. static readonly SHORT: number;
  79699. /**
  79700. * The unsigned short type.
  79701. */
  79702. static readonly UNSIGNED_SHORT: number;
  79703. /**
  79704. * The integer type.
  79705. */
  79706. static readonly INT: number;
  79707. /**
  79708. * The unsigned integer type.
  79709. */
  79710. static readonly UNSIGNED_INT: number;
  79711. /**
  79712. * The float type.
  79713. */
  79714. static readonly FLOAT: number;
  79715. /**
  79716. * Gets or sets the instance divisor when in instanced mode
  79717. */
  79718. get instanceDivisor(): number;
  79719. set instanceDivisor(value: number);
  79720. /**
  79721. * Gets the byte stride.
  79722. */
  79723. readonly byteStride: number;
  79724. /**
  79725. * Gets the byte offset.
  79726. */
  79727. readonly byteOffset: number;
  79728. /**
  79729. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  79730. */
  79731. readonly normalized: boolean;
  79732. /**
  79733. * Gets the data type of each component in the array.
  79734. */
  79735. readonly type: number;
  79736. /**
  79737. * Constructor
  79738. * @param engine the engine
  79739. * @param data the data to use for this vertex buffer
  79740. * @param kind the vertex buffer kind
  79741. * @param updatable whether the data is updatable
  79742. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  79743. * @param stride the stride (optional)
  79744. * @param instanced whether the buffer is instanced (optional)
  79745. * @param offset the offset of the data (optional)
  79746. * @param size the number of components (optional)
  79747. * @param type the type of the component (optional)
  79748. * @param normalized whether the data contains normalized data (optional)
  79749. * @param useBytes set to true if stride and offset are in bytes (optional)
  79750. * @param divisor defines the instance divisor to use (1 by default)
  79751. */
  79752. 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);
  79753. /** @hidden */
  79754. _rebuild(): void;
  79755. /**
  79756. * Returns the kind of the VertexBuffer (string)
  79757. * @returns a string
  79758. */
  79759. getKind(): string;
  79760. /**
  79761. * Gets a boolean indicating if the VertexBuffer is updatable?
  79762. * @returns true if the buffer is updatable
  79763. */
  79764. isUpdatable(): boolean;
  79765. /**
  79766. * Gets current buffer's data
  79767. * @returns a DataArray or null
  79768. */
  79769. getData(): Nullable<DataArray>;
  79770. /**
  79771. * Gets underlying native buffer
  79772. * @returns underlying native buffer
  79773. */
  79774. getBuffer(): Nullable<DataBuffer>;
  79775. /**
  79776. * Gets the stride in float32 units (i.e. byte stride / 4).
  79777. * May not be an integer if the byte stride is not divisible by 4.
  79778. * @returns the stride in float32 units
  79779. * @deprecated Please use byteStride instead.
  79780. */
  79781. getStrideSize(): number;
  79782. /**
  79783. * Returns the offset as a multiple of the type byte length.
  79784. * @returns the offset in bytes
  79785. * @deprecated Please use byteOffset instead.
  79786. */
  79787. getOffset(): number;
  79788. /**
  79789. * Returns the number of components per vertex attribute (integer)
  79790. * @returns the size in float
  79791. */
  79792. getSize(): number;
  79793. /**
  79794. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  79795. * @returns true if this buffer is instanced
  79796. */
  79797. getIsInstanced(): boolean;
  79798. /**
  79799. * Returns the instancing divisor, zero for non-instanced (integer).
  79800. * @returns a number
  79801. */
  79802. getInstanceDivisor(): number;
  79803. /**
  79804. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  79805. * @param data defines the data to store
  79806. */
  79807. create(data?: DataArray): void;
  79808. /**
  79809. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  79810. * This function will create a new buffer if the current one is not updatable
  79811. * @param data defines the data to store
  79812. */
  79813. update(data: DataArray): void;
  79814. /**
  79815. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  79816. * Returns the directly updated WebGLBuffer.
  79817. * @param data the new data
  79818. * @param offset the new offset
  79819. * @param useBytes set to true if the offset is in bytes
  79820. */
  79821. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  79822. /**
  79823. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  79824. */
  79825. dispose(): void;
  79826. /**
  79827. * Enumerates each value of this vertex buffer as numbers.
  79828. * @param count the number of values to enumerate
  79829. * @param callback the callback function called for each value
  79830. */
  79831. forEach(count: number, callback: (value: number, index: number) => void): void;
  79832. /**
  79833. * Positions
  79834. */
  79835. static readonly PositionKind: string;
  79836. /**
  79837. * Normals
  79838. */
  79839. static readonly NormalKind: string;
  79840. /**
  79841. * Tangents
  79842. */
  79843. static readonly TangentKind: string;
  79844. /**
  79845. * Texture coordinates
  79846. */
  79847. static readonly UVKind: string;
  79848. /**
  79849. * Texture coordinates 2
  79850. */
  79851. static readonly UV2Kind: string;
  79852. /**
  79853. * Texture coordinates 3
  79854. */
  79855. static readonly UV3Kind: string;
  79856. /**
  79857. * Texture coordinates 4
  79858. */
  79859. static readonly UV4Kind: string;
  79860. /**
  79861. * Texture coordinates 5
  79862. */
  79863. static readonly UV5Kind: string;
  79864. /**
  79865. * Texture coordinates 6
  79866. */
  79867. static readonly UV6Kind: string;
  79868. /**
  79869. * Colors
  79870. */
  79871. static readonly ColorKind: string;
  79872. /**
  79873. * Matrix indices (for bones)
  79874. */
  79875. static readonly MatricesIndicesKind: string;
  79876. /**
  79877. * Matrix weights (for bones)
  79878. */
  79879. static readonly MatricesWeightsKind: string;
  79880. /**
  79881. * Additional matrix indices (for bones)
  79882. */
  79883. static readonly MatricesIndicesExtraKind: string;
  79884. /**
  79885. * Additional matrix weights (for bones)
  79886. */
  79887. static readonly MatricesWeightsExtraKind: string;
  79888. /**
  79889. * Deduces the stride given a kind.
  79890. * @param kind The kind string to deduce
  79891. * @returns The deduced stride
  79892. */
  79893. static DeduceStride(kind: string): number;
  79894. /**
  79895. * Gets the byte length of the given type.
  79896. * @param type the type
  79897. * @returns the number of bytes
  79898. */
  79899. static GetTypeByteLength(type: number): number;
  79900. /**
  79901. * Enumerates each value of the given parameters as numbers.
  79902. * @param data the data to enumerate
  79903. * @param byteOffset the byte offset of the data
  79904. * @param byteStride the byte stride of the data
  79905. * @param componentCount the number of components per element
  79906. * @param componentType the type of the component
  79907. * @param count the number of values to enumerate
  79908. * @param normalized whether the data is normalized
  79909. * @param callback the callback function called for each value
  79910. */
  79911. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  79912. private static _GetFloatValue;
  79913. }
  79914. }
  79915. declare module BABYLON {
  79916. /**
  79917. * @hidden
  79918. */
  79919. export class IntersectionInfo {
  79920. bu: Nullable<number>;
  79921. bv: Nullable<number>;
  79922. distance: number;
  79923. faceId: number;
  79924. subMeshId: number;
  79925. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  79926. }
  79927. }
  79928. declare module BABYLON {
  79929. /**
  79930. * Represens a plane by the equation ax + by + cz + d = 0
  79931. */
  79932. export class Plane {
  79933. private static _TmpMatrix;
  79934. /**
  79935. * Normal of the plane (a,b,c)
  79936. */
  79937. normal: Vector3;
  79938. /**
  79939. * d component of the plane
  79940. */
  79941. d: number;
  79942. /**
  79943. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  79944. * @param a a component of the plane
  79945. * @param b b component of the plane
  79946. * @param c c component of the plane
  79947. * @param d d component of the plane
  79948. */
  79949. constructor(a: number, b: number, c: number, d: number);
  79950. /**
  79951. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  79952. */
  79953. asArray(): number[];
  79954. /**
  79955. * @returns a new plane copied from the current Plane.
  79956. */
  79957. clone(): Plane;
  79958. /**
  79959. * @returns the string "Plane".
  79960. */
  79961. getClassName(): string;
  79962. /**
  79963. * @returns the Plane hash code.
  79964. */
  79965. getHashCode(): number;
  79966. /**
  79967. * Normalize the current Plane in place.
  79968. * @returns the updated Plane.
  79969. */
  79970. normalize(): Plane;
  79971. /**
  79972. * Applies a transformation the plane and returns the result
  79973. * @param transformation the transformation matrix to be applied to the plane
  79974. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  79975. */
  79976. transform(transformation: DeepImmutable<Matrix>): Plane;
  79977. /**
  79978. * Calcualtte the dot product between the point and the plane normal
  79979. * @param point point to calculate the dot product with
  79980. * @returns the dot product (float) of the point coordinates and the plane normal.
  79981. */
  79982. dotCoordinate(point: DeepImmutable<Vector3>): number;
  79983. /**
  79984. * Updates the current Plane from the plane defined by the three given points.
  79985. * @param point1 one of the points used to contruct the plane
  79986. * @param point2 one of the points used to contruct the plane
  79987. * @param point3 one of the points used to contruct the plane
  79988. * @returns the updated Plane.
  79989. */
  79990. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  79991. /**
  79992. * Checks if the plane is facing a given direction
  79993. * @param direction the direction to check if the plane is facing
  79994. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  79995. * @returns True is the vector "direction" is the same side than the plane normal.
  79996. */
  79997. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  79998. /**
  79999. * Calculates the distance to a point
  80000. * @param point point to calculate distance to
  80001. * @returns the signed distance (float) from the given point to the Plane.
  80002. */
  80003. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80004. /**
  80005. * Creates a plane from an array
  80006. * @param array the array to create a plane from
  80007. * @returns a new Plane from the given array.
  80008. */
  80009. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80010. /**
  80011. * Creates a plane from three points
  80012. * @param point1 point used to create the plane
  80013. * @param point2 point used to create the plane
  80014. * @param point3 point used to create the plane
  80015. * @returns a new Plane defined by the three given points.
  80016. */
  80017. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80018. /**
  80019. * Creates a plane from an origin point and a normal
  80020. * @param origin origin of the plane to be constructed
  80021. * @param normal normal of the plane to be constructed
  80022. * @returns a new Plane the normal vector to this plane at the given origin point.
  80023. * Note : the vector "normal" is updated because normalized.
  80024. */
  80025. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  80026. /**
  80027. * Calculates the distance from a plane and a point
  80028. * @param origin origin of the plane to be constructed
  80029. * @param normal normal of the plane to be constructed
  80030. * @param point point to calculate distance to
  80031. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  80032. */
  80033. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  80034. }
  80035. }
  80036. declare module BABYLON {
  80037. /**
  80038. * Class used to store bounding sphere information
  80039. */
  80040. export class BoundingSphere {
  80041. /**
  80042. * Gets the center of the bounding sphere in local space
  80043. */
  80044. readonly center: Vector3;
  80045. /**
  80046. * Radius of the bounding sphere in local space
  80047. */
  80048. radius: number;
  80049. /**
  80050. * Gets the center of the bounding sphere in world space
  80051. */
  80052. readonly centerWorld: Vector3;
  80053. /**
  80054. * Radius of the bounding sphere in world space
  80055. */
  80056. radiusWorld: number;
  80057. /**
  80058. * Gets the minimum vector in local space
  80059. */
  80060. readonly minimum: Vector3;
  80061. /**
  80062. * Gets the maximum vector in local space
  80063. */
  80064. readonly maximum: Vector3;
  80065. private _worldMatrix;
  80066. private static readonly TmpVector3;
  80067. /**
  80068. * Creates a new bounding sphere
  80069. * @param min defines the minimum vector (in local space)
  80070. * @param max defines the maximum vector (in local space)
  80071. * @param worldMatrix defines the new world matrix
  80072. */
  80073. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80074. /**
  80075. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  80076. * @param min defines the new minimum vector (in local space)
  80077. * @param max defines the new maximum vector (in local space)
  80078. * @param worldMatrix defines the new world matrix
  80079. */
  80080. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80081. /**
  80082. * Scale the current bounding sphere by applying a scale factor
  80083. * @param factor defines the scale factor to apply
  80084. * @returns the current bounding box
  80085. */
  80086. scale(factor: number): BoundingSphere;
  80087. /**
  80088. * Gets the world matrix of the bounding box
  80089. * @returns a matrix
  80090. */
  80091. getWorldMatrix(): DeepImmutable<Matrix>;
  80092. /** @hidden */
  80093. _update(worldMatrix: DeepImmutable<Matrix>): void;
  80094. /**
  80095. * Tests if the bounding sphere is intersecting the frustum planes
  80096. * @param frustumPlanes defines the frustum planes to test
  80097. * @returns true if there is an intersection
  80098. */
  80099. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80100. /**
  80101. * Tests if the bounding sphere center is in between the frustum planes.
  80102. * Used for optimistic fast inclusion.
  80103. * @param frustumPlanes defines the frustum planes to test
  80104. * @returns true if the sphere center is in between the frustum planes
  80105. */
  80106. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80107. /**
  80108. * Tests if a point is inside the bounding sphere
  80109. * @param point defines the point to test
  80110. * @returns true if the point is inside the bounding sphere
  80111. */
  80112. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80113. /**
  80114. * Checks if two sphere intersct
  80115. * @param sphere0 sphere 0
  80116. * @param sphere1 sphere 1
  80117. * @returns true if the speres intersect
  80118. */
  80119. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  80120. }
  80121. }
  80122. declare module BABYLON {
  80123. /**
  80124. * Class used to store bounding box information
  80125. */
  80126. export class BoundingBox implements ICullable {
  80127. /**
  80128. * Gets the 8 vectors representing the bounding box in local space
  80129. */
  80130. readonly vectors: Vector3[];
  80131. /**
  80132. * Gets the center of the bounding box in local space
  80133. */
  80134. readonly center: Vector3;
  80135. /**
  80136. * Gets the center of the bounding box in world space
  80137. */
  80138. readonly centerWorld: Vector3;
  80139. /**
  80140. * Gets the extend size in local space
  80141. */
  80142. readonly extendSize: Vector3;
  80143. /**
  80144. * Gets the extend size in world space
  80145. */
  80146. readonly extendSizeWorld: Vector3;
  80147. /**
  80148. * Gets the OBB (object bounding box) directions
  80149. */
  80150. readonly directions: Vector3[];
  80151. /**
  80152. * Gets the 8 vectors representing the bounding box in world space
  80153. */
  80154. readonly vectorsWorld: Vector3[];
  80155. /**
  80156. * Gets the minimum vector in world space
  80157. */
  80158. readonly minimumWorld: Vector3;
  80159. /**
  80160. * Gets the maximum vector in world space
  80161. */
  80162. readonly maximumWorld: Vector3;
  80163. /**
  80164. * Gets the minimum vector in local space
  80165. */
  80166. readonly minimum: Vector3;
  80167. /**
  80168. * Gets the maximum vector in local space
  80169. */
  80170. readonly maximum: Vector3;
  80171. private _worldMatrix;
  80172. private static readonly TmpVector3;
  80173. /**
  80174. * @hidden
  80175. */
  80176. _tag: number;
  80177. /**
  80178. * Creates a new bounding box
  80179. * @param min defines the minimum vector (in local space)
  80180. * @param max defines the maximum vector (in local space)
  80181. * @param worldMatrix defines the new world matrix
  80182. */
  80183. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80184. /**
  80185. * Recreates the entire bounding box from scratch as if we call the constructor in place
  80186. * @param min defines the new minimum vector (in local space)
  80187. * @param max defines the new maximum vector (in local space)
  80188. * @param worldMatrix defines the new world matrix
  80189. */
  80190. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80191. /**
  80192. * Scale the current bounding box by applying a scale factor
  80193. * @param factor defines the scale factor to apply
  80194. * @returns the current bounding box
  80195. */
  80196. scale(factor: number): BoundingBox;
  80197. /**
  80198. * Gets the world matrix of the bounding box
  80199. * @returns a matrix
  80200. */
  80201. getWorldMatrix(): DeepImmutable<Matrix>;
  80202. /** @hidden */
  80203. _update(world: DeepImmutable<Matrix>): void;
  80204. /**
  80205. * Tests if the bounding box is intersecting the frustum planes
  80206. * @param frustumPlanes defines the frustum planes to test
  80207. * @returns true if there is an intersection
  80208. */
  80209. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80210. /**
  80211. * Tests if the bounding box is entirely inside the frustum planes
  80212. * @param frustumPlanes defines the frustum planes to test
  80213. * @returns true if there is an inclusion
  80214. */
  80215. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80216. /**
  80217. * Tests if a point is inside the bounding box
  80218. * @param point defines the point to test
  80219. * @returns true if the point is inside the bounding box
  80220. */
  80221. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80222. /**
  80223. * Tests if the bounding box intersects with a bounding sphere
  80224. * @param sphere defines the sphere to test
  80225. * @returns true if there is an intersection
  80226. */
  80227. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  80228. /**
  80229. * Tests if the bounding box intersects with a box defined by a min and max vectors
  80230. * @param min defines the min vector to use
  80231. * @param max defines the max vector to use
  80232. * @returns true if there is an intersection
  80233. */
  80234. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  80235. /**
  80236. * Tests if two bounding boxes are intersections
  80237. * @param box0 defines the first box to test
  80238. * @param box1 defines the second box to test
  80239. * @returns true if there is an intersection
  80240. */
  80241. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  80242. /**
  80243. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  80244. * @param minPoint defines the minimum vector of the bounding box
  80245. * @param maxPoint defines the maximum vector of the bounding box
  80246. * @param sphereCenter defines the sphere center
  80247. * @param sphereRadius defines the sphere radius
  80248. * @returns true if there is an intersection
  80249. */
  80250. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  80251. /**
  80252. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  80253. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80254. * @param frustumPlanes defines the frustum planes to test
  80255. * @return true if there is an inclusion
  80256. */
  80257. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80258. /**
  80259. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  80260. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  80261. * @param frustumPlanes defines the frustum planes to test
  80262. * @return true if there is an intersection
  80263. */
  80264. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80265. }
  80266. }
  80267. declare module BABYLON {
  80268. /** @hidden */
  80269. export class Collider {
  80270. /** Define if a collision was found */
  80271. collisionFound: boolean;
  80272. /**
  80273. * Define last intersection point in local space
  80274. */
  80275. intersectionPoint: Vector3;
  80276. /**
  80277. * Define last collided mesh
  80278. */
  80279. collidedMesh: Nullable<AbstractMesh>;
  80280. private _collisionPoint;
  80281. private _planeIntersectionPoint;
  80282. private _tempVector;
  80283. private _tempVector2;
  80284. private _tempVector3;
  80285. private _tempVector4;
  80286. private _edge;
  80287. private _baseToVertex;
  80288. private _destinationPoint;
  80289. private _slidePlaneNormal;
  80290. private _displacementVector;
  80291. /** @hidden */
  80292. _radius: Vector3;
  80293. /** @hidden */
  80294. _retry: number;
  80295. private _velocity;
  80296. private _basePoint;
  80297. private _epsilon;
  80298. /** @hidden */
  80299. _velocityWorldLength: number;
  80300. /** @hidden */
  80301. _basePointWorld: Vector3;
  80302. private _velocityWorld;
  80303. private _normalizedVelocity;
  80304. /** @hidden */
  80305. _initialVelocity: Vector3;
  80306. /** @hidden */
  80307. _initialPosition: Vector3;
  80308. private _nearestDistance;
  80309. private _collisionMask;
  80310. get collisionMask(): number;
  80311. set collisionMask(mask: number);
  80312. /**
  80313. * Gets the plane normal used to compute the sliding response (in local space)
  80314. */
  80315. get slidePlaneNormal(): Vector3;
  80316. /** @hidden */
  80317. _initialize(source: Vector3, dir: Vector3, e: number): void;
  80318. /** @hidden */
  80319. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  80320. /** @hidden */
  80321. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  80322. /** @hidden */
  80323. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80324. /** @hidden */
  80325. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  80326. /** @hidden */
  80327. _getResponse(pos: Vector3, vel: Vector3): void;
  80328. }
  80329. }
  80330. declare module BABYLON {
  80331. /**
  80332. * Interface for cullable objects
  80333. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  80334. */
  80335. export interface ICullable {
  80336. /**
  80337. * Checks if the object or part of the object is in the frustum
  80338. * @param frustumPlanes Camera near/planes
  80339. * @returns true if the object is in frustum otherwise false
  80340. */
  80341. isInFrustum(frustumPlanes: Plane[]): boolean;
  80342. /**
  80343. * Checks if a cullable object (mesh...) is in the camera frustum
  80344. * Unlike isInFrustum this cheks the full bounding box
  80345. * @param frustumPlanes Camera near/planes
  80346. * @returns true if the object is in frustum otherwise false
  80347. */
  80348. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  80349. }
  80350. /**
  80351. * Info for a bounding data of a mesh
  80352. */
  80353. export class BoundingInfo implements ICullable {
  80354. /**
  80355. * Bounding box for the mesh
  80356. */
  80357. readonly boundingBox: BoundingBox;
  80358. /**
  80359. * Bounding sphere for the mesh
  80360. */
  80361. readonly boundingSphere: BoundingSphere;
  80362. private _isLocked;
  80363. private static readonly TmpVector3;
  80364. /**
  80365. * Constructs bounding info
  80366. * @param minimum min vector of the bounding box/sphere
  80367. * @param maximum max vector of the bounding box/sphere
  80368. * @param worldMatrix defines the new world matrix
  80369. */
  80370. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  80371. /**
  80372. * Recreates the entire bounding info from scratch as if we call the constructor in place
  80373. * @param min defines the new minimum vector (in local space)
  80374. * @param max defines the new maximum vector (in local space)
  80375. * @param worldMatrix defines the new world matrix
  80376. */
  80377. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  80378. /**
  80379. * min vector of the bounding box/sphere
  80380. */
  80381. get minimum(): Vector3;
  80382. /**
  80383. * max vector of the bounding box/sphere
  80384. */
  80385. get maximum(): Vector3;
  80386. /**
  80387. * If the info is locked and won't be updated to avoid perf overhead
  80388. */
  80389. get isLocked(): boolean;
  80390. set isLocked(value: boolean);
  80391. /**
  80392. * Updates the bounding sphere and box
  80393. * @param world world matrix to be used to update
  80394. */
  80395. update(world: DeepImmutable<Matrix>): void;
  80396. /**
  80397. * Recreate the bounding info to be centered around a specific point given a specific extend.
  80398. * @param center New center of the bounding info
  80399. * @param extend New extend of the bounding info
  80400. * @returns the current bounding info
  80401. */
  80402. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  80403. /**
  80404. * Scale the current bounding info by applying a scale factor
  80405. * @param factor defines the scale factor to apply
  80406. * @returns the current bounding info
  80407. */
  80408. scale(factor: number): BoundingInfo;
  80409. /**
  80410. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  80411. * @param frustumPlanes defines the frustum to test
  80412. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  80413. * @returns true if the bounding info is in the frustum planes
  80414. */
  80415. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  80416. /**
  80417. * Gets the world distance between the min and max points of the bounding box
  80418. */
  80419. get diagonalLength(): number;
  80420. /**
  80421. * Checks if a cullable object (mesh...) is in the camera frustum
  80422. * Unlike isInFrustum this cheks the full bounding box
  80423. * @param frustumPlanes Camera near/planes
  80424. * @returns true if the object is in frustum otherwise false
  80425. */
  80426. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  80427. /** @hidden */
  80428. _checkCollision(collider: Collider): boolean;
  80429. /**
  80430. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  80431. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80432. * @param point the point to check intersection with
  80433. * @returns if the point intersects
  80434. */
  80435. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  80436. /**
  80437. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  80438. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80439. * @param boundingInfo the bounding info to check intersection with
  80440. * @param precise if the intersection should be done using OBB
  80441. * @returns if the bounding info intersects
  80442. */
  80443. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  80444. }
  80445. }
  80446. declare module BABYLON {
  80447. /**
  80448. * Extracts minimum and maximum values from a list of indexed positions
  80449. * @param positions defines the positions to use
  80450. * @param indices defines the indices to the positions
  80451. * @param indexStart defines the start index
  80452. * @param indexCount defines the end index
  80453. * @param bias defines bias value to add to the result
  80454. * @return minimum and maximum values
  80455. */
  80456. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  80457. minimum: Vector3;
  80458. maximum: Vector3;
  80459. };
  80460. /**
  80461. * Extracts minimum and maximum values from a list of positions
  80462. * @param positions defines the positions to use
  80463. * @param start defines the start index in the positions array
  80464. * @param count defines the number of positions to handle
  80465. * @param bias defines bias value to add to the result
  80466. * @param stride defines the stride size to use (distance between two positions in the positions array)
  80467. * @return minimum and maximum values
  80468. */
  80469. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  80470. minimum: Vector3;
  80471. maximum: Vector3;
  80472. };
  80473. }
  80474. declare module BABYLON {
  80475. /** @hidden */
  80476. export class WebGLDataBuffer extends DataBuffer {
  80477. private _buffer;
  80478. constructor(resource: WebGLBuffer);
  80479. get underlyingResource(): any;
  80480. }
  80481. }
  80482. declare module BABYLON {
  80483. /** @hidden */
  80484. export class WebGLPipelineContext implements IPipelineContext {
  80485. engine: ThinEngine;
  80486. program: Nullable<WebGLProgram>;
  80487. context?: WebGLRenderingContext;
  80488. vertexShader?: WebGLShader;
  80489. fragmentShader?: WebGLShader;
  80490. isParallelCompiled: boolean;
  80491. onCompiled?: () => void;
  80492. transformFeedback?: WebGLTransformFeedback | null;
  80493. vertexCompilationError: Nullable<string>;
  80494. fragmentCompilationError: Nullable<string>;
  80495. programLinkError: Nullable<string>;
  80496. programValidationError: Nullable<string>;
  80497. get isAsync(): boolean;
  80498. get isReady(): boolean;
  80499. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  80500. }
  80501. }
  80502. declare module BABYLON {
  80503. interface ThinEngine {
  80504. /**
  80505. * Create an uniform buffer
  80506. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80507. * @param elements defines the content of the uniform buffer
  80508. * @returns the webGL uniform buffer
  80509. */
  80510. createUniformBuffer(elements: FloatArray): DataBuffer;
  80511. /**
  80512. * Create a dynamic uniform buffer
  80513. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80514. * @param elements defines the content of the uniform buffer
  80515. * @returns the webGL uniform buffer
  80516. */
  80517. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  80518. /**
  80519. * Update an existing uniform buffer
  80520. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  80521. * @param uniformBuffer defines the target uniform buffer
  80522. * @param elements defines the content to update
  80523. * @param offset defines the offset in the uniform buffer where update should start
  80524. * @param count defines the size of the data to update
  80525. */
  80526. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  80527. /**
  80528. * Bind an uniform buffer to the current webGL context
  80529. * @param buffer defines the buffer to bind
  80530. */
  80531. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  80532. /**
  80533. * Bind a buffer to the current webGL context at a given location
  80534. * @param buffer defines the buffer to bind
  80535. * @param location defines the index where to bind the buffer
  80536. */
  80537. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  80538. /**
  80539. * Bind a specific block at a given index in a specific shader program
  80540. * @param pipelineContext defines the pipeline context to use
  80541. * @param blockName defines the block name
  80542. * @param index defines the index where to bind the block
  80543. */
  80544. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  80545. }
  80546. }
  80547. declare module BABYLON {
  80548. /**
  80549. * Uniform buffer objects.
  80550. *
  80551. * Handles blocks of uniform on the GPU.
  80552. *
  80553. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80554. *
  80555. * For more information, please refer to :
  80556. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80557. */
  80558. export class UniformBuffer {
  80559. private _engine;
  80560. private _buffer;
  80561. private _data;
  80562. private _bufferData;
  80563. private _dynamic?;
  80564. private _uniformLocations;
  80565. private _uniformSizes;
  80566. private _uniformLocationPointer;
  80567. private _needSync;
  80568. private _noUBO;
  80569. private _currentEffect;
  80570. /** @hidden */
  80571. _alreadyBound: boolean;
  80572. private static _MAX_UNIFORM_SIZE;
  80573. private static _tempBuffer;
  80574. /**
  80575. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  80576. * This is dynamic to allow compat with webgl 1 and 2.
  80577. * You will need to pass the name of the uniform as well as the value.
  80578. */
  80579. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  80580. /**
  80581. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  80582. * This is dynamic to allow compat with webgl 1 and 2.
  80583. * You will need to pass the name of the uniform as well as the value.
  80584. */
  80585. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  80586. /**
  80587. * Lambda to Update a single float in a uniform buffer.
  80588. * This is dynamic to allow compat with webgl 1 and 2.
  80589. * You will need to pass the name of the uniform as well as the value.
  80590. */
  80591. updateFloat: (name: string, x: number) => void;
  80592. /**
  80593. * Lambda to Update a vec2 of float in a uniform buffer.
  80594. * This is dynamic to allow compat with webgl 1 and 2.
  80595. * You will need to pass the name of the uniform as well as the value.
  80596. */
  80597. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  80598. /**
  80599. * Lambda to Update a vec3 of float in a uniform buffer.
  80600. * This is dynamic to allow compat with webgl 1 and 2.
  80601. * You will need to pass the name of the uniform as well as the value.
  80602. */
  80603. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  80604. /**
  80605. * Lambda to Update a vec4 of float in a uniform buffer.
  80606. * This is dynamic to allow compat with webgl 1 and 2.
  80607. * You will need to pass the name of the uniform as well as the value.
  80608. */
  80609. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  80610. /**
  80611. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  80612. * This is dynamic to allow compat with webgl 1 and 2.
  80613. * You will need to pass the name of the uniform as well as the value.
  80614. */
  80615. updateMatrix: (name: string, mat: Matrix) => void;
  80616. /**
  80617. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  80618. * This is dynamic to allow compat with webgl 1 and 2.
  80619. * You will need to pass the name of the uniform as well as the value.
  80620. */
  80621. updateVector3: (name: string, vector: Vector3) => void;
  80622. /**
  80623. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  80624. * This is dynamic to allow compat with webgl 1 and 2.
  80625. * You will need to pass the name of the uniform as well as the value.
  80626. */
  80627. updateVector4: (name: string, vector: Vector4) => void;
  80628. /**
  80629. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  80630. * This is dynamic to allow compat with webgl 1 and 2.
  80631. * You will need to pass the name of the uniform as well as the value.
  80632. */
  80633. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  80634. /**
  80635. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  80636. * This is dynamic to allow compat with webgl 1 and 2.
  80637. * You will need to pass the name of the uniform as well as the value.
  80638. */
  80639. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  80640. /**
  80641. * Instantiates a new Uniform buffer objects.
  80642. *
  80643. * Handles blocks of uniform on the GPU.
  80644. *
  80645. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  80646. *
  80647. * For more information, please refer to :
  80648. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  80649. * @param engine Define the engine the buffer is associated with
  80650. * @param data Define the data contained in the buffer
  80651. * @param dynamic Define if the buffer is updatable
  80652. */
  80653. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  80654. /**
  80655. * Indicates if the buffer is using the WebGL2 UBO implementation,
  80656. * or just falling back on setUniformXXX calls.
  80657. */
  80658. get useUbo(): boolean;
  80659. /**
  80660. * Indicates if the WebGL underlying uniform buffer is in sync
  80661. * with the javascript cache data.
  80662. */
  80663. get isSync(): boolean;
  80664. /**
  80665. * Indicates if the WebGL underlying uniform buffer is dynamic.
  80666. * Also, a dynamic UniformBuffer will disable cache verification and always
  80667. * update the underlying WebGL uniform buffer to the GPU.
  80668. * @returns if Dynamic, otherwise false
  80669. */
  80670. isDynamic(): boolean;
  80671. /**
  80672. * The data cache on JS side.
  80673. * @returns the underlying data as a float array
  80674. */
  80675. getData(): Float32Array;
  80676. /**
  80677. * The underlying WebGL Uniform buffer.
  80678. * @returns the webgl buffer
  80679. */
  80680. getBuffer(): Nullable<DataBuffer>;
  80681. /**
  80682. * std140 layout specifies how to align data within an UBO structure.
  80683. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  80684. * for specs.
  80685. */
  80686. private _fillAlignment;
  80687. /**
  80688. * Adds an uniform in the buffer.
  80689. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  80690. * for the layout to be correct !
  80691. * @param name Name of the uniform, as used in the uniform block in the shader.
  80692. * @param size Data size, or data directly.
  80693. */
  80694. addUniform(name: string, size: number | number[]): void;
  80695. /**
  80696. * Adds a Matrix 4x4 to the uniform buffer.
  80697. * @param name Name of the uniform, as used in the uniform block in the shader.
  80698. * @param mat A 4x4 matrix.
  80699. */
  80700. addMatrix(name: string, mat: Matrix): void;
  80701. /**
  80702. * Adds a vec2 to the uniform buffer.
  80703. * @param name Name of the uniform, as used in the uniform block in the shader.
  80704. * @param x Define the x component value of the vec2
  80705. * @param y Define the y component value of the vec2
  80706. */
  80707. addFloat2(name: string, x: number, y: number): void;
  80708. /**
  80709. * Adds a vec3 to the uniform buffer.
  80710. * @param name Name of the uniform, as used in the uniform block in the shader.
  80711. * @param x Define the x component value of the vec3
  80712. * @param y Define the y component value of the vec3
  80713. * @param z Define the z component value of the vec3
  80714. */
  80715. addFloat3(name: string, x: number, y: number, z: number): void;
  80716. /**
  80717. * Adds a vec3 to the uniform buffer.
  80718. * @param name Name of the uniform, as used in the uniform block in the shader.
  80719. * @param color Define the vec3 from a Color
  80720. */
  80721. addColor3(name: string, color: Color3): void;
  80722. /**
  80723. * Adds a vec4 to the uniform buffer.
  80724. * @param name Name of the uniform, as used in the uniform block in the shader.
  80725. * @param color Define the rgb components from a Color
  80726. * @param alpha Define the a component of the vec4
  80727. */
  80728. addColor4(name: string, color: Color3, alpha: number): void;
  80729. /**
  80730. * Adds a vec3 to the uniform buffer.
  80731. * @param name Name of the uniform, as used in the uniform block in the shader.
  80732. * @param vector Define the vec3 components from a Vector
  80733. */
  80734. addVector3(name: string, vector: Vector3): void;
  80735. /**
  80736. * Adds a Matrix 3x3 to the uniform buffer.
  80737. * @param name Name of the uniform, as used in the uniform block in the shader.
  80738. */
  80739. addMatrix3x3(name: string): void;
  80740. /**
  80741. * Adds a Matrix 2x2 to the uniform buffer.
  80742. * @param name Name of the uniform, as used in the uniform block in the shader.
  80743. */
  80744. addMatrix2x2(name: string): void;
  80745. /**
  80746. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  80747. */
  80748. create(): void;
  80749. /** @hidden */
  80750. _rebuild(): void;
  80751. /**
  80752. * Updates the WebGL Uniform Buffer on the GPU.
  80753. * If the `dynamic` flag is set to true, no cache comparison is done.
  80754. * Otherwise, the buffer will be updated only if the cache differs.
  80755. */
  80756. update(): void;
  80757. /**
  80758. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  80759. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80760. * @param data Define the flattened data
  80761. * @param size Define the size of the data.
  80762. */
  80763. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  80764. private _valueCache;
  80765. private _cacheMatrix;
  80766. private _updateMatrix3x3ForUniform;
  80767. private _updateMatrix3x3ForEffect;
  80768. private _updateMatrix2x2ForEffect;
  80769. private _updateMatrix2x2ForUniform;
  80770. private _updateFloatForEffect;
  80771. private _updateFloatForUniform;
  80772. private _updateFloat2ForEffect;
  80773. private _updateFloat2ForUniform;
  80774. private _updateFloat3ForEffect;
  80775. private _updateFloat3ForUniform;
  80776. private _updateFloat4ForEffect;
  80777. private _updateFloat4ForUniform;
  80778. private _updateMatrixForEffect;
  80779. private _updateMatrixForUniform;
  80780. private _updateVector3ForEffect;
  80781. private _updateVector3ForUniform;
  80782. private _updateVector4ForEffect;
  80783. private _updateVector4ForUniform;
  80784. private _updateColor3ForEffect;
  80785. private _updateColor3ForUniform;
  80786. private _updateColor4ForEffect;
  80787. private _updateColor4ForUniform;
  80788. /**
  80789. * Sets a sampler uniform on the effect.
  80790. * @param name Define the name of the sampler.
  80791. * @param texture Define the texture to set in the sampler
  80792. */
  80793. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  80794. /**
  80795. * Directly updates the value of the uniform in the cache AND on the GPU.
  80796. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  80797. * @param data Define the flattened data
  80798. */
  80799. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  80800. /**
  80801. * Binds this uniform buffer to an effect.
  80802. * @param effect Define the effect to bind the buffer to
  80803. * @param name Name of the uniform block in the shader.
  80804. */
  80805. bindToEffect(effect: Effect, name: string): void;
  80806. /**
  80807. * Disposes the uniform buffer.
  80808. */
  80809. dispose(): void;
  80810. }
  80811. }
  80812. declare module BABYLON {
  80813. /**
  80814. * Enum that determines the text-wrapping mode to use.
  80815. */
  80816. export enum InspectableType {
  80817. /**
  80818. * Checkbox for booleans
  80819. */
  80820. Checkbox = 0,
  80821. /**
  80822. * Sliders for numbers
  80823. */
  80824. Slider = 1,
  80825. /**
  80826. * Vector3
  80827. */
  80828. Vector3 = 2,
  80829. /**
  80830. * Quaternions
  80831. */
  80832. Quaternion = 3,
  80833. /**
  80834. * Color3
  80835. */
  80836. Color3 = 4,
  80837. /**
  80838. * String
  80839. */
  80840. String = 5
  80841. }
  80842. /**
  80843. * Interface used to define custom inspectable properties.
  80844. * This interface is used by the inspector to display custom property grids
  80845. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80846. */
  80847. export interface IInspectable {
  80848. /**
  80849. * Gets the label to display
  80850. */
  80851. label: string;
  80852. /**
  80853. * Gets the name of the property to edit
  80854. */
  80855. propertyName: string;
  80856. /**
  80857. * Gets the type of the editor to use
  80858. */
  80859. type: InspectableType;
  80860. /**
  80861. * Gets the minimum value of the property when using in "slider" mode
  80862. */
  80863. min?: number;
  80864. /**
  80865. * Gets the maximum value of the property when using in "slider" mode
  80866. */
  80867. max?: number;
  80868. /**
  80869. * Gets the setp to use when using in "slider" mode
  80870. */
  80871. step?: number;
  80872. }
  80873. }
  80874. declare module BABYLON {
  80875. /**
  80876. * Class used to provide helper for timing
  80877. */
  80878. export class TimingTools {
  80879. /**
  80880. * Polyfill for setImmediate
  80881. * @param action defines the action to execute after the current execution block
  80882. */
  80883. static SetImmediate(action: () => void): void;
  80884. }
  80885. }
  80886. declare module BABYLON {
  80887. /**
  80888. * Class used to enable instatition of objects by class name
  80889. */
  80890. export class InstantiationTools {
  80891. /**
  80892. * Use this object to register external classes like custom textures or material
  80893. * to allow the laoders to instantiate them
  80894. */
  80895. static RegisteredExternalClasses: {
  80896. [key: string]: Object;
  80897. };
  80898. /**
  80899. * Tries to instantiate a new object from a given class name
  80900. * @param className defines the class name to instantiate
  80901. * @returns the new object or null if the system was not able to do the instantiation
  80902. */
  80903. static Instantiate(className: string): any;
  80904. }
  80905. }
  80906. declare module BABYLON {
  80907. /**
  80908. * Define options used to create a depth texture
  80909. */
  80910. export class DepthTextureCreationOptions {
  80911. /** Specifies whether or not a stencil should be allocated in the texture */
  80912. generateStencil?: boolean;
  80913. /** Specifies whether or not bilinear filtering is enable on the texture */
  80914. bilinearFiltering?: boolean;
  80915. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  80916. comparisonFunction?: number;
  80917. /** Specifies if the created texture is a cube texture */
  80918. isCube?: boolean;
  80919. }
  80920. }
  80921. declare module BABYLON {
  80922. interface ThinEngine {
  80923. /**
  80924. * Creates a depth stencil cube texture.
  80925. * This is only available in WebGL 2.
  80926. * @param size The size of face edge in the cube texture.
  80927. * @param options The options defining the cube texture.
  80928. * @returns The cube texture
  80929. */
  80930. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  80931. /**
  80932. * Creates a cube texture
  80933. * @param rootUrl defines the url where the files to load is located
  80934. * @param scene defines the current scene
  80935. * @param files defines the list of files to load (1 per face)
  80936. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80937. * @param onLoad defines an optional callback raised when the texture is loaded
  80938. * @param onError defines an optional callback raised if there is an issue to load the texture
  80939. * @param format defines the format of the data
  80940. * @param forcedExtension defines the extension to use to pick the right loader
  80941. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80942. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80943. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80944. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  80945. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  80946. * @returns the cube texture as an InternalTexture
  80947. */
  80948. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap: boolean | undefined, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>, format: number | undefined, forcedExtension: any, createPolynomials: boolean, lodScale: number, lodOffset: number, fallback: Nullable<InternalTexture>, excludeLoaders: Array<IInternalTextureLoader>): InternalTexture;
  80949. /**
  80950. * Creates a cube texture
  80951. * @param rootUrl defines the url where the files to load is located
  80952. * @param scene defines the current scene
  80953. * @param files defines the list of files to load (1 per face)
  80954. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80955. * @param onLoad defines an optional callback raised when the texture is loaded
  80956. * @param onError defines an optional callback raised if there is an issue to load the texture
  80957. * @param format defines the format of the data
  80958. * @param forcedExtension defines the extension to use to pick the right loader
  80959. * @returns the cube texture as an InternalTexture
  80960. */
  80961. 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;
  80962. /**
  80963. * Creates a cube texture
  80964. * @param rootUrl defines the url where the files to load is located
  80965. * @param scene defines the current scene
  80966. * @param files defines the list of files to load (1 per face)
  80967. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  80968. * @param onLoad defines an optional callback raised when the texture is loaded
  80969. * @param onError defines an optional callback raised if there is an issue to load the texture
  80970. * @param format defines the format of the data
  80971. * @param forcedExtension defines the extension to use to pick the right loader
  80972. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  80973. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  80974. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  80975. * @returns the cube texture as an InternalTexture
  80976. */
  80977. 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;
  80978. /** @hidden */
  80979. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  80980. /** @hidden */
  80981. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  80982. /** @hidden */
  80983. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80984. /** @hidden */
  80985. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  80986. /**
  80987. * @hidden
  80988. */
  80989. _setCubeMapTextureParams(loadMipmap: boolean): void;
  80990. }
  80991. }
  80992. declare module BABYLON {
  80993. /**
  80994. * Class for creating a cube texture
  80995. */
  80996. export class CubeTexture extends BaseTexture {
  80997. private _delayedOnLoad;
  80998. /**
  80999. * Observable triggered once the texture has been loaded.
  81000. */
  81001. onLoadObservable: Observable<CubeTexture>;
  81002. /**
  81003. * The url of the texture
  81004. */
  81005. url: string;
  81006. /**
  81007. * Gets or sets the center of the bounding box associated with the cube texture.
  81008. * It must define where the camera used to render the texture was set
  81009. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81010. */
  81011. boundingBoxPosition: Vector3;
  81012. private _boundingBoxSize;
  81013. /**
  81014. * Gets or sets the size of the bounding box associated with the cube texture
  81015. * When defined, the cubemap will switch to local mode
  81016. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  81017. * @example https://www.babylonjs-playground.com/#RNASML
  81018. */
  81019. set boundingBoxSize(value: Vector3);
  81020. /**
  81021. * Returns the bounding box size
  81022. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81023. */
  81024. get boundingBoxSize(): Vector3;
  81025. protected _rotationY: number;
  81026. /**
  81027. * Sets texture matrix rotation angle around Y axis in radians.
  81028. */
  81029. set rotationY(value: number);
  81030. /**
  81031. * Gets texture matrix rotation angle around Y axis radians.
  81032. */
  81033. get rotationY(): number;
  81034. /**
  81035. * Are mip maps generated for this texture or not.
  81036. */
  81037. get noMipmap(): boolean;
  81038. private _noMipmap;
  81039. private _files;
  81040. protected _forcedExtension: Nullable<string>;
  81041. private _extensions;
  81042. private _textureMatrix;
  81043. private _format;
  81044. private _createPolynomials;
  81045. /** @hidden */
  81046. _prefiltered: boolean;
  81047. /**
  81048. * Creates a cube texture from an array of image urls
  81049. * @param files defines an array of image urls
  81050. * @param scene defines the hosting scene
  81051. * @param noMipmap specifies if mip maps are not used
  81052. * @returns a cube texture
  81053. */
  81054. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  81055. /**
  81056. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  81057. * @param url defines the url of the prefiltered texture
  81058. * @param scene defines the scene the texture is attached to
  81059. * @param forcedExtension defines the extension of the file if different from the url
  81060. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81061. * @return the prefiltered texture
  81062. */
  81063. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  81064. /**
  81065. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  81066. * as prefiltered data.
  81067. * @param rootUrl defines the url of the texture or the root name of the six images
  81068. * @param scene defines the scene the texture is attached to
  81069. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  81070. * @param noMipmap defines if mipmaps should be created or not
  81071. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  81072. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  81073. * @param onError defines a callback triggered in case of error during load
  81074. * @param format defines the internal format to use for the texture once loaded
  81075. * @param prefiltered defines whether or not the texture is created from prefiltered data
  81076. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  81077. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  81078. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81079. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81080. * @return the cube texture
  81081. */
  81082. 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);
  81083. /**
  81084. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  81085. */
  81086. get isPrefiltered(): boolean;
  81087. /**
  81088. * Get the current class name of the texture useful for serialization or dynamic coding.
  81089. * @returns "CubeTexture"
  81090. */
  81091. getClassName(): string;
  81092. /**
  81093. * Update the url (and optional buffer) of this texture if url was null during construction.
  81094. * @param url the url of the texture
  81095. * @param forcedExtension defines the extension to use
  81096. * @param onLoad callback called when the texture is loaded (defaults to null)
  81097. * @param prefiltered Defines whether the updated texture is prefiltered or not
  81098. */
  81099. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  81100. /**
  81101. * Delays loading of the cube texture
  81102. * @param forcedExtension defines the extension to use
  81103. */
  81104. delayLoad(forcedExtension?: string): void;
  81105. /**
  81106. * Returns the reflection texture matrix
  81107. * @returns the reflection texture matrix
  81108. */
  81109. getReflectionTextureMatrix(): Matrix;
  81110. /**
  81111. * Sets the reflection texture matrix
  81112. * @param value Reflection texture matrix
  81113. */
  81114. setReflectionTextureMatrix(value: Matrix): void;
  81115. /**
  81116. * Parses text to create a cube texture
  81117. * @param parsedTexture define the serialized text to read from
  81118. * @param scene defines the hosting scene
  81119. * @param rootUrl defines the root url of the cube texture
  81120. * @returns a cube texture
  81121. */
  81122. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  81123. /**
  81124. * Makes a clone, or deep copy, of the cube texture
  81125. * @returns a new cube texture
  81126. */
  81127. clone(): CubeTexture;
  81128. }
  81129. }
  81130. declare module BABYLON {
  81131. /**
  81132. * Manages the defines for the Material
  81133. */
  81134. export class MaterialDefines {
  81135. /** @hidden */
  81136. protected _keys: string[];
  81137. private _isDirty;
  81138. /** @hidden */
  81139. _renderId: number;
  81140. /** @hidden */
  81141. _areLightsDirty: boolean;
  81142. /** @hidden */
  81143. _areLightsDisposed: boolean;
  81144. /** @hidden */
  81145. _areAttributesDirty: boolean;
  81146. /** @hidden */
  81147. _areTexturesDirty: boolean;
  81148. /** @hidden */
  81149. _areFresnelDirty: boolean;
  81150. /** @hidden */
  81151. _areMiscDirty: boolean;
  81152. /** @hidden */
  81153. _areImageProcessingDirty: boolean;
  81154. /** @hidden */
  81155. _normals: boolean;
  81156. /** @hidden */
  81157. _uvs: boolean;
  81158. /** @hidden */
  81159. _needNormals: boolean;
  81160. /** @hidden */
  81161. _needUVs: boolean;
  81162. [id: string]: any;
  81163. /**
  81164. * Specifies if the material needs to be re-calculated
  81165. */
  81166. get isDirty(): boolean;
  81167. /**
  81168. * Marks the material to indicate that it has been re-calculated
  81169. */
  81170. markAsProcessed(): void;
  81171. /**
  81172. * Marks the material to indicate that it needs to be re-calculated
  81173. */
  81174. markAsUnprocessed(): void;
  81175. /**
  81176. * Marks the material to indicate all of its defines need to be re-calculated
  81177. */
  81178. markAllAsDirty(): void;
  81179. /**
  81180. * Marks the material to indicate that image processing needs to be re-calculated
  81181. */
  81182. markAsImageProcessingDirty(): void;
  81183. /**
  81184. * Marks the material to indicate the lights need to be re-calculated
  81185. * @param disposed Defines whether the light is dirty due to dispose or not
  81186. */
  81187. markAsLightDirty(disposed?: boolean): void;
  81188. /**
  81189. * Marks the attribute state as changed
  81190. */
  81191. markAsAttributesDirty(): void;
  81192. /**
  81193. * Marks the texture state as changed
  81194. */
  81195. markAsTexturesDirty(): void;
  81196. /**
  81197. * Marks the fresnel state as changed
  81198. */
  81199. markAsFresnelDirty(): void;
  81200. /**
  81201. * Marks the misc state as changed
  81202. */
  81203. markAsMiscDirty(): void;
  81204. /**
  81205. * Rebuilds the material defines
  81206. */
  81207. rebuild(): void;
  81208. /**
  81209. * Specifies if two material defines are equal
  81210. * @param other - A material define instance to compare to
  81211. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  81212. */
  81213. isEqual(other: MaterialDefines): boolean;
  81214. /**
  81215. * Clones this instance's defines to another instance
  81216. * @param other - material defines to clone values to
  81217. */
  81218. cloneTo(other: MaterialDefines): void;
  81219. /**
  81220. * Resets the material define values
  81221. */
  81222. reset(): void;
  81223. /**
  81224. * Converts the material define values to a string
  81225. * @returns - String of material define information
  81226. */
  81227. toString(): string;
  81228. }
  81229. }
  81230. declare module BABYLON {
  81231. /**
  81232. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  81233. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  81234. * 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;
  81235. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  81236. */
  81237. export class ColorCurves {
  81238. private _dirty;
  81239. private _tempColor;
  81240. private _globalCurve;
  81241. private _highlightsCurve;
  81242. private _midtonesCurve;
  81243. private _shadowsCurve;
  81244. private _positiveCurve;
  81245. private _negativeCurve;
  81246. private _globalHue;
  81247. private _globalDensity;
  81248. private _globalSaturation;
  81249. private _globalExposure;
  81250. /**
  81251. * Gets the global Hue value.
  81252. * 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).
  81253. */
  81254. get globalHue(): number;
  81255. /**
  81256. * Sets the global Hue value.
  81257. * 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).
  81258. */
  81259. set globalHue(value: number);
  81260. /**
  81261. * Gets the global Density value.
  81262. * 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.
  81263. * Values less than zero provide a filter of opposite hue.
  81264. */
  81265. get globalDensity(): number;
  81266. /**
  81267. * Sets the global Density value.
  81268. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  81269. * Values less than zero provide a filter of opposite hue.
  81270. */
  81271. set globalDensity(value: number);
  81272. /**
  81273. * Gets the global Saturation value.
  81274. * 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.
  81275. */
  81276. get globalSaturation(): number;
  81277. /**
  81278. * Sets the global Saturation value.
  81279. * 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.
  81280. */
  81281. set globalSaturation(value: number);
  81282. /**
  81283. * Gets the global Exposure value.
  81284. * 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.
  81285. */
  81286. get globalExposure(): number;
  81287. /**
  81288. * Sets the global Exposure value.
  81289. * 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.
  81290. */
  81291. set globalExposure(value: number);
  81292. private _highlightsHue;
  81293. private _highlightsDensity;
  81294. private _highlightsSaturation;
  81295. private _highlightsExposure;
  81296. /**
  81297. * Gets the highlights Hue value.
  81298. * 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).
  81299. */
  81300. get highlightsHue(): number;
  81301. /**
  81302. * Sets the highlights Hue value.
  81303. * 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).
  81304. */
  81305. set highlightsHue(value: number);
  81306. /**
  81307. * Gets the highlights Density value.
  81308. * 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.
  81309. * Values less than zero provide a filter of opposite hue.
  81310. */
  81311. get highlightsDensity(): number;
  81312. /**
  81313. * Sets the highlights Density value.
  81314. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  81315. * Values less than zero provide a filter of opposite hue.
  81316. */
  81317. set highlightsDensity(value: number);
  81318. /**
  81319. * Gets the highlights Saturation value.
  81320. * 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.
  81321. */
  81322. get highlightsSaturation(): number;
  81323. /**
  81324. * Sets the highlights Saturation value.
  81325. * 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.
  81326. */
  81327. set highlightsSaturation(value: number);
  81328. /**
  81329. * Gets the highlights Exposure value.
  81330. * 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.
  81331. */
  81332. get highlightsExposure(): number;
  81333. /**
  81334. * Sets the highlights Exposure value.
  81335. * 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.
  81336. */
  81337. set highlightsExposure(value: number);
  81338. private _midtonesHue;
  81339. private _midtonesDensity;
  81340. private _midtonesSaturation;
  81341. private _midtonesExposure;
  81342. /**
  81343. * Gets the midtones Hue value.
  81344. * 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).
  81345. */
  81346. get midtonesHue(): number;
  81347. /**
  81348. * Sets the midtones Hue value.
  81349. * 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).
  81350. */
  81351. set midtonesHue(value: number);
  81352. /**
  81353. * Gets the midtones Density value.
  81354. * 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.
  81355. * Values less than zero provide a filter of opposite hue.
  81356. */
  81357. get midtonesDensity(): number;
  81358. /**
  81359. * Sets the midtones Density value.
  81360. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  81361. * Values less than zero provide a filter of opposite hue.
  81362. */
  81363. set midtonesDensity(value: number);
  81364. /**
  81365. * Gets the midtones Saturation value.
  81366. * 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.
  81367. */
  81368. get midtonesSaturation(): number;
  81369. /**
  81370. * Sets the midtones Saturation value.
  81371. * 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.
  81372. */
  81373. set midtonesSaturation(value: number);
  81374. /**
  81375. * Gets the midtones Exposure value.
  81376. * 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.
  81377. */
  81378. get midtonesExposure(): number;
  81379. /**
  81380. * Sets the midtones Exposure value.
  81381. * 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.
  81382. */
  81383. set midtonesExposure(value: number);
  81384. private _shadowsHue;
  81385. private _shadowsDensity;
  81386. private _shadowsSaturation;
  81387. private _shadowsExposure;
  81388. /**
  81389. * Gets the shadows Hue value.
  81390. * 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).
  81391. */
  81392. get shadowsHue(): number;
  81393. /**
  81394. * Sets the shadows Hue value.
  81395. * 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).
  81396. */
  81397. set shadowsHue(value: number);
  81398. /**
  81399. * Gets the shadows Density value.
  81400. * 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.
  81401. * Values less than zero provide a filter of opposite hue.
  81402. */
  81403. get shadowsDensity(): number;
  81404. /**
  81405. * Sets the shadows Density value.
  81406. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  81407. * Values less than zero provide a filter of opposite hue.
  81408. */
  81409. set shadowsDensity(value: number);
  81410. /**
  81411. * Gets the shadows Saturation value.
  81412. * 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.
  81413. */
  81414. get shadowsSaturation(): number;
  81415. /**
  81416. * Sets the shadows Saturation value.
  81417. * 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.
  81418. */
  81419. set shadowsSaturation(value: number);
  81420. /**
  81421. * Gets the shadows Exposure value.
  81422. * 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.
  81423. */
  81424. get shadowsExposure(): number;
  81425. /**
  81426. * Sets the shadows Exposure value.
  81427. * 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.
  81428. */
  81429. set shadowsExposure(value: number);
  81430. /**
  81431. * Returns the class name
  81432. * @returns The class name
  81433. */
  81434. getClassName(): string;
  81435. /**
  81436. * Binds the color curves to the shader.
  81437. * @param colorCurves The color curve to bind
  81438. * @param effect The effect to bind to
  81439. * @param positiveUniform The positive uniform shader parameter
  81440. * @param neutralUniform The neutral uniform shader parameter
  81441. * @param negativeUniform The negative uniform shader parameter
  81442. */
  81443. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  81444. /**
  81445. * Prepare the list of uniforms associated with the ColorCurves effects.
  81446. * @param uniformsList The list of uniforms used in the effect
  81447. */
  81448. static PrepareUniforms(uniformsList: string[]): void;
  81449. /**
  81450. * Returns color grading data based on a hue, density, saturation and exposure value.
  81451. * @param filterHue The hue of the color filter.
  81452. * @param filterDensity The density of the color filter.
  81453. * @param saturation The saturation.
  81454. * @param exposure The exposure.
  81455. * @param result The result data container.
  81456. */
  81457. private getColorGradingDataToRef;
  81458. /**
  81459. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  81460. * @param value The input slider value in range [-100,100].
  81461. * @returns Adjusted value.
  81462. */
  81463. private static applyColorGradingSliderNonlinear;
  81464. /**
  81465. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  81466. * @param hue The hue (H) input.
  81467. * @param saturation The saturation (S) input.
  81468. * @param brightness The brightness (B) input.
  81469. * @result An RGBA color represented as Vector4.
  81470. */
  81471. private static fromHSBToRef;
  81472. /**
  81473. * Returns a value clamped between min and max
  81474. * @param value The value to clamp
  81475. * @param min The minimum of value
  81476. * @param max The maximum of value
  81477. * @returns The clamped value.
  81478. */
  81479. private static clamp;
  81480. /**
  81481. * Clones the current color curve instance.
  81482. * @return The cloned curves
  81483. */
  81484. clone(): ColorCurves;
  81485. /**
  81486. * Serializes the current color curve instance to a json representation.
  81487. * @return a JSON representation
  81488. */
  81489. serialize(): any;
  81490. /**
  81491. * Parses the color curve from a json representation.
  81492. * @param source the JSON source to parse
  81493. * @return The parsed curves
  81494. */
  81495. static Parse(source: any): ColorCurves;
  81496. }
  81497. }
  81498. declare module BABYLON {
  81499. /**
  81500. * Interface to follow in your material defines to integrate easily the
  81501. * Image proccessing functions.
  81502. * @hidden
  81503. */
  81504. export interface IImageProcessingConfigurationDefines {
  81505. IMAGEPROCESSING: boolean;
  81506. VIGNETTE: boolean;
  81507. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81508. VIGNETTEBLENDMODEOPAQUE: boolean;
  81509. TONEMAPPING: boolean;
  81510. TONEMAPPING_ACES: boolean;
  81511. CONTRAST: boolean;
  81512. EXPOSURE: boolean;
  81513. COLORCURVES: boolean;
  81514. COLORGRADING: boolean;
  81515. COLORGRADING3D: boolean;
  81516. SAMPLER3DGREENDEPTH: boolean;
  81517. SAMPLER3DBGRMAP: boolean;
  81518. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81519. }
  81520. /**
  81521. * @hidden
  81522. */
  81523. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  81524. IMAGEPROCESSING: boolean;
  81525. VIGNETTE: boolean;
  81526. VIGNETTEBLENDMODEMULTIPLY: boolean;
  81527. VIGNETTEBLENDMODEOPAQUE: boolean;
  81528. TONEMAPPING: boolean;
  81529. TONEMAPPING_ACES: boolean;
  81530. CONTRAST: boolean;
  81531. COLORCURVES: boolean;
  81532. COLORGRADING: boolean;
  81533. COLORGRADING3D: boolean;
  81534. SAMPLER3DGREENDEPTH: boolean;
  81535. SAMPLER3DBGRMAP: boolean;
  81536. IMAGEPROCESSINGPOSTPROCESS: boolean;
  81537. EXPOSURE: boolean;
  81538. constructor();
  81539. }
  81540. /**
  81541. * This groups together the common properties used for image processing either in direct forward pass
  81542. * or through post processing effect depending on the use of the image processing pipeline in your scene
  81543. * or not.
  81544. */
  81545. export class ImageProcessingConfiguration {
  81546. /**
  81547. * Default tone mapping applied in BabylonJS.
  81548. */
  81549. static readonly TONEMAPPING_STANDARD: number;
  81550. /**
  81551. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  81552. * to other engines rendering to increase portability.
  81553. */
  81554. static readonly TONEMAPPING_ACES: number;
  81555. /**
  81556. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  81557. */
  81558. colorCurves: Nullable<ColorCurves>;
  81559. private _colorCurvesEnabled;
  81560. /**
  81561. * Gets wether the color curves effect is enabled.
  81562. */
  81563. get colorCurvesEnabled(): boolean;
  81564. /**
  81565. * Sets wether the color curves effect is enabled.
  81566. */
  81567. set colorCurvesEnabled(value: boolean);
  81568. private _colorGradingTexture;
  81569. /**
  81570. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81571. */
  81572. get colorGradingTexture(): Nullable<BaseTexture>;
  81573. /**
  81574. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  81575. */
  81576. set colorGradingTexture(value: Nullable<BaseTexture>);
  81577. private _colorGradingEnabled;
  81578. /**
  81579. * Gets wether the color grading effect is enabled.
  81580. */
  81581. get colorGradingEnabled(): boolean;
  81582. /**
  81583. * Sets wether the color grading effect is enabled.
  81584. */
  81585. set colorGradingEnabled(value: boolean);
  81586. private _colorGradingWithGreenDepth;
  81587. /**
  81588. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  81589. */
  81590. get colorGradingWithGreenDepth(): boolean;
  81591. /**
  81592. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  81593. */
  81594. set colorGradingWithGreenDepth(value: boolean);
  81595. private _colorGradingBGR;
  81596. /**
  81597. * Gets wether the color grading texture contains BGR values.
  81598. */
  81599. get colorGradingBGR(): boolean;
  81600. /**
  81601. * Sets wether the color grading texture contains BGR values.
  81602. */
  81603. set colorGradingBGR(value: boolean);
  81604. /** @hidden */
  81605. _exposure: number;
  81606. /**
  81607. * Gets the Exposure used in the effect.
  81608. */
  81609. get exposure(): number;
  81610. /**
  81611. * Sets the Exposure used in the effect.
  81612. */
  81613. set exposure(value: number);
  81614. private _toneMappingEnabled;
  81615. /**
  81616. * Gets wether the tone mapping effect is enabled.
  81617. */
  81618. get toneMappingEnabled(): boolean;
  81619. /**
  81620. * Sets wether the tone mapping effect is enabled.
  81621. */
  81622. set toneMappingEnabled(value: boolean);
  81623. private _toneMappingType;
  81624. /**
  81625. * Gets the type of tone mapping effect.
  81626. */
  81627. get toneMappingType(): number;
  81628. /**
  81629. * Sets the type of tone mapping effect used in BabylonJS.
  81630. */
  81631. set toneMappingType(value: number);
  81632. protected _contrast: number;
  81633. /**
  81634. * Gets the contrast used in the effect.
  81635. */
  81636. get contrast(): number;
  81637. /**
  81638. * Sets the contrast used in the effect.
  81639. */
  81640. set contrast(value: number);
  81641. /**
  81642. * Vignette stretch size.
  81643. */
  81644. vignetteStretch: number;
  81645. /**
  81646. * Vignette centre X Offset.
  81647. */
  81648. vignetteCentreX: number;
  81649. /**
  81650. * Vignette centre Y Offset.
  81651. */
  81652. vignetteCentreY: number;
  81653. /**
  81654. * Vignette weight or intensity of the vignette effect.
  81655. */
  81656. vignetteWeight: number;
  81657. /**
  81658. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  81659. * if vignetteEnabled is set to true.
  81660. */
  81661. vignetteColor: Color4;
  81662. /**
  81663. * Camera field of view used by the Vignette effect.
  81664. */
  81665. vignetteCameraFov: number;
  81666. private _vignetteBlendMode;
  81667. /**
  81668. * Gets the vignette blend mode allowing different kind of effect.
  81669. */
  81670. get vignetteBlendMode(): number;
  81671. /**
  81672. * Sets the vignette blend mode allowing different kind of effect.
  81673. */
  81674. set vignetteBlendMode(value: number);
  81675. private _vignetteEnabled;
  81676. /**
  81677. * Gets wether the vignette effect is enabled.
  81678. */
  81679. get vignetteEnabled(): boolean;
  81680. /**
  81681. * Sets wether the vignette effect is enabled.
  81682. */
  81683. set vignetteEnabled(value: boolean);
  81684. private _applyByPostProcess;
  81685. /**
  81686. * Gets wether the image processing is applied through a post process or not.
  81687. */
  81688. get applyByPostProcess(): boolean;
  81689. /**
  81690. * Sets wether the image processing is applied through a post process or not.
  81691. */
  81692. set applyByPostProcess(value: boolean);
  81693. private _isEnabled;
  81694. /**
  81695. * Gets wether the image processing is enabled or not.
  81696. */
  81697. get isEnabled(): boolean;
  81698. /**
  81699. * Sets wether the image processing is enabled or not.
  81700. */
  81701. set isEnabled(value: boolean);
  81702. /**
  81703. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  81704. */
  81705. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  81706. /**
  81707. * Method called each time the image processing information changes requires to recompile the effect.
  81708. */
  81709. protected _updateParameters(): void;
  81710. /**
  81711. * Gets the current class name.
  81712. * @return "ImageProcessingConfiguration"
  81713. */
  81714. getClassName(): string;
  81715. /**
  81716. * Prepare the list of uniforms associated with the Image Processing effects.
  81717. * @param uniforms The list of uniforms used in the effect
  81718. * @param defines the list of defines currently in use
  81719. */
  81720. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  81721. /**
  81722. * Prepare the list of samplers associated with the Image Processing effects.
  81723. * @param samplersList The list of uniforms used in the effect
  81724. * @param defines the list of defines currently in use
  81725. */
  81726. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  81727. /**
  81728. * Prepare the list of defines associated to the shader.
  81729. * @param defines the list of defines to complete
  81730. * @param forPostProcess Define if we are currently in post process mode or not
  81731. */
  81732. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  81733. /**
  81734. * Returns true if all the image processing information are ready.
  81735. * @returns True if ready, otherwise, false
  81736. */
  81737. isReady(): boolean;
  81738. /**
  81739. * Binds the image processing to the shader.
  81740. * @param effect The effect to bind to
  81741. * @param overrideAspectRatio Override the aspect ratio of the effect
  81742. */
  81743. bind(effect: Effect, overrideAspectRatio?: number): void;
  81744. /**
  81745. * Clones the current image processing instance.
  81746. * @return The cloned image processing
  81747. */
  81748. clone(): ImageProcessingConfiguration;
  81749. /**
  81750. * Serializes the current image processing instance to a json representation.
  81751. * @return a JSON representation
  81752. */
  81753. serialize(): any;
  81754. /**
  81755. * Parses the image processing from a json representation.
  81756. * @param source the JSON source to parse
  81757. * @return The parsed image processing
  81758. */
  81759. static Parse(source: any): ImageProcessingConfiguration;
  81760. private static _VIGNETTEMODE_MULTIPLY;
  81761. private static _VIGNETTEMODE_OPAQUE;
  81762. /**
  81763. * Used to apply the vignette as a mix with the pixel color.
  81764. */
  81765. static get VIGNETTEMODE_MULTIPLY(): number;
  81766. /**
  81767. * Used to apply the vignette as a replacement of the pixel color.
  81768. */
  81769. static get VIGNETTEMODE_OPAQUE(): number;
  81770. }
  81771. }
  81772. declare module BABYLON {
  81773. /** @hidden */
  81774. export var postprocessVertexShader: {
  81775. name: string;
  81776. shader: string;
  81777. };
  81778. }
  81779. declare module BABYLON {
  81780. interface ThinEngine {
  81781. /**
  81782. * Creates a new render target texture
  81783. * @param size defines the size of the texture
  81784. * @param options defines the options used to create the texture
  81785. * @returns a new render target texture stored in an InternalTexture
  81786. */
  81787. createRenderTargetTexture(size: number | {
  81788. width: number;
  81789. height: number;
  81790. layers?: number;
  81791. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  81792. /**
  81793. * Creates a depth stencil texture.
  81794. * This is only available in WebGL 2 or with the depth texture extension available.
  81795. * @param size The size of face edge in the texture.
  81796. * @param options The options defining the texture.
  81797. * @returns The texture
  81798. */
  81799. createDepthStencilTexture(size: number | {
  81800. width: number;
  81801. height: number;
  81802. layers?: number;
  81803. }, options: DepthTextureCreationOptions): InternalTexture;
  81804. /** @hidden */
  81805. _createDepthStencilTexture(size: number | {
  81806. width: number;
  81807. height: number;
  81808. layers?: number;
  81809. }, options: DepthTextureCreationOptions): InternalTexture;
  81810. }
  81811. }
  81812. declare module BABYLON {
  81813. /** Defines supported spaces */
  81814. export enum Space {
  81815. /** Local (object) space */
  81816. LOCAL = 0,
  81817. /** World space */
  81818. WORLD = 1,
  81819. /** Bone space */
  81820. BONE = 2
  81821. }
  81822. /** Defines the 3 main axes */
  81823. export class Axis {
  81824. /** X axis */
  81825. static X: Vector3;
  81826. /** Y axis */
  81827. static Y: Vector3;
  81828. /** Z axis */
  81829. static Z: Vector3;
  81830. }
  81831. }
  81832. declare module BABYLON {
  81833. /**
  81834. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  81835. * This is the base of the follow, arc rotate cameras and Free camera
  81836. * @see http://doc.babylonjs.com/features/cameras
  81837. */
  81838. export class TargetCamera extends Camera {
  81839. private static _RigCamTransformMatrix;
  81840. private static _TargetTransformMatrix;
  81841. private static _TargetFocalPoint;
  81842. /**
  81843. * Define the current direction the camera is moving to
  81844. */
  81845. cameraDirection: Vector3;
  81846. /**
  81847. * Define the current rotation the camera is rotating to
  81848. */
  81849. cameraRotation: Vector2;
  81850. /**
  81851. * When set, the up vector of the camera will be updated by the rotation of the camera
  81852. */
  81853. updateUpVectorFromRotation: boolean;
  81854. private _tmpQuaternion;
  81855. /**
  81856. * Define the current rotation of the camera
  81857. */
  81858. rotation: Vector3;
  81859. /**
  81860. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  81861. */
  81862. rotationQuaternion: Quaternion;
  81863. /**
  81864. * Define the current speed of the camera
  81865. */
  81866. speed: number;
  81867. /**
  81868. * Add constraint to the camera to prevent it to move freely in all directions and
  81869. * around all axis.
  81870. */
  81871. noRotationConstraint: boolean;
  81872. /**
  81873. * Define the current target of the camera as an object or a position.
  81874. */
  81875. lockedTarget: any;
  81876. /** @hidden */
  81877. _currentTarget: Vector3;
  81878. /** @hidden */
  81879. _initialFocalDistance: number;
  81880. /** @hidden */
  81881. _viewMatrix: Matrix;
  81882. /** @hidden */
  81883. _camMatrix: Matrix;
  81884. /** @hidden */
  81885. _cameraTransformMatrix: Matrix;
  81886. /** @hidden */
  81887. _cameraRotationMatrix: Matrix;
  81888. /** @hidden */
  81889. _referencePoint: Vector3;
  81890. /** @hidden */
  81891. _transformedReferencePoint: Vector3;
  81892. protected _globalCurrentTarget: Vector3;
  81893. protected _globalCurrentUpVector: Vector3;
  81894. /** @hidden */
  81895. _reset: () => void;
  81896. private _defaultUp;
  81897. /**
  81898. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  81899. * This is the base of the follow, arc rotate cameras and Free camera
  81900. * @see http://doc.babylonjs.com/features/cameras
  81901. * @param name Defines the name of the camera in the scene
  81902. * @param position Defines the start position of the camera in the scene
  81903. * @param scene Defines the scene the camera belongs to
  81904. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  81905. */
  81906. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  81907. /**
  81908. * Gets the position in front of the camera at a given distance.
  81909. * @param distance The distance from the camera we want the position to be
  81910. * @returns the position
  81911. */
  81912. getFrontPosition(distance: number): Vector3;
  81913. /** @hidden */
  81914. _getLockedTargetPosition(): Nullable<Vector3>;
  81915. private _storedPosition;
  81916. private _storedRotation;
  81917. private _storedRotationQuaternion;
  81918. /**
  81919. * Store current camera state of the camera (fov, position, rotation, etc..)
  81920. * @returns the camera
  81921. */
  81922. storeState(): Camera;
  81923. /**
  81924. * Restored camera state. You must call storeState() first
  81925. * @returns whether it was successful or not
  81926. * @hidden
  81927. */
  81928. _restoreStateValues(): boolean;
  81929. /** @hidden */
  81930. _initCache(): void;
  81931. /** @hidden */
  81932. _updateCache(ignoreParentClass?: boolean): void;
  81933. /** @hidden */
  81934. _isSynchronizedViewMatrix(): boolean;
  81935. /** @hidden */
  81936. _computeLocalCameraSpeed(): number;
  81937. /**
  81938. * Defines the target the camera should look at.
  81939. * @param target Defines the new target as a Vector or a mesh
  81940. */
  81941. setTarget(target: Vector3): void;
  81942. /**
  81943. * Return the current target position of the camera. This value is expressed in local space.
  81944. * @returns the target position
  81945. */
  81946. getTarget(): Vector3;
  81947. /** @hidden */
  81948. _decideIfNeedsToMove(): boolean;
  81949. /** @hidden */
  81950. _updatePosition(): void;
  81951. /** @hidden */
  81952. _checkInputs(): void;
  81953. protected _updateCameraRotationMatrix(): void;
  81954. /**
  81955. * 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)
  81956. * @returns the current camera
  81957. */
  81958. private _rotateUpVectorWithCameraRotationMatrix;
  81959. private _cachedRotationZ;
  81960. private _cachedQuaternionRotationZ;
  81961. /** @hidden */
  81962. _getViewMatrix(): Matrix;
  81963. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  81964. /**
  81965. * @hidden
  81966. */
  81967. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  81968. /**
  81969. * @hidden
  81970. */
  81971. _updateRigCameras(): void;
  81972. private _getRigCamPositionAndTarget;
  81973. /**
  81974. * Gets the current object class name.
  81975. * @return the class name
  81976. */
  81977. getClassName(): string;
  81978. }
  81979. }
  81980. declare module BABYLON {
  81981. /**
  81982. * Gather the list of keyboard event types as constants.
  81983. */
  81984. export class KeyboardEventTypes {
  81985. /**
  81986. * The keydown event is fired when a key becomes active (pressed).
  81987. */
  81988. static readonly KEYDOWN: number;
  81989. /**
  81990. * The keyup event is fired when a key has been released.
  81991. */
  81992. static readonly KEYUP: number;
  81993. }
  81994. /**
  81995. * This class is used to store keyboard related info for the onKeyboardObservable event.
  81996. */
  81997. export class KeyboardInfo {
  81998. /**
  81999. * Defines the type of event (KeyboardEventTypes)
  82000. */
  82001. type: number;
  82002. /**
  82003. * Defines the related dom event
  82004. */
  82005. event: KeyboardEvent;
  82006. /**
  82007. * Instantiates a new keyboard info.
  82008. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82009. * @param type Defines the type of event (KeyboardEventTypes)
  82010. * @param event Defines the related dom event
  82011. */
  82012. constructor(
  82013. /**
  82014. * Defines the type of event (KeyboardEventTypes)
  82015. */
  82016. type: number,
  82017. /**
  82018. * Defines the related dom event
  82019. */
  82020. event: KeyboardEvent);
  82021. }
  82022. /**
  82023. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82024. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  82025. */
  82026. export class KeyboardInfoPre extends KeyboardInfo {
  82027. /**
  82028. * Defines the type of event (KeyboardEventTypes)
  82029. */
  82030. type: number;
  82031. /**
  82032. * Defines the related dom event
  82033. */
  82034. event: KeyboardEvent;
  82035. /**
  82036. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  82037. */
  82038. skipOnPointerObservable: boolean;
  82039. /**
  82040. * Instantiates a new keyboard pre info.
  82041. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  82042. * @param type Defines the type of event (KeyboardEventTypes)
  82043. * @param event Defines the related dom event
  82044. */
  82045. constructor(
  82046. /**
  82047. * Defines the type of event (KeyboardEventTypes)
  82048. */
  82049. type: number,
  82050. /**
  82051. * Defines the related dom event
  82052. */
  82053. event: KeyboardEvent);
  82054. }
  82055. }
  82056. declare module BABYLON {
  82057. /**
  82058. * Manage the keyboard inputs to control the movement of a free camera.
  82059. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  82060. */
  82061. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  82062. /**
  82063. * Defines the camera the input is attached to.
  82064. */
  82065. camera: FreeCamera;
  82066. /**
  82067. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  82068. */
  82069. keysUp: number[];
  82070. /**
  82071. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  82072. */
  82073. keysDown: number[];
  82074. /**
  82075. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  82076. */
  82077. keysLeft: number[];
  82078. /**
  82079. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  82080. */
  82081. keysRight: number[];
  82082. private _keys;
  82083. private _onCanvasBlurObserver;
  82084. private _onKeyboardObserver;
  82085. private _engine;
  82086. private _scene;
  82087. /**
  82088. * Attach the input controls to a specific dom element to get the input from.
  82089. * @param element Defines the element the controls should be listened from
  82090. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  82091. */
  82092. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  82093. /**
  82094. * Detach the current controls from the specified dom element.
  82095. * @param element Defines the element to stop listening the inputs from
  82096. */
  82097. detachControl(element: Nullable<HTMLElement>): void;
  82098. /**
  82099. * Update the current camera state depending on the inputs that have been used this frame.
  82100. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  82101. */
  82102. checkInputs(): void;
  82103. /**
  82104. * Gets the class name of the current intput.
  82105. * @returns the class name
  82106. */
  82107. getClassName(): string;
  82108. /** @hidden */
  82109. _onLostFocus(): void;
  82110. /**
  82111. * Get the friendly name associated with the input class.
  82112. * @returns the input friendly name
  82113. */
  82114. getSimpleName(): string;
  82115. }
  82116. }
  82117. declare module BABYLON {
  82118. /**
  82119. * Interface describing all the common properties and methods a shadow light needs to implement.
  82120. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  82121. * as well as binding the different shadow properties to the effects.
  82122. */
  82123. export interface IShadowLight extends Light {
  82124. /**
  82125. * The light id in the scene (used in scene.findLighById for instance)
  82126. */
  82127. id: string;
  82128. /**
  82129. * The position the shdow will be casted from.
  82130. */
  82131. position: Vector3;
  82132. /**
  82133. * In 2d mode (needCube being false), the direction used to cast the shadow.
  82134. */
  82135. direction: Vector3;
  82136. /**
  82137. * The transformed position. Position of the light in world space taking parenting in account.
  82138. */
  82139. transformedPosition: Vector3;
  82140. /**
  82141. * The transformed direction. Direction of the light in world space taking parenting in account.
  82142. */
  82143. transformedDirection: Vector3;
  82144. /**
  82145. * The friendly name of the light in the scene.
  82146. */
  82147. name: string;
  82148. /**
  82149. * Defines the shadow projection clipping minimum z value.
  82150. */
  82151. shadowMinZ: number;
  82152. /**
  82153. * Defines the shadow projection clipping maximum z value.
  82154. */
  82155. shadowMaxZ: number;
  82156. /**
  82157. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82158. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82159. */
  82160. computeTransformedInformation(): boolean;
  82161. /**
  82162. * Gets the scene the light belongs to.
  82163. * @returns The scene
  82164. */
  82165. getScene(): Scene;
  82166. /**
  82167. * Callback defining a custom Projection Matrix Builder.
  82168. * This can be used to override the default projection matrix computation.
  82169. */
  82170. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82171. /**
  82172. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82173. * @param matrix The materix to updated with the projection information
  82174. * @param viewMatrix The transform matrix of the light
  82175. * @param renderList The list of mesh to render in the map
  82176. * @returns The current light
  82177. */
  82178. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82179. /**
  82180. * Gets the current depth scale used in ESM.
  82181. * @returns The scale
  82182. */
  82183. getDepthScale(): number;
  82184. /**
  82185. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82186. * @returns true if a cube texture needs to be use
  82187. */
  82188. needCube(): boolean;
  82189. /**
  82190. * Detects if the projection matrix requires to be recomputed this frame.
  82191. * @returns true if it requires to be recomputed otherwise, false.
  82192. */
  82193. needProjectionMatrixCompute(): boolean;
  82194. /**
  82195. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82196. */
  82197. forceProjectionMatrixCompute(): void;
  82198. /**
  82199. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82200. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82201. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82202. */
  82203. getShadowDirection(faceIndex?: number): Vector3;
  82204. /**
  82205. * Gets the minZ used for shadow according to both the scene and the light.
  82206. * @param activeCamera The camera we are returning the min for
  82207. * @returns the depth min z
  82208. */
  82209. getDepthMinZ(activeCamera: Camera): number;
  82210. /**
  82211. * Gets the maxZ used for shadow according to both the scene and the light.
  82212. * @param activeCamera The camera we are returning the max for
  82213. * @returns the depth max z
  82214. */
  82215. getDepthMaxZ(activeCamera: Camera): number;
  82216. }
  82217. /**
  82218. * Base implementation IShadowLight
  82219. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  82220. */
  82221. export abstract class ShadowLight extends Light implements IShadowLight {
  82222. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  82223. protected _position: Vector3;
  82224. protected _setPosition(value: Vector3): void;
  82225. /**
  82226. * Sets the position the shadow will be casted from. Also use as the light position for both
  82227. * point and spot lights.
  82228. */
  82229. get position(): Vector3;
  82230. /**
  82231. * Sets the position the shadow will be casted from. Also use as the light position for both
  82232. * point and spot lights.
  82233. */
  82234. set position(value: Vector3);
  82235. protected _direction: Vector3;
  82236. protected _setDirection(value: Vector3): void;
  82237. /**
  82238. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  82239. * Also use as the light direction on spot and directional lights.
  82240. */
  82241. get direction(): Vector3;
  82242. /**
  82243. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  82244. * Also use as the light direction on spot and directional lights.
  82245. */
  82246. set direction(value: Vector3);
  82247. protected _shadowMinZ: number;
  82248. /**
  82249. * Gets the shadow projection clipping minimum z value.
  82250. */
  82251. get shadowMinZ(): number;
  82252. /**
  82253. * Sets the shadow projection clipping minimum z value.
  82254. */
  82255. set shadowMinZ(value: number);
  82256. protected _shadowMaxZ: number;
  82257. /**
  82258. * Sets the shadow projection clipping maximum z value.
  82259. */
  82260. get shadowMaxZ(): number;
  82261. /**
  82262. * Gets the shadow projection clipping maximum z value.
  82263. */
  82264. set shadowMaxZ(value: number);
  82265. /**
  82266. * Callback defining a custom Projection Matrix Builder.
  82267. * This can be used to override the default projection matrix computation.
  82268. */
  82269. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  82270. /**
  82271. * The transformed position. Position of the light in world space taking parenting in account.
  82272. */
  82273. transformedPosition: Vector3;
  82274. /**
  82275. * The transformed direction. Direction of the light in world space taking parenting in account.
  82276. */
  82277. transformedDirection: Vector3;
  82278. private _needProjectionMatrixCompute;
  82279. /**
  82280. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  82281. * @returns true if the information has been computed, false if it does not need to (no parenting)
  82282. */
  82283. computeTransformedInformation(): boolean;
  82284. /**
  82285. * Return the depth scale used for the shadow map.
  82286. * @returns the depth scale.
  82287. */
  82288. getDepthScale(): number;
  82289. /**
  82290. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  82291. * @param faceIndex The index of the face we are computed the direction to generate shadow
  82292. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  82293. */
  82294. getShadowDirection(faceIndex?: number): Vector3;
  82295. /**
  82296. * Returns the ShadowLight absolute position in the World.
  82297. * @returns the position vector in world space
  82298. */
  82299. getAbsolutePosition(): Vector3;
  82300. /**
  82301. * Sets the ShadowLight direction toward the passed target.
  82302. * @param target The point to target in local space
  82303. * @returns the updated ShadowLight direction
  82304. */
  82305. setDirectionToTarget(target: Vector3): Vector3;
  82306. /**
  82307. * Returns the light rotation in euler definition.
  82308. * @returns the x y z rotation in local space.
  82309. */
  82310. getRotation(): Vector3;
  82311. /**
  82312. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  82313. * @returns true if a cube texture needs to be use
  82314. */
  82315. needCube(): boolean;
  82316. /**
  82317. * Detects if the projection matrix requires to be recomputed this frame.
  82318. * @returns true if it requires to be recomputed otherwise, false.
  82319. */
  82320. needProjectionMatrixCompute(): boolean;
  82321. /**
  82322. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  82323. */
  82324. forceProjectionMatrixCompute(): void;
  82325. /** @hidden */
  82326. _initCache(): void;
  82327. /** @hidden */
  82328. _isSynchronized(): boolean;
  82329. /**
  82330. * Computes the world matrix of the node
  82331. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  82332. * @returns the world matrix
  82333. */
  82334. computeWorldMatrix(force?: boolean): Matrix;
  82335. /**
  82336. * Gets the minZ used for shadow according to both the scene and the light.
  82337. * @param activeCamera The camera we are returning the min for
  82338. * @returns the depth min z
  82339. */
  82340. getDepthMinZ(activeCamera: Camera): number;
  82341. /**
  82342. * Gets the maxZ used for shadow according to both the scene and the light.
  82343. * @param activeCamera The camera we are returning the max for
  82344. * @returns the depth max z
  82345. */
  82346. getDepthMaxZ(activeCamera: Camera): number;
  82347. /**
  82348. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  82349. * @param matrix The materix to updated with the projection information
  82350. * @param viewMatrix The transform matrix of the light
  82351. * @param renderList The list of mesh to render in the map
  82352. * @returns The current light
  82353. */
  82354. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  82355. }
  82356. }
  82357. declare module BABYLON {
  82358. /**
  82359. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  82360. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  82361. */
  82362. export class EffectFallbacks implements IEffectFallbacks {
  82363. private _defines;
  82364. private _currentRank;
  82365. private _maxRank;
  82366. private _mesh;
  82367. /**
  82368. * Removes the fallback from the bound mesh.
  82369. */
  82370. unBindMesh(): void;
  82371. /**
  82372. * Adds a fallback on the specified property.
  82373. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82374. * @param define The name of the define in the shader
  82375. */
  82376. addFallback(rank: number, define: string): void;
  82377. /**
  82378. * Sets the mesh to use CPU skinning when needing to fallback.
  82379. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  82380. * @param mesh The mesh to use the fallbacks.
  82381. */
  82382. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  82383. /**
  82384. * Checks to see if more fallbacks are still availible.
  82385. */
  82386. get hasMoreFallbacks(): boolean;
  82387. /**
  82388. * Removes the defines that should be removed when falling back.
  82389. * @param currentDefines defines the current define statements for the shader.
  82390. * @param effect defines the current effect we try to compile
  82391. * @returns The resulting defines with defines of the current rank removed.
  82392. */
  82393. reduce(currentDefines: string, effect: Effect): string;
  82394. }
  82395. }
  82396. declare module BABYLON {
  82397. /**
  82398. * "Static Class" containing the most commonly used helper while dealing with material for
  82399. * rendering purpose.
  82400. *
  82401. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  82402. *
  82403. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  82404. */
  82405. export class MaterialHelper {
  82406. /**
  82407. * Bind the current view position to an effect.
  82408. * @param effect The effect to be bound
  82409. * @param scene The scene the eyes position is used from
  82410. */
  82411. static BindEyePosition(effect: Effect, scene: Scene): void;
  82412. /**
  82413. * Helps preparing the defines values about the UVs in used in the effect.
  82414. * UVs are shared as much as we can accross channels in the shaders.
  82415. * @param texture The texture we are preparing the UVs for
  82416. * @param defines The defines to update
  82417. * @param key The channel key "diffuse", "specular"... used in the shader
  82418. */
  82419. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  82420. /**
  82421. * Binds a texture matrix value to its corrsponding uniform
  82422. * @param texture The texture to bind the matrix for
  82423. * @param uniformBuffer The uniform buffer receivin the data
  82424. * @param key The channel key "diffuse", "specular"... used in the shader
  82425. */
  82426. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  82427. /**
  82428. * Gets the current status of the fog (should it be enabled?)
  82429. * @param mesh defines the mesh to evaluate for fog support
  82430. * @param scene defines the hosting scene
  82431. * @returns true if fog must be enabled
  82432. */
  82433. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  82434. /**
  82435. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  82436. * @param mesh defines the current mesh
  82437. * @param scene defines the current scene
  82438. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  82439. * @param pointsCloud defines if point cloud rendering has to be turned on
  82440. * @param fogEnabled defines if fog has to be turned on
  82441. * @param alphaTest defines if alpha testing has to be turned on
  82442. * @param defines defines the current list of defines
  82443. */
  82444. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  82445. /**
  82446. * Helper used to prepare the list of defines associated with frame values for shader compilation
  82447. * @param scene defines the current scene
  82448. * @param engine defines the current engine
  82449. * @param defines specifies the list of active defines
  82450. * @param useInstances defines if instances have to be turned on
  82451. * @param useClipPlane defines if clip plane have to be turned on
  82452. */
  82453. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  82454. /**
  82455. * Prepares the defines for bones
  82456. * @param mesh The mesh containing the geometry data we will draw
  82457. * @param defines The defines to update
  82458. */
  82459. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  82460. /**
  82461. * Prepares the defines for morph targets
  82462. * @param mesh The mesh containing the geometry data we will draw
  82463. * @param defines The defines to update
  82464. */
  82465. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  82466. /**
  82467. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  82468. * @param mesh The mesh containing the geometry data we will draw
  82469. * @param defines The defines to update
  82470. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  82471. * @param useBones Precise whether bones should be used or not (override mesh info)
  82472. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  82473. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  82474. * @returns false if defines are considered not dirty and have not been checked
  82475. */
  82476. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  82477. /**
  82478. * Prepares the defines related to multiview
  82479. * @param scene The scene we are intending to draw
  82480. * @param defines The defines to update
  82481. */
  82482. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  82483. /**
  82484. * Prepares the defines related to the light information passed in parameter
  82485. * @param scene The scene we are intending to draw
  82486. * @param mesh The mesh the effect is compiling for
  82487. * @param light The light the effect is compiling for
  82488. * @param lightIndex The index of the light
  82489. * @param defines The defines to update
  82490. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82491. * @param state Defines the current state regarding what is needed (normals, etc...)
  82492. */
  82493. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  82494. needNormals: boolean;
  82495. needRebuild: boolean;
  82496. shadowEnabled: boolean;
  82497. specularEnabled: boolean;
  82498. lightmapMode: boolean;
  82499. }): void;
  82500. /**
  82501. * Prepares the defines related to the light information passed in parameter
  82502. * @param scene The scene we are intending to draw
  82503. * @param mesh The mesh the effect is compiling for
  82504. * @param defines The defines to update
  82505. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  82506. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  82507. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  82508. * @returns true if normals will be required for the rest of the effect
  82509. */
  82510. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  82511. /**
  82512. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  82513. * @param lightIndex defines the light index
  82514. * @param uniformsList The uniform list
  82515. * @param samplersList The sampler list
  82516. * @param projectedLightTexture defines if projected texture must be used
  82517. * @param uniformBuffersList defines an optional list of uniform buffers
  82518. */
  82519. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  82520. /**
  82521. * Prepares the uniforms and samplers list to be used in the effect
  82522. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  82523. * @param samplersList The sampler list
  82524. * @param defines The defines helping in the list generation
  82525. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  82526. */
  82527. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  82528. /**
  82529. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  82530. * @param defines The defines to update while falling back
  82531. * @param fallbacks The authorized effect fallbacks
  82532. * @param maxSimultaneousLights The maximum number of lights allowed
  82533. * @param rank the current rank of the Effect
  82534. * @returns The newly affected rank
  82535. */
  82536. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  82537. private static _TmpMorphInfluencers;
  82538. /**
  82539. * Prepares the list of attributes required for morph targets according to the effect defines.
  82540. * @param attribs The current list of supported attribs
  82541. * @param mesh The mesh to prepare the morph targets attributes for
  82542. * @param influencers The number of influencers
  82543. */
  82544. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  82545. /**
  82546. * Prepares the list of attributes required for morph targets according to the effect defines.
  82547. * @param attribs The current list of supported attribs
  82548. * @param mesh The mesh to prepare the morph targets attributes for
  82549. * @param defines The current Defines of the effect
  82550. */
  82551. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  82552. /**
  82553. * Prepares the list of attributes required for bones according to the effect defines.
  82554. * @param attribs The current list of supported attribs
  82555. * @param mesh The mesh to prepare the bones attributes for
  82556. * @param defines The current Defines of the effect
  82557. * @param fallbacks The current efffect fallback strategy
  82558. */
  82559. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  82560. /**
  82561. * Check and prepare the list of attributes required for instances according to the effect defines.
  82562. * @param attribs The current list of supported attribs
  82563. * @param defines The current MaterialDefines of the effect
  82564. */
  82565. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  82566. /**
  82567. * Add the list of attributes required for instances to the attribs array.
  82568. * @param attribs The current list of supported attribs
  82569. */
  82570. static PushAttributesForInstances(attribs: string[]): void;
  82571. /**
  82572. * Binds the light information to the effect.
  82573. * @param light The light containing the generator
  82574. * @param effect The effect we are binding the data to
  82575. * @param lightIndex The light index in the effect used to render
  82576. */
  82577. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  82578. /**
  82579. * Binds the lights information from the scene to the effect for the given mesh.
  82580. * @param light Light to bind
  82581. * @param lightIndex Light index
  82582. * @param scene The scene where the light belongs to
  82583. * @param effect The effect we are binding the data to
  82584. * @param useSpecular Defines if specular is supported
  82585. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82586. */
  82587. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  82588. /**
  82589. * Binds the lights information from the scene to the effect for the given mesh.
  82590. * @param scene The scene the lights belongs to
  82591. * @param mesh The mesh we are binding the information to render
  82592. * @param effect The effect we are binding the data to
  82593. * @param defines The generated defines for the effect
  82594. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  82595. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  82596. */
  82597. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  82598. private static _tempFogColor;
  82599. /**
  82600. * Binds the fog information from the scene to the effect for the given mesh.
  82601. * @param scene The scene the lights belongs to
  82602. * @param mesh The mesh we are binding the information to render
  82603. * @param effect The effect we are binding the data to
  82604. * @param linearSpace Defines if the fog effect is applied in linear space
  82605. */
  82606. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  82607. /**
  82608. * Binds the bones information from the mesh to the effect.
  82609. * @param mesh The mesh we are binding the information to render
  82610. * @param effect The effect we are binding the data to
  82611. */
  82612. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  82613. /**
  82614. * Binds the morph targets information from the mesh to the effect.
  82615. * @param abstractMesh The mesh we are binding the information to render
  82616. * @param effect The effect we are binding the data to
  82617. */
  82618. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  82619. /**
  82620. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  82621. * @param defines The generated defines used in the effect
  82622. * @param effect The effect we are binding the data to
  82623. * @param scene The scene we are willing to render with logarithmic scale for
  82624. */
  82625. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  82626. /**
  82627. * Binds the clip plane information from the scene to the effect.
  82628. * @param scene The scene the clip plane information are extracted from
  82629. * @param effect The effect we are binding the data to
  82630. */
  82631. static BindClipPlane(effect: Effect, scene: Scene): void;
  82632. }
  82633. }
  82634. declare module BABYLON {
  82635. /** @hidden */
  82636. export var packingFunctions: {
  82637. name: string;
  82638. shader: string;
  82639. };
  82640. }
  82641. declare module BABYLON {
  82642. /** @hidden */
  82643. export var clipPlaneFragmentDeclaration: {
  82644. name: string;
  82645. shader: string;
  82646. };
  82647. }
  82648. declare module BABYLON {
  82649. /** @hidden */
  82650. export var clipPlaneFragment: {
  82651. name: string;
  82652. shader: string;
  82653. };
  82654. }
  82655. declare module BABYLON {
  82656. /** @hidden */
  82657. export var shadowMapPixelShader: {
  82658. name: string;
  82659. shader: string;
  82660. };
  82661. }
  82662. declare module BABYLON {
  82663. /** @hidden */
  82664. export var bonesDeclaration: {
  82665. name: string;
  82666. shader: string;
  82667. };
  82668. }
  82669. declare module BABYLON {
  82670. /** @hidden */
  82671. export var morphTargetsVertexGlobalDeclaration: {
  82672. name: string;
  82673. shader: string;
  82674. };
  82675. }
  82676. declare module BABYLON {
  82677. /** @hidden */
  82678. export var morphTargetsVertexDeclaration: {
  82679. name: string;
  82680. shader: string;
  82681. };
  82682. }
  82683. declare module BABYLON {
  82684. /** @hidden */
  82685. export var instancesDeclaration: {
  82686. name: string;
  82687. shader: string;
  82688. };
  82689. }
  82690. declare module BABYLON {
  82691. /** @hidden */
  82692. export var helperFunctions: {
  82693. name: string;
  82694. shader: string;
  82695. };
  82696. }
  82697. declare module BABYLON {
  82698. /** @hidden */
  82699. export var clipPlaneVertexDeclaration: {
  82700. name: string;
  82701. shader: string;
  82702. };
  82703. }
  82704. declare module BABYLON {
  82705. /** @hidden */
  82706. export var morphTargetsVertex: {
  82707. name: string;
  82708. shader: string;
  82709. };
  82710. }
  82711. declare module BABYLON {
  82712. /** @hidden */
  82713. export var instancesVertex: {
  82714. name: string;
  82715. shader: string;
  82716. };
  82717. }
  82718. declare module BABYLON {
  82719. /** @hidden */
  82720. export var bonesVertex: {
  82721. name: string;
  82722. shader: string;
  82723. };
  82724. }
  82725. declare module BABYLON {
  82726. /** @hidden */
  82727. export var clipPlaneVertex: {
  82728. name: string;
  82729. shader: string;
  82730. };
  82731. }
  82732. declare module BABYLON {
  82733. /** @hidden */
  82734. export var shadowMapVertexShader: {
  82735. name: string;
  82736. shader: string;
  82737. };
  82738. }
  82739. declare module BABYLON {
  82740. /** @hidden */
  82741. export var depthBoxBlurPixelShader: {
  82742. name: string;
  82743. shader: string;
  82744. };
  82745. }
  82746. declare module BABYLON {
  82747. /**
  82748. * Class representing a ray with position and direction
  82749. */
  82750. export class Ray {
  82751. /** origin point */
  82752. origin: Vector3;
  82753. /** direction */
  82754. direction: Vector3;
  82755. /** length of the ray */
  82756. length: number;
  82757. private static readonly TmpVector3;
  82758. private _tmpRay;
  82759. /**
  82760. * Creates a new ray
  82761. * @param origin origin point
  82762. * @param direction direction
  82763. * @param length length of the ray
  82764. */
  82765. constructor(
  82766. /** origin point */
  82767. origin: Vector3,
  82768. /** direction */
  82769. direction: Vector3,
  82770. /** length of the ray */
  82771. length?: number);
  82772. /**
  82773. * Checks if the ray intersects a box
  82774. * @param minimum bound of the box
  82775. * @param maximum bound of the box
  82776. * @param intersectionTreshold extra extend to be added to the box in all direction
  82777. * @returns if the box was hit
  82778. */
  82779. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  82780. /**
  82781. * Checks if the ray intersects a box
  82782. * @param box the bounding box to check
  82783. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  82784. * @returns if the box was hit
  82785. */
  82786. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  82787. /**
  82788. * If the ray hits a sphere
  82789. * @param sphere the bounding sphere to check
  82790. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  82791. * @returns true if it hits the sphere
  82792. */
  82793. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  82794. /**
  82795. * If the ray hits a triange
  82796. * @param vertex0 triangle vertex
  82797. * @param vertex1 triangle vertex
  82798. * @param vertex2 triangle vertex
  82799. * @returns intersection information if hit
  82800. */
  82801. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  82802. /**
  82803. * Checks if ray intersects a plane
  82804. * @param plane the plane to check
  82805. * @returns the distance away it was hit
  82806. */
  82807. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  82808. /**
  82809. * Calculate the intercept of a ray on a given axis
  82810. * @param axis to check 'x' | 'y' | 'z'
  82811. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  82812. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  82813. */
  82814. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  82815. /**
  82816. * Checks if ray intersects a mesh
  82817. * @param mesh the mesh to check
  82818. * @param fastCheck if only the bounding box should checked
  82819. * @returns picking info of the intersecton
  82820. */
  82821. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  82822. /**
  82823. * Checks if ray intersects a mesh
  82824. * @param meshes the meshes to check
  82825. * @param fastCheck if only the bounding box should checked
  82826. * @param results array to store result in
  82827. * @returns Array of picking infos
  82828. */
  82829. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  82830. private _comparePickingInfo;
  82831. private static smallnum;
  82832. private static rayl;
  82833. /**
  82834. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  82835. * @param sega the first point of the segment to test the intersection against
  82836. * @param segb the second point of the segment to test the intersection against
  82837. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  82838. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  82839. */
  82840. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  82841. /**
  82842. * Update the ray from viewport position
  82843. * @param x position
  82844. * @param y y position
  82845. * @param viewportWidth viewport width
  82846. * @param viewportHeight viewport height
  82847. * @param world world matrix
  82848. * @param view view matrix
  82849. * @param projection projection matrix
  82850. * @returns this ray updated
  82851. */
  82852. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82853. /**
  82854. * Creates a ray with origin and direction of 0,0,0
  82855. * @returns the new ray
  82856. */
  82857. static Zero(): Ray;
  82858. /**
  82859. * Creates a new ray from screen space and viewport
  82860. * @param x position
  82861. * @param y y position
  82862. * @param viewportWidth viewport width
  82863. * @param viewportHeight viewport height
  82864. * @param world world matrix
  82865. * @param view view matrix
  82866. * @param projection projection matrix
  82867. * @returns new ray
  82868. */
  82869. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  82870. /**
  82871. * 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
  82872. * transformed to the given world matrix.
  82873. * @param origin The origin point
  82874. * @param end The end point
  82875. * @param world a matrix to transform the ray to. Default is the identity matrix.
  82876. * @returns the new ray
  82877. */
  82878. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  82879. /**
  82880. * Transforms a ray by a matrix
  82881. * @param ray ray to transform
  82882. * @param matrix matrix to apply
  82883. * @returns the resulting new ray
  82884. */
  82885. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  82886. /**
  82887. * Transforms a ray by a matrix
  82888. * @param ray ray to transform
  82889. * @param matrix matrix to apply
  82890. * @param result ray to store result in
  82891. */
  82892. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  82893. /**
  82894. * Unproject a ray from screen space to object space
  82895. * @param sourceX defines the screen space x coordinate to use
  82896. * @param sourceY defines the screen space y coordinate to use
  82897. * @param viewportWidth defines the current width of the viewport
  82898. * @param viewportHeight defines the current height of the viewport
  82899. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  82900. * @param view defines the view matrix to use
  82901. * @param projection defines the projection matrix to use
  82902. */
  82903. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  82904. }
  82905. /**
  82906. * Type used to define predicate used to select faces when a mesh intersection is detected
  82907. */
  82908. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  82909. interface Scene {
  82910. /** @hidden */
  82911. _tempPickingRay: Nullable<Ray>;
  82912. /** @hidden */
  82913. _cachedRayForTransform: Ray;
  82914. /** @hidden */
  82915. _pickWithRayInverseMatrix: Matrix;
  82916. /** @hidden */
  82917. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  82918. /** @hidden */
  82919. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  82920. }
  82921. }
  82922. declare module BABYLON {
  82923. /**
  82924. * Groups all the scene component constants in one place to ease maintenance.
  82925. * @hidden
  82926. */
  82927. export class SceneComponentConstants {
  82928. static readonly NAME_EFFECTLAYER: string;
  82929. static readonly NAME_LAYER: string;
  82930. static readonly NAME_LENSFLARESYSTEM: string;
  82931. static readonly NAME_BOUNDINGBOXRENDERER: string;
  82932. static readonly NAME_PARTICLESYSTEM: string;
  82933. static readonly NAME_GAMEPAD: string;
  82934. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  82935. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  82936. static readonly NAME_DEPTHRENDERER: string;
  82937. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  82938. static readonly NAME_SPRITE: string;
  82939. static readonly NAME_OUTLINERENDERER: string;
  82940. static readonly NAME_PROCEDURALTEXTURE: string;
  82941. static readonly NAME_SHADOWGENERATOR: string;
  82942. static readonly NAME_OCTREE: string;
  82943. static readonly NAME_PHYSICSENGINE: string;
  82944. static readonly NAME_AUDIO: string;
  82945. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  82946. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82947. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  82948. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  82949. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  82950. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  82951. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  82952. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  82953. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  82954. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  82955. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  82956. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  82957. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  82958. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  82959. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  82960. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  82961. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  82962. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  82963. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  82964. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  82965. static readonly STEP_AFTERRENDER_AUDIO: number;
  82966. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  82967. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  82968. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  82969. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  82970. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  82971. static readonly STEP_POINTERMOVE_SPRITE: number;
  82972. static readonly STEP_POINTERDOWN_SPRITE: number;
  82973. static readonly STEP_POINTERUP_SPRITE: number;
  82974. }
  82975. /**
  82976. * This represents a scene component.
  82977. *
  82978. * This is used to decouple the dependency the scene is having on the different workloads like
  82979. * layers, post processes...
  82980. */
  82981. export interface ISceneComponent {
  82982. /**
  82983. * The name of the component. Each component must have a unique name.
  82984. */
  82985. name: string;
  82986. /**
  82987. * The scene the component belongs to.
  82988. */
  82989. scene: Scene;
  82990. /**
  82991. * Register the component to one instance of a scene.
  82992. */
  82993. register(): void;
  82994. /**
  82995. * Rebuilds the elements related to this component in case of
  82996. * context lost for instance.
  82997. */
  82998. rebuild(): void;
  82999. /**
  83000. * Disposes the component and the associated ressources.
  83001. */
  83002. dispose(): void;
  83003. }
  83004. /**
  83005. * This represents a SERIALIZABLE scene component.
  83006. *
  83007. * This extends Scene Component to add Serialization methods on top.
  83008. */
  83009. export interface ISceneSerializableComponent extends ISceneComponent {
  83010. /**
  83011. * Adds all the elements from the container to the scene
  83012. * @param container the container holding the elements
  83013. */
  83014. addFromContainer(container: AbstractScene): void;
  83015. /**
  83016. * Removes all the elements in the container from the scene
  83017. * @param container contains the elements to remove
  83018. * @param dispose if the removed element should be disposed (default: false)
  83019. */
  83020. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  83021. /**
  83022. * Serializes the component data to the specified json object
  83023. * @param serializationObject The object to serialize to
  83024. */
  83025. serialize(serializationObject: any): void;
  83026. }
  83027. /**
  83028. * Strong typing of a Mesh related stage step action
  83029. */
  83030. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  83031. /**
  83032. * Strong typing of a Evaluate Sub Mesh related stage step action
  83033. */
  83034. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  83035. /**
  83036. * Strong typing of a Active Mesh related stage step action
  83037. */
  83038. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  83039. /**
  83040. * Strong typing of a Camera related stage step action
  83041. */
  83042. export type CameraStageAction = (camera: Camera) => void;
  83043. /**
  83044. * Strong typing of a Camera Frame buffer related stage step action
  83045. */
  83046. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  83047. /**
  83048. * Strong typing of a Render Target related stage step action
  83049. */
  83050. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  83051. /**
  83052. * Strong typing of a RenderingGroup related stage step action
  83053. */
  83054. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  83055. /**
  83056. * Strong typing of a Mesh Render related stage step action
  83057. */
  83058. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  83059. /**
  83060. * Strong typing of a simple stage step action
  83061. */
  83062. export type SimpleStageAction = () => void;
  83063. /**
  83064. * Strong typing of a render target action.
  83065. */
  83066. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  83067. /**
  83068. * Strong typing of a pointer move action.
  83069. */
  83070. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  83071. /**
  83072. * Strong typing of a pointer up/down action.
  83073. */
  83074. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  83075. /**
  83076. * Representation of a stage in the scene (Basically a list of ordered steps)
  83077. * @hidden
  83078. */
  83079. export class Stage<T extends Function> extends Array<{
  83080. index: number;
  83081. component: ISceneComponent;
  83082. action: T;
  83083. }> {
  83084. /**
  83085. * Hide ctor from the rest of the world.
  83086. * @param items The items to add.
  83087. */
  83088. private constructor();
  83089. /**
  83090. * Creates a new Stage.
  83091. * @returns A new instance of a Stage
  83092. */
  83093. static Create<T extends Function>(): Stage<T>;
  83094. /**
  83095. * Registers a step in an ordered way in the targeted stage.
  83096. * @param index Defines the position to register the step in
  83097. * @param component Defines the component attached to the step
  83098. * @param action Defines the action to launch during the step
  83099. */
  83100. registerStep(index: number, component: ISceneComponent, action: T): void;
  83101. /**
  83102. * Clears all the steps from the stage.
  83103. */
  83104. clear(): void;
  83105. }
  83106. }
  83107. declare module BABYLON {
  83108. interface Scene {
  83109. /** @hidden */
  83110. _pointerOverSprite: Nullable<Sprite>;
  83111. /** @hidden */
  83112. _pickedDownSprite: Nullable<Sprite>;
  83113. /** @hidden */
  83114. _tempSpritePickingRay: Nullable<Ray>;
  83115. /**
  83116. * All of the sprite managers added to this scene
  83117. * @see http://doc.babylonjs.com/babylon101/sprites
  83118. */
  83119. spriteManagers: Array<ISpriteManager>;
  83120. /**
  83121. * An event triggered when sprites rendering is about to start
  83122. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83123. */
  83124. onBeforeSpritesRenderingObservable: Observable<Scene>;
  83125. /**
  83126. * An event triggered when sprites rendering is done
  83127. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  83128. */
  83129. onAfterSpritesRenderingObservable: Observable<Scene>;
  83130. /** @hidden */
  83131. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83132. /** Launch a ray to try to pick a sprite in the scene
  83133. * @param x position on screen
  83134. * @param y position on screen
  83135. * @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
  83136. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83137. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83138. * @returns a PickingInfo
  83139. */
  83140. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83141. /** Use the given ray to pick a sprite in the scene
  83142. * @param ray The ray (in world space) to use to pick meshes
  83143. * @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
  83144. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  83145. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83146. * @returns a PickingInfo
  83147. */
  83148. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  83149. /** @hidden */
  83150. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83151. /** Launch a ray to try to pick sprites in the scene
  83152. * @param x position on screen
  83153. * @param y position on screen
  83154. * @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
  83155. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  83156. * @returns a PickingInfo array
  83157. */
  83158. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83159. /** Use the given ray to pick sprites in the scene
  83160. * @param ray The ray (in world space) to use to pick meshes
  83161. * @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
  83162. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  83163. * @returns a PickingInfo array
  83164. */
  83165. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  83166. /**
  83167. * Force the sprite under the pointer
  83168. * @param sprite defines the sprite to use
  83169. */
  83170. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  83171. /**
  83172. * Gets the sprite under the pointer
  83173. * @returns a Sprite or null if no sprite is under the pointer
  83174. */
  83175. getPointerOverSprite(): Nullable<Sprite>;
  83176. }
  83177. /**
  83178. * Defines the sprite scene component responsible to manage sprites
  83179. * in a given scene.
  83180. */
  83181. export class SpriteSceneComponent implements ISceneComponent {
  83182. /**
  83183. * The component name helpfull to identify the component in the list of scene components.
  83184. */
  83185. readonly name: string;
  83186. /**
  83187. * The scene the component belongs to.
  83188. */
  83189. scene: Scene;
  83190. /** @hidden */
  83191. private _spritePredicate;
  83192. /**
  83193. * Creates a new instance of the component for the given scene
  83194. * @param scene Defines the scene to register the component in
  83195. */
  83196. constructor(scene: Scene);
  83197. /**
  83198. * Registers the component in a given scene
  83199. */
  83200. register(): void;
  83201. /**
  83202. * Rebuilds the elements related to this component in case of
  83203. * context lost for instance.
  83204. */
  83205. rebuild(): void;
  83206. /**
  83207. * Disposes the component and the associated ressources.
  83208. */
  83209. dispose(): void;
  83210. private _pickSpriteButKeepRay;
  83211. private _pointerMove;
  83212. private _pointerDown;
  83213. private _pointerUp;
  83214. }
  83215. }
  83216. declare module BABYLON {
  83217. /** @hidden */
  83218. export var fogFragmentDeclaration: {
  83219. name: string;
  83220. shader: string;
  83221. };
  83222. }
  83223. declare module BABYLON {
  83224. /** @hidden */
  83225. export var fogFragment: {
  83226. name: string;
  83227. shader: string;
  83228. };
  83229. }
  83230. declare module BABYLON {
  83231. /** @hidden */
  83232. export var spritesPixelShader: {
  83233. name: string;
  83234. shader: string;
  83235. };
  83236. }
  83237. declare module BABYLON {
  83238. /** @hidden */
  83239. export var fogVertexDeclaration: {
  83240. name: string;
  83241. shader: string;
  83242. };
  83243. }
  83244. declare module BABYLON {
  83245. /** @hidden */
  83246. export var spritesVertexShader: {
  83247. name: string;
  83248. shader: string;
  83249. };
  83250. }
  83251. declare module BABYLON {
  83252. /**
  83253. * Defines the minimum interface to fullfil in order to be a sprite manager.
  83254. */
  83255. export interface ISpriteManager extends IDisposable {
  83256. /**
  83257. * Restricts the camera to viewing objects with the same layerMask.
  83258. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  83259. */
  83260. layerMask: number;
  83261. /**
  83262. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83263. */
  83264. isPickable: boolean;
  83265. /**
  83266. * Specifies the rendering group id for this mesh (0 by default)
  83267. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83268. */
  83269. renderingGroupId: number;
  83270. /**
  83271. * Defines the list of sprites managed by the manager.
  83272. */
  83273. sprites: Array<Sprite>;
  83274. /**
  83275. * Tests the intersection of a sprite with a specific ray.
  83276. * @param ray The ray we are sending to test the collision
  83277. * @param camera The camera space we are sending rays in
  83278. * @param predicate A predicate allowing excluding sprites from the list of object to test
  83279. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  83280. * @returns picking info or null.
  83281. */
  83282. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83283. /**
  83284. * Intersects the sprites with a ray
  83285. * @param ray defines the ray to intersect with
  83286. * @param camera defines the current active camera
  83287. * @param predicate defines a predicate used to select candidate sprites
  83288. * @returns null if no hit or a PickingInfo array
  83289. */
  83290. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83291. /**
  83292. * Renders the list of sprites on screen.
  83293. */
  83294. render(): void;
  83295. }
  83296. /**
  83297. * Class used to manage multiple sprites on the same spritesheet
  83298. * @see http://doc.babylonjs.com/babylon101/sprites
  83299. */
  83300. export class SpriteManager implements ISpriteManager {
  83301. /** defines the manager's name */
  83302. name: string;
  83303. /** Gets the list of sprites */
  83304. sprites: Sprite[];
  83305. /** Gets or sets the rendering group id (0 by default) */
  83306. renderingGroupId: number;
  83307. /** Gets or sets camera layer mask */
  83308. layerMask: number;
  83309. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  83310. fogEnabled: boolean;
  83311. /** Gets or sets a boolean indicating if the sprites are pickable */
  83312. isPickable: boolean;
  83313. /** Defines the default width of a cell in the spritesheet */
  83314. cellWidth: number;
  83315. /** Defines the default height of a cell in the spritesheet */
  83316. cellHeight: number;
  83317. /** Associative array from JSON sprite data file */
  83318. private _cellData;
  83319. /** Array of sprite names from JSON sprite data file */
  83320. private _spriteMap;
  83321. /** True when packed cell data from JSON file is ready*/
  83322. private _packedAndReady;
  83323. /**
  83324. * An event triggered when the manager is disposed.
  83325. */
  83326. onDisposeObservable: Observable<SpriteManager>;
  83327. private _onDisposeObserver;
  83328. /**
  83329. * Callback called when the manager is disposed
  83330. */
  83331. set onDispose(callback: () => void);
  83332. private _capacity;
  83333. private _fromPacked;
  83334. private _spriteTexture;
  83335. private _epsilon;
  83336. private _scene;
  83337. private _vertexData;
  83338. private _buffer;
  83339. private _vertexBuffers;
  83340. private _indexBuffer;
  83341. private _effectBase;
  83342. private _effectFog;
  83343. /**
  83344. * Gets or sets the spritesheet texture
  83345. */
  83346. get texture(): Texture;
  83347. set texture(value: Texture);
  83348. /**
  83349. * Creates a new sprite manager
  83350. * @param name defines the manager's name
  83351. * @param imgUrl defines the sprite sheet url
  83352. * @param capacity defines the maximum allowed number of sprites
  83353. * @param cellSize defines the size of a sprite cell
  83354. * @param scene defines the hosting scene
  83355. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  83356. * @param samplingMode defines the smapling mode to use with spritesheet
  83357. * @param fromPacked set to false; do not alter
  83358. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  83359. */
  83360. constructor(
  83361. /** defines the manager's name */
  83362. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  83363. private _makePacked;
  83364. private _appendSpriteVertex;
  83365. /**
  83366. * Intersects the sprites with a ray
  83367. * @param ray defines the ray to intersect with
  83368. * @param camera defines the current active camera
  83369. * @param predicate defines a predicate used to select candidate sprites
  83370. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  83371. * @returns null if no hit or a PickingInfo
  83372. */
  83373. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  83374. /**
  83375. * Intersects the sprites with a ray
  83376. * @param ray defines the ray to intersect with
  83377. * @param camera defines the current active camera
  83378. * @param predicate defines a predicate used to select candidate sprites
  83379. * @returns null if no hit or a PickingInfo array
  83380. */
  83381. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  83382. /**
  83383. * Render all child sprites
  83384. */
  83385. render(): void;
  83386. /**
  83387. * Release associated resources
  83388. */
  83389. dispose(): void;
  83390. }
  83391. }
  83392. declare module BABYLON {
  83393. /** Interface used by value gradients (color, factor, ...) */
  83394. export interface IValueGradient {
  83395. /**
  83396. * Gets or sets the gradient value (between 0 and 1)
  83397. */
  83398. gradient: number;
  83399. }
  83400. /** Class used to store color4 gradient */
  83401. export class ColorGradient implements IValueGradient {
  83402. /**
  83403. * Gets or sets the gradient value (between 0 and 1)
  83404. */
  83405. gradient: number;
  83406. /**
  83407. * Gets or sets first associated color
  83408. */
  83409. color1: Color4;
  83410. /**
  83411. * Gets or sets second associated color
  83412. */
  83413. color2?: Color4;
  83414. /**
  83415. * Will get a color picked randomly between color1 and color2.
  83416. * If color2 is undefined then color1 will be used
  83417. * @param result defines the target Color4 to store the result in
  83418. */
  83419. getColorToRef(result: Color4): void;
  83420. }
  83421. /** Class used to store color 3 gradient */
  83422. export class Color3Gradient implements IValueGradient {
  83423. /**
  83424. * Gets or sets the gradient value (between 0 and 1)
  83425. */
  83426. gradient: number;
  83427. /**
  83428. * Gets or sets the associated color
  83429. */
  83430. color: Color3;
  83431. }
  83432. /** Class used to store factor gradient */
  83433. export class FactorGradient implements IValueGradient {
  83434. /**
  83435. * Gets or sets the gradient value (between 0 and 1)
  83436. */
  83437. gradient: number;
  83438. /**
  83439. * Gets or sets first associated factor
  83440. */
  83441. factor1: number;
  83442. /**
  83443. * Gets or sets second associated factor
  83444. */
  83445. factor2?: number;
  83446. /**
  83447. * Will get a number picked randomly between factor1 and factor2.
  83448. * If factor2 is undefined then factor1 will be used
  83449. * @returns the picked number
  83450. */
  83451. getFactor(): number;
  83452. }
  83453. /**
  83454. * Helper used to simplify some generic gradient tasks
  83455. */
  83456. export class GradientHelper {
  83457. /**
  83458. * Gets the current gradient from an array of IValueGradient
  83459. * @param ratio defines the current ratio to get
  83460. * @param gradients defines the array of IValueGradient
  83461. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  83462. */
  83463. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  83464. }
  83465. }
  83466. declare module BABYLON {
  83467. /**
  83468. * Interface for the size containing width and height
  83469. */
  83470. export interface ISize {
  83471. /**
  83472. * Width
  83473. */
  83474. width: number;
  83475. /**
  83476. * Heighht
  83477. */
  83478. height: number;
  83479. }
  83480. /**
  83481. * Size containing widht and height
  83482. */
  83483. export class Size implements ISize {
  83484. /**
  83485. * Width
  83486. */
  83487. width: number;
  83488. /**
  83489. * Height
  83490. */
  83491. height: number;
  83492. /**
  83493. * Creates a Size object from the given width and height (floats).
  83494. * @param width width of the new size
  83495. * @param height height of the new size
  83496. */
  83497. constructor(width: number, height: number);
  83498. /**
  83499. * Returns a string with the Size width and height
  83500. * @returns a string with the Size width and height
  83501. */
  83502. toString(): string;
  83503. /**
  83504. * "Size"
  83505. * @returns the string "Size"
  83506. */
  83507. getClassName(): string;
  83508. /**
  83509. * Returns the Size hash code.
  83510. * @returns a hash code for a unique width and height
  83511. */
  83512. getHashCode(): number;
  83513. /**
  83514. * Updates the current size from the given one.
  83515. * @param src the given size
  83516. */
  83517. copyFrom(src: Size): void;
  83518. /**
  83519. * Updates in place the current Size from the given floats.
  83520. * @param width width of the new size
  83521. * @param height height of the new size
  83522. * @returns the updated Size.
  83523. */
  83524. copyFromFloats(width: number, height: number): Size;
  83525. /**
  83526. * Updates in place the current Size from the given floats.
  83527. * @param width width to set
  83528. * @param height height to set
  83529. * @returns the updated Size.
  83530. */
  83531. set(width: number, height: number): Size;
  83532. /**
  83533. * Multiplies the width and height by numbers
  83534. * @param w factor to multiple the width by
  83535. * @param h factor to multiple the height by
  83536. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  83537. */
  83538. multiplyByFloats(w: number, h: number): Size;
  83539. /**
  83540. * Clones the size
  83541. * @returns a new Size copied from the given one.
  83542. */
  83543. clone(): Size;
  83544. /**
  83545. * True if the current Size and the given one width and height are strictly equal.
  83546. * @param other the other size to compare against
  83547. * @returns True if the current Size and the given one width and height are strictly equal.
  83548. */
  83549. equals(other: Size): boolean;
  83550. /**
  83551. * The surface of the Size : width * height (float).
  83552. */
  83553. get surface(): number;
  83554. /**
  83555. * Create a new size of zero
  83556. * @returns a new Size set to (0.0, 0.0)
  83557. */
  83558. static Zero(): Size;
  83559. /**
  83560. * Sums the width and height of two sizes
  83561. * @param otherSize size to add to this size
  83562. * @returns a new Size set as the addition result of the current Size and the given one.
  83563. */
  83564. add(otherSize: Size): Size;
  83565. /**
  83566. * Subtracts the width and height of two
  83567. * @param otherSize size to subtract to this size
  83568. * @returns a new Size set as the subtraction result of the given one from the current Size.
  83569. */
  83570. subtract(otherSize: Size): Size;
  83571. /**
  83572. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  83573. * @param start starting size to lerp between
  83574. * @param end end size to lerp between
  83575. * @param amount amount to lerp between the start and end values
  83576. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  83577. */
  83578. static Lerp(start: Size, end: Size, amount: number): Size;
  83579. }
  83580. }
  83581. declare module BABYLON {
  83582. interface ThinEngine {
  83583. /**
  83584. * Creates a dynamic texture
  83585. * @param width defines the width of the texture
  83586. * @param height defines the height of the texture
  83587. * @param generateMipMaps defines if the engine should generate the mip levels
  83588. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83589. * @returns the dynamic texture inside an InternalTexture
  83590. */
  83591. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  83592. /**
  83593. * Update the content of a dynamic texture
  83594. * @param texture defines the texture to update
  83595. * @param canvas defines the canvas containing the source
  83596. * @param invertY defines if data must be stored with Y axis inverted
  83597. * @param premulAlpha defines if alpha is stored as premultiplied
  83598. * @param format defines the format of the data
  83599. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  83600. */
  83601. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  83602. }
  83603. }
  83604. declare module BABYLON {
  83605. /**
  83606. * Helper class used to generate a canvas to manipulate images
  83607. */
  83608. export class CanvasGenerator {
  83609. /**
  83610. * Create a new canvas (or offscreen canvas depending on the context)
  83611. * @param width defines the expected width
  83612. * @param height defines the expected height
  83613. * @return a new canvas or offscreen canvas
  83614. */
  83615. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  83616. }
  83617. }
  83618. declare module BABYLON {
  83619. /**
  83620. * A class extending Texture allowing drawing on a texture
  83621. * @see http://doc.babylonjs.com/how_to/dynamictexture
  83622. */
  83623. export class DynamicTexture extends Texture {
  83624. private _generateMipMaps;
  83625. private _canvas;
  83626. private _context;
  83627. private _engine;
  83628. /**
  83629. * Creates a DynamicTexture
  83630. * @param name defines the name of the texture
  83631. * @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
  83632. * @param scene defines the scene where you want the texture
  83633. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  83634. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  83635. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  83636. */
  83637. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  83638. /**
  83639. * Get the current class name of the texture useful for serialization or dynamic coding.
  83640. * @returns "DynamicTexture"
  83641. */
  83642. getClassName(): string;
  83643. /**
  83644. * Gets the current state of canRescale
  83645. */
  83646. get canRescale(): boolean;
  83647. private _recreate;
  83648. /**
  83649. * Scales the texture
  83650. * @param ratio the scale factor to apply to both width and height
  83651. */
  83652. scale(ratio: number): void;
  83653. /**
  83654. * Resizes the texture
  83655. * @param width the new width
  83656. * @param height the new height
  83657. */
  83658. scaleTo(width: number, height: number): void;
  83659. /**
  83660. * Gets the context of the canvas used by the texture
  83661. * @returns the canvas context of the dynamic texture
  83662. */
  83663. getContext(): CanvasRenderingContext2D;
  83664. /**
  83665. * Clears the texture
  83666. */
  83667. clear(): void;
  83668. /**
  83669. * Updates the texture
  83670. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83671. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  83672. */
  83673. update(invertY?: boolean, premulAlpha?: boolean): void;
  83674. /**
  83675. * Draws text onto the texture
  83676. * @param text defines the text to be drawn
  83677. * @param x defines the placement of the text from the left
  83678. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  83679. * @param font defines the font to be used with font-style, font-size, font-name
  83680. * @param color defines the color used for the text
  83681. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  83682. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  83683. * @param update defines whether texture is immediately update (default is true)
  83684. */
  83685. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  83686. /**
  83687. * Clones the texture
  83688. * @returns the clone of the texture.
  83689. */
  83690. clone(): DynamicTexture;
  83691. /**
  83692. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83693. * @returns a serialized dynamic texture object
  83694. */
  83695. serialize(): any;
  83696. /** @hidden */
  83697. _rebuild(): void;
  83698. }
  83699. }
  83700. declare module BABYLON {
  83701. interface Engine {
  83702. /**
  83703. * Creates a raw texture
  83704. * @param data defines the data to store in the texture
  83705. * @param width defines the width of the texture
  83706. * @param height defines the height of the texture
  83707. * @param format defines the format of the data
  83708. * @param generateMipMaps defines if the engine should generate the mip levels
  83709. * @param invertY defines if data must be stored with Y axis inverted
  83710. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  83711. * @param compression defines the compression used (null by default)
  83712. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83713. * @returns the raw texture inside an InternalTexture
  83714. */
  83715. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  83716. /**
  83717. * Update a raw texture
  83718. * @param texture defines the texture to update
  83719. * @param data defines the data to store in the texture
  83720. * @param format defines the format of the data
  83721. * @param invertY defines if data must be stored with Y axis inverted
  83722. */
  83723. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83724. /**
  83725. * Update a raw texture
  83726. * @param texture defines the texture to update
  83727. * @param data defines the data to store in the texture
  83728. * @param format defines the format of the data
  83729. * @param invertY defines if data must be stored with Y axis inverted
  83730. * @param compression defines the compression used (null by default)
  83731. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83732. */
  83733. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  83734. /**
  83735. * Creates a new raw cube texture
  83736. * @param data defines the array of data to use to create each face
  83737. * @param size defines the size of the textures
  83738. * @param format defines the format of the data
  83739. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83740. * @param generateMipMaps defines if the engine should generate the mip levels
  83741. * @param invertY defines if data must be stored with Y axis inverted
  83742. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83743. * @param compression defines the compression used (null by default)
  83744. * @returns the cube texture as an InternalTexture
  83745. */
  83746. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  83747. /**
  83748. * Update a raw cube texture
  83749. * @param texture defines the texture to udpdate
  83750. * @param data defines the data to store
  83751. * @param format defines the data format
  83752. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83753. * @param invertY defines if data must be stored with Y axis inverted
  83754. */
  83755. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  83756. /**
  83757. * Update a raw cube texture
  83758. * @param texture defines the texture to udpdate
  83759. * @param data defines the data to store
  83760. * @param format defines the data format
  83761. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83762. * @param invertY defines if data must be stored with Y axis inverted
  83763. * @param compression defines the compression used (null by default)
  83764. */
  83765. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  83766. /**
  83767. * Update a raw cube texture
  83768. * @param texture defines the texture to udpdate
  83769. * @param data defines the data to store
  83770. * @param format defines the data format
  83771. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  83772. * @param invertY defines if data must be stored with Y axis inverted
  83773. * @param compression defines the compression used (null by default)
  83774. * @param level defines which level of the texture to update
  83775. */
  83776. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  83777. /**
  83778. * Creates a new raw cube texture from a specified url
  83779. * @param url defines the url where the data is located
  83780. * @param scene defines the current scene
  83781. * @param size defines the size of the textures
  83782. * @param format defines the format of the data
  83783. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83784. * @param noMipmap defines if the engine should avoid generating the mip levels
  83785. * @param callback defines a callback used to extract texture data from loaded data
  83786. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83787. * @param onLoad defines a callback called when texture is loaded
  83788. * @param onError defines a callback called if there is an error
  83789. * @returns the cube texture as an InternalTexture
  83790. */
  83791. 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;
  83792. /**
  83793. * Creates a new raw cube texture from a specified url
  83794. * @param url defines the url where the data is located
  83795. * @param scene defines the current scene
  83796. * @param size defines the size of the textures
  83797. * @param format defines the format of the data
  83798. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  83799. * @param noMipmap defines if the engine should avoid generating the mip levels
  83800. * @param callback defines a callback used to extract texture data from loaded data
  83801. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  83802. * @param onLoad defines a callback called when texture is loaded
  83803. * @param onError defines a callback called if there is an error
  83804. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83805. * @param invertY defines if data must be stored with Y axis inverted
  83806. * @returns the cube texture as an InternalTexture
  83807. */
  83808. 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;
  83809. /**
  83810. * Creates a new raw 3D texture
  83811. * @param data defines the data used to create the texture
  83812. * @param width defines the width of the texture
  83813. * @param height defines the height of the texture
  83814. * @param depth defines the depth of the texture
  83815. * @param format defines the format of the texture
  83816. * @param generateMipMaps defines if the engine must generate mip levels
  83817. * @param invertY defines if data must be stored with Y axis inverted
  83818. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83819. * @param compression defines the compressed used (can be null)
  83820. * @param textureType defines the compressed used (can be null)
  83821. * @returns a new raw 3D texture (stored in an InternalTexture)
  83822. */
  83823. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83824. /**
  83825. * Update a raw 3D texture
  83826. * @param texture defines the texture to update
  83827. * @param data defines the data to store
  83828. * @param format defines the data format
  83829. * @param invertY defines if data must be stored with Y axis inverted
  83830. */
  83831. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83832. /**
  83833. * Update a raw 3D texture
  83834. * @param texture defines the texture to update
  83835. * @param data defines the data to store
  83836. * @param format defines the data format
  83837. * @param invertY defines if data must be stored with Y axis inverted
  83838. * @param compression defines the used compression (can be null)
  83839. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83840. */
  83841. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83842. /**
  83843. * Creates a new raw 2D array texture
  83844. * @param data defines the data used to create the texture
  83845. * @param width defines the width of the texture
  83846. * @param height defines the height of the texture
  83847. * @param depth defines the number of layers of the texture
  83848. * @param format defines the format of the texture
  83849. * @param generateMipMaps defines if the engine must generate mip levels
  83850. * @param invertY defines if data must be stored with Y axis inverted
  83851. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  83852. * @param compression defines the compressed used (can be null)
  83853. * @param textureType defines the compressed used (can be null)
  83854. * @returns a new raw 2D array texture (stored in an InternalTexture)
  83855. */
  83856. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  83857. /**
  83858. * Update a raw 2D array texture
  83859. * @param texture defines the texture to update
  83860. * @param data defines the data to store
  83861. * @param format defines the data format
  83862. * @param invertY defines if data must be stored with Y axis inverted
  83863. */
  83864. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  83865. /**
  83866. * Update a raw 2D array texture
  83867. * @param texture defines the texture to update
  83868. * @param data defines the data to store
  83869. * @param format defines the data format
  83870. * @param invertY defines if data must be stored with Y axis inverted
  83871. * @param compression defines the used compression (can be null)
  83872. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  83873. */
  83874. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  83875. }
  83876. }
  83877. declare module BABYLON {
  83878. /**
  83879. * Raw texture can help creating a texture directly from an array of data.
  83880. * This can be super useful if you either get the data from an uncompressed source or
  83881. * if you wish to create your texture pixel by pixel.
  83882. */
  83883. export class RawTexture extends Texture {
  83884. /**
  83885. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83886. */
  83887. format: number;
  83888. private _engine;
  83889. /**
  83890. * Instantiates a new RawTexture.
  83891. * Raw texture can help creating a texture directly from an array of data.
  83892. * This can be super useful if you either get the data from an uncompressed source or
  83893. * if you wish to create your texture pixel by pixel.
  83894. * @param data define the array of data to use to create the texture
  83895. * @param width define the width of the texture
  83896. * @param height define the height of the texture
  83897. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83898. * @param scene define the scene the texture belongs to
  83899. * @param generateMipMaps define whether mip maps should be generated or not
  83900. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83901. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83902. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83903. */
  83904. constructor(data: ArrayBufferView, width: number, height: number,
  83905. /**
  83906. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  83907. */
  83908. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  83909. /**
  83910. * Updates the texture underlying data.
  83911. * @param data Define the new data of the texture
  83912. */
  83913. update(data: ArrayBufferView): void;
  83914. /**
  83915. * Creates a luminance texture from some data.
  83916. * @param data Define the texture data
  83917. * @param width Define the width of the texture
  83918. * @param height Define the height of the texture
  83919. * @param scene Define the scene the texture belongs to
  83920. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83921. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83922. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83923. * @returns the luminance texture
  83924. */
  83925. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83926. /**
  83927. * Creates a luminance alpha texture from some data.
  83928. * @param data Define the texture data
  83929. * @param width Define the width of the texture
  83930. * @param height Define the height of the texture
  83931. * @param scene Define the scene the texture belongs to
  83932. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83933. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83934. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83935. * @returns the luminance alpha texture
  83936. */
  83937. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83938. /**
  83939. * Creates an alpha texture from some data.
  83940. * @param data Define the texture data
  83941. * @param width Define the width of the texture
  83942. * @param height Define the height of the texture
  83943. * @param scene Define the scene the texture belongs to
  83944. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83945. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83946. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83947. * @returns the alpha texture
  83948. */
  83949. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  83950. /**
  83951. * Creates a RGB texture from some data.
  83952. * @param data Define the texture data
  83953. * @param width Define the width of the texture
  83954. * @param height Define the height of the texture
  83955. * @param scene Define the scene the texture belongs to
  83956. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83957. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83958. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83959. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83960. * @returns the RGB alpha texture
  83961. */
  83962. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83963. /**
  83964. * Creates a RGBA texture from some data.
  83965. * @param data Define the texture data
  83966. * @param width Define the width of the texture
  83967. * @param height Define the height of the texture
  83968. * @param scene Define the scene the texture belongs to
  83969. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83970. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83971. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83972. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83973. * @returns the RGBA texture
  83974. */
  83975. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83976. /**
  83977. * Creates a R texture from some data.
  83978. * @param data Define the texture data
  83979. * @param width Define the width of the texture
  83980. * @param height Define the height of the texture
  83981. * @param scene Define the scene the texture belongs to
  83982. * @param generateMipMaps Define whether or not to create mip maps for the texture
  83983. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  83984. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  83985. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  83986. * @returns the R texture
  83987. */
  83988. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  83989. }
  83990. }
  83991. declare module BABYLON {
  83992. interface AbstractScene {
  83993. /**
  83994. * The list of procedural textures added to the scene
  83995. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83996. */
  83997. proceduralTextures: Array<ProceduralTexture>;
  83998. }
  83999. /**
  84000. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  84001. * in a given scene.
  84002. */
  84003. export class ProceduralTextureSceneComponent implements ISceneComponent {
  84004. /**
  84005. * The component name helpfull to identify the component in the list of scene components.
  84006. */
  84007. readonly name: string;
  84008. /**
  84009. * The scene the component belongs to.
  84010. */
  84011. scene: Scene;
  84012. /**
  84013. * Creates a new instance of the component for the given scene
  84014. * @param scene Defines the scene to register the component in
  84015. */
  84016. constructor(scene: Scene);
  84017. /**
  84018. * Registers the component in a given scene
  84019. */
  84020. register(): void;
  84021. /**
  84022. * Rebuilds the elements related to this component in case of
  84023. * context lost for instance.
  84024. */
  84025. rebuild(): void;
  84026. /**
  84027. * Disposes the component and the associated ressources.
  84028. */
  84029. dispose(): void;
  84030. private _beforeClear;
  84031. }
  84032. }
  84033. declare module BABYLON {
  84034. interface ThinEngine {
  84035. /**
  84036. * Creates a new render target cube texture
  84037. * @param size defines the size of the texture
  84038. * @param options defines the options used to create the texture
  84039. * @returns a new render target cube texture stored in an InternalTexture
  84040. */
  84041. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  84042. }
  84043. }
  84044. declare module BABYLON {
  84045. /** @hidden */
  84046. export var proceduralVertexShader: {
  84047. name: string;
  84048. shader: string;
  84049. };
  84050. }
  84051. declare module BABYLON {
  84052. /**
  84053. * 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.
  84054. * This is the base class of any Procedural texture and contains most of the shareable code.
  84055. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84056. */
  84057. export class ProceduralTexture extends Texture {
  84058. isCube: boolean;
  84059. /**
  84060. * Define if the texture is enabled or not (disabled texture will not render)
  84061. */
  84062. isEnabled: boolean;
  84063. /**
  84064. * Define if the texture must be cleared before rendering (default is true)
  84065. */
  84066. autoClear: boolean;
  84067. /**
  84068. * Callback called when the texture is generated
  84069. */
  84070. onGenerated: () => void;
  84071. /**
  84072. * Event raised when the texture is generated
  84073. */
  84074. onGeneratedObservable: Observable<ProceduralTexture>;
  84075. /** @hidden */
  84076. _generateMipMaps: boolean;
  84077. /** @hidden **/
  84078. _effect: Effect;
  84079. /** @hidden */
  84080. _textures: {
  84081. [key: string]: Texture;
  84082. };
  84083. private _size;
  84084. private _currentRefreshId;
  84085. private _frameId;
  84086. private _refreshRate;
  84087. private _vertexBuffers;
  84088. private _indexBuffer;
  84089. private _uniforms;
  84090. private _samplers;
  84091. private _fragment;
  84092. private _floats;
  84093. private _ints;
  84094. private _floatsArrays;
  84095. private _colors3;
  84096. private _colors4;
  84097. private _vectors2;
  84098. private _vectors3;
  84099. private _matrices;
  84100. private _fallbackTexture;
  84101. private _fallbackTextureUsed;
  84102. private _engine;
  84103. private _cachedDefines;
  84104. private _contentUpdateId;
  84105. private _contentData;
  84106. /**
  84107. * Instantiates a new procedural texture.
  84108. * 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.
  84109. * This is the base class of any Procedural texture and contains most of the shareable code.
  84110. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  84111. * @param name Define the name of the texture
  84112. * @param size Define the size of the texture to create
  84113. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  84114. * @param scene Define the scene the texture belongs to
  84115. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  84116. * @param generateMipMaps Define if the texture should creates mip maps or not
  84117. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  84118. */
  84119. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  84120. /**
  84121. * The effect that is created when initializing the post process.
  84122. * @returns The created effect corresponding the the postprocess.
  84123. */
  84124. getEffect(): Effect;
  84125. /**
  84126. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  84127. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  84128. */
  84129. getContent(): Nullable<ArrayBufferView>;
  84130. private _createIndexBuffer;
  84131. /** @hidden */
  84132. _rebuild(): void;
  84133. /**
  84134. * Resets the texture in order to recreate its associated resources.
  84135. * This can be called in case of context loss
  84136. */
  84137. reset(): void;
  84138. protected _getDefines(): string;
  84139. /**
  84140. * Is the texture ready to be used ? (rendered at least once)
  84141. * @returns true if ready, otherwise, false.
  84142. */
  84143. isReady(): boolean;
  84144. /**
  84145. * Resets the refresh counter of the texture and start bak from scratch.
  84146. * Could be useful to regenerate the texture if it is setup to render only once.
  84147. */
  84148. resetRefreshCounter(): void;
  84149. /**
  84150. * Set the fragment shader to use in order to render the texture.
  84151. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  84152. */
  84153. setFragment(fragment: any): void;
  84154. /**
  84155. * Define the refresh rate of the texture or the rendering frequency.
  84156. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  84157. */
  84158. get refreshRate(): number;
  84159. set refreshRate(value: number);
  84160. /** @hidden */
  84161. _shouldRender(): boolean;
  84162. /**
  84163. * Get the size the texture is rendering at.
  84164. * @returns the size (texture is always squared)
  84165. */
  84166. getRenderSize(): number;
  84167. /**
  84168. * Resize the texture to new value.
  84169. * @param size Define the new size the texture should have
  84170. * @param generateMipMaps Define whether the new texture should create mip maps
  84171. */
  84172. resize(size: number, generateMipMaps: boolean): void;
  84173. private _checkUniform;
  84174. /**
  84175. * Set a texture in the shader program used to render.
  84176. * @param name Define the name of the uniform samplers as defined in the shader
  84177. * @param texture Define the texture to bind to this sampler
  84178. * @return the texture itself allowing "fluent" like uniform updates
  84179. */
  84180. setTexture(name: string, texture: Texture): ProceduralTexture;
  84181. /**
  84182. * Set a float in the shader.
  84183. * @param name Define the name of the uniform as defined in the shader
  84184. * @param value Define the value to give to the uniform
  84185. * @return the texture itself allowing "fluent" like uniform updates
  84186. */
  84187. setFloat(name: string, value: number): ProceduralTexture;
  84188. /**
  84189. * Set a int in the shader.
  84190. * @param name Define the name of the uniform as defined in the shader
  84191. * @param value Define the value to give to the uniform
  84192. * @return the texture itself allowing "fluent" like uniform updates
  84193. */
  84194. setInt(name: string, value: number): ProceduralTexture;
  84195. /**
  84196. * Set an array of floats in the shader.
  84197. * @param name Define the name of the uniform as defined in the shader
  84198. * @param value Define the value to give to the uniform
  84199. * @return the texture itself allowing "fluent" like uniform updates
  84200. */
  84201. setFloats(name: string, value: number[]): ProceduralTexture;
  84202. /**
  84203. * Set a vec3 in the shader from a Color3.
  84204. * @param name Define the name of the uniform as defined in the shader
  84205. * @param value Define the value to give to the uniform
  84206. * @return the texture itself allowing "fluent" like uniform updates
  84207. */
  84208. setColor3(name: string, value: Color3): ProceduralTexture;
  84209. /**
  84210. * Set a vec4 in the shader from a Color4.
  84211. * @param name Define the name of the uniform as defined in the shader
  84212. * @param value Define the value to give to the uniform
  84213. * @return the texture itself allowing "fluent" like uniform updates
  84214. */
  84215. setColor4(name: string, value: Color4): ProceduralTexture;
  84216. /**
  84217. * Set a vec2 in the shader from a Vector2.
  84218. * @param name Define the name of the uniform as defined in the shader
  84219. * @param value Define the value to give to the uniform
  84220. * @return the texture itself allowing "fluent" like uniform updates
  84221. */
  84222. setVector2(name: string, value: Vector2): ProceduralTexture;
  84223. /**
  84224. * Set a vec3 in the shader from a Vector3.
  84225. * @param name Define the name of the uniform as defined in the shader
  84226. * @param value Define the value to give to the uniform
  84227. * @return the texture itself allowing "fluent" like uniform updates
  84228. */
  84229. setVector3(name: string, value: Vector3): ProceduralTexture;
  84230. /**
  84231. * Set a mat4 in the shader from a MAtrix.
  84232. * @param name Define the name of the uniform as defined in the shader
  84233. * @param value Define the value to give to the uniform
  84234. * @return the texture itself allowing "fluent" like uniform updates
  84235. */
  84236. setMatrix(name: string, value: Matrix): ProceduralTexture;
  84237. /**
  84238. * Render the texture to its associated render target.
  84239. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  84240. */
  84241. render(useCameraPostProcess?: boolean): void;
  84242. /**
  84243. * Clone the texture.
  84244. * @returns the cloned texture
  84245. */
  84246. clone(): ProceduralTexture;
  84247. /**
  84248. * Dispose the texture and release its asoociated resources.
  84249. */
  84250. dispose(): void;
  84251. }
  84252. }
  84253. declare module BABYLON {
  84254. /**
  84255. * This represents the base class for particle system in Babylon.
  84256. * 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.
  84257. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84258. * @example https://doc.babylonjs.com/babylon101/particles
  84259. */
  84260. export class BaseParticleSystem {
  84261. /**
  84262. * Source color is added to the destination color without alpha affecting the result
  84263. */
  84264. static BLENDMODE_ONEONE: number;
  84265. /**
  84266. * Blend current color and particle color using particle’s alpha
  84267. */
  84268. static BLENDMODE_STANDARD: number;
  84269. /**
  84270. * Add current color and particle color multiplied by particle’s alpha
  84271. */
  84272. static BLENDMODE_ADD: number;
  84273. /**
  84274. * Multiply current color with particle color
  84275. */
  84276. static BLENDMODE_MULTIPLY: number;
  84277. /**
  84278. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  84279. */
  84280. static BLENDMODE_MULTIPLYADD: number;
  84281. /**
  84282. * List of animations used by the particle system.
  84283. */
  84284. animations: Animation[];
  84285. /**
  84286. * The id of the Particle system.
  84287. */
  84288. id: string;
  84289. /**
  84290. * The friendly name of the Particle system.
  84291. */
  84292. name: string;
  84293. /**
  84294. * The rendering group used by the Particle system to chose when to render.
  84295. */
  84296. renderingGroupId: number;
  84297. /**
  84298. * The emitter represents the Mesh or position we are attaching the particle system to.
  84299. */
  84300. emitter: Nullable<AbstractMesh | Vector3>;
  84301. /**
  84302. * The maximum number of particles to emit per frame
  84303. */
  84304. emitRate: number;
  84305. /**
  84306. * If you want to launch only a few particles at once, that can be done, as well.
  84307. */
  84308. manualEmitCount: number;
  84309. /**
  84310. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  84311. */
  84312. updateSpeed: number;
  84313. /**
  84314. * The amount of time the particle system is running (depends of the overall update speed).
  84315. */
  84316. targetStopDuration: number;
  84317. /**
  84318. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  84319. */
  84320. disposeOnStop: boolean;
  84321. /**
  84322. * Minimum power of emitting particles.
  84323. */
  84324. minEmitPower: number;
  84325. /**
  84326. * Maximum power of emitting particles.
  84327. */
  84328. maxEmitPower: number;
  84329. /**
  84330. * Minimum life time of emitting particles.
  84331. */
  84332. minLifeTime: number;
  84333. /**
  84334. * Maximum life time of emitting particles.
  84335. */
  84336. maxLifeTime: number;
  84337. /**
  84338. * Minimum Size of emitting particles.
  84339. */
  84340. minSize: number;
  84341. /**
  84342. * Maximum Size of emitting particles.
  84343. */
  84344. maxSize: number;
  84345. /**
  84346. * Minimum scale of emitting particles on X axis.
  84347. */
  84348. minScaleX: number;
  84349. /**
  84350. * Maximum scale of emitting particles on X axis.
  84351. */
  84352. maxScaleX: number;
  84353. /**
  84354. * Minimum scale of emitting particles on Y axis.
  84355. */
  84356. minScaleY: number;
  84357. /**
  84358. * Maximum scale of emitting particles on Y axis.
  84359. */
  84360. maxScaleY: number;
  84361. /**
  84362. * Gets or sets the minimal initial rotation in radians.
  84363. */
  84364. minInitialRotation: number;
  84365. /**
  84366. * Gets or sets the maximal initial rotation in radians.
  84367. */
  84368. maxInitialRotation: number;
  84369. /**
  84370. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  84371. */
  84372. minAngularSpeed: number;
  84373. /**
  84374. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  84375. */
  84376. maxAngularSpeed: number;
  84377. /**
  84378. * The texture used to render each particle. (this can be a spritesheet)
  84379. */
  84380. particleTexture: Nullable<Texture>;
  84381. /**
  84382. * The layer mask we are rendering the particles through.
  84383. */
  84384. layerMask: number;
  84385. /**
  84386. * This can help using your own shader to render the particle system.
  84387. * The according effect will be created
  84388. */
  84389. customShader: any;
  84390. /**
  84391. * By default particle system starts as soon as they are created. This prevents the
  84392. * automatic start to happen and let you decide when to start emitting particles.
  84393. */
  84394. preventAutoStart: boolean;
  84395. private _noiseTexture;
  84396. /**
  84397. * Gets or sets a texture used to add random noise to particle positions
  84398. */
  84399. get noiseTexture(): Nullable<ProceduralTexture>;
  84400. set noiseTexture(value: Nullable<ProceduralTexture>);
  84401. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  84402. noiseStrength: Vector3;
  84403. /**
  84404. * Callback triggered when the particle animation is ending.
  84405. */
  84406. onAnimationEnd: Nullable<() => void>;
  84407. /**
  84408. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  84409. */
  84410. blendMode: number;
  84411. /**
  84412. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  84413. * to override the particles.
  84414. */
  84415. forceDepthWrite: boolean;
  84416. /** 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 */
  84417. preWarmCycles: number;
  84418. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  84419. preWarmStepOffset: number;
  84420. /**
  84421. * 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)
  84422. */
  84423. spriteCellChangeSpeed: number;
  84424. /**
  84425. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  84426. */
  84427. startSpriteCellID: number;
  84428. /**
  84429. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  84430. */
  84431. endSpriteCellID: number;
  84432. /**
  84433. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  84434. */
  84435. spriteCellWidth: number;
  84436. /**
  84437. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  84438. */
  84439. spriteCellHeight: number;
  84440. /**
  84441. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  84442. */
  84443. spriteRandomStartCell: boolean;
  84444. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  84445. translationPivot: Vector2;
  84446. /** @hidden */
  84447. protected _isAnimationSheetEnabled: boolean;
  84448. /**
  84449. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  84450. */
  84451. beginAnimationOnStart: boolean;
  84452. /**
  84453. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  84454. */
  84455. beginAnimationFrom: number;
  84456. /**
  84457. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  84458. */
  84459. beginAnimationTo: number;
  84460. /**
  84461. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  84462. */
  84463. beginAnimationLoop: boolean;
  84464. /**
  84465. * Gets or sets a world offset applied to all particles
  84466. */
  84467. worldOffset: Vector3;
  84468. /**
  84469. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  84470. */
  84471. get isAnimationSheetEnabled(): boolean;
  84472. set isAnimationSheetEnabled(value: boolean);
  84473. /**
  84474. * Get hosting scene
  84475. * @returns the scene
  84476. */
  84477. getScene(): Scene;
  84478. /**
  84479. * You can use gravity if you want to give an orientation to your particles.
  84480. */
  84481. gravity: Vector3;
  84482. protected _colorGradients: Nullable<Array<ColorGradient>>;
  84483. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  84484. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  84485. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  84486. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  84487. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  84488. protected _dragGradients: Nullable<Array<FactorGradient>>;
  84489. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  84490. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  84491. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  84492. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  84493. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  84494. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  84495. /**
  84496. * Defines the delay in milliseconds before starting the system (0 by default)
  84497. */
  84498. startDelay: number;
  84499. /**
  84500. * Gets the current list of drag gradients.
  84501. * You must use addDragGradient and removeDragGradient to udpate this list
  84502. * @returns the list of drag gradients
  84503. */
  84504. getDragGradients(): Nullable<Array<FactorGradient>>;
  84505. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  84506. limitVelocityDamping: number;
  84507. /**
  84508. * Gets the current list of limit velocity gradients.
  84509. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  84510. * @returns the list of limit velocity gradients
  84511. */
  84512. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  84513. /**
  84514. * Gets the current list of color gradients.
  84515. * You must use addColorGradient and removeColorGradient to udpate this list
  84516. * @returns the list of color gradients
  84517. */
  84518. getColorGradients(): Nullable<Array<ColorGradient>>;
  84519. /**
  84520. * Gets the current list of size gradients.
  84521. * You must use addSizeGradient and removeSizeGradient to udpate this list
  84522. * @returns the list of size gradients
  84523. */
  84524. getSizeGradients(): Nullable<Array<FactorGradient>>;
  84525. /**
  84526. * Gets the current list of color remap gradients.
  84527. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  84528. * @returns the list of color remap gradients
  84529. */
  84530. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  84531. /**
  84532. * Gets the current list of alpha remap gradients.
  84533. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  84534. * @returns the list of alpha remap gradients
  84535. */
  84536. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  84537. /**
  84538. * Gets the current list of life time gradients.
  84539. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  84540. * @returns the list of life time gradients
  84541. */
  84542. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  84543. /**
  84544. * Gets the current list of angular speed gradients.
  84545. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  84546. * @returns the list of angular speed gradients
  84547. */
  84548. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  84549. /**
  84550. * Gets the current list of velocity gradients.
  84551. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  84552. * @returns the list of velocity gradients
  84553. */
  84554. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  84555. /**
  84556. * Gets the current list of start size gradients.
  84557. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  84558. * @returns the list of start size gradients
  84559. */
  84560. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  84561. /**
  84562. * Gets the current list of emit rate gradients.
  84563. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  84564. * @returns the list of emit rate gradients
  84565. */
  84566. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  84567. /**
  84568. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84569. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84570. */
  84571. get direction1(): Vector3;
  84572. set direction1(value: Vector3);
  84573. /**
  84574. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84575. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84576. */
  84577. get direction2(): Vector3;
  84578. set direction2(value: Vector3);
  84579. /**
  84580. * 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.
  84581. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84582. */
  84583. get minEmitBox(): Vector3;
  84584. set minEmitBox(value: Vector3);
  84585. /**
  84586. * 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.
  84587. * This only works when particleEmitterTyps is a BoxParticleEmitter
  84588. */
  84589. get maxEmitBox(): Vector3;
  84590. set maxEmitBox(value: Vector3);
  84591. /**
  84592. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84593. */
  84594. color1: Color4;
  84595. /**
  84596. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  84597. */
  84598. color2: Color4;
  84599. /**
  84600. * Color the particle will have at the end of its lifetime
  84601. */
  84602. colorDead: Color4;
  84603. /**
  84604. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  84605. */
  84606. textureMask: Color4;
  84607. /**
  84608. * The particle emitter type defines the emitter used by the particle system.
  84609. * It can be for example box, sphere, or cone...
  84610. */
  84611. particleEmitterType: IParticleEmitterType;
  84612. /** @hidden */
  84613. _isSubEmitter: boolean;
  84614. /**
  84615. * Gets or sets the billboard mode to use when isBillboardBased = true.
  84616. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  84617. */
  84618. billboardMode: number;
  84619. protected _isBillboardBased: boolean;
  84620. /**
  84621. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  84622. */
  84623. get isBillboardBased(): boolean;
  84624. set isBillboardBased(value: boolean);
  84625. /**
  84626. * The scene the particle system belongs to.
  84627. */
  84628. protected _scene: Scene;
  84629. /**
  84630. * Local cache of defines for image processing.
  84631. */
  84632. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  84633. /**
  84634. * Default configuration related to image processing available in the standard Material.
  84635. */
  84636. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  84637. /**
  84638. * Gets the image processing configuration used either in this material.
  84639. */
  84640. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  84641. /**
  84642. * Sets the Default image processing configuration used either in the this material.
  84643. *
  84644. * If sets to null, the scene one is in use.
  84645. */
  84646. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  84647. /**
  84648. * Attaches a new image processing configuration to the Standard Material.
  84649. * @param configuration
  84650. */
  84651. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  84652. /** @hidden */
  84653. protected _reset(): void;
  84654. /** @hidden */
  84655. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  84656. /**
  84657. * Instantiates a particle system.
  84658. * 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.
  84659. * @param name The name of the particle system
  84660. */
  84661. constructor(name: string);
  84662. /**
  84663. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  84664. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84665. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84666. * @returns the emitter
  84667. */
  84668. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  84669. /**
  84670. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  84671. * @param radius The radius of the hemisphere to emit from
  84672. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84673. * @returns the emitter
  84674. */
  84675. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  84676. /**
  84677. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  84678. * @param radius The radius of the sphere to emit from
  84679. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  84680. * @returns the emitter
  84681. */
  84682. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  84683. /**
  84684. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  84685. * @param radius The radius of the sphere to emit from
  84686. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  84687. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  84688. * @returns the emitter
  84689. */
  84690. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  84691. /**
  84692. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  84693. * @param radius The radius of the emission cylinder
  84694. * @param height The height of the emission cylinder
  84695. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  84696. * @param directionRandomizer How much to randomize the particle direction [0-1]
  84697. * @returns the emitter
  84698. */
  84699. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  84700. /**
  84701. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  84702. * @param radius The radius of the cylinder to emit from
  84703. * @param height The height of the emission cylinder
  84704. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84705. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  84706. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  84707. * @returns the emitter
  84708. */
  84709. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  84710. /**
  84711. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  84712. * @param radius The radius of the cone to emit from
  84713. * @param angle The base angle of the cone
  84714. * @returns the emitter
  84715. */
  84716. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  84717. /**
  84718. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  84719. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  84720. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  84721. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84722. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  84723. * @returns the emitter
  84724. */
  84725. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  84726. }
  84727. }
  84728. declare module BABYLON {
  84729. /**
  84730. * Type of sub emitter
  84731. */
  84732. export enum SubEmitterType {
  84733. /**
  84734. * Attached to the particle over it's lifetime
  84735. */
  84736. ATTACHED = 0,
  84737. /**
  84738. * Created when the particle dies
  84739. */
  84740. END = 1
  84741. }
  84742. /**
  84743. * Sub emitter class used to emit particles from an existing particle
  84744. */
  84745. export class SubEmitter {
  84746. /**
  84747. * the particle system to be used by the sub emitter
  84748. */
  84749. particleSystem: ParticleSystem;
  84750. /**
  84751. * Type of the submitter (Default: END)
  84752. */
  84753. type: SubEmitterType;
  84754. /**
  84755. * 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)
  84756. * Note: This only is supported when using an emitter of type Mesh
  84757. */
  84758. inheritDirection: boolean;
  84759. /**
  84760. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  84761. */
  84762. inheritedVelocityAmount: number;
  84763. /**
  84764. * Creates a sub emitter
  84765. * @param particleSystem the particle system to be used by the sub emitter
  84766. */
  84767. constructor(
  84768. /**
  84769. * the particle system to be used by the sub emitter
  84770. */
  84771. particleSystem: ParticleSystem);
  84772. /**
  84773. * Clones the sub emitter
  84774. * @returns the cloned sub emitter
  84775. */
  84776. clone(): SubEmitter;
  84777. /**
  84778. * Serialize current object to a JSON object
  84779. * @returns the serialized object
  84780. */
  84781. serialize(): any;
  84782. /** @hidden */
  84783. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  84784. /**
  84785. * Creates a new SubEmitter from a serialized JSON version
  84786. * @param serializationObject defines the JSON object to read from
  84787. * @param scene defines the hosting scene
  84788. * @param rootUrl defines the rootUrl for data loading
  84789. * @returns a new SubEmitter
  84790. */
  84791. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  84792. /** Release associated resources */
  84793. dispose(): void;
  84794. }
  84795. }
  84796. declare module BABYLON {
  84797. /** @hidden */
  84798. export var imageProcessingDeclaration: {
  84799. name: string;
  84800. shader: string;
  84801. };
  84802. }
  84803. declare module BABYLON {
  84804. /** @hidden */
  84805. export var imageProcessingFunctions: {
  84806. name: string;
  84807. shader: string;
  84808. };
  84809. }
  84810. declare module BABYLON {
  84811. /** @hidden */
  84812. export var particlesPixelShader: {
  84813. name: string;
  84814. shader: string;
  84815. };
  84816. }
  84817. declare module BABYLON {
  84818. /** @hidden */
  84819. export var particlesVertexShader: {
  84820. name: string;
  84821. shader: string;
  84822. };
  84823. }
  84824. declare module BABYLON {
  84825. /**
  84826. * This represents a particle system in Babylon.
  84827. * 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.
  84828. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  84829. * @example https://doc.babylonjs.com/babylon101/particles
  84830. */
  84831. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  84832. /**
  84833. * Billboard mode will only apply to Y axis
  84834. */
  84835. static readonly BILLBOARDMODE_Y: number;
  84836. /**
  84837. * Billboard mode will apply to all axes
  84838. */
  84839. static readonly BILLBOARDMODE_ALL: number;
  84840. /**
  84841. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  84842. */
  84843. static readonly BILLBOARDMODE_STRETCHED: number;
  84844. /**
  84845. * This function can be defined to provide custom update for active particles.
  84846. * This function will be called instead of regular update (age, position, color, etc.).
  84847. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  84848. */
  84849. updateFunction: (particles: Particle[]) => void;
  84850. private _emitterWorldMatrix;
  84851. /**
  84852. * This function can be defined to specify initial direction for every new particle.
  84853. * It by default use the emitterType defined function
  84854. */
  84855. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  84856. /**
  84857. * This function can be defined to specify initial position for every new particle.
  84858. * It by default use the emitterType defined function
  84859. */
  84860. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  84861. /**
  84862. * @hidden
  84863. */
  84864. _inheritedVelocityOffset: Vector3;
  84865. /**
  84866. * An event triggered when the system is disposed
  84867. */
  84868. onDisposeObservable: Observable<ParticleSystem>;
  84869. private _onDisposeObserver;
  84870. /**
  84871. * Sets a callback that will be triggered when the system is disposed
  84872. */
  84873. set onDispose(callback: () => void);
  84874. private _particles;
  84875. private _epsilon;
  84876. private _capacity;
  84877. private _stockParticles;
  84878. private _newPartsExcess;
  84879. private _vertexData;
  84880. private _vertexBuffer;
  84881. private _vertexBuffers;
  84882. private _spriteBuffer;
  84883. private _indexBuffer;
  84884. private _effect;
  84885. private _customEffect;
  84886. private _cachedDefines;
  84887. private _scaledColorStep;
  84888. private _colorDiff;
  84889. private _scaledDirection;
  84890. private _scaledGravity;
  84891. private _currentRenderId;
  84892. private _alive;
  84893. private _useInstancing;
  84894. private _started;
  84895. private _stopped;
  84896. private _actualFrame;
  84897. private _scaledUpdateSpeed;
  84898. private _vertexBufferSize;
  84899. /** @hidden */
  84900. _currentEmitRateGradient: Nullable<FactorGradient>;
  84901. /** @hidden */
  84902. _currentEmitRate1: number;
  84903. /** @hidden */
  84904. _currentEmitRate2: number;
  84905. /** @hidden */
  84906. _currentStartSizeGradient: Nullable<FactorGradient>;
  84907. /** @hidden */
  84908. _currentStartSize1: number;
  84909. /** @hidden */
  84910. _currentStartSize2: number;
  84911. private readonly _rawTextureWidth;
  84912. private _rampGradientsTexture;
  84913. private _useRampGradients;
  84914. /** Gets or sets a boolean indicating that ramp gradients must be used
  84915. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  84916. */
  84917. get useRampGradients(): boolean;
  84918. set useRampGradients(value: boolean);
  84919. /**
  84920. * 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.
  84921. * 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: [])
  84922. */
  84923. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  84924. private _subEmitters;
  84925. /**
  84926. * @hidden
  84927. * If the particle systems emitter should be disposed when the particle system is disposed
  84928. */
  84929. _disposeEmitterOnDispose: boolean;
  84930. /**
  84931. * The current active Sub-systems, this property is used by the root particle system only.
  84932. */
  84933. activeSubSystems: Array<ParticleSystem>;
  84934. private _rootParticleSystem;
  84935. /**
  84936. * Gets the current list of active particles
  84937. */
  84938. get particles(): Particle[];
  84939. /**
  84940. * Returns the string "ParticleSystem"
  84941. * @returns a string containing the class name
  84942. */
  84943. getClassName(): string;
  84944. /**
  84945. * Instantiates a particle system.
  84946. * 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.
  84947. * @param name The name of the particle system
  84948. * @param capacity The max number of particles alive at the same time
  84949. * @param scene The scene the particle system belongs to
  84950. * @param customEffect a custom effect used to change the way particles are rendered by default
  84951. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  84952. * @param epsilon Offset used to render the particles
  84953. */
  84954. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  84955. private _addFactorGradient;
  84956. private _removeFactorGradient;
  84957. /**
  84958. * Adds a new life time gradient
  84959. * @param gradient defines the gradient to use (between 0 and 1)
  84960. * @param factor defines the life time factor to affect to the specified gradient
  84961. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84962. * @returns the current particle system
  84963. */
  84964. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84965. /**
  84966. * Remove a specific life time gradient
  84967. * @param gradient defines the gradient to remove
  84968. * @returns the current particle system
  84969. */
  84970. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84971. /**
  84972. * Adds a new size gradient
  84973. * @param gradient defines the gradient to use (between 0 and 1)
  84974. * @param factor defines the size factor to affect to the specified gradient
  84975. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84976. * @returns the current particle system
  84977. */
  84978. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84979. /**
  84980. * Remove a specific size gradient
  84981. * @param gradient defines the gradient to remove
  84982. * @returns the current particle system
  84983. */
  84984. removeSizeGradient(gradient: number): IParticleSystem;
  84985. /**
  84986. * Adds a new color remap gradient
  84987. * @param gradient defines the gradient to use (between 0 and 1)
  84988. * @param min defines the color remap minimal range
  84989. * @param max defines the color remap maximal range
  84990. * @returns the current particle system
  84991. */
  84992. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84993. /**
  84994. * Remove a specific color remap gradient
  84995. * @param gradient defines the gradient to remove
  84996. * @returns the current particle system
  84997. */
  84998. removeColorRemapGradient(gradient: number): IParticleSystem;
  84999. /**
  85000. * Adds a new alpha remap gradient
  85001. * @param gradient defines the gradient to use (between 0 and 1)
  85002. * @param min defines the alpha remap minimal range
  85003. * @param max defines the alpha remap maximal range
  85004. * @returns the current particle system
  85005. */
  85006. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85007. /**
  85008. * Remove a specific alpha remap gradient
  85009. * @param gradient defines the gradient to remove
  85010. * @returns the current particle system
  85011. */
  85012. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  85013. /**
  85014. * Adds a new angular speed gradient
  85015. * @param gradient defines the gradient to use (between 0 and 1)
  85016. * @param factor defines the angular speed to affect to the specified gradient
  85017. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85018. * @returns the current particle system
  85019. */
  85020. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85021. /**
  85022. * Remove a specific angular speed gradient
  85023. * @param gradient defines the gradient to remove
  85024. * @returns the current particle system
  85025. */
  85026. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85027. /**
  85028. * Adds a new velocity gradient
  85029. * @param gradient defines the gradient to use (between 0 and 1)
  85030. * @param factor defines the velocity to affect to the specified gradient
  85031. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85032. * @returns the current particle system
  85033. */
  85034. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85035. /**
  85036. * Remove a specific velocity gradient
  85037. * @param gradient defines the gradient to remove
  85038. * @returns the current particle system
  85039. */
  85040. removeVelocityGradient(gradient: number): IParticleSystem;
  85041. /**
  85042. * Adds a new limit velocity gradient
  85043. * @param gradient defines the gradient to use (between 0 and 1)
  85044. * @param factor defines the limit velocity value to affect to the specified gradient
  85045. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85046. * @returns the current particle system
  85047. */
  85048. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85049. /**
  85050. * Remove a specific limit velocity gradient
  85051. * @param gradient defines the gradient to remove
  85052. * @returns the current particle system
  85053. */
  85054. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85055. /**
  85056. * Adds a new drag gradient
  85057. * @param gradient defines the gradient to use (between 0 and 1)
  85058. * @param factor defines the drag value to affect to the specified gradient
  85059. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85060. * @returns the current particle system
  85061. */
  85062. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85063. /**
  85064. * Remove a specific drag gradient
  85065. * @param gradient defines the gradient to remove
  85066. * @returns the current particle system
  85067. */
  85068. removeDragGradient(gradient: number): IParticleSystem;
  85069. /**
  85070. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85071. * @param gradient defines the gradient to use (between 0 and 1)
  85072. * @param factor defines the emit rate value to affect to the specified gradient
  85073. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85074. * @returns the current particle system
  85075. */
  85076. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85077. /**
  85078. * Remove a specific emit rate gradient
  85079. * @param gradient defines the gradient to remove
  85080. * @returns the current particle system
  85081. */
  85082. removeEmitRateGradient(gradient: number): IParticleSystem;
  85083. /**
  85084. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85085. * @param gradient defines the gradient to use (between 0 and 1)
  85086. * @param factor defines the start size value to affect to the specified gradient
  85087. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85088. * @returns the current particle system
  85089. */
  85090. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85091. /**
  85092. * Remove a specific start size gradient
  85093. * @param gradient defines the gradient to remove
  85094. * @returns the current particle system
  85095. */
  85096. removeStartSizeGradient(gradient: number): IParticleSystem;
  85097. private _createRampGradientTexture;
  85098. /**
  85099. * Gets the current list of ramp gradients.
  85100. * You must use addRampGradient and removeRampGradient to udpate this list
  85101. * @returns the list of ramp gradients
  85102. */
  85103. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85104. /**
  85105. * Adds a new ramp gradient used to remap particle colors
  85106. * @param gradient defines the gradient to use (between 0 and 1)
  85107. * @param color defines the color to affect to the specified gradient
  85108. * @returns the current particle system
  85109. */
  85110. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  85111. /**
  85112. * Remove a specific ramp gradient
  85113. * @param gradient defines the gradient to remove
  85114. * @returns the current particle system
  85115. */
  85116. removeRampGradient(gradient: number): ParticleSystem;
  85117. /**
  85118. * Adds a new color gradient
  85119. * @param gradient defines the gradient to use (between 0 and 1)
  85120. * @param color1 defines the color to affect to the specified gradient
  85121. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85122. * @returns this particle system
  85123. */
  85124. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85125. /**
  85126. * Remove a specific color gradient
  85127. * @param gradient defines the gradient to remove
  85128. * @returns this particle system
  85129. */
  85130. removeColorGradient(gradient: number): IParticleSystem;
  85131. private _fetchR;
  85132. protected _reset(): void;
  85133. private _resetEffect;
  85134. private _createVertexBuffers;
  85135. private _createIndexBuffer;
  85136. /**
  85137. * Gets the maximum number of particles active at the same time.
  85138. * @returns The max number of active particles.
  85139. */
  85140. getCapacity(): number;
  85141. /**
  85142. * Gets whether there are still active particles in the system.
  85143. * @returns True if it is alive, otherwise false.
  85144. */
  85145. isAlive(): boolean;
  85146. /**
  85147. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85148. * @returns True if it has been started, otherwise false.
  85149. */
  85150. isStarted(): boolean;
  85151. private _prepareSubEmitterInternalArray;
  85152. /**
  85153. * Starts the particle system and begins to emit
  85154. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  85155. */
  85156. start(delay?: number): void;
  85157. /**
  85158. * Stops the particle system.
  85159. * @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.
  85160. */
  85161. stop(stopSubEmitters?: boolean): void;
  85162. /**
  85163. * Remove all active particles
  85164. */
  85165. reset(): void;
  85166. /**
  85167. * @hidden (for internal use only)
  85168. */
  85169. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  85170. /**
  85171. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  85172. * Its lifetime will start back at 0.
  85173. */
  85174. recycleParticle: (particle: Particle) => void;
  85175. private _stopSubEmitters;
  85176. private _createParticle;
  85177. private _removeFromRoot;
  85178. private _emitFromParticle;
  85179. private _update;
  85180. /** @hidden */
  85181. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  85182. /** @hidden */
  85183. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  85184. /** @hidden */
  85185. private _getEffect;
  85186. /**
  85187. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  85188. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  85189. */
  85190. animate(preWarmOnly?: boolean): void;
  85191. private _appendParticleVertices;
  85192. /**
  85193. * Rebuilds the particle system.
  85194. */
  85195. rebuild(): void;
  85196. /**
  85197. * Is this system ready to be used/rendered
  85198. * @return true if the system is ready
  85199. */
  85200. isReady(): boolean;
  85201. private _render;
  85202. /**
  85203. * Renders the particle system in its current state.
  85204. * @returns the current number of particles
  85205. */
  85206. render(): number;
  85207. /**
  85208. * Disposes the particle system and free the associated resources
  85209. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85210. */
  85211. dispose(disposeTexture?: boolean): void;
  85212. /**
  85213. * Clones the particle system.
  85214. * @param name The name of the cloned object
  85215. * @param newEmitter The new emitter to use
  85216. * @returns the cloned particle system
  85217. */
  85218. clone(name: string, newEmitter: any): ParticleSystem;
  85219. /**
  85220. * Serializes the particle system to a JSON object.
  85221. * @returns the JSON object
  85222. */
  85223. serialize(): any;
  85224. /** @hidden */
  85225. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  85226. /** @hidden */
  85227. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  85228. /**
  85229. * Parses a JSON object to create a particle system.
  85230. * @param parsedParticleSystem The JSON object to parse
  85231. * @param scene The scene to create the particle system in
  85232. * @param rootUrl The root url to use to load external dependencies like texture
  85233. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  85234. * @returns the Parsed particle system
  85235. */
  85236. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  85237. }
  85238. }
  85239. declare module BABYLON {
  85240. /**
  85241. * A particle represents one of the element emitted by a particle system.
  85242. * This is mainly define by its coordinates, direction, velocity and age.
  85243. */
  85244. export class Particle {
  85245. /**
  85246. * The particle system the particle belongs to.
  85247. */
  85248. particleSystem: ParticleSystem;
  85249. private static _Count;
  85250. /**
  85251. * Unique ID of the particle
  85252. */
  85253. id: number;
  85254. /**
  85255. * The world position of the particle in the scene.
  85256. */
  85257. position: Vector3;
  85258. /**
  85259. * The world direction of the particle in the scene.
  85260. */
  85261. direction: Vector3;
  85262. /**
  85263. * The color of the particle.
  85264. */
  85265. color: Color4;
  85266. /**
  85267. * The color change of the particle per step.
  85268. */
  85269. colorStep: Color4;
  85270. /**
  85271. * Defines how long will the life of the particle be.
  85272. */
  85273. lifeTime: number;
  85274. /**
  85275. * The current age of the particle.
  85276. */
  85277. age: number;
  85278. /**
  85279. * The current size of the particle.
  85280. */
  85281. size: number;
  85282. /**
  85283. * The current scale of the particle.
  85284. */
  85285. scale: Vector2;
  85286. /**
  85287. * The current angle of the particle.
  85288. */
  85289. angle: number;
  85290. /**
  85291. * Defines how fast is the angle changing.
  85292. */
  85293. angularSpeed: number;
  85294. /**
  85295. * Defines the cell index used by the particle to be rendered from a sprite.
  85296. */
  85297. cellIndex: number;
  85298. /**
  85299. * The information required to support color remapping
  85300. */
  85301. remapData: Vector4;
  85302. /** @hidden */
  85303. _randomCellOffset?: number;
  85304. /** @hidden */
  85305. _initialDirection: Nullable<Vector3>;
  85306. /** @hidden */
  85307. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  85308. /** @hidden */
  85309. _initialStartSpriteCellID: number;
  85310. /** @hidden */
  85311. _initialEndSpriteCellID: number;
  85312. /** @hidden */
  85313. _currentColorGradient: Nullable<ColorGradient>;
  85314. /** @hidden */
  85315. _currentColor1: Color4;
  85316. /** @hidden */
  85317. _currentColor2: Color4;
  85318. /** @hidden */
  85319. _currentSizeGradient: Nullable<FactorGradient>;
  85320. /** @hidden */
  85321. _currentSize1: number;
  85322. /** @hidden */
  85323. _currentSize2: number;
  85324. /** @hidden */
  85325. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  85326. /** @hidden */
  85327. _currentAngularSpeed1: number;
  85328. /** @hidden */
  85329. _currentAngularSpeed2: number;
  85330. /** @hidden */
  85331. _currentVelocityGradient: Nullable<FactorGradient>;
  85332. /** @hidden */
  85333. _currentVelocity1: number;
  85334. /** @hidden */
  85335. _currentVelocity2: number;
  85336. /** @hidden */
  85337. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  85338. /** @hidden */
  85339. _currentLimitVelocity1: number;
  85340. /** @hidden */
  85341. _currentLimitVelocity2: number;
  85342. /** @hidden */
  85343. _currentDragGradient: Nullable<FactorGradient>;
  85344. /** @hidden */
  85345. _currentDrag1: number;
  85346. /** @hidden */
  85347. _currentDrag2: number;
  85348. /** @hidden */
  85349. _randomNoiseCoordinates1: Vector3;
  85350. /** @hidden */
  85351. _randomNoiseCoordinates2: Vector3;
  85352. /**
  85353. * Creates a new instance Particle
  85354. * @param particleSystem the particle system the particle belongs to
  85355. */
  85356. constructor(
  85357. /**
  85358. * The particle system the particle belongs to.
  85359. */
  85360. particleSystem: ParticleSystem);
  85361. private updateCellInfoFromSystem;
  85362. /**
  85363. * Defines how the sprite cell index is updated for the particle
  85364. */
  85365. updateCellIndex(): void;
  85366. /** @hidden */
  85367. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  85368. /** @hidden */
  85369. _inheritParticleInfoToSubEmitters(): void;
  85370. /** @hidden */
  85371. _reset(): void;
  85372. /**
  85373. * Copy the properties of particle to another one.
  85374. * @param other the particle to copy the information to.
  85375. */
  85376. copyTo(other: Particle): void;
  85377. }
  85378. }
  85379. declare module BABYLON {
  85380. /**
  85381. * Particle emitter represents a volume emitting particles.
  85382. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  85383. */
  85384. export interface IParticleEmitterType {
  85385. /**
  85386. * Called by the particle System when the direction is computed for the created particle.
  85387. * @param worldMatrix is the world matrix of the particle system
  85388. * @param directionToUpdate is the direction vector to update with the result
  85389. * @param particle is the particle we are computed the direction for
  85390. */
  85391. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85392. /**
  85393. * Called by the particle System when the position is computed for the created particle.
  85394. * @param worldMatrix is the world matrix of the particle system
  85395. * @param positionToUpdate is the position vector to update with the result
  85396. * @param particle is the particle we are computed the position for
  85397. */
  85398. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85399. /**
  85400. * Clones the current emitter and returns a copy of it
  85401. * @returns the new emitter
  85402. */
  85403. clone(): IParticleEmitterType;
  85404. /**
  85405. * Called by the GPUParticleSystem to setup the update shader
  85406. * @param effect defines the update shader
  85407. */
  85408. applyToShader(effect: Effect): void;
  85409. /**
  85410. * Returns a string to use to update the GPU particles update shader
  85411. * @returns the effect defines string
  85412. */
  85413. getEffectDefines(): string;
  85414. /**
  85415. * Returns a string representing the class name
  85416. * @returns a string containing the class name
  85417. */
  85418. getClassName(): string;
  85419. /**
  85420. * Serializes the particle system to a JSON object.
  85421. * @returns the JSON object
  85422. */
  85423. serialize(): any;
  85424. /**
  85425. * Parse properties from a JSON object
  85426. * @param serializationObject defines the JSON object
  85427. * @param scene defines the hosting scene
  85428. */
  85429. parse(serializationObject: any, scene: Scene): void;
  85430. }
  85431. }
  85432. declare module BABYLON {
  85433. /**
  85434. * Particle emitter emitting particles from the inside of a box.
  85435. * It emits the particles randomly between 2 given directions.
  85436. */
  85437. export class BoxParticleEmitter implements IParticleEmitterType {
  85438. /**
  85439. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85440. */
  85441. direction1: Vector3;
  85442. /**
  85443. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85444. */
  85445. direction2: Vector3;
  85446. /**
  85447. * 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.
  85448. */
  85449. minEmitBox: Vector3;
  85450. /**
  85451. * 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.
  85452. */
  85453. maxEmitBox: Vector3;
  85454. /**
  85455. * Creates a new instance BoxParticleEmitter
  85456. */
  85457. constructor();
  85458. /**
  85459. * Called by the particle System when the direction is computed for the created particle.
  85460. * @param worldMatrix is the world matrix of the particle system
  85461. * @param directionToUpdate is the direction vector to update with the result
  85462. * @param particle is the particle we are computed the direction for
  85463. */
  85464. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85465. /**
  85466. * Called by the particle System when the position is computed for the created particle.
  85467. * @param worldMatrix is the world matrix of the particle system
  85468. * @param positionToUpdate is the position vector to update with the result
  85469. * @param particle is the particle we are computed the position for
  85470. */
  85471. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85472. /**
  85473. * Clones the current emitter and returns a copy of it
  85474. * @returns the new emitter
  85475. */
  85476. clone(): BoxParticleEmitter;
  85477. /**
  85478. * Called by the GPUParticleSystem to setup the update shader
  85479. * @param effect defines the update shader
  85480. */
  85481. applyToShader(effect: Effect): void;
  85482. /**
  85483. * Returns a string to use to update the GPU particles update shader
  85484. * @returns a string containng the defines string
  85485. */
  85486. getEffectDefines(): string;
  85487. /**
  85488. * Returns the string "BoxParticleEmitter"
  85489. * @returns a string containing the class name
  85490. */
  85491. getClassName(): string;
  85492. /**
  85493. * Serializes the particle system to a JSON object.
  85494. * @returns the JSON object
  85495. */
  85496. serialize(): any;
  85497. /**
  85498. * Parse properties from a JSON object
  85499. * @param serializationObject defines the JSON object
  85500. */
  85501. parse(serializationObject: any): void;
  85502. }
  85503. }
  85504. declare module BABYLON {
  85505. /**
  85506. * Particle emitter emitting particles from the inside of a cone.
  85507. * It emits the particles alongside the cone volume from the base to the particle.
  85508. * The emission direction might be randomized.
  85509. */
  85510. export class ConeParticleEmitter implements IParticleEmitterType {
  85511. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85512. directionRandomizer: number;
  85513. private _radius;
  85514. private _angle;
  85515. private _height;
  85516. /**
  85517. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  85518. */
  85519. radiusRange: number;
  85520. /**
  85521. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  85522. */
  85523. heightRange: number;
  85524. /**
  85525. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  85526. */
  85527. emitFromSpawnPointOnly: boolean;
  85528. /**
  85529. * Gets or sets the radius of the emission cone
  85530. */
  85531. get radius(): number;
  85532. set radius(value: number);
  85533. /**
  85534. * Gets or sets the angle of the emission cone
  85535. */
  85536. get angle(): number;
  85537. set angle(value: number);
  85538. private _buildHeight;
  85539. /**
  85540. * Creates a new instance ConeParticleEmitter
  85541. * @param radius the radius of the emission cone (1 by default)
  85542. * @param angle the cone base angle (PI by default)
  85543. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  85544. */
  85545. constructor(radius?: number, angle?: number,
  85546. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  85547. directionRandomizer?: number);
  85548. /**
  85549. * Called by the particle System when the direction is computed for the created particle.
  85550. * @param worldMatrix is the world matrix of the particle system
  85551. * @param directionToUpdate is the direction vector to update with the result
  85552. * @param particle is the particle we are computed the direction for
  85553. */
  85554. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85555. /**
  85556. * Called by the particle System when the position is computed for the created particle.
  85557. * @param worldMatrix is the world matrix of the particle system
  85558. * @param positionToUpdate is the position vector to update with the result
  85559. * @param particle is the particle we are computed the position for
  85560. */
  85561. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85562. /**
  85563. * Clones the current emitter and returns a copy of it
  85564. * @returns the new emitter
  85565. */
  85566. clone(): ConeParticleEmitter;
  85567. /**
  85568. * Called by the GPUParticleSystem to setup the update shader
  85569. * @param effect defines the update shader
  85570. */
  85571. applyToShader(effect: Effect): void;
  85572. /**
  85573. * Returns a string to use to update the GPU particles update shader
  85574. * @returns a string containng the defines string
  85575. */
  85576. getEffectDefines(): string;
  85577. /**
  85578. * Returns the string "ConeParticleEmitter"
  85579. * @returns a string containing the class name
  85580. */
  85581. getClassName(): string;
  85582. /**
  85583. * Serializes the particle system to a JSON object.
  85584. * @returns the JSON object
  85585. */
  85586. serialize(): any;
  85587. /**
  85588. * Parse properties from a JSON object
  85589. * @param serializationObject defines the JSON object
  85590. */
  85591. parse(serializationObject: any): void;
  85592. }
  85593. }
  85594. declare module BABYLON {
  85595. /**
  85596. * Particle emitter emitting particles from the inside of a cylinder.
  85597. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  85598. */
  85599. export class CylinderParticleEmitter implements IParticleEmitterType {
  85600. /**
  85601. * The radius of the emission cylinder.
  85602. */
  85603. radius: number;
  85604. /**
  85605. * The height of the emission cylinder.
  85606. */
  85607. height: number;
  85608. /**
  85609. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85610. */
  85611. radiusRange: number;
  85612. /**
  85613. * How much to randomize the particle direction [0-1].
  85614. */
  85615. directionRandomizer: number;
  85616. /**
  85617. * Creates a new instance CylinderParticleEmitter
  85618. * @param radius the radius of the emission cylinder (1 by default)
  85619. * @param height the height of the emission cylinder (1 by default)
  85620. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85621. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85622. */
  85623. constructor(
  85624. /**
  85625. * The radius of the emission cylinder.
  85626. */
  85627. radius?: number,
  85628. /**
  85629. * The height of the emission cylinder.
  85630. */
  85631. height?: number,
  85632. /**
  85633. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85634. */
  85635. radiusRange?: number,
  85636. /**
  85637. * How much to randomize the particle direction [0-1].
  85638. */
  85639. directionRandomizer?: number);
  85640. /**
  85641. * Called by the particle System when the direction is computed for the created particle.
  85642. * @param worldMatrix is the world matrix of the particle system
  85643. * @param directionToUpdate is the direction vector to update with the result
  85644. * @param particle is the particle we are computed the direction for
  85645. */
  85646. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85647. /**
  85648. * Called by the particle System when the position is computed for the created particle.
  85649. * @param worldMatrix is the world matrix of the particle system
  85650. * @param positionToUpdate is the position vector to update with the result
  85651. * @param particle is the particle we are computed the position for
  85652. */
  85653. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85654. /**
  85655. * Clones the current emitter and returns a copy of it
  85656. * @returns the new emitter
  85657. */
  85658. clone(): CylinderParticleEmitter;
  85659. /**
  85660. * Called by the GPUParticleSystem to setup the update shader
  85661. * @param effect defines the update shader
  85662. */
  85663. applyToShader(effect: Effect): void;
  85664. /**
  85665. * Returns a string to use to update the GPU particles update shader
  85666. * @returns a string containng the defines string
  85667. */
  85668. getEffectDefines(): string;
  85669. /**
  85670. * Returns the string "CylinderParticleEmitter"
  85671. * @returns a string containing the class name
  85672. */
  85673. getClassName(): string;
  85674. /**
  85675. * Serializes the particle system to a JSON object.
  85676. * @returns the JSON object
  85677. */
  85678. serialize(): any;
  85679. /**
  85680. * Parse properties from a JSON object
  85681. * @param serializationObject defines the JSON object
  85682. */
  85683. parse(serializationObject: any): void;
  85684. }
  85685. /**
  85686. * Particle emitter emitting particles from the inside of a cylinder.
  85687. * It emits the particles randomly between two vectors.
  85688. */
  85689. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  85690. /**
  85691. * The min limit of the emission direction.
  85692. */
  85693. direction1: Vector3;
  85694. /**
  85695. * The max limit of the emission direction.
  85696. */
  85697. direction2: Vector3;
  85698. /**
  85699. * Creates a new instance CylinderDirectedParticleEmitter
  85700. * @param radius the radius of the emission cylinder (1 by default)
  85701. * @param height the height of the emission cylinder (1 by default)
  85702. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85703. * @param direction1 the min limit of the emission direction (up vector by default)
  85704. * @param direction2 the max limit of the emission direction (up vector by default)
  85705. */
  85706. constructor(radius?: number, height?: number, radiusRange?: number,
  85707. /**
  85708. * The min limit of the emission direction.
  85709. */
  85710. direction1?: Vector3,
  85711. /**
  85712. * The max limit of the emission direction.
  85713. */
  85714. direction2?: Vector3);
  85715. /**
  85716. * Called by the particle System when the direction is computed for the created particle.
  85717. * @param worldMatrix is the world matrix of the particle system
  85718. * @param directionToUpdate is the direction vector to update with the result
  85719. * @param particle is the particle we are computed the direction for
  85720. */
  85721. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85722. /**
  85723. * Clones the current emitter and returns a copy of it
  85724. * @returns the new emitter
  85725. */
  85726. clone(): CylinderDirectedParticleEmitter;
  85727. /**
  85728. * Called by the GPUParticleSystem to setup the update shader
  85729. * @param effect defines the update shader
  85730. */
  85731. applyToShader(effect: Effect): void;
  85732. /**
  85733. * Returns a string to use to update the GPU particles update shader
  85734. * @returns a string containng the defines string
  85735. */
  85736. getEffectDefines(): string;
  85737. /**
  85738. * Returns the string "CylinderDirectedParticleEmitter"
  85739. * @returns a string containing the class name
  85740. */
  85741. getClassName(): string;
  85742. /**
  85743. * Serializes the particle system to a JSON object.
  85744. * @returns the JSON object
  85745. */
  85746. serialize(): any;
  85747. /**
  85748. * Parse properties from a JSON object
  85749. * @param serializationObject defines the JSON object
  85750. */
  85751. parse(serializationObject: any): void;
  85752. }
  85753. }
  85754. declare module BABYLON {
  85755. /**
  85756. * Particle emitter emitting particles from the inside of a hemisphere.
  85757. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  85758. */
  85759. export class HemisphericParticleEmitter implements IParticleEmitterType {
  85760. /**
  85761. * The radius of the emission hemisphere.
  85762. */
  85763. radius: number;
  85764. /**
  85765. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85766. */
  85767. radiusRange: number;
  85768. /**
  85769. * How much to randomize the particle direction [0-1].
  85770. */
  85771. directionRandomizer: number;
  85772. /**
  85773. * Creates a new instance HemisphericParticleEmitter
  85774. * @param radius the radius of the emission hemisphere (1 by default)
  85775. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85776. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85777. */
  85778. constructor(
  85779. /**
  85780. * The radius of the emission hemisphere.
  85781. */
  85782. radius?: number,
  85783. /**
  85784. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85785. */
  85786. radiusRange?: number,
  85787. /**
  85788. * How much to randomize the particle direction [0-1].
  85789. */
  85790. directionRandomizer?: number);
  85791. /**
  85792. * Called by the particle System when the direction is computed for the created particle.
  85793. * @param worldMatrix is the world matrix of the particle system
  85794. * @param directionToUpdate is the direction vector to update with the result
  85795. * @param particle is the particle we are computed the direction for
  85796. */
  85797. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85798. /**
  85799. * Called by the particle System when the position is computed for the created particle.
  85800. * @param worldMatrix is the world matrix of the particle system
  85801. * @param positionToUpdate is the position vector to update with the result
  85802. * @param particle is the particle we are computed the position for
  85803. */
  85804. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85805. /**
  85806. * Clones the current emitter and returns a copy of it
  85807. * @returns the new emitter
  85808. */
  85809. clone(): HemisphericParticleEmitter;
  85810. /**
  85811. * Called by the GPUParticleSystem to setup the update shader
  85812. * @param effect defines the update shader
  85813. */
  85814. applyToShader(effect: Effect): void;
  85815. /**
  85816. * Returns a string to use to update the GPU particles update shader
  85817. * @returns a string containng the defines string
  85818. */
  85819. getEffectDefines(): string;
  85820. /**
  85821. * Returns the string "HemisphericParticleEmitter"
  85822. * @returns a string containing the class name
  85823. */
  85824. getClassName(): string;
  85825. /**
  85826. * Serializes the particle system to a JSON object.
  85827. * @returns the JSON object
  85828. */
  85829. serialize(): any;
  85830. /**
  85831. * Parse properties from a JSON object
  85832. * @param serializationObject defines the JSON object
  85833. */
  85834. parse(serializationObject: any): void;
  85835. }
  85836. }
  85837. declare module BABYLON {
  85838. /**
  85839. * Particle emitter emitting particles from a point.
  85840. * It emits the particles randomly between 2 given directions.
  85841. */
  85842. export class PointParticleEmitter implements IParticleEmitterType {
  85843. /**
  85844. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85845. */
  85846. direction1: Vector3;
  85847. /**
  85848. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85849. */
  85850. direction2: Vector3;
  85851. /**
  85852. * Creates a new instance PointParticleEmitter
  85853. */
  85854. constructor();
  85855. /**
  85856. * Called by the particle System when the direction is computed for the created particle.
  85857. * @param worldMatrix is the world matrix of the particle system
  85858. * @param directionToUpdate is the direction vector to update with the result
  85859. * @param particle is the particle we are computed the direction for
  85860. */
  85861. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85862. /**
  85863. * Called by the particle System when the position is computed for the created particle.
  85864. * @param worldMatrix is the world matrix of the particle system
  85865. * @param positionToUpdate is the position vector to update with the result
  85866. * @param particle is the particle we are computed the position for
  85867. */
  85868. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85869. /**
  85870. * Clones the current emitter and returns a copy of it
  85871. * @returns the new emitter
  85872. */
  85873. clone(): PointParticleEmitter;
  85874. /**
  85875. * Called by the GPUParticleSystem to setup the update shader
  85876. * @param effect defines the update shader
  85877. */
  85878. applyToShader(effect: Effect): void;
  85879. /**
  85880. * Returns a string to use to update the GPU particles update shader
  85881. * @returns a string containng the defines string
  85882. */
  85883. getEffectDefines(): string;
  85884. /**
  85885. * Returns the string "PointParticleEmitter"
  85886. * @returns a string containing the class name
  85887. */
  85888. getClassName(): string;
  85889. /**
  85890. * Serializes the particle system to a JSON object.
  85891. * @returns the JSON object
  85892. */
  85893. serialize(): any;
  85894. /**
  85895. * Parse properties from a JSON object
  85896. * @param serializationObject defines the JSON object
  85897. */
  85898. parse(serializationObject: any): void;
  85899. }
  85900. }
  85901. declare module BABYLON {
  85902. /**
  85903. * Particle emitter emitting particles from the inside of a sphere.
  85904. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  85905. */
  85906. export class SphereParticleEmitter implements IParticleEmitterType {
  85907. /**
  85908. * The radius of the emission sphere.
  85909. */
  85910. radius: number;
  85911. /**
  85912. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85913. */
  85914. radiusRange: number;
  85915. /**
  85916. * How much to randomize the particle direction [0-1].
  85917. */
  85918. directionRandomizer: number;
  85919. /**
  85920. * Creates a new instance SphereParticleEmitter
  85921. * @param radius the radius of the emission sphere (1 by default)
  85922. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85923. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  85924. */
  85925. constructor(
  85926. /**
  85927. * The radius of the emission sphere.
  85928. */
  85929. radius?: number,
  85930. /**
  85931. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  85932. */
  85933. radiusRange?: number,
  85934. /**
  85935. * How much to randomize the particle direction [0-1].
  85936. */
  85937. directionRandomizer?: number);
  85938. /**
  85939. * Called by the particle System when the direction is computed for the created particle.
  85940. * @param worldMatrix is the world matrix of the particle system
  85941. * @param directionToUpdate is the direction vector to update with the result
  85942. * @param particle is the particle we are computed the direction for
  85943. */
  85944. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85945. /**
  85946. * Called by the particle System when the position is computed for the created particle.
  85947. * @param worldMatrix is the world matrix of the particle system
  85948. * @param positionToUpdate is the position vector to update with the result
  85949. * @param particle is the particle we are computed the position for
  85950. */
  85951. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  85952. /**
  85953. * Clones the current emitter and returns a copy of it
  85954. * @returns the new emitter
  85955. */
  85956. clone(): SphereParticleEmitter;
  85957. /**
  85958. * Called by the GPUParticleSystem to setup the update shader
  85959. * @param effect defines the update shader
  85960. */
  85961. applyToShader(effect: Effect): void;
  85962. /**
  85963. * Returns a string to use to update the GPU particles update shader
  85964. * @returns a string containng the defines string
  85965. */
  85966. getEffectDefines(): string;
  85967. /**
  85968. * Returns the string "SphereParticleEmitter"
  85969. * @returns a string containing the class name
  85970. */
  85971. getClassName(): string;
  85972. /**
  85973. * Serializes the particle system to a JSON object.
  85974. * @returns the JSON object
  85975. */
  85976. serialize(): any;
  85977. /**
  85978. * Parse properties from a JSON object
  85979. * @param serializationObject defines the JSON object
  85980. */
  85981. parse(serializationObject: any): void;
  85982. }
  85983. /**
  85984. * Particle emitter emitting particles from the inside of a sphere.
  85985. * It emits the particles randomly between two vectors.
  85986. */
  85987. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  85988. /**
  85989. * The min limit of the emission direction.
  85990. */
  85991. direction1: Vector3;
  85992. /**
  85993. * The max limit of the emission direction.
  85994. */
  85995. direction2: Vector3;
  85996. /**
  85997. * Creates a new instance SphereDirectedParticleEmitter
  85998. * @param radius the radius of the emission sphere (1 by default)
  85999. * @param direction1 the min limit of the emission direction (up vector by default)
  86000. * @param direction2 the max limit of the emission direction (up vector by default)
  86001. */
  86002. constructor(radius?: number,
  86003. /**
  86004. * The min limit of the emission direction.
  86005. */
  86006. direction1?: Vector3,
  86007. /**
  86008. * The max limit of the emission direction.
  86009. */
  86010. direction2?: Vector3);
  86011. /**
  86012. * Called by the particle System when the direction is computed for the created particle.
  86013. * @param worldMatrix is the world matrix of the particle system
  86014. * @param directionToUpdate is the direction vector to update with the result
  86015. * @param particle is the particle we are computed the direction for
  86016. */
  86017. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86018. /**
  86019. * Clones the current emitter and returns a copy of it
  86020. * @returns the new emitter
  86021. */
  86022. clone(): SphereDirectedParticleEmitter;
  86023. /**
  86024. * Called by the GPUParticleSystem to setup the update shader
  86025. * @param effect defines the update shader
  86026. */
  86027. applyToShader(effect: Effect): void;
  86028. /**
  86029. * Returns a string to use to update the GPU particles update shader
  86030. * @returns a string containng the defines string
  86031. */
  86032. getEffectDefines(): string;
  86033. /**
  86034. * Returns the string "SphereDirectedParticleEmitter"
  86035. * @returns a string containing the class name
  86036. */
  86037. getClassName(): string;
  86038. /**
  86039. * Serializes the particle system to a JSON object.
  86040. * @returns the JSON object
  86041. */
  86042. serialize(): any;
  86043. /**
  86044. * Parse properties from a JSON object
  86045. * @param serializationObject defines the JSON object
  86046. */
  86047. parse(serializationObject: any): void;
  86048. }
  86049. }
  86050. declare module BABYLON {
  86051. /**
  86052. * Particle emitter emitting particles from a custom list of positions.
  86053. */
  86054. export class CustomParticleEmitter implements IParticleEmitterType {
  86055. /**
  86056. * Gets or sets the position generator that will create the inital position of each particle.
  86057. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86058. */
  86059. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  86060. /**
  86061. * Gets or sets the destination generator that will create the final destination of each particle.
  86062. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  86063. */
  86064. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  86065. /**
  86066. * Creates a new instance CustomParticleEmitter
  86067. */
  86068. constructor();
  86069. /**
  86070. * Called by the particle System when the direction is computed for the created particle.
  86071. * @param worldMatrix is the world matrix of the particle system
  86072. * @param directionToUpdate is the direction vector to update with the result
  86073. * @param particle is the particle we are computed the direction for
  86074. */
  86075. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86076. /**
  86077. * Called by the particle System when the position is computed for the created particle.
  86078. * @param worldMatrix is the world matrix of the particle system
  86079. * @param positionToUpdate is the position vector to update with the result
  86080. * @param particle is the particle we are computed the position for
  86081. */
  86082. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86083. /**
  86084. * Clones the current emitter and returns a copy of it
  86085. * @returns the new emitter
  86086. */
  86087. clone(): CustomParticleEmitter;
  86088. /**
  86089. * Called by the GPUParticleSystem to setup the update shader
  86090. * @param effect defines the update shader
  86091. */
  86092. applyToShader(effect: Effect): void;
  86093. /**
  86094. * Returns a string to use to update the GPU particles update shader
  86095. * @returns a string containng the defines string
  86096. */
  86097. getEffectDefines(): string;
  86098. /**
  86099. * Returns the string "PointParticleEmitter"
  86100. * @returns a string containing the class name
  86101. */
  86102. getClassName(): string;
  86103. /**
  86104. * Serializes the particle system to a JSON object.
  86105. * @returns the JSON object
  86106. */
  86107. serialize(): any;
  86108. /**
  86109. * Parse properties from a JSON object
  86110. * @param serializationObject defines the JSON object
  86111. */
  86112. parse(serializationObject: any): void;
  86113. }
  86114. }
  86115. declare module BABYLON {
  86116. /**
  86117. * Particle emitter emitting particles from the inside of a box.
  86118. * It emits the particles randomly between 2 given directions.
  86119. */
  86120. export class MeshParticleEmitter implements IParticleEmitterType {
  86121. /** Defines the mesh to use as source */
  86122. mesh?: AbstractMesh | undefined;
  86123. private _indices;
  86124. private _positions;
  86125. private _normals;
  86126. private _storedNormal;
  86127. /**
  86128. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86129. */
  86130. direction1: Vector3;
  86131. /**
  86132. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86133. */
  86134. direction2: Vector3;
  86135. /**
  86136. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  86137. */
  86138. useMeshNormalsForDirection: boolean;
  86139. /**
  86140. * Creates a new instance MeshParticleEmitter
  86141. * @param mesh defines the mesh to use as source
  86142. */
  86143. constructor(
  86144. /** Defines the mesh to use as source */
  86145. mesh?: AbstractMesh | undefined);
  86146. /**
  86147. * Called by the particle System when the direction is computed for the created particle.
  86148. * @param worldMatrix is the world matrix of the particle system
  86149. * @param directionToUpdate is the direction vector to update with the result
  86150. * @param particle is the particle we are computed the direction for
  86151. */
  86152. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86153. /**
  86154. * Called by the particle System when the position is computed for the created particle.
  86155. * @param worldMatrix is the world matrix of the particle system
  86156. * @param positionToUpdate is the position vector to update with the result
  86157. * @param particle is the particle we are computed the position for
  86158. */
  86159. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  86160. /**
  86161. * Clones the current emitter and returns a copy of it
  86162. * @returns the new emitter
  86163. */
  86164. clone(): MeshParticleEmitter;
  86165. /**
  86166. * Called by the GPUParticleSystem to setup the update shader
  86167. * @param effect defines the update shader
  86168. */
  86169. applyToShader(effect: Effect): void;
  86170. /**
  86171. * Returns a string to use to update the GPU particles update shader
  86172. * @returns a string containng the defines string
  86173. */
  86174. getEffectDefines(): string;
  86175. /**
  86176. * Returns the string "BoxParticleEmitter"
  86177. * @returns a string containing the class name
  86178. */
  86179. getClassName(): string;
  86180. /**
  86181. * Serializes the particle system to a JSON object.
  86182. * @returns the JSON object
  86183. */
  86184. serialize(): any;
  86185. /**
  86186. * Parse properties from a JSON object
  86187. * @param serializationObject defines the JSON object
  86188. * @param scene defines the hosting scene
  86189. */
  86190. parse(serializationObject: any, scene: Scene): void;
  86191. }
  86192. }
  86193. declare module BABYLON {
  86194. /**
  86195. * Interface representing a particle system in Babylon.js.
  86196. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  86197. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  86198. */
  86199. export interface IParticleSystem {
  86200. /**
  86201. * List of animations used by the particle system.
  86202. */
  86203. animations: Animation[];
  86204. /**
  86205. * The id of the Particle system.
  86206. */
  86207. id: string;
  86208. /**
  86209. * The name of the Particle system.
  86210. */
  86211. name: string;
  86212. /**
  86213. * The emitter represents the Mesh or position we are attaching the particle system to.
  86214. */
  86215. emitter: Nullable<AbstractMesh | Vector3>;
  86216. /**
  86217. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  86218. */
  86219. isBillboardBased: boolean;
  86220. /**
  86221. * The rendering group used by the Particle system to chose when to render.
  86222. */
  86223. renderingGroupId: number;
  86224. /**
  86225. * The layer mask we are rendering the particles through.
  86226. */
  86227. layerMask: number;
  86228. /**
  86229. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  86230. */
  86231. updateSpeed: number;
  86232. /**
  86233. * The amount of time the particle system is running (depends of the overall update speed).
  86234. */
  86235. targetStopDuration: number;
  86236. /**
  86237. * The texture used to render each particle. (this can be a spritesheet)
  86238. */
  86239. particleTexture: Nullable<Texture>;
  86240. /**
  86241. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  86242. */
  86243. blendMode: number;
  86244. /**
  86245. * Minimum life time of emitting particles.
  86246. */
  86247. minLifeTime: number;
  86248. /**
  86249. * Maximum life time of emitting particles.
  86250. */
  86251. maxLifeTime: number;
  86252. /**
  86253. * Minimum Size of emitting particles.
  86254. */
  86255. minSize: number;
  86256. /**
  86257. * Maximum Size of emitting particles.
  86258. */
  86259. maxSize: number;
  86260. /**
  86261. * Minimum scale of emitting particles on X axis.
  86262. */
  86263. minScaleX: number;
  86264. /**
  86265. * Maximum scale of emitting particles on X axis.
  86266. */
  86267. maxScaleX: number;
  86268. /**
  86269. * Minimum scale of emitting particles on Y axis.
  86270. */
  86271. minScaleY: number;
  86272. /**
  86273. * Maximum scale of emitting particles on Y axis.
  86274. */
  86275. maxScaleY: number;
  86276. /**
  86277. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86278. */
  86279. color1: Color4;
  86280. /**
  86281. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  86282. */
  86283. color2: Color4;
  86284. /**
  86285. * Color the particle will have at the end of its lifetime.
  86286. */
  86287. colorDead: Color4;
  86288. /**
  86289. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  86290. */
  86291. emitRate: number;
  86292. /**
  86293. * You can use gravity if you want to give an orientation to your particles.
  86294. */
  86295. gravity: Vector3;
  86296. /**
  86297. * Minimum power of emitting particles.
  86298. */
  86299. minEmitPower: number;
  86300. /**
  86301. * Maximum power of emitting particles.
  86302. */
  86303. maxEmitPower: number;
  86304. /**
  86305. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  86306. */
  86307. minAngularSpeed: number;
  86308. /**
  86309. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  86310. */
  86311. maxAngularSpeed: number;
  86312. /**
  86313. * Gets or sets the minimal initial rotation in radians.
  86314. */
  86315. minInitialRotation: number;
  86316. /**
  86317. * Gets or sets the maximal initial rotation in radians.
  86318. */
  86319. maxInitialRotation: number;
  86320. /**
  86321. * The particle emitter type defines the emitter used by the particle system.
  86322. * It can be for example box, sphere, or cone...
  86323. */
  86324. particleEmitterType: Nullable<IParticleEmitterType>;
  86325. /**
  86326. * Defines the delay in milliseconds before starting the system (0 by default)
  86327. */
  86328. startDelay: number;
  86329. /**
  86330. * 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
  86331. */
  86332. preWarmCycles: number;
  86333. /**
  86334. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  86335. */
  86336. preWarmStepOffset: number;
  86337. /**
  86338. * 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)
  86339. */
  86340. spriteCellChangeSpeed: number;
  86341. /**
  86342. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  86343. */
  86344. startSpriteCellID: number;
  86345. /**
  86346. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  86347. */
  86348. endSpriteCellID: number;
  86349. /**
  86350. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  86351. */
  86352. spriteCellWidth: number;
  86353. /**
  86354. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  86355. */
  86356. spriteCellHeight: number;
  86357. /**
  86358. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  86359. */
  86360. spriteRandomStartCell: boolean;
  86361. /**
  86362. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  86363. */
  86364. isAnimationSheetEnabled: boolean;
  86365. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  86366. translationPivot: Vector2;
  86367. /**
  86368. * Gets or sets a texture used to add random noise to particle positions
  86369. */
  86370. noiseTexture: Nullable<BaseTexture>;
  86371. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  86372. noiseStrength: Vector3;
  86373. /**
  86374. * Gets or sets the billboard mode to use when isBillboardBased = true.
  86375. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  86376. */
  86377. billboardMode: number;
  86378. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  86379. limitVelocityDamping: number;
  86380. /**
  86381. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  86382. */
  86383. beginAnimationOnStart: boolean;
  86384. /**
  86385. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  86386. */
  86387. beginAnimationFrom: number;
  86388. /**
  86389. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  86390. */
  86391. beginAnimationTo: number;
  86392. /**
  86393. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  86394. */
  86395. beginAnimationLoop: boolean;
  86396. /**
  86397. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  86398. */
  86399. disposeOnStop: boolean;
  86400. /**
  86401. * Gets the maximum number of particles active at the same time.
  86402. * @returns The max number of active particles.
  86403. */
  86404. getCapacity(): number;
  86405. /**
  86406. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86407. * @returns True if it has been started, otherwise false.
  86408. */
  86409. isStarted(): boolean;
  86410. /**
  86411. * Animates the particle system for this frame.
  86412. */
  86413. animate(): void;
  86414. /**
  86415. * Renders the particle system in its current state.
  86416. * @returns the current number of particles
  86417. */
  86418. render(): number;
  86419. /**
  86420. * Dispose the particle system and frees its associated resources.
  86421. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86422. */
  86423. dispose(disposeTexture?: boolean): void;
  86424. /**
  86425. * Clones the particle system.
  86426. * @param name The name of the cloned object
  86427. * @param newEmitter The new emitter to use
  86428. * @returns the cloned particle system
  86429. */
  86430. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  86431. /**
  86432. * Serializes the particle system to a JSON object.
  86433. * @returns the JSON object
  86434. */
  86435. serialize(): any;
  86436. /**
  86437. * Rebuild the particle system
  86438. */
  86439. rebuild(): void;
  86440. /**
  86441. * Starts the particle system and begins to emit
  86442. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  86443. */
  86444. start(delay?: number): void;
  86445. /**
  86446. * Stops the particle system.
  86447. */
  86448. stop(): void;
  86449. /**
  86450. * Remove all active particles
  86451. */
  86452. reset(): void;
  86453. /**
  86454. * Is this system ready to be used/rendered
  86455. * @return true if the system is ready
  86456. */
  86457. isReady(): boolean;
  86458. /**
  86459. * Adds a new color gradient
  86460. * @param gradient defines the gradient to use (between 0 and 1)
  86461. * @param color1 defines the color to affect to the specified gradient
  86462. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86463. * @returns the current particle system
  86464. */
  86465. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86466. /**
  86467. * Remove a specific color gradient
  86468. * @param gradient defines the gradient to remove
  86469. * @returns the current particle system
  86470. */
  86471. removeColorGradient(gradient: number): IParticleSystem;
  86472. /**
  86473. * Adds a new size gradient
  86474. * @param gradient defines the gradient to use (between 0 and 1)
  86475. * @param factor defines the size factor to affect to the specified gradient
  86476. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86477. * @returns the current particle system
  86478. */
  86479. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86480. /**
  86481. * Remove a specific size gradient
  86482. * @param gradient defines the gradient to remove
  86483. * @returns the current particle system
  86484. */
  86485. removeSizeGradient(gradient: number): IParticleSystem;
  86486. /**
  86487. * Gets the current list of color gradients.
  86488. * You must use addColorGradient and removeColorGradient to udpate this list
  86489. * @returns the list of color gradients
  86490. */
  86491. getColorGradients(): Nullable<Array<ColorGradient>>;
  86492. /**
  86493. * Gets the current list of size gradients.
  86494. * You must use addSizeGradient and removeSizeGradient to udpate this list
  86495. * @returns the list of size gradients
  86496. */
  86497. getSizeGradients(): Nullable<Array<FactorGradient>>;
  86498. /**
  86499. * Gets the current list of angular speed gradients.
  86500. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  86501. * @returns the list of angular speed gradients
  86502. */
  86503. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  86504. /**
  86505. * Adds a new angular speed gradient
  86506. * @param gradient defines the gradient to use (between 0 and 1)
  86507. * @param factor defines the angular speed to affect to the specified gradient
  86508. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86509. * @returns the current particle system
  86510. */
  86511. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86512. /**
  86513. * Remove a specific angular speed gradient
  86514. * @param gradient defines the gradient to remove
  86515. * @returns the current particle system
  86516. */
  86517. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86518. /**
  86519. * Gets the current list of velocity gradients.
  86520. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  86521. * @returns the list of velocity gradients
  86522. */
  86523. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  86524. /**
  86525. * Adds a new velocity gradient
  86526. * @param gradient defines the gradient to use (between 0 and 1)
  86527. * @param factor defines the velocity to affect to the specified gradient
  86528. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86529. * @returns the current particle system
  86530. */
  86531. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86532. /**
  86533. * Remove a specific velocity gradient
  86534. * @param gradient defines the gradient to remove
  86535. * @returns the current particle system
  86536. */
  86537. removeVelocityGradient(gradient: number): IParticleSystem;
  86538. /**
  86539. * Gets the current list of limit velocity gradients.
  86540. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  86541. * @returns the list of limit velocity gradients
  86542. */
  86543. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  86544. /**
  86545. * Adds a new limit velocity gradient
  86546. * @param gradient defines the gradient to use (between 0 and 1)
  86547. * @param factor defines the limit velocity to affect to the specified gradient
  86548. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86549. * @returns the current particle system
  86550. */
  86551. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86552. /**
  86553. * Remove a specific limit velocity gradient
  86554. * @param gradient defines the gradient to remove
  86555. * @returns the current particle system
  86556. */
  86557. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86558. /**
  86559. * Adds a new drag gradient
  86560. * @param gradient defines the gradient to use (between 0 and 1)
  86561. * @param factor defines the drag to affect to the specified gradient
  86562. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86563. * @returns the current particle system
  86564. */
  86565. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86566. /**
  86567. * Remove a specific drag gradient
  86568. * @param gradient defines the gradient to remove
  86569. * @returns the current particle system
  86570. */
  86571. removeDragGradient(gradient: number): IParticleSystem;
  86572. /**
  86573. * Gets the current list of drag gradients.
  86574. * You must use addDragGradient and removeDragGradient to udpate this list
  86575. * @returns the list of drag gradients
  86576. */
  86577. getDragGradients(): Nullable<Array<FactorGradient>>;
  86578. /**
  86579. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86580. * @param gradient defines the gradient to use (between 0 and 1)
  86581. * @param factor defines the emit rate to affect to the specified gradient
  86582. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86583. * @returns the current particle system
  86584. */
  86585. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86586. /**
  86587. * Remove a specific emit rate gradient
  86588. * @param gradient defines the gradient to remove
  86589. * @returns the current particle system
  86590. */
  86591. removeEmitRateGradient(gradient: number): IParticleSystem;
  86592. /**
  86593. * Gets the current list of emit rate gradients.
  86594. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  86595. * @returns the list of emit rate gradients
  86596. */
  86597. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  86598. /**
  86599. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86600. * @param gradient defines the gradient to use (between 0 and 1)
  86601. * @param factor defines the start size to affect to the specified gradient
  86602. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86603. * @returns the current particle system
  86604. */
  86605. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86606. /**
  86607. * Remove a specific start size gradient
  86608. * @param gradient defines the gradient to remove
  86609. * @returns the current particle system
  86610. */
  86611. removeStartSizeGradient(gradient: number): IParticleSystem;
  86612. /**
  86613. * Gets the current list of start size gradients.
  86614. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  86615. * @returns the list of start size gradients
  86616. */
  86617. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  86618. /**
  86619. * Adds a new life time gradient
  86620. * @param gradient defines the gradient to use (between 0 and 1)
  86621. * @param factor defines the life time factor to affect to the specified gradient
  86622. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86623. * @returns the current particle system
  86624. */
  86625. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86626. /**
  86627. * Remove a specific life time gradient
  86628. * @param gradient defines the gradient to remove
  86629. * @returns the current particle system
  86630. */
  86631. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86632. /**
  86633. * Gets the current list of life time gradients.
  86634. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  86635. * @returns the list of life time gradients
  86636. */
  86637. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  86638. /**
  86639. * Gets the current list of color gradients.
  86640. * You must use addColorGradient and removeColorGradient to udpate this list
  86641. * @returns the list of color gradients
  86642. */
  86643. getColorGradients(): Nullable<Array<ColorGradient>>;
  86644. /**
  86645. * Adds a new ramp gradient used to remap particle colors
  86646. * @param gradient defines the gradient to use (between 0 and 1)
  86647. * @param color defines the color to affect to the specified gradient
  86648. * @returns the current particle system
  86649. */
  86650. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  86651. /**
  86652. * Gets the current list of ramp gradients.
  86653. * You must use addRampGradient and removeRampGradient to udpate this list
  86654. * @returns the list of ramp gradients
  86655. */
  86656. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86657. /** Gets or sets a boolean indicating that ramp gradients must be used
  86658. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  86659. */
  86660. useRampGradients: boolean;
  86661. /**
  86662. * Adds a new color remap gradient
  86663. * @param gradient defines the gradient to use (between 0 and 1)
  86664. * @param min defines the color remap minimal range
  86665. * @param max defines the color remap maximal range
  86666. * @returns the current particle system
  86667. */
  86668. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86669. /**
  86670. * Gets the current list of color remap gradients.
  86671. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  86672. * @returns the list of color remap gradients
  86673. */
  86674. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  86675. /**
  86676. * Adds a new alpha remap gradient
  86677. * @param gradient defines the gradient to use (between 0 and 1)
  86678. * @param min defines the alpha remap minimal range
  86679. * @param max defines the alpha remap maximal range
  86680. * @returns the current particle system
  86681. */
  86682. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86683. /**
  86684. * Gets the current list of alpha remap gradients.
  86685. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  86686. * @returns the list of alpha remap gradients
  86687. */
  86688. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  86689. /**
  86690. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  86691. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86692. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86693. * @returns the emitter
  86694. */
  86695. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  86696. /**
  86697. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  86698. * @param radius The radius of the hemisphere to emit from
  86699. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86700. * @returns the emitter
  86701. */
  86702. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  86703. /**
  86704. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  86705. * @param radius The radius of the sphere to emit from
  86706. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  86707. * @returns the emitter
  86708. */
  86709. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  86710. /**
  86711. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  86712. * @param radius The radius of the sphere to emit from
  86713. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  86714. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  86715. * @returns the emitter
  86716. */
  86717. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86718. /**
  86719. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  86720. * @param radius The radius of the emission cylinder
  86721. * @param height The height of the emission cylinder
  86722. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  86723. * @param directionRandomizer How much to randomize the particle direction [0-1]
  86724. * @returns the emitter
  86725. */
  86726. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  86727. /**
  86728. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  86729. * @param radius The radius of the cylinder to emit from
  86730. * @param height The height of the emission cylinder
  86731. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86732. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  86733. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  86734. * @returns the emitter
  86735. */
  86736. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  86737. /**
  86738. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  86739. * @param radius The radius of the cone to emit from
  86740. * @param angle The base angle of the cone
  86741. * @returns the emitter
  86742. */
  86743. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  86744. /**
  86745. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  86746. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  86747. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  86748. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86749. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  86750. * @returns the emitter
  86751. */
  86752. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  86753. /**
  86754. * Get hosting scene
  86755. * @returns the scene
  86756. */
  86757. getScene(): Scene;
  86758. }
  86759. }
  86760. declare module BABYLON {
  86761. /**
  86762. * 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.
  86763. * @see https://doc.babylonjs.com/how_to/transformnode
  86764. */
  86765. export class TransformNode extends Node {
  86766. /**
  86767. * Object will not rotate to face the camera
  86768. */
  86769. static BILLBOARDMODE_NONE: number;
  86770. /**
  86771. * Object will rotate to face the camera but only on the x axis
  86772. */
  86773. static BILLBOARDMODE_X: number;
  86774. /**
  86775. * Object will rotate to face the camera but only on the y axis
  86776. */
  86777. static BILLBOARDMODE_Y: number;
  86778. /**
  86779. * Object will rotate to face the camera but only on the z axis
  86780. */
  86781. static BILLBOARDMODE_Z: number;
  86782. /**
  86783. * Object will rotate to face the camera
  86784. */
  86785. static BILLBOARDMODE_ALL: number;
  86786. /**
  86787. * Object will rotate to face the camera's position instead of orientation
  86788. */
  86789. static BILLBOARDMODE_USE_POSITION: number;
  86790. private _forward;
  86791. private _forwardInverted;
  86792. private _up;
  86793. private _right;
  86794. private _rightInverted;
  86795. private _position;
  86796. private _rotation;
  86797. private _rotationQuaternion;
  86798. protected _scaling: Vector3;
  86799. protected _isDirty: boolean;
  86800. private _transformToBoneReferal;
  86801. private _isAbsoluteSynced;
  86802. private _billboardMode;
  86803. /**
  86804. * Gets or sets the billboard mode. Default is 0.
  86805. *
  86806. * | Value | Type | Description |
  86807. * | --- | --- | --- |
  86808. * | 0 | BILLBOARDMODE_NONE | |
  86809. * | 1 | BILLBOARDMODE_X | |
  86810. * | 2 | BILLBOARDMODE_Y | |
  86811. * | 4 | BILLBOARDMODE_Z | |
  86812. * | 7 | BILLBOARDMODE_ALL | |
  86813. *
  86814. */
  86815. get billboardMode(): number;
  86816. set billboardMode(value: number);
  86817. private _preserveParentRotationForBillboard;
  86818. /**
  86819. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  86820. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  86821. */
  86822. get preserveParentRotationForBillboard(): boolean;
  86823. set preserveParentRotationForBillboard(value: boolean);
  86824. /**
  86825. * 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
  86826. */
  86827. scalingDeterminant: number;
  86828. private _infiniteDistance;
  86829. /**
  86830. * Gets or sets the distance of the object to max, often used by skybox
  86831. */
  86832. get infiniteDistance(): boolean;
  86833. set infiniteDistance(value: boolean);
  86834. /**
  86835. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  86836. * By default the system will update normals to compensate
  86837. */
  86838. ignoreNonUniformScaling: boolean;
  86839. /**
  86840. * 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
  86841. */
  86842. reIntegrateRotationIntoRotationQuaternion: boolean;
  86843. /** @hidden */
  86844. _poseMatrix: Nullable<Matrix>;
  86845. /** @hidden */
  86846. _localMatrix: Matrix;
  86847. private _usePivotMatrix;
  86848. private _absolutePosition;
  86849. private _absoluteScaling;
  86850. private _absoluteRotationQuaternion;
  86851. private _pivotMatrix;
  86852. private _pivotMatrixInverse;
  86853. protected _postMultiplyPivotMatrix: boolean;
  86854. protected _isWorldMatrixFrozen: boolean;
  86855. /** @hidden */
  86856. _indexInSceneTransformNodesArray: number;
  86857. /**
  86858. * An event triggered after the world matrix is updated
  86859. */
  86860. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  86861. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  86862. /**
  86863. * Gets a string identifying the name of the class
  86864. * @returns "TransformNode" string
  86865. */
  86866. getClassName(): string;
  86867. /**
  86868. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  86869. */
  86870. get position(): Vector3;
  86871. set position(newPosition: Vector3);
  86872. /**
  86873. * 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)).
  86874. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  86875. */
  86876. get rotation(): Vector3;
  86877. set rotation(newRotation: Vector3);
  86878. /**
  86879. * 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)).
  86880. */
  86881. get scaling(): Vector3;
  86882. set scaling(newScaling: Vector3);
  86883. /**
  86884. * 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).
  86885. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  86886. */
  86887. get rotationQuaternion(): Nullable<Quaternion>;
  86888. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  86889. /**
  86890. * The forward direction of that transform in world space.
  86891. */
  86892. get forward(): Vector3;
  86893. /**
  86894. * The up direction of that transform in world space.
  86895. */
  86896. get up(): Vector3;
  86897. /**
  86898. * The right direction of that transform in world space.
  86899. */
  86900. get right(): Vector3;
  86901. /**
  86902. * Copies the parameter passed Matrix into the mesh Pose matrix.
  86903. * @param matrix the matrix to copy the pose from
  86904. * @returns this TransformNode.
  86905. */
  86906. updatePoseMatrix(matrix: Matrix): TransformNode;
  86907. /**
  86908. * Returns the mesh Pose matrix.
  86909. * @returns the pose matrix
  86910. */
  86911. getPoseMatrix(): Matrix;
  86912. /** @hidden */
  86913. _isSynchronized(): boolean;
  86914. /** @hidden */
  86915. _initCache(): void;
  86916. /**
  86917. * Flag the transform node as dirty (Forcing it to update everything)
  86918. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  86919. * @returns this transform node
  86920. */
  86921. markAsDirty(property: string): TransformNode;
  86922. /**
  86923. * Returns the current mesh absolute position.
  86924. * Returns a Vector3.
  86925. */
  86926. get absolutePosition(): Vector3;
  86927. /**
  86928. * Returns the current mesh absolute scaling.
  86929. * Returns a Vector3.
  86930. */
  86931. get absoluteScaling(): Vector3;
  86932. /**
  86933. * Returns the current mesh absolute rotation.
  86934. * Returns a Quaternion.
  86935. */
  86936. get absoluteRotationQuaternion(): Quaternion;
  86937. /**
  86938. * Sets a new matrix to apply before all other transformation
  86939. * @param matrix defines the transform matrix
  86940. * @returns the current TransformNode
  86941. */
  86942. setPreTransformMatrix(matrix: Matrix): TransformNode;
  86943. /**
  86944. * Sets a new pivot matrix to the current node
  86945. * @param matrix defines the new pivot matrix to use
  86946. * @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
  86947. * @returns the current TransformNode
  86948. */
  86949. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  86950. /**
  86951. * Returns the mesh pivot matrix.
  86952. * Default : Identity.
  86953. * @returns the matrix
  86954. */
  86955. getPivotMatrix(): Matrix;
  86956. /**
  86957. * Instantiate (when possible) or clone that node with its hierarchy
  86958. * @param newParent defines the new parent to use for the instance (or clone)
  86959. * @param options defines options to configure how copy is done
  86960. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  86961. * @returns an instance (or a clone) of the current node with its hiearchy
  86962. */
  86963. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  86964. doNotInstantiate: boolean;
  86965. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  86966. /**
  86967. * Prevents the World matrix to be computed any longer
  86968. * @param newWorldMatrix defines an optional matrix to use as world matrix
  86969. * @returns the TransformNode.
  86970. */
  86971. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  86972. /**
  86973. * Allows back the World matrix computation.
  86974. * @returns the TransformNode.
  86975. */
  86976. unfreezeWorldMatrix(): this;
  86977. /**
  86978. * True if the World matrix has been frozen.
  86979. */
  86980. get isWorldMatrixFrozen(): boolean;
  86981. /**
  86982. * Retuns the mesh absolute position in the World.
  86983. * @returns a Vector3.
  86984. */
  86985. getAbsolutePosition(): Vector3;
  86986. /**
  86987. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  86988. * @param absolutePosition the absolute position to set
  86989. * @returns the TransformNode.
  86990. */
  86991. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  86992. /**
  86993. * Sets the mesh position in its local space.
  86994. * @param vector3 the position to set in localspace
  86995. * @returns the TransformNode.
  86996. */
  86997. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  86998. /**
  86999. * Returns the mesh position in the local space from the current World matrix values.
  87000. * @returns a new Vector3.
  87001. */
  87002. getPositionExpressedInLocalSpace(): Vector3;
  87003. /**
  87004. * Translates the mesh along the passed Vector3 in its local space.
  87005. * @param vector3 the distance to translate in localspace
  87006. * @returns the TransformNode.
  87007. */
  87008. locallyTranslate(vector3: Vector3): TransformNode;
  87009. private static _lookAtVectorCache;
  87010. /**
  87011. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  87012. * @param targetPoint the position (must be in same space as current mesh) to look at
  87013. * @param yawCor optional yaw (y-axis) correction in radians
  87014. * @param pitchCor optional pitch (x-axis) correction in radians
  87015. * @param rollCor optional roll (z-axis) correction in radians
  87016. * @param space the choosen space of the target
  87017. * @returns the TransformNode.
  87018. */
  87019. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  87020. /**
  87021. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87022. * This Vector3 is expressed in the World space.
  87023. * @param localAxis axis to rotate
  87024. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  87025. */
  87026. getDirection(localAxis: Vector3): Vector3;
  87027. /**
  87028. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  87029. * localAxis is expressed in the mesh local space.
  87030. * result is computed in the Wordl space from the mesh World matrix.
  87031. * @param localAxis axis to rotate
  87032. * @param result the resulting transformnode
  87033. * @returns this TransformNode.
  87034. */
  87035. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  87036. /**
  87037. * Sets this transform node rotation to the given local axis.
  87038. * @param localAxis the axis in local space
  87039. * @param yawCor optional yaw (y-axis) correction in radians
  87040. * @param pitchCor optional pitch (x-axis) correction in radians
  87041. * @param rollCor optional roll (z-axis) correction in radians
  87042. * @returns this TransformNode
  87043. */
  87044. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  87045. /**
  87046. * Sets a new pivot point to the current node
  87047. * @param point defines the new pivot point to use
  87048. * @param space defines if the point is in world or local space (local by default)
  87049. * @returns the current TransformNode
  87050. */
  87051. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  87052. /**
  87053. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  87054. * @returns the pivot point
  87055. */
  87056. getPivotPoint(): Vector3;
  87057. /**
  87058. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  87059. * @param result the vector3 to store the result
  87060. * @returns this TransformNode.
  87061. */
  87062. getPivotPointToRef(result: Vector3): TransformNode;
  87063. /**
  87064. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  87065. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  87066. */
  87067. getAbsolutePivotPoint(): Vector3;
  87068. /**
  87069. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  87070. * @param result vector3 to store the result
  87071. * @returns this TransformNode.
  87072. */
  87073. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  87074. /**
  87075. * Defines the passed node as the parent of the current node.
  87076. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  87077. * @see https://doc.babylonjs.com/how_to/parenting
  87078. * @param node the node ot set as the parent
  87079. * @returns this TransformNode.
  87080. */
  87081. setParent(node: Nullable<Node>): TransformNode;
  87082. private _nonUniformScaling;
  87083. /**
  87084. * True if the scaling property of this object is non uniform eg. (1,2,1)
  87085. */
  87086. get nonUniformScaling(): boolean;
  87087. /** @hidden */
  87088. _updateNonUniformScalingState(value: boolean): boolean;
  87089. /**
  87090. * Attach the current TransformNode to another TransformNode associated with a bone
  87091. * @param bone Bone affecting the TransformNode
  87092. * @param affectedTransformNode TransformNode associated with the bone
  87093. * @returns this object
  87094. */
  87095. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  87096. /**
  87097. * Detach the transform node if its associated with a bone
  87098. * @returns this object
  87099. */
  87100. detachFromBone(): TransformNode;
  87101. private static _rotationAxisCache;
  87102. /**
  87103. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  87104. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87105. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87106. * The passed axis is also normalized.
  87107. * @param axis the axis to rotate around
  87108. * @param amount the amount to rotate in radians
  87109. * @param space Space to rotate in (Default: local)
  87110. * @returns the TransformNode.
  87111. */
  87112. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  87113. /**
  87114. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  87115. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  87116. * The passed axis is also normalized. .
  87117. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  87118. * @param point the point to rotate around
  87119. * @param axis the axis to rotate around
  87120. * @param amount the amount to rotate in radians
  87121. * @returns the TransformNode
  87122. */
  87123. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  87124. /**
  87125. * Translates the mesh along the axis vector for the passed distance in the given space.
  87126. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  87127. * @param axis the axis to translate in
  87128. * @param distance the distance to translate
  87129. * @param space Space to rotate in (Default: local)
  87130. * @returns the TransformNode.
  87131. */
  87132. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  87133. /**
  87134. * Adds a rotation step to the mesh current rotation.
  87135. * x, y, z are Euler angles expressed in radians.
  87136. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  87137. * This means this rotation is made in the mesh local space only.
  87138. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  87139. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  87140. * ```javascript
  87141. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  87142. * ```
  87143. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  87144. * 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.
  87145. * @param x Rotation to add
  87146. * @param y Rotation to add
  87147. * @param z Rotation to add
  87148. * @returns the TransformNode.
  87149. */
  87150. addRotation(x: number, y: number, z: number): TransformNode;
  87151. /**
  87152. * @hidden
  87153. */
  87154. protected _getEffectiveParent(): Nullable<Node>;
  87155. /**
  87156. * Computes the world matrix of the node
  87157. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87158. * @returns the world matrix
  87159. */
  87160. computeWorldMatrix(force?: boolean): Matrix;
  87161. /**
  87162. * Resets this nodeTransform's local matrix to Matrix.Identity().
  87163. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  87164. */
  87165. resetLocalMatrix(independentOfChildren?: boolean): void;
  87166. protected _afterComputeWorldMatrix(): void;
  87167. /**
  87168. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  87169. * @param func callback function to add
  87170. *
  87171. * @returns the TransformNode.
  87172. */
  87173. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87174. /**
  87175. * Removes a registered callback function.
  87176. * @param func callback function to remove
  87177. * @returns the TransformNode.
  87178. */
  87179. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  87180. /**
  87181. * Gets the position of the current mesh in camera space
  87182. * @param camera defines the camera to use
  87183. * @returns a position
  87184. */
  87185. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  87186. /**
  87187. * Returns the distance from the mesh to the active camera
  87188. * @param camera defines the camera to use
  87189. * @returns the distance
  87190. */
  87191. getDistanceToCamera(camera?: Nullable<Camera>): number;
  87192. /**
  87193. * Clone the current transform node
  87194. * @param name Name of the new clone
  87195. * @param newParent New parent for the clone
  87196. * @param doNotCloneChildren Do not clone children hierarchy
  87197. * @returns the new transform node
  87198. */
  87199. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  87200. /**
  87201. * Serializes the objects information.
  87202. * @param currentSerializationObject defines the object to serialize in
  87203. * @returns the serialized object
  87204. */
  87205. serialize(currentSerializationObject?: any): any;
  87206. /**
  87207. * Returns a new TransformNode object parsed from the source provided.
  87208. * @param parsedTransformNode is the source.
  87209. * @param scene the scne the object belongs to
  87210. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  87211. * @returns a new TransformNode object parsed from the source provided.
  87212. */
  87213. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  87214. /**
  87215. * Get all child-transformNodes of this node
  87216. * @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
  87217. * @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
  87218. * @returns an array of TransformNode
  87219. */
  87220. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  87221. /**
  87222. * Releases resources associated with this transform node.
  87223. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87224. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87225. */
  87226. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87227. /**
  87228. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  87229. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  87230. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  87231. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  87232. * @returns the current mesh
  87233. */
  87234. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  87235. private _syncAbsoluteScalingAndRotation;
  87236. }
  87237. }
  87238. declare module BABYLON {
  87239. /**
  87240. * Class used to override all child animations of a given target
  87241. */
  87242. export class AnimationPropertiesOverride {
  87243. /**
  87244. * Gets or sets a value indicating if animation blending must be used
  87245. */
  87246. enableBlending: boolean;
  87247. /**
  87248. * Gets or sets the blending speed to use when enableBlending is true
  87249. */
  87250. blendingSpeed: number;
  87251. /**
  87252. * Gets or sets the default loop mode to use
  87253. */
  87254. loopMode: number;
  87255. }
  87256. }
  87257. declare module BABYLON {
  87258. /**
  87259. * Class used to store bone information
  87260. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  87261. */
  87262. export class Bone extends Node {
  87263. /**
  87264. * defines the bone name
  87265. */
  87266. name: string;
  87267. private static _tmpVecs;
  87268. private static _tmpQuat;
  87269. private static _tmpMats;
  87270. /**
  87271. * Gets the list of child bones
  87272. */
  87273. children: Bone[];
  87274. /** Gets the animations associated with this bone */
  87275. animations: Animation[];
  87276. /**
  87277. * Gets or sets bone length
  87278. */
  87279. length: number;
  87280. /**
  87281. * @hidden Internal only
  87282. * Set this value to map this bone to a different index in the transform matrices
  87283. * Set this value to -1 to exclude the bone from the transform matrices
  87284. */
  87285. _index: Nullable<number>;
  87286. private _skeleton;
  87287. private _localMatrix;
  87288. private _restPose;
  87289. private _baseMatrix;
  87290. private _absoluteTransform;
  87291. private _invertedAbsoluteTransform;
  87292. private _parent;
  87293. private _scalingDeterminant;
  87294. private _worldTransform;
  87295. private _localScaling;
  87296. private _localRotation;
  87297. private _localPosition;
  87298. private _needToDecompose;
  87299. private _needToCompose;
  87300. /** @hidden */
  87301. _linkedTransformNode: Nullable<TransformNode>;
  87302. /** @hidden */
  87303. _waitingTransformNodeId: Nullable<string>;
  87304. /** @hidden */
  87305. get _matrix(): Matrix;
  87306. /** @hidden */
  87307. set _matrix(value: Matrix);
  87308. /**
  87309. * Create a new bone
  87310. * @param name defines the bone name
  87311. * @param skeleton defines the parent skeleton
  87312. * @param parentBone defines the parent (can be null if the bone is the root)
  87313. * @param localMatrix defines the local matrix
  87314. * @param restPose defines the rest pose matrix
  87315. * @param baseMatrix defines the base matrix
  87316. * @param index defines index of the bone in the hiearchy
  87317. */
  87318. constructor(
  87319. /**
  87320. * defines the bone name
  87321. */
  87322. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  87323. /**
  87324. * Gets the current object class name.
  87325. * @return the class name
  87326. */
  87327. getClassName(): string;
  87328. /**
  87329. * Gets the parent skeleton
  87330. * @returns a skeleton
  87331. */
  87332. getSkeleton(): Skeleton;
  87333. /**
  87334. * Gets parent bone
  87335. * @returns a bone or null if the bone is the root of the bone hierarchy
  87336. */
  87337. getParent(): Nullable<Bone>;
  87338. /**
  87339. * Returns an array containing the root bones
  87340. * @returns an array containing the root bones
  87341. */
  87342. getChildren(): Array<Bone>;
  87343. /**
  87344. * Gets the node index in matrix array generated for rendering
  87345. * @returns the node index
  87346. */
  87347. getIndex(): number;
  87348. /**
  87349. * Sets the parent bone
  87350. * @param parent defines the parent (can be null if the bone is the root)
  87351. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87352. */
  87353. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  87354. /**
  87355. * Gets the local matrix
  87356. * @returns a matrix
  87357. */
  87358. getLocalMatrix(): Matrix;
  87359. /**
  87360. * Gets the base matrix (initial matrix which remains unchanged)
  87361. * @returns a matrix
  87362. */
  87363. getBaseMatrix(): Matrix;
  87364. /**
  87365. * Gets the rest pose matrix
  87366. * @returns a matrix
  87367. */
  87368. getRestPose(): Matrix;
  87369. /**
  87370. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  87371. */
  87372. getWorldMatrix(): Matrix;
  87373. /**
  87374. * Sets the local matrix to rest pose matrix
  87375. */
  87376. returnToRest(): void;
  87377. /**
  87378. * Gets the inverse of the absolute transform matrix.
  87379. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  87380. * @returns a matrix
  87381. */
  87382. getInvertedAbsoluteTransform(): Matrix;
  87383. /**
  87384. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  87385. * @returns a matrix
  87386. */
  87387. getAbsoluteTransform(): Matrix;
  87388. /**
  87389. * Links with the given transform node.
  87390. * The local matrix of this bone is copied from the transform node every frame.
  87391. * @param transformNode defines the transform node to link to
  87392. */
  87393. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  87394. /**
  87395. * Gets the node used to drive the bone's transformation
  87396. * @returns a transform node or null
  87397. */
  87398. getTransformNode(): Nullable<TransformNode>;
  87399. /** Gets or sets current position (in local space) */
  87400. get position(): Vector3;
  87401. set position(newPosition: Vector3);
  87402. /** Gets or sets current rotation (in local space) */
  87403. get rotation(): Vector3;
  87404. set rotation(newRotation: Vector3);
  87405. /** Gets or sets current rotation quaternion (in local space) */
  87406. get rotationQuaternion(): Quaternion;
  87407. set rotationQuaternion(newRotation: Quaternion);
  87408. /** Gets or sets current scaling (in local space) */
  87409. get scaling(): Vector3;
  87410. set scaling(newScaling: Vector3);
  87411. /**
  87412. * Gets the animation properties override
  87413. */
  87414. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  87415. private _decompose;
  87416. private _compose;
  87417. /**
  87418. * Update the base and local matrices
  87419. * @param matrix defines the new base or local matrix
  87420. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  87421. * @param updateLocalMatrix defines if the local matrix should be updated
  87422. */
  87423. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  87424. /** @hidden */
  87425. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  87426. /**
  87427. * Flag the bone as dirty (Forcing it to update everything)
  87428. */
  87429. markAsDirty(): void;
  87430. /** @hidden */
  87431. _markAsDirtyAndCompose(): void;
  87432. private _markAsDirtyAndDecompose;
  87433. /**
  87434. * Translate the bone in local or world space
  87435. * @param vec The amount to translate the bone
  87436. * @param space The space that the translation is in
  87437. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87438. */
  87439. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87440. /**
  87441. * Set the postion of the bone in local or world space
  87442. * @param position The position to set the bone
  87443. * @param space The space that the position is in
  87444. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87445. */
  87446. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87447. /**
  87448. * Set the absolute position of the bone (world space)
  87449. * @param position The position to set the bone
  87450. * @param mesh The mesh that this bone is attached to
  87451. */
  87452. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  87453. /**
  87454. * Scale the bone on the x, y and z axes (in local space)
  87455. * @param x The amount to scale the bone on the x axis
  87456. * @param y The amount to scale the bone on the y axis
  87457. * @param z The amount to scale the bone on the z axis
  87458. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  87459. */
  87460. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  87461. /**
  87462. * Set the bone scaling in local space
  87463. * @param scale defines the scaling vector
  87464. */
  87465. setScale(scale: Vector3): void;
  87466. /**
  87467. * Gets the current scaling in local space
  87468. * @returns the current scaling vector
  87469. */
  87470. getScale(): Vector3;
  87471. /**
  87472. * Gets the current scaling in local space and stores it in a target vector
  87473. * @param result defines the target vector
  87474. */
  87475. getScaleToRef(result: Vector3): void;
  87476. /**
  87477. * Set the yaw, pitch, and roll of the bone in local or world space
  87478. * @param yaw The rotation of the bone on the y axis
  87479. * @param pitch The rotation of the bone on the x axis
  87480. * @param roll The rotation of the bone on the z axis
  87481. * @param space The space that the axes of rotation are in
  87482. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87483. */
  87484. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  87485. /**
  87486. * Add a rotation to the bone on an axis in local or world space
  87487. * @param axis The axis to rotate the bone on
  87488. * @param amount The amount to rotate the bone
  87489. * @param space The space that the axis is in
  87490. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87491. */
  87492. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  87493. /**
  87494. * Set the rotation of the bone to a particular axis angle in local or world space
  87495. * @param axis The axis to rotate the bone on
  87496. * @param angle The angle that the bone should be rotated to
  87497. * @param space The space that the axis is in
  87498. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87499. */
  87500. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  87501. /**
  87502. * Set the euler rotation of the bone in local of world space
  87503. * @param rotation The euler rotation that the bone should be set to
  87504. * @param space The space that the rotation is in
  87505. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87506. */
  87507. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  87508. /**
  87509. * Set the quaternion rotation of the bone in local of world space
  87510. * @param quat The quaternion rotation that the bone should be set to
  87511. * @param space The space that the rotation is in
  87512. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87513. */
  87514. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  87515. /**
  87516. * Set the rotation matrix of the bone in local of world space
  87517. * @param rotMat The rotation matrix that the bone should be set to
  87518. * @param space The space that the rotation is in
  87519. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87520. */
  87521. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  87522. private _rotateWithMatrix;
  87523. private _getNegativeRotationToRef;
  87524. /**
  87525. * Get the position of the bone in local or world space
  87526. * @param space The space that the returned position is in
  87527. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87528. * @returns The position of the bone
  87529. */
  87530. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87531. /**
  87532. * Copy the position of the bone to a vector3 in local or world space
  87533. * @param space The space that the returned position is in
  87534. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87535. * @param result The vector3 to copy the position to
  87536. */
  87537. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  87538. /**
  87539. * Get the absolute position of the bone (world space)
  87540. * @param mesh The mesh that this bone is attached to
  87541. * @returns The absolute position of the bone
  87542. */
  87543. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  87544. /**
  87545. * Copy the absolute position of the bone (world space) to the result param
  87546. * @param mesh The mesh that this bone is attached to
  87547. * @param result The vector3 to copy the absolute position to
  87548. */
  87549. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  87550. /**
  87551. * Compute the absolute transforms of this bone and its children
  87552. */
  87553. computeAbsoluteTransforms(): void;
  87554. /**
  87555. * Get the world direction from an axis that is in the local space of the bone
  87556. * @param localAxis The local direction that is used to compute the world direction
  87557. * @param mesh The mesh that this bone is attached to
  87558. * @returns The world direction
  87559. */
  87560. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87561. /**
  87562. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  87563. * @param localAxis The local direction that is used to compute the world direction
  87564. * @param mesh The mesh that this bone is attached to
  87565. * @param result The vector3 that the world direction will be copied to
  87566. */
  87567. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87568. /**
  87569. * Get the euler rotation of the bone in local or world space
  87570. * @param space The space that the rotation should be in
  87571. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87572. * @returns The euler rotation
  87573. */
  87574. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  87575. /**
  87576. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  87577. * @param space The space that the rotation should be in
  87578. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87579. * @param result The vector3 that the rotation should be copied to
  87580. */
  87581. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87582. /**
  87583. * Get the quaternion rotation of the bone in either local or world space
  87584. * @param space The space that the rotation should be in
  87585. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87586. * @returns The quaternion rotation
  87587. */
  87588. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  87589. /**
  87590. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  87591. * @param space The space that the rotation should be in
  87592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87593. * @param result The quaternion that the rotation should be copied to
  87594. */
  87595. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  87596. /**
  87597. * Get the rotation matrix of the bone in local or world space
  87598. * @param space The space that the rotation should be in
  87599. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87600. * @returns The rotation matrix
  87601. */
  87602. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  87603. /**
  87604. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  87605. * @param space The space that the rotation should be in
  87606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  87607. * @param result The quaternion that the rotation should be copied to
  87608. */
  87609. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  87610. /**
  87611. * Get the world position of a point that is in the local space of the bone
  87612. * @param position The local position
  87613. * @param mesh The mesh that this bone is attached to
  87614. * @returns The world position
  87615. */
  87616. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87617. /**
  87618. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  87619. * @param position The local position
  87620. * @param mesh The mesh that this bone is attached to
  87621. * @param result The vector3 that the world position should be copied to
  87622. */
  87623. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87624. /**
  87625. * Get the local position of a point that is in world space
  87626. * @param position The world position
  87627. * @param mesh The mesh that this bone is attached to
  87628. * @returns The local position
  87629. */
  87630. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  87631. /**
  87632. * Get the local position of a point that is in world space and copy it to the result param
  87633. * @param position The world position
  87634. * @param mesh The mesh that this bone is attached to
  87635. * @param result The vector3 that the local position should be copied to
  87636. */
  87637. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  87638. }
  87639. }
  87640. declare module BABYLON {
  87641. /**
  87642. * Defines a runtime animation
  87643. */
  87644. export class RuntimeAnimation {
  87645. private _events;
  87646. /**
  87647. * The current frame of the runtime animation
  87648. */
  87649. private _currentFrame;
  87650. /**
  87651. * The animation used by the runtime animation
  87652. */
  87653. private _animation;
  87654. /**
  87655. * The target of the runtime animation
  87656. */
  87657. private _target;
  87658. /**
  87659. * The initiating animatable
  87660. */
  87661. private _host;
  87662. /**
  87663. * The original value of the runtime animation
  87664. */
  87665. private _originalValue;
  87666. /**
  87667. * The original blend value of the runtime animation
  87668. */
  87669. private _originalBlendValue;
  87670. /**
  87671. * The offsets cache of the runtime animation
  87672. */
  87673. private _offsetsCache;
  87674. /**
  87675. * The high limits cache of the runtime animation
  87676. */
  87677. private _highLimitsCache;
  87678. /**
  87679. * Specifies if the runtime animation has been stopped
  87680. */
  87681. private _stopped;
  87682. /**
  87683. * The blending factor of the runtime animation
  87684. */
  87685. private _blendingFactor;
  87686. /**
  87687. * The BabylonJS scene
  87688. */
  87689. private _scene;
  87690. /**
  87691. * The current value of the runtime animation
  87692. */
  87693. private _currentValue;
  87694. /** @hidden */
  87695. _animationState: _IAnimationState;
  87696. /**
  87697. * The active target of the runtime animation
  87698. */
  87699. private _activeTargets;
  87700. private _currentActiveTarget;
  87701. private _directTarget;
  87702. /**
  87703. * The target path of the runtime animation
  87704. */
  87705. private _targetPath;
  87706. /**
  87707. * The weight of the runtime animation
  87708. */
  87709. private _weight;
  87710. /**
  87711. * The ratio offset of the runtime animation
  87712. */
  87713. private _ratioOffset;
  87714. /**
  87715. * The previous delay of the runtime animation
  87716. */
  87717. private _previousDelay;
  87718. /**
  87719. * The previous ratio of the runtime animation
  87720. */
  87721. private _previousRatio;
  87722. private _enableBlending;
  87723. private _keys;
  87724. private _minFrame;
  87725. private _maxFrame;
  87726. private _minValue;
  87727. private _maxValue;
  87728. private _targetIsArray;
  87729. /**
  87730. * Gets the current frame of the runtime animation
  87731. */
  87732. get currentFrame(): number;
  87733. /**
  87734. * Gets the weight of the runtime animation
  87735. */
  87736. get weight(): number;
  87737. /**
  87738. * Gets the current value of the runtime animation
  87739. */
  87740. get currentValue(): any;
  87741. /**
  87742. * Gets the target path of the runtime animation
  87743. */
  87744. get targetPath(): string;
  87745. /**
  87746. * Gets the actual target of the runtime animation
  87747. */
  87748. get target(): any;
  87749. /** @hidden */
  87750. _onLoop: () => void;
  87751. /**
  87752. * Create a new RuntimeAnimation object
  87753. * @param target defines the target of the animation
  87754. * @param animation defines the source animation object
  87755. * @param scene defines the hosting scene
  87756. * @param host defines the initiating Animatable
  87757. */
  87758. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  87759. private _preparePath;
  87760. /**
  87761. * Gets the animation from the runtime animation
  87762. */
  87763. get animation(): Animation;
  87764. /**
  87765. * Resets the runtime animation to the beginning
  87766. * @param restoreOriginal defines whether to restore the target property to the original value
  87767. */
  87768. reset(restoreOriginal?: boolean): void;
  87769. /**
  87770. * Specifies if the runtime animation is stopped
  87771. * @returns Boolean specifying if the runtime animation is stopped
  87772. */
  87773. isStopped(): boolean;
  87774. /**
  87775. * Disposes of the runtime animation
  87776. */
  87777. dispose(): void;
  87778. /**
  87779. * Apply the interpolated value to the target
  87780. * @param currentValue defines the value computed by the animation
  87781. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  87782. */
  87783. setValue(currentValue: any, weight: number): void;
  87784. private _getOriginalValues;
  87785. private _setValue;
  87786. /**
  87787. * Gets the loop pmode of the runtime animation
  87788. * @returns Loop Mode
  87789. */
  87790. private _getCorrectLoopMode;
  87791. /**
  87792. * Move the current animation to a given frame
  87793. * @param frame defines the frame to move to
  87794. */
  87795. goToFrame(frame: number): void;
  87796. /**
  87797. * @hidden Internal use only
  87798. */
  87799. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  87800. /**
  87801. * Execute the current animation
  87802. * @param delay defines the delay to add to the current frame
  87803. * @param from defines the lower bound of the animation range
  87804. * @param to defines the upper bound of the animation range
  87805. * @param loop defines if the current animation must loop
  87806. * @param speedRatio defines the current speed ratio
  87807. * @param weight defines the weight of the animation (default is -1 so no weight)
  87808. * @param onLoop optional callback called when animation loops
  87809. * @returns a boolean indicating if the animation is running
  87810. */
  87811. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  87812. }
  87813. }
  87814. declare module BABYLON {
  87815. /**
  87816. * Class used to store an actual running animation
  87817. */
  87818. export class Animatable {
  87819. /** defines the target object */
  87820. target: any;
  87821. /** defines the starting frame number (default is 0) */
  87822. fromFrame: number;
  87823. /** defines the ending frame number (default is 100) */
  87824. toFrame: number;
  87825. /** defines if the animation must loop (default is false) */
  87826. loopAnimation: boolean;
  87827. /** defines a callback to call when animation ends if it is not looping */
  87828. onAnimationEnd?: (() => void) | null | undefined;
  87829. /** defines a callback to call when animation loops */
  87830. onAnimationLoop?: (() => void) | null | undefined;
  87831. private _localDelayOffset;
  87832. private _pausedDelay;
  87833. private _runtimeAnimations;
  87834. private _paused;
  87835. private _scene;
  87836. private _speedRatio;
  87837. private _weight;
  87838. private _syncRoot;
  87839. /**
  87840. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  87841. * This will only apply for non looping animation (default is true)
  87842. */
  87843. disposeOnEnd: boolean;
  87844. /**
  87845. * Gets a boolean indicating if the animation has started
  87846. */
  87847. animationStarted: boolean;
  87848. /**
  87849. * Observer raised when the animation ends
  87850. */
  87851. onAnimationEndObservable: Observable<Animatable>;
  87852. /**
  87853. * Observer raised when the animation loops
  87854. */
  87855. onAnimationLoopObservable: Observable<Animatable>;
  87856. /**
  87857. * Gets the root Animatable used to synchronize and normalize animations
  87858. */
  87859. get syncRoot(): Nullable<Animatable>;
  87860. /**
  87861. * Gets the current frame of the first RuntimeAnimation
  87862. * Used to synchronize Animatables
  87863. */
  87864. get masterFrame(): number;
  87865. /**
  87866. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  87867. */
  87868. get weight(): number;
  87869. set weight(value: number);
  87870. /**
  87871. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  87872. */
  87873. get speedRatio(): number;
  87874. set speedRatio(value: number);
  87875. /**
  87876. * Creates a new Animatable
  87877. * @param scene defines the hosting scene
  87878. * @param target defines the target object
  87879. * @param fromFrame defines the starting frame number (default is 0)
  87880. * @param toFrame defines the ending frame number (default is 100)
  87881. * @param loopAnimation defines if the animation must loop (default is false)
  87882. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  87883. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  87884. * @param animations defines a group of animation to add to the new Animatable
  87885. * @param onAnimationLoop defines a callback to call when animation loops
  87886. */
  87887. constructor(scene: Scene,
  87888. /** defines the target object */
  87889. target: any,
  87890. /** defines the starting frame number (default is 0) */
  87891. fromFrame?: number,
  87892. /** defines the ending frame number (default is 100) */
  87893. toFrame?: number,
  87894. /** defines if the animation must loop (default is false) */
  87895. loopAnimation?: boolean, speedRatio?: number,
  87896. /** defines a callback to call when animation ends if it is not looping */
  87897. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  87898. /** defines a callback to call when animation loops */
  87899. onAnimationLoop?: (() => void) | null | undefined);
  87900. /**
  87901. * Synchronize and normalize current Animatable with a source Animatable
  87902. * This is useful when using animation weights and when animations are not of the same length
  87903. * @param root defines the root Animatable to synchronize with
  87904. * @returns the current Animatable
  87905. */
  87906. syncWith(root: Animatable): Animatable;
  87907. /**
  87908. * Gets the list of runtime animations
  87909. * @returns an array of RuntimeAnimation
  87910. */
  87911. getAnimations(): RuntimeAnimation[];
  87912. /**
  87913. * Adds more animations to the current animatable
  87914. * @param target defines the target of the animations
  87915. * @param animations defines the new animations to add
  87916. */
  87917. appendAnimations(target: any, animations: Animation[]): void;
  87918. /**
  87919. * Gets the source animation for a specific property
  87920. * @param property defines the propertyu to look for
  87921. * @returns null or the source animation for the given property
  87922. */
  87923. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  87924. /**
  87925. * Gets the runtime animation for a specific property
  87926. * @param property defines the propertyu to look for
  87927. * @returns null or the runtime animation for the given property
  87928. */
  87929. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  87930. /**
  87931. * Resets the animatable to its original state
  87932. */
  87933. reset(): void;
  87934. /**
  87935. * Allows the animatable to blend with current running animations
  87936. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87937. * @param blendingSpeed defines the blending speed to use
  87938. */
  87939. enableBlending(blendingSpeed: number): void;
  87940. /**
  87941. * Disable animation blending
  87942. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  87943. */
  87944. disableBlending(): void;
  87945. /**
  87946. * Jump directly to a given frame
  87947. * @param frame defines the frame to jump to
  87948. */
  87949. goToFrame(frame: number): void;
  87950. /**
  87951. * Pause the animation
  87952. */
  87953. pause(): void;
  87954. /**
  87955. * Restart the animation
  87956. */
  87957. restart(): void;
  87958. private _raiseOnAnimationEnd;
  87959. /**
  87960. * Stop and delete the current animation
  87961. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  87962. * @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)
  87963. */
  87964. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  87965. /**
  87966. * Wait asynchronously for the animation to end
  87967. * @returns a promise which will be fullfilled when the animation ends
  87968. */
  87969. waitAsync(): Promise<Animatable>;
  87970. /** @hidden */
  87971. _animate(delay: number): boolean;
  87972. }
  87973. interface Scene {
  87974. /** @hidden */
  87975. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  87976. /** @hidden */
  87977. _processLateAnimationBindingsForMatrices(holder: {
  87978. totalWeight: number;
  87979. animations: RuntimeAnimation[];
  87980. originalValue: Matrix;
  87981. }): any;
  87982. /** @hidden */
  87983. _processLateAnimationBindingsForQuaternions(holder: {
  87984. totalWeight: number;
  87985. animations: RuntimeAnimation[];
  87986. originalValue: Quaternion;
  87987. }, refQuaternion: Quaternion): Quaternion;
  87988. /** @hidden */
  87989. _processLateAnimationBindings(): void;
  87990. /**
  87991. * Will start the animation sequence of a given target
  87992. * @param target defines the target
  87993. * @param from defines from which frame should animation start
  87994. * @param to defines until which frame should animation run.
  87995. * @param weight defines the weight to apply to the animation (1.0 by default)
  87996. * @param loop defines if the animation loops
  87997. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  87998. * @param onAnimationEnd defines the function to be executed when the animation ends
  87999. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88000. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88001. * @param onAnimationLoop defines the callback to call when an animation loops
  88002. * @returns the animatable object created for this animation
  88003. */
  88004. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88005. /**
  88006. * Will start the animation sequence of a given target
  88007. * @param target defines the target
  88008. * @param from defines from which frame should animation start
  88009. * @param to defines until which frame should animation run.
  88010. * @param loop defines if the animation loops
  88011. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88012. * @param onAnimationEnd defines the function to be executed when the animation ends
  88013. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88014. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88015. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  88016. * @param onAnimationLoop defines the callback to call when an animation loops
  88017. * @returns the animatable object created for this animation
  88018. */
  88019. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  88020. /**
  88021. * Will start the animation sequence of a given target and its hierarchy
  88022. * @param target defines the target
  88023. * @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.
  88024. * @param from defines from which frame should animation start
  88025. * @param to defines until which frame should animation run.
  88026. * @param loop defines if the animation loops
  88027. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  88028. * @param onAnimationEnd defines the function to be executed when the animation ends
  88029. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  88030. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  88031. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  88032. * @param onAnimationLoop defines the callback to call when an animation loops
  88033. * @returns the list of created animatables
  88034. */
  88035. 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[];
  88036. /**
  88037. * Begin a new animation on a given node
  88038. * @param target defines the target where the animation will take place
  88039. * @param animations defines the list of animations to start
  88040. * @param from defines the initial value
  88041. * @param to defines the final value
  88042. * @param loop defines if you want animation to loop (off by default)
  88043. * @param speedRatio defines the speed ratio to apply to all animations
  88044. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88045. * @param onAnimationLoop defines the callback to call when an animation loops
  88046. * @returns the list of created animatables
  88047. */
  88048. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  88049. /**
  88050. * Begin a new animation on a given node and its hierarchy
  88051. * @param target defines the root node where the animation will take place
  88052. * @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.
  88053. * @param animations defines the list of animations to start
  88054. * @param from defines the initial value
  88055. * @param to defines the final value
  88056. * @param loop defines if you want animation to loop (off by default)
  88057. * @param speedRatio defines the speed ratio to apply to all animations
  88058. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  88059. * @param onAnimationLoop defines the callback to call when an animation loops
  88060. * @returns the list of animatables created for all nodes
  88061. */
  88062. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  88063. /**
  88064. * Gets the animatable associated with a specific target
  88065. * @param target defines the target of the animatable
  88066. * @returns the required animatable if found
  88067. */
  88068. getAnimatableByTarget(target: any): Nullable<Animatable>;
  88069. /**
  88070. * Gets all animatables associated with a given target
  88071. * @param target defines the target to look animatables for
  88072. * @returns an array of Animatables
  88073. */
  88074. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  88075. /**
  88076. * Stops and removes all animations that have been applied to the scene
  88077. */
  88078. stopAllAnimations(): void;
  88079. /**
  88080. * Gets the current delta time used by animation engine
  88081. */
  88082. deltaTime: number;
  88083. }
  88084. interface Bone {
  88085. /**
  88086. * Copy an animation range from another bone
  88087. * @param source defines the source bone
  88088. * @param rangeName defines the range name to copy
  88089. * @param frameOffset defines the frame offset
  88090. * @param rescaleAsRequired defines if rescaling must be applied if required
  88091. * @param skelDimensionsRatio defines the scaling ratio
  88092. * @returns true if operation was successful
  88093. */
  88094. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  88095. }
  88096. }
  88097. declare module BABYLON {
  88098. /**
  88099. * Class used to handle skinning animations
  88100. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88101. */
  88102. export class Skeleton implements IAnimatable {
  88103. /** defines the skeleton name */
  88104. name: string;
  88105. /** defines the skeleton Id */
  88106. id: string;
  88107. /**
  88108. * Defines the list of child bones
  88109. */
  88110. bones: Bone[];
  88111. /**
  88112. * Defines an estimate of the dimension of the skeleton at rest
  88113. */
  88114. dimensionsAtRest: Vector3;
  88115. /**
  88116. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  88117. */
  88118. needInitialSkinMatrix: boolean;
  88119. /**
  88120. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  88121. */
  88122. overrideMesh: Nullable<AbstractMesh>;
  88123. /**
  88124. * Gets the list of animations attached to this skeleton
  88125. */
  88126. animations: Array<Animation>;
  88127. private _scene;
  88128. private _isDirty;
  88129. private _transformMatrices;
  88130. private _transformMatrixTexture;
  88131. private _meshesWithPoseMatrix;
  88132. private _animatables;
  88133. private _identity;
  88134. private _synchronizedWithMesh;
  88135. private _ranges;
  88136. private _lastAbsoluteTransformsUpdateId;
  88137. private _canUseTextureForBones;
  88138. private _uniqueId;
  88139. /** @hidden */
  88140. _numBonesWithLinkedTransformNode: number;
  88141. /** @hidden */
  88142. _hasWaitingData: Nullable<boolean>;
  88143. /**
  88144. * Specifies if the skeleton should be serialized
  88145. */
  88146. doNotSerialize: boolean;
  88147. private _useTextureToStoreBoneMatrices;
  88148. /**
  88149. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  88150. * Please note that this option is not available if the hardware does not support it
  88151. */
  88152. get useTextureToStoreBoneMatrices(): boolean;
  88153. set useTextureToStoreBoneMatrices(value: boolean);
  88154. private _animationPropertiesOverride;
  88155. /**
  88156. * Gets or sets the animation properties override
  88157. */
  88158. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88159. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  88160. /**
  88161. * List of inspectable custom properties (used by the Inspector)
  88162. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88163. */
  88164. inspectableCustomProperties: IInspectable[];
  88165. /**
  88166. * An observable triggered before computing the skeleton's matrices
  88167. */
  88168. onBeforeComputeObservable: Observable<Skeleton>;
  88169. /**
  88170. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  88171. */
  88172. get isUsingTextureForMatrices(): boolean;
  88173. /**
  88174. * Gets the unique ID of this skeleton
  88175. */
  88176. get uniqueId(): number;
  88177. /**
  88178. * Creates a new skeleton
  88179. * @param name defines the skeleton name
  88180. * @param id defines the skeleton Id
  88181. * @param scene defines the hosting scene
  88182. */
  88183. constructor(
  88184. /** defines the skeleton name */
  88185. name: string,
  88186. /** defines the skeleton Id */
  88187. id: string, scene: Scene);
  88188. /**
  88189. * Gets the current object class name.
  88190. * @return the class name
  88191. */
  88192. getClassName(): string;
  88193. /**
  88194. * Returns an array containing the root bones
  88195. * @returns an array containing the root bones
  88196. */
  88197. getChildren(): Array<Bone>;
  88198. /**
  88199. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  88200. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88201. * @returns a Float32Array containing matrices data
  88202. */
  88203. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  88204. /**
  88205. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  88206. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  88207. * @returns a raw texture containing the data
  88208. */
  88209. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  88210. /**
  88211. * Gets the current hosting scene
  88212. * @returns a scene object
  88213. */
  88214. getScene(): Scene;
  88215. /**
  88216. * Gets a string representing the current skeleton data
  88217. * @param fullDetails defines a boolean indicating if we want a verbose version
  88218. * @returns a string representing the current skeleton data
  88219. */
  88220. toString(fullDetails?: boolean): string;
  88221. /**
  88222. * Get bone's index searching by name
  88223. * @param name defines bone's name to search for
  88224. * @return the indice of the bone. Returns -1 if not found
  88225. */
  88226. getBoneIndexByName(name: string): number;
  88227. /**
  88228. * Creater a new animation range
  88229. * @param name defines the name of the range
  88230. * @param from defines the start key
  88231. * @param to defines the end key
  88232. */
  88233. createAnimationRange(name: string, from: number, to: number): void;
  88234. /**
  88235. * Delete a specific animation range
  88236. * @param name defines the name of the range
  88237. * @param deleteFrames defines if frames must be removed as well
  88238. */
  88239. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  88240. /**
  88241. * Gets a specific animation range
  88242. * @param name defines the name of the range to look for
  88243. * @returns the requested animation range or null if not found
  88244. */
  88245. getAnimationRange(name: string): Nullable<AnimationRange>;
  88246. /**
  88247. * Gets the list of all animation ranges defined on this skeleton
  88248. * @returns an array
  88249. */
  88250. getAnimationRanges(): Nullable<AnimationRange>[];
  88251. /**
  88252. * Copy animation range from a source skeleton.
  88253. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  88254. * @param source defines the source skeleton
  88255. * @param name defines the name of the range to copy
  88256. * @param rescaleAsRequired defines if rescaling must be applied if required
  88257. * @returns true if operation was successful
  88258. */
  88259. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  88260. /**
  88261. * Forces the skeleton to go to rest pose
  88262. */
  88263. returnToRest(): void;
  88264. private _getHighestAnimationFrame;
  88265. /**
  88266. * Begin a specific animation range
  88267. * @param name defines the name of the range to start
  88268. * @param loop defines if looping must be turned on (false by default)
  88269. * @param speedRatio defines the speed ratio to apply (1 by default)
  88270. * @param onAnimationEnd defines a callback which will be called when animation will end
  88271. * @returns a new animatable
  88272. */
  88273. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  88274. /** @hidden */
  88275. _markAsDirty(): void;
  88276. /** @hidden */
  88277. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88278. /** @hidden */
  88279. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  88280. private _computeTransformMatrices;
  88281. /**
  88282. * Build all resources required to render a skeleton
  88283. */
  88284. prepare(): void;
  88285. /**
  88286. * Gets the list of animatables currently running for this skeleton
  88287. * @returns an array of animatables
  88288. */
  88289. getAnimatables(): IAnimatable[];
  88290. /**
  88291. * Clone the current skeleton
  88292. * @param name defines the name of the new skeleton
  88293. * @param id defines the id of the new skeleton
  88294. * @returns the new skeleton
  88295. */
  88296. clone(name: string, id?: string): Skeleton;
  88297. /**
  88298. * Enable animation blending for this skeleton
  88299. * @param blendingSpeed defines the blending speed to apply
  88300. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  88301. */
  88302. enableBlending(blendingSpeed?: number): void;
  88303. /**
  88304. * Releases all resources associated with the current skeleton
  88305. */
  88306. dispose(): void;
  88307. /**
  88308. * Serialize the skeleton in a JSON object
  88309. * @returns a JSON object
  88310. */
  88311. serialize(): any;
  88312. /**
  88313. * Creates a new skeleton from serialized data
  88314. * @param parsedSkeleton defines the serialized data
  88315. * @param scene defines the hosting scene
  88316. * @returns a new skeleton
  88317. */
  88318. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  88319. /**
  88320. * Compute all node absolute transforms
  88321. * @param forceUpdate defines if computation must be done even if cache is up to date
  88322. */
  88323. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  88324. /**
  88325. * Gets the root pose matrix
  88326. * @returns a matrix
  88327. */
  88328. getPoseMatrix(): Nullable<Matrix>;
  88329. /**
  88330. * Sorts bones per internal index
  88331. */
  88332. sortBones(): void;
  88333. private _sortBones;
  88334. }
  88335. }
  88336. declare module BABYLON {
  88337. /**
  88338. * Creates an instance based on a source mesh.
  88339. */
  88340. export class InstancedMesh extends AbstractMesh {
  88341. private _sourceMesh;
  88342. private _currentLOD;
  88343. /** @hidden */
  88344. _indexInSourceMeshInstanceArray: number;
  88345. constructor(name: string, source: Mesh);
  88346. /**
  88347. * Returns the string "InstancedMesh".
  88348. */
  88349. getClassName(): string;
  88350. /** Gets the list of lights affecting that mesh */
  88351. get lightSources(): Light[];
  88352. _resyncLightSources(): void;
  88353. _resyncLightSource(light: Light): void;
  88354. _removeLightSource(light: Light, dispose: boolean): void;
  88355. /**
  88356. * If the source mesh receives shadows
  88357. */
  88358. get receiveShadows(): boolean;
  88359. /**
  88360. * The material of the source mesh
  88361. */
  88362. get material(): Nullable<Material>;
  88363. /**
  88364. * Visibility of the source mesh
  88365. */
  88366. get visibility(): number;
  88367. /**
  88368. * Skeleton of the source mesh
  88369. */
  88370. get skeleton(): Nullable<Skeleton>;
  88371. /**
  88372. * Rendering ground id of the source mesh
  88373. */
  88374. get renderingGroupId(): number;
  88375. set renderingGroupId(value: number);
  88376. /**
  88377. * Returns the total number of vertices (integer).
  88378. */
  88379. getTotalVertices(): number;
  88380. /**
  88381. * Returns a positive integer : the total number of indices in this mesh geometry.
  88382. * @returns the numner of indices or zero if the mesh has no geometry.
  88383. */
  88384. getTotalIndices(): number;
  88385. /**
  88386. * The source mesh of the instance
  88387. */
  88388. get sourceMesh(): Mesh;
  88389. /**
  88390. * Is this node ready to be used/rendered
  88391. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  88392. * @return {boolean} is it ready
  88393. */
  88394. isReady(completeCheck?: boolean): boolean;
  88395. /**
  88396. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88397. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  88398. * @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.
  88399. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  88400. */
  88401. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  88402. /**
  88403. * Sets the vertex data of the mesh geometry for the requested `kind`.
  88404. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  88405. * The `data` are either a numeric array either a Float32Array.
  88406. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  88407. * 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).
  88408. * Note that a new underlying VertexBuffer object is created each call.
  88409. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  88410. *
  88411. * Possible `kind` values :
  88412. * - VertexBuffer.PositionKind
  88413. * - VertexBuffer.UVKind
  88414. * - VertexBuffer.UV2Kind
  88415. * - VertexBuffer.UV3Kind
  88416. * - VertexBuffer.UV4Kind
  88417. * - VertexBuffer.UV5Kind
  88418. * - VertexBuffer.UV6Kind
  88419. * - VertexBuffer.ColorKind
  88420. * - VertexBuffer.MatricesIndicesKind
  88421. * - VertexBuffer.MatricesIndicesExtraKind
  88422. * - VertexBuffer.MatricesWeightsKind
  88423. * - VertexBuffer.MatricesWeightsExtraKind
  88424. *
  88425. * Returns the Mesh.
  88426. */
  88427. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  88428. /**
  88429. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  88430. * If the mesh has no geometry, it is simply returned as it is.
  88431. * The `data` are either a numeric array either a Float32Array.
  88432. * No new underlying VertexBuffer object is created.
  88433. * 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.
  88434. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  88435. *
  88436. * Possible `kind` values :
  88437. * - VertexBuffer.PositionKind
  88438. * - VertexBuffer.UVKind
  88439. * - VertexBuffer.UV2Kind
  88440. * - VertexBuffer.UV3Kind
  88441. * - VertexBuffer.UV4Kind
  88442. * - VertexBuffer.UV5Kind
  88443. * - VertexBuffer.UV6Kind
  88444. * - VertexBuffer.ColorKind
  88445. * - VertexBuffer.MatricesIndicesKind
  88446. * - VertexBuffer.MatricesIndicesExtraKind
  88447. * - VertexBuffer.MatricesWeightsKind
  88448. * - VertexBuffer.MatricesWeightsExtraKind
  88449. *
  88450. * Returns the Mesh.
  88451. */
  88452. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  88453. /**
  88454. * Sets the mesh indices.
  88455. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  88456. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  88457. * This method creates a new index buffer each call.
  88458. * Returns the Mesh.
  88459. */
  88460. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  88461. /**
  88462. * Boolean : True if the mesh owns the requested kind of data.
  88463. */
  88464. isVerticesDataPresent(kind: string): boolean;
  88465. /**
  88466. * Returns an array of indices (IndicesArray).
  88467. */
  88468. getIndices(): Nullable<IndicesArray>;
  88469. get _positions(): Nullable<Vector3[]>;
  88470. /**
  88471. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  88472. * This means the mesh underlying bounding box and sphere are recomputed.
  88473. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  88474. * @returns the current mesh
  88475. */
  88476. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  88477. /** @hidden */
  88478. _preActivate(): InstancedMesh;
  88479. /** @hidden */
  88480. _activate(renderId: number, intermediateRendering: boolean): boolean;
  88481. /** @hidden */
  88482. _postActivate(): void;
  88483. getWorldMatrix(): Matrix;
  88484. get isAnInstance(): boolean;
  88485. /**
  88486. * Returns the current associated LOD AbstractMesh.
  88487. */
  88488. getLOD(camera: Camera): AbstractMesh;
  88489. /** @hidden */
  88490. _syncSubMeshes(): InstancedMesh;
  88491. /** @hidden */
  88492. _generatePointsArray(): boolean;
  88493. /**
  88494. * Creates a new InstancedMesh from the current mesh.
  88495. * - name (string) : the cloned mesh name
  88496. * - newParent (optional Node) : the optional Node to parent the clone to.
  88497. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  88498. *
  88499. * Returns the clone.
  88500. */
  88501. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  88502. /**
  88503. * Disposes the InstancedMesh.
  88504. * Returns nothing.
  88505. */
  88506. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88507. }
  88508. interface Mesh {
  88509. /**
  88510. * Register a custom buffer that will be instanced
  88511. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88512. * @param kind defines the buffer kind
  88513. * @param stride defines the stride in floats
  88514. */
  88515. registerInstancedBuffer(kind: string, stride: number): void;
  88516. /** @hidden */
  88517. _userInstancedBuffersStorage: {
  88518. data: {
  88519. [key: string]: Float32Array;
  88520. };
  88521. sizes: {
  88522. [key: string]: number;
  88523. };
  88524. vertexBuffers: {
  88525. [key: string]: Nullable<VertexBuffer>;
  88526. };
  88527. strides: {
  88528. [key: string]: number;
  88529. };
  88530. };
  88531. }
  88532. interface AbstractMesh {
  88533. /**
  88534. * Object used to store instanced buffers defined by user
  88535. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  88536. */
  88537. instancedBuffers: {
  88538. [key: string]: any;
  88539. };
  88540. }
  88541. }
  88542. declare module BABYLON {
  88543. /**
  88544. * Defines the options associated with the creation of a shader material.
  88545. */
  88546. export interface IShaderMaterialOptions {
  88547. /**
  88548. * Does the material work in alpha blend mode
  88549. */
  88550. needAlphaBlending: boolean;
  88551. /**
  88552. * Does the material work in alpha test mode
  88553. */
  88554. needAlphaTesting: boolean;
  88555. /**
  88556. * The list of attribute names used in the shader
  88557. */
  88558. attributes: string[];
  88559. /**
  88560. * The list of unifrom names used in the shader
  88561. */
  88562. uniforms: string[];
  88563. /**
  88564. * The list of UBO names used in the shader
  88565. */
  88566. uniformBuffers: string[];
  88567. /**
  88568. * The list of sampler names used in the shader
  88569. */
  88570. samplers: string[];
  88571. /**
  88572. * The list of defines used in the shader
  88573. */
  88574. defines: string[];
  88575. }
  88576. /**
  88577. * 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.
  88578. *
  88579. * This returned material effects how the mesh will look based on the code in the shaders.
  88580. *
  88581. * @see http://doc.babylonjs.com/how_to/shader_material
  88582. */
  88583. export class ShaderMaterial extends Material {
  88584. private _shaderPath;
  88585. private _options;
  88586. private _textures;
  88587. private _textureArrays;
  88588. private _floats;
  88589. private _ints;
  88590. private _floatsArrays;
  88591. private _colors3;
  88592. private _colors3Arrays;
  88593. private _colors4;
  88594. private _colors4Arrays;
  88595. private _vectors2;
  88596. private _vectors3;
  88597. private _vectors4;
  88598. private _matrices;
  88599. private _matrixArrays;
  88600. private _matrices3x3;
  88601. private _matrices2x2;
  88602. private _vectors2Arrays;
  88603. private _vectors3Arrays;
  88604. private _vectors4Arrays;
  88605. private _cachedWorldViewMatrix;
  88606. private _cachedWorldViewProjectionMatrix;
  88607. private _renderId;
  88608. private _multiview;
  88609. /**
  88610. * Instantiate a new shader material.
  88611. * 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.
  88612. * This returned material effects how the mesh will look based on the code in the shaders.
  88613. * @see http://doc.babylonjs.com/how_to/shader_material
  88614. * @param name Define the name of the material in the scene
  88615. * @param scene Define the scene the material belongs to
  88616. * @param shaderPath Defines the route to the shader code in one of three ways:
  88617. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  88618. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  88619. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  88620. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  88621. * @param options Define the options used to create the shader
  88622. */
  88623. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  88624. /**
  88625. * Gets the shader path used to define the shader code
  88626. * It can be modified to trigger a new compilation
  88627. */
  88628. get shaderPath(): any;
  88629. /**
  88630. * Sets the shader path used to define the shader code
  88631. * It can be modified to trigger a new compilation
  88632. */
  88633. set shaderPath(shaderPath: any);
  88634. /**
  88635. * Gets the options used to compile the shader.
  88636. * They can be modified to trigger a new compilation
  88637. */
  88638. get options(): IShaderMaterialOptions;
  88639. /**
  88640. * Gets the current class name of the material e.g. "ShaderMaterial"
  88641. * Mainly use in serialization.
  88642. * @returns the class name
  88643. */
  88644. getClassName(): string;
  88645. /**
  88646. * Specifies if the material will require alpha blending
  88647. * @returns a boolean specifying if alpha blending is needed
  88648. */
  88649. needAlphaBlending(): boolean;
  88650. /**
  88651. * Specifies if this material should be rendered in alpha test mode
  88652. * @returns a boolean specifying if an alpha test is needed.
  88653. */
  88654. needAlphaTesting(): boolean;
  88655. private _checkUniform;
  88656. /**
  88657. * Set a texture in the shader.
  88658. * @param name Define the name of the uniform samplers as defined in the shader
  88659. * @param texture Define the texture to bind to this sampler
  88660. * @return the material itself allowing "fluent" like uniform updates
  88661. */
  88662. setTexture(name: string, texture: Texture): ShaderMaterial;
  88663. /**
  88664. * Set a texture array in the shader.
  88665. * @param name Define the name of the uniform sampler array as defined in the shader
  88666. * @param textures Define the list of textures to bind to this sampler
  88667. * @return the material itself allowing "fluent" like uniform updates
  88668. */
  88669. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  88670. /**
  88671. * Set a float in the shader.
  88672. * @param name Define the name of the uniform as defined in the shader
  88673. * @param value Define the value to give to the uniform
  88674. * @return the material itself allowing "fluent" like uniform updates
  88675. */
  88676. setFloat(name: string, value: number): ShaderMaterial;
  88677. /**
  88678. * Set a int in the shader.
  88679. * @param name Define the name of the uniform as defined in the shader
  88680. * @param value Define the value to give to the uniform
  88681. * @return the material itself allowing "fluent" like uniform updates
  88682. */
  88683. setInt(name: string, value: number): ShaderMaterial;
  88684. /**
  88685. * Set an array of floats in the shader.
  88686. * @param name Define the name of the uniform as defined in the shader
  88687. * @param value Define the value to give to the uniform
  88688. * @return the material itself allowing "fluent" like uniform updates
  88689. */
  88690. setFloats(name: string, value: number[]): ShaderMaterial;
  88691. /**
  88692. * Set a vec3 in the shader from a Color3.
  88693. * @param name Define the name of the uniform as defined in the shader
  88694. * @param value Define the value to give to the uniform
  88695. * @return the material itself allowing "fluent" like uniform updates
  88696. */
  88697. setColor3(name: string, value: Color3): ShaderMaterial;
  88698. /**
  88699. * Set a vec3 array in the shader from a Color3 array.
  88700. * @param name Define the name of the uniform as defined in the shader
  88701. * @param value Define the value to give to the uniform
  88702. * @return the material itself allowing "fluent" like uniform updates
  88703. */
  88704. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  88705. /**
  88706. * Set a vec4 in the shader from a Color4.
  88707. * @param name Define the name of the uniform as defined in the shader
  88708. * @param value Define the value to give to the uniform
  88709. * @return the material itself allowing "fluent" like uniform updates
  88710. */
  88711. setColor4(name: string, value: Color4): ShaderMaterial;
  88712. /**
  88713. * Set a vec4 array in the shader from a Color4 array.
  88714. * @param name Define the name of the uniform as defined in the shader
  88715. * @param value Define the value to give to the uniform
  88716. * @return the material itself allowing "fluent" like uniform updates
  88717. */
  88718. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  88719. /**
  88720. * Set a vec2 in the shader from a Vector2.
  88721. * @param name Define the name of the uniform as defined in the shader
  88722. * @param value Define the value to give to the uniform
  88723. * @return the material itself allowing "fluent" like uniform updates
  88724. */
  88725. setVector2(name: string, value: Vector2): ShaderMaterial;
  88726. /**
  88727. * Set a vec3 in the shader from a Vector3.
  88728. * @param name Define the name of the uniform as defined in the shader
  88729. * @param value Define the value to give to the uniform
  88730. * @return the material itself allowing "fluent" like uniform updates
  88731. */
  88732. setVector3(name: string, value: Vector3): ShaderMaterial;
  88733. /**
  88734. * Set a vec4 in the shader from a Vector4.
  88735. * @param name Define the name of the uniform as defined in the shader
  88736. * @param value Define the value to give to the uniform
  88737. * @return the material itself allowing "fluent" like uniform updates
  88738. */
  88739. setVector4(name: string, value: Vector4): ShaderMaterial;
  88740. /**
  88741. * Set a mat4 in the shader from a Matrix.
  88742. * @param name Define the name of the uniform as defined in the shader
  88743. * @param value Define the value to give to the uniform
  88744. * @return the material itself allowing "fluent" like uniform updates
  88745. */
  88746. setMatrix(name: string, value: Matrix): ShaderMaterial;
  88747. /**
  88748. * Set a float32Array in the shader from a matrix array.
  88749. * @param name Define the name of the uniform as defined in the shader
  88750. * @param value Define the value to give to the uniform
  88751. * @return the material itself allowing "fluent" like uniform updates
  88752. */
  88753. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  88754. /**
  88755. * Set a mat3 in the shader from a Float32Array.
  88756. * @param name Define the name of the uniform as defined in the shader
  88757. * @param value Define the value to give to the uniform
  88758. * @return the material itself allowing "fluent" like uniform updates
  88759. */
  88760. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  88761. /**
  88762. * Set a mat2 in the shader from a Float32Array.
  88763. * @param name Define the name of the uniform as defined in the shader
  88764. * @param value Define the value to give to the uniform
  88765. * @return the material itself allowing "fluent" like uniform updates
  88766. */
  88767. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  88768. /**
  88769. * Set a vec2 array in the shader from a number array.
  88770. * @param name Define the name of the uniform as defined in the shader
  88771. * @param value Define the value to give to the uniform
  88772. * @return the material itself allowing "fluent" like uniform updates
  88773. */
  88774. setArray2(name: string, value: number[]): ShaderMaterial;
  88775. /**
  88776. * Set a vec3 array in the shader from a number array.
  88777. * @param name Define the name of the uniform as defined in the shader
  88778. * @param value Define the value to give to the uniform
  88779. * @return the material itself allowing "fluent" like uniform updates
  88780. */
  88781. setArray3(name: string, value: number[]): ShaderMaterial;
  88782. /**
  88783. * Set a vec4 array in the shader from a number array.
  88784. * @param name Define the name of the uniform as defined in the shader
  88785. * @param value Define the value to give to the uniform
  88786. * @return the material itself allowing "fluent" like uniform updates
  88787. */
  88788. setArray4(name: string, value: number[]): ShaderMaterial;
  88789. private _checkCache;
  88790. /**
  88791. * Specifies that the submesh is ready to be used
  88792. * @param mesh defines the mesh to check
  88793. * @param subMesh defines which submesh to check
  88794. * @param useInstances specifies that instances should be used
  88795. * @returns a boolean indicating that the submesh is ready or not
  88796. */
  88797. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  88798. /**
  88799. * Checks if the material is ready to render the requested mesh
  88800. * @param mesh Define the mesh to render
  88801. * @param useInstances Define whether or not the material is used with instances
  88802. * @returns true if ready, otherwise false
  88803. */
  88804. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  88805. /**
  88806. * Binds the world matrix to the material
  88807. * @param world defines the world transformation matrix
  88808. */
  88809. bindOnlyWorldMatrix(world: Matrix): void;
  88810. /**
  88811. * Binds the material to the mesh
  88812. * @param world defines the world transformation matrix
  88813. * @param mesh defines the mesh to bind the material to
  88814. */
  88815. bind(world: Matrix, mesh?: Mesh): void;
  88816. /**
  88817. * Gets the active textures from the material
  88818. * @returns an array of textures
  88819. */
  88820. getActiveTextures(): BaseTexture[];
  88821. /**
  88822. * Specifies if the material uses a texture
  88823. * @param texture defines the texture to check against the material
  88824. * @returns a boolean specifying if the material uses the texture
  88825. */
  88826. hasTexture(texture: BaseTexture): boolean;
  88827. /**
  88828. * Makes a duplicate of the material, and gives it a new name
  88829. * @param name defines the new name for the duplicated material
  88830. * @returns the cloned material
  88831. */
  88832. clone(name: string): ShaderMaterial;
  88833. /**
  88834. * Disposes the material
  88835. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  88836. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  88837. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  88838. */
  88839. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  88840. /**
  88841. * Serializes this material in a JSON representation
  88842. * @returns the serialized material object
  88843. */
  88844. serialize(): any;
  88845. /**
  88846. * Creates a shader material from parsed shader material data
  88847. * @param source defines the JSON represnetation of the material
  88848. * @param scene defines the hosting scene
  88849. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  88850. * @returns a new material
  88851. */
  88852. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  88853. }
  88854. }
  88855. declare module BABYLON {
  88856. /** @hidden */
  88857. export var colorPixelShader: {
  88858. name: string;
  88859. shader: string;
  88860. };
  88861. }
  88862. declare module BABYLON {
  88863. /** @hidden */
  88864. export var colorVertexShader: {
  88865. name: string;
  88866. shader: string;
  88867. };
  88868. }
  88869. declare module BABYLON {
  88870. /**
  88871. * Line mesh
  88872. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  88873. */
  88874. export class LinesMesh extends Mesh {
  88875. /**
  88876. * If vertex color should be applied to the mesh
  88877. */
  88878. readonly useVertexColor?: boolean | undefined;
  88879. /**
  88880. * If vertex alpha should be applied to the mesh
  88881. */
  88882. readonly useVertexAlpha?: boolean | undefined;
  88883. /**
  88884. * Color of the line (Default: White)
  88885. */
  88886. color: Color3;
  88887. /**
  88888. * Alpha of the line (Default: 1)
  88889. */
  88890. alpha: number;
  88891. /**
  88892. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88893. * This margin is expressed in world space coordinates, so its value may vary.
  88894. * Default value is 0.1
  88895. */
  88896. intersectionThreshold: number;
  88897. private _colorShader;
  88898. private color4;
  88899. /**
  88900. * Creates a new LinesMesh
  88901. * @param name defines the name
  88902. * @param scene defines the hosting scene
  88903. * @param parent defines the parent mesh if any
  88904. * @param source defines the optional source LinesMesh used to clone data from
  88905. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  88906. * When false, achieved by calling a clone(), also passing False.
  88907. * This will make creation of children, recursive.
  88908. * @param useVertexColor defines if this LinesMesh supports vertex color
  88909. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  88910. */
  88911. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  88912. /**
  88913. * If vertex color should be applied to the mesh
  88914. */
  88915. useVertexColor?: boolean | undefined,
  88916. /**
  88917. * If vertex alpha should be applied to the mesh
  88918. */
  88919. useVertexAlpha?: boolean | undefined);
  88920. private _addClipPlaneDefine;
  88921. private _removeClipPlaneDefine;
  88922. isReady(): boolean;
  88923. /**
  88924. * Returns the string "LineMesh"
  88925. */
  88926. getClassName(): string;
  88927. /**
  88928. * @hidden
  88929. */
  88930. get material(): Material;
  88931. /**
  88932. * @hidden
  88933. */
  88934. set material(value: Material);
  88935. /**
  88936. * @hidden
  88937. */
  88938. get checkCollisions(): boolean;
  88939. /** @hidden */
  88940. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  88941. /** @hidden */
  88942. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  88943. /**
  88944. * Disposes of the line mesh
  88945. * @param doNotRecurse If children should be disposed
  88946. */
  88947. dispose(doNotRecurse?: boolean): void;
  88948. /**
  88949. * Returns a new LineMesh object cloned from the current one.
  88950. */
  88951. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  88952. /**
  88953. * Creates a new InstancedLinesMesh object from the mesh model.
  88954. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  88955. * @param name defines the name of the new instance
  88956. * @returns a new InstancedLinesMesh
  88957. */
  88958. createInstance(name: string): InstancedLinesMesh;
  88959. }
  88960. /**
  88961. * Creates an instance based on a source LinesMesh
  88962. */
  88963. export class InstancedLinesMesh extends InstancedMesh {
  88964. /**
  88965. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  88966. * This margin is expressed in world space coordinates, so its value may vary.
  88967. * Initilized with the intersectionThreshold value of the source LinesMesh
  88968. */
  88969. intersectionThreshold: number;
  88970. constructor(name: string, source: LinesMesh);
  88971. /**
  88972. * Returns the string "InstancedLinesMesh".
  88973. */
  88974. getClassName(): string;
  88975. }
  88976. }
  88977. declare module BABYLON {
  88978. /** @hidden */
  88979. export var linePixelShader: {
  88980. name: string;
  88981. shader: string;
  88982. };
  88983. }
  88984. declare module BABYLON {
  88985. /** @hidden */
  88986. export var lineVertexShader: {
  88987. name: string;
  88988. shader: string;
  88989. };
  88990. }
  88991. declare module BABYLON {
  88992. interface AbstractMesh {
  88993. /**
  88994. * Gets the edgesRenderer associated with the mesh
  88995. */
  88996. edgesRenderer: Nullable<EdgesRenderer>;
  88997. }
  88998. interface LinesMesh {
  88999. /**
  89000. * Enables the edge rendering mode on the mesh.
  89001. * This mode makes the mesh edges visible
  89002. * @param epsilon defines the maximal distance between two angles to detect a face
  89003. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89004. * @returns the currentAbstractMesh
  89005. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89006. */
  89007. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  89008. }
  89009. interface InstancedLinesMesh {
  89010. /**
  89011. * Enables the edge rendering mode on the mesh.
  89012. * This mode makes the mesh edges visible
  89013. * @param epsilon defines the maximal distance between two angles to detect a face
  89014. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  89015. * @returns the current InstancedLinesMesh
  89016. * @see https://www.babylonjs-playground.com/#19O9TU#0
  89017. */
  89018. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  89019. }
  89020. /**
  89021. * Defines the minimum contract an Edges renderer should follow.
  89022. */
  89023. export interface IEdgesRenderer extends IDisposable {
  89024. /**
  89025. * Gets or sets a boolean indicating if the edgesRenderer is active
  89026. */
  89027. isEnabled: boolean;
  89028. /**
  89029. * Renders the edges of the attached mesh,
  89030. */
  89031. render(): void;
  89032. /**
  89033. * Checks wether or not the edges renderer is ready to render.
  89034. * @return true if ready, otherwise false.
  89035. */
  89036. isReady(): boolean;
  89037. }
  89038. /**
  89039. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  89040. */
  89041. export class EdgesRenderer implements IEdgesRenderer {
  89042. /**
  89043. * Define the size of the edges with an orthographic camera
  89044. */
  89045. edgesWidthScalerForOrthographic: number;
  89046. /**
  89047. * Define the size of the edges with a perspective camera
  89048. */
  89049. edgesWidthScalerForPerspective: number;
  89050. protected _source: AbstractMesh;
  89051. protected _linesPositions: number[];
  89052. protected _linesNormals: number[];
  89053. protected _linesIndices: number[];
  89054. protected _epsilon: number;
  89055. protected _indicesCount: number;
  89056. protected _lineShader: ShaderMaterial;
  89057. protected _ib: DataBuffer;
  89058. protected _buffers: {
  89059. [key: string]: Nullable<VertexBuffer>;
  89060. };
  89061. protected _checkVerticesInsteadOfIndices: boolean;
  89062. private _meshRebuildObserver;
  89063. private _meshDisposeObserver;
  89064. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  89065. isEnabled: boolean;
  89066. /**
  89067. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  89068. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  89069. * @param source Mesh used to create edges
  89070. * @param epsilon sum of angles in adjacency to check for edge
  89071. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  89072. * @param generateEdgesLines - should generate Lines or only prepare resources.
  89073. */
  89074. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  89075. protected _prepareRessources(): void;
  89076. /** @hidden */
  89077. _rebuild(): void;
  89078. /**
  89079. * Releases the required resources for the edges renderer
  89080. */
  89081. dispose(): void;
  89082. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  89083. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  89084. /**
  89085. * Checks if the pair of p0 and p1 is en edge
  89086. * @param faceIndex
  89087. * @param edge
  89088. * @param faceNormals
  89089. * @param p0
  89090. * @param p1
  89091. * @private
  89092. */
  89093. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  89094. /**
  89095. * push line into the position, normal and index buffer
  89096. * @protected
  89097. */
  89098. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  89099. /**
  89100. * Generates lines edges from adjacencjes
  89101. * @private
  89102. */
  89103. _generateEdgesLines(): void;
  89104. /**
  89105. * Checks wether or not the edges renderer is ready to render.
  89106. * @return true if ready, otherwise false.
  89107. */
  89108. isReady(): boolean;
  89109. /**
  89110. * Renders the edges of the attached mesh,
  89111. */
  89112. render(): void;
  89113. }
  89114. /**
  89115. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  89116. */
  89117. export class LineEdgesRenderer extends EdgesRenderer {
  89118. /**
  89119. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  89120. * @param source LineMesh used to generate edges
  89121. * @param epsilon not important (specified angle for edge detection)
  89122. * @param checkVerticesInsteadOfIndices not important for LineMesh
  89123. */
  89124. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  89125. /**
  89126. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  89127. */
  89128. _generateEdgesLines(): void;
  89129. }
  89130. }
  89131. declare module BABYLON {
  89132. /**
  89133. * This represents the object necessary to create a rendering group.
  89134. * This is exclusively used and created by the rendering manager.
  89135. * To modify the behavior, you use the available helpers in your scene or meshes.
  89136. * @hidden
  89137. */
  89138. export class RenderingGroup {
  89139. index: number;
  89140. private static _zeroVector;
  89141. private _scene;
  89142. private _opaqueSubMeshes;
  89143. private _transparentSubMeshes;
  89144. private _alphaTestSubMeshes;
  89145. private _depthOnlySubMeshes;
  89146. private _particleSystems;
  89147. private _spriteManagers;
  89148. private _opaqueSortCompareFn;
  89149. private _alphaTestSortCompareFn;
  89150. private _transparentSortCompareFn;
  89151. private _renderOpaque;
  89152. private _renderAlphaTest;
  89153. private _renderTransparent;
  89154. /** @hidden */
  89155. _edgesRenderers: SmartArray<IEdgesRenderer>;
  89156. onBeforeTransparentRendering: () => void;
  89157. /**
  89158. * Set the opaque sort comparison function.
  89159. * If null the sub meshes will be render in the order they were created
  89160. */
  89161. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89162. /**
  89163. * Set the alpha test sort comparison function.
  89164. * If null the sub meshes will be render in the order they were created
  89165. */
  89166. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89167. /**
  89168. * Set the transparent sort comparison function.
  89169. * If null the sub meshes will be render in the order they were created
  89170. */
  89171. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  89172. /**
  89173. * Creates a new rendering group.
  89174. * @param index The rendering group index
  89175. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  89176. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  89177. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  89178. */
  89179. 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>);
  89180. /**
  89181. * Render all the sub meshes contained in the group.
  89182. * @param customRenderFunction Used to override the default render behaviour of the group.
  89183. * @returns true if rendered some submeshes.
  89184. */
  89185. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  89186. /**
  89187. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  89188. * @param subMeshes The submeshes to render
  89189. */
  89190. private renderOpaqueSorted;
  89191. /**
  89192. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  89193. * @param subMeshes The submeshes to render
  89194. */
  89195. private renderAlphaTestSorted;
  89196. /**
  89197. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  89198. * @param subMeshes The submeshes to render
  89199. */
  89200. private renderTransparentSorted;
  89201. /**
  89202. * Renders the submeshes in a specified order.
  89203. * @param subMeshes The submeshes to sort before render
  89204. * @param sortCompareFn The comparison function use to sort
  89205. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  89206. * @param transparent Specifies to activate blending if true
  89207. */
  89208. private static renderSorted;
  89209. /**
  89210. * Renders the submeshes in the order they were dispatched (no sort applied).
  89211. * @param subMeshes The submeshes to render
  89212. */
  89213. private static renderUnsorted;
  89214. /**
  89215. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89216. * are rendered back to front if in the same alpha index.
  89217. *
  89218. * @param a The first submesh
  89219. * @param b The second submesh
  89220. * @returns The result of the comparison
  89221. */
  89222. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  89223. /**
  89224. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89225. * are rendered back to front.
  89226. *
  89227. * @param a The first submesh
  89228. * @param b The second submesh
  89229. * @returns The result of the comparison
  89230. */
  89231. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  89232. /**
  89233. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  89234. * are rendered front to back (prevent overdraw).
  89235. *
  89236. * @param a The first submesh
  89237. * @param b The second submesh
  89238. * @returns The result of the comparison
  89239. */
  89240. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  89241. /**
  89242. * Resets the different lists of submeshes to prepare a new frame.
  89243. */
  89244. prepare(): void;
  89245. dispose(): void;
  89246. /**
  89247. * Inserts the submesh in its correct queue depending on its material.
  89248. * @param subMesh The submesh to dispatch
  89249. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89250. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89251. */
  89252. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89253. dispatchSprites(spriteManager: ISpriteManager): void;
  89254. dispatchParticles(particleSystem: IParticleSystem): void;
  89255. private _renderParticles;
  89256. private _renderSprites;
  89257. }
  89258. }
  89259. declare module BABYLON {
  89260. /**
  89261. * Interface describing the different options available in the rendering manager
  89262. * regarding Auto Clear between groups.
  89263. */
  89264. export interface IRenderingManagerAutoClearSetup {
  89265. /**
  89266. * Defines whether or not autoclear is enable.
  89267. */
  89268. autoClear: boolean;
  89269. /**
  89270. * Defines whether or not to autoclear the depth buffer.
  89271. */
  89272. depth: boolean;
  89273. /**
  89274. * Defines whether or not to autoclear the stencil buffer.
  89275. */
  89276. stencil: boolean;
  89277. }
  89278. /**
  89279. * This class is used by the onRenderingGroupObservable
  89280. */
  89281. export class RenderingGroupInfo {
  89282. /**
  89283. * The Scene that being rendered
  89284. */
  89285. scene: Scene;
  89286. /**
  89287. * The camera currently used for the rendering pass
  89288. */
  89289. camera: Nullable<Camera>;
  89290. /**
  89291. * The ID of the renderingGroup being processed
  89292. */
  89293. renderingGroupId: number;
  89294. }
  89295. /**
  89296. * This is the manager responsible of all the rendering for meshes sprites and particles.
  89297. * It is enable to manage the different groups as well as the different necessary sort functions.
  89298. * This should not be used directly aside of the few static configurations
  89299. */
  89300. export class RenderingManager {
  89301. /**
  89302. * The max id used for rendering groups (not included)
  89303. */
  89304. static MAX_RENDERINGGROUPS: number;
  89305. /**
  89306. * The min id used for rendering groups (included)
  89307. */
  89308. static MIN_RENDERINGGROUPS: number;
  89309. /**
  89310. * Used to globally prevent autoclearing scenes.
  89311. */
  89312. static AUTOCLEAR: boolean;
  89313. /**
  89314. * @hidden
  89315. */
  89316. _useSceneAutoClearSetup: boolean;
  89317. private _scene;
  89318. private _renderingGroups;
  89319. private _depthStencilBufferAlreadyCleaned;
  89320. private _autoClearDepthStencil;
  89321. private _customOpaqueSortCompareFn;
  89322. private _customAlphaTestSortCompareFn;
  89323. private _customTransparentSortCompareFn;
  89324. private _renderingGroupInfo;
  89325. /**
  89326. * Instantiates a new rendering group for a particular scene
  89327. * @param scene Defines the scene the groups belongs to
  89328. */
  89329. constructor(scene: Scene);
  89330. private _clearDepthStencilBuffer;
  89331. /**
  89332. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  89333. * @hidden
  89334. */
  89335. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  89336. /**
  89337. * Resets the different information of the group to prepare a new frame
  89338. * @hidden
  89339. */
  89340. reset(): void;
  89341. /**
  89342. * Dispose and release the group and its associated resources.
  89343. * @hidden
  89344. */
  89345. dispose(): void;
  89346. /**
  89347. * Clear the info related to rendering groups preventing retention points during dispose.
  89348. */
  89349. freeRenderingGroups(): void;
  89350. private _prepareRenderingGroup;
  89351. /**
  89352. * Add a sprite manager to the rendering manager in order to render it this frame.
  89353. * @param spriteManager Define the sprite manager to render
  89354. */
  89355. dispatchSprites(spriteManager: ISpriteManager): void;
  89356. /**
  89357. * Add a particle system to the rendering manager in order to render it this frame.
  89358. * @param particleSystem Define the particle system to render
  89359. */
  89360. dispatchParticles(particleSystem: IParticleSystem): void;
  89361. /**
  89362. * Add a submesh to the manager in order to render it this frame
  89363. * @param subMesh The submesh to dispatch
  89364. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  89365. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  89366. */
  89367. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  89368. /**
  89369. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  89370. * This allowed control for front to back rendering or reversly depending of the special needs.
  89371. *
  89372. * @param renderingGroupId The rendering group id corresponding to its index
  89373. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  89374. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  89375. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  89376. */
  89377. 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;
  89378. /**
  89379. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  89380. *
  89381. * @param renderingGroupId The rendering group id corresponding to its index
  89382. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  89383. * @param depth Automatically clears depth between groups if true and autoClear is true.
  89384. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  89385. */
  89386. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  89387. /**
  89388. * Gets the current auto clear configuration for one rendering group of the rendering
  89389. * manager.
  89390. * @param index the rendering group index to get the information for
  89391. * @returns The auto clear setup for the requested rendering group
  89392. */
  89393. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  89394. }
  89395. }
  89396. declare module BABYLON {
  89397. /**
  89398. * Defines the options associated with the creation of a custom shader for a shadow generator.
  89399. */
  89400. export interface ICustomShaderOptions {
  89401. /**
  89402. * Gets or sets the custom shader name to use
  89403. */
  89404. shaderName: string;
  89405. /**
  89406. * The list of attribute names used in the shader
  89407. */
  89408. attributes?: string[];
  89409. /**
  89410. * The list of unifrom names used in the shader
  89411. */
  89412. uniforms?: string[];
  89413. /**
  89414. * The list of sampler names used in the shader
  89415. */
  89416. samplers?: string[];
  89417. /**
  89418. * The list of defines used in the shader
  89419. */
  89420. defines?: string[];
  89421. }
  89422. /**
  89423. * Interface to implement to create a shadow generator compatible with BJS.
  89424. */
  89425. export interface IShadowGenerator {
  89426. /**
  89427. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89428. * @returns The render target texture if present otherwise, null
  89429. */
  89430. getShadowMap(): Nullable<RenderTargetTexture>;
  89431. /**
  89432. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89433. * @param subMesh The submesh we want to render in the shadow map
  89434. * @param useInstances Defines wether will draw in the map using instances
  89435. * @returns true if ready otherwise, false
  89436. */
  89437. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89438. /**
  89439. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89440. * @param defines Defines of the material we want to update
  89441. * @param lightIndex Index of the light in the enabled light list of the material
  89442. */
  89443. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  89444. /**
  89445. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89446. * defined in the generator but impacting the effect).
  89447. * It implies the unifroms available on the materials are the standard BJS ones.
  89448. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89449. * @param effect The effect we are binfing the information for
  89450. */
  89451. bindShadowLight(lightIndex: string, effect: Effect): void;
  89452. /**
  89453. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89454. * (eq to shadow prjection matrix * light transform matrix)
  89455. * @returns The transform matrix used to create the shadow map
  89456. */
  89457. getTransformMatrix(): Matrix;
  89458. /**
  89459. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89460. * Cube and 2D textures for instance.
  89461. */
  89462. recreateShadowMap(): void;
  89463. /**
  89464. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89465. * @param onCompiled Callback triggered at the and of the effects compilation
  89466. * @param options Sets of optional options forcing the compilation with different modes
  89467. */
  89468. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89469. useInstances: boolean;
  89470. }>): void;
  89471. /**
  89472. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89473. * @param options Sets of optional options forcing the compilation with different modes
  89474. * @returns A promise that resolves when the compilation completes
  89475. */
  89476. forceCompilationAsync(options?: Partial<{
  89477. useInstances: boolean;
  89478. }>): Promise<void>;
  89479. /**
  89480. * Serializes the shadow generator setup to a json object.
  89481. * @returns The serialized JSON object
  89482. */
  89483. serialize(): any;
  89484. /**
  89485. * Disposes the Shadow map and related Textures and effects.
  89486. */
  89487. dispose(): void;
  89488. }
  89489. /**
  89490. * Default implementation IShadowGenerator.
  89491. * This is the main object responsible of generating shadows in the framework.
  89492. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  89493. */
  89494. export class ShadowGenerator implements IShadowGenerator {
  89495. /**
  89496. * Name of the shadow generator class
  89497. */
  89498. static CLASSNAME: string;
  89499. /**
  89500. * Shadow generator mode None: no filtering applied.
  89501. */
  89502. static readonly FILTER_NONE: number;
  89503. /**
  89504. * Shadow generator mode ESM: Exponential Shadow Mapping.
  89505. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89506. */
  89507. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  89508. /**
  89509. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  89510. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  89511. */
  89512. static readonly FILTER_POISSONSAMPLING: number;
  89513. /**
  89514. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  89515. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89516. */
  89517. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  89518. /**
  89519. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  89520. * edge artifacts on steep falloff.
  89521. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89522. */
  89523. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  89524. /**
  89525. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  89526. * edge artifacts on steep falloff.
  89527. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  89528. */
  89529. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  89530. /**
  89531. * Shadow generator mode PCF: Percentage Closer Filtering
  89532. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89533. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  89534. */
  89535. static readonly FILTER_PCF: number;
  89536. /**
  89537. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  89538. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  89539. * Contact Hardening
  89540. */
  89541. static readonly FILTER_PCSS: number;
  89542. /**
  89543. * Reserved for PCF and PCSS
  89544. * Highest Quality.
  89545. *
  89546. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  89547. *
  89548. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  89549. */
  89550. static readonly QUALITY_HIGH: number;
  89551. /**
  89552. * Reserved for PCF and PCSS
  89553. * Good tradeoff for quality/perf cross devices
  89554. *
  89555. * Execute PCF on a 3*3 kernel.
  89556. *
  89557. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  89558. */
  89559. static readonly QUALITY_MEDIUM: number;
  89560. /**
  89561. * Reserved for PCF and PCSS
  89562. * The lowest quality but the fastest.
  89563. *
  89564. * Execute PCF on a 1*1 kernel.
  89565. *
  89566. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  89567. */
  89568. static readonly QUALITY_LOW: number;
  89569. /** Gets or sets the custom shader name to use */
  89570. customShaderOptions: ICustomShaderOptions;
  89571. /**
  89572. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  89573. */
  89574. onBeforeShadowMapRenderObservable: Observable<Effect>;
  89575. /**
  89576. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  89577. */
  89578. onAfterShadowMapRenderObservable: Observable<Effect>;
  89579. /**
  89580. * Observable triggered before a mesh is rendered in the shadow map.
  89581. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  89582. */
  89583. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  89584. /**
  89585. * Observable triggered after a mesh is rendered in the shadow map.
  89586. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  89587. */
  89588. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  89589. protected _bias: number;
  89590. /**
  89591. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  89592. */
  89593. get bias(): number;
  89594. /**
  89595. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  89596. */
  89597. set bias(bias: number);
  89598. protected _normalBias: number;
  89599. /**
  89600. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89601. */
  89602. get normalBias(): number;
  89603. /**
  89604. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  89605. */
  89606. set normalBias(normalBias: number);
  89607. protected _blurBoxOffset: number;
  89608. /**
  89609. * Gets the blur box offset: offset applied during the blur pass.
  89610. * Only useful if useKernelBlur = false
  89611. */
  89612. get blurBoxOffset(): number;
  89613. /**
  89614. * Sets the blur box offset: offset applied during the blur pass.
  89615. * Only useful if useKernelBlur = false
  89616. */
  89617. set blurBoxOffset(value: number);
  89618. protected _blurScale: number;
  89619. /**
  89620. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  89621. * 2 means half of the size.
  89622. */
  89623. get blurScale(): number;
  89624. /**
  89625. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  89626. * 2 means half of the size.
  89627. */
  89628. set blurScale(value: number);
  89629. protected _blurKernel: number;
  89630. /**
  89631. * Gets the blur kernel: kernel size of the blur pass.
  89632. * Only useful if useKernelBlur = true
  89633. */
  89634. get blurKernel(): number;
  89635. /**
  89636. * Sets the blur kernel: kernel size of the blur pass.
  89637. * Only useful if useKernelBlur = true
  89638. */
  89639. set blurKernel(value: number);
  89640. protected _useKernelBlur: boolean;
  89641. /**
  89642. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  89643. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89644. */
  89645. get useKernelBlur(): boolean;
  89646. /**
  89647. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  89648. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  89649. */
  89650. set useKernelBlur(value: boolean);
  89651. protected _depthScale: number;
  89652. /**
  89653. * Gets the depth scale used in ESM mode.
  89654. */
  89655. get depthScale(): number;
  89656. /**
  89657. * Sets the depth scale used in ESM mode.
  89658. * This can override the scale stored on the light.
  89659. */
  89660. set depthScale(value: number);
  89661. protected _validateFilter(filter: number): number;
  89662. protected _filter: number;
  89663. /**
  89664. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  89665. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89666. */
  89667. get filter(): number;
  89668. /**
  89669. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  89670. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  89671. */
  89672. set filter(value: number);
  89673. /**
  89674. * Gets if the current filter is set to Poisson Sampling.
  89675. */
  89676. get usePoissonSampling(): boolean;
  89677. /**
  89678. * Sets the current filter to Poisson Sampling.
  89679. */
  89680. set usePoissonSampling(value: boolean);
  89681. /**
  89682. * Gets if the current filter is set to ESM.
  89683. */
  89684. get useExponentialShadowMap(): boolean;
  89685. /**
  89686. * Sets the current filter is to ESM.
  89687. */
  89688. set useExponentialShadowMap(value: boolean);
  89689. /**
  89690. * Gets if the current filter is set to filtered ESM.
  89691. */
  89692. get useBlurExponentialShadowMap(): boolean;
  89693. /**
  89694. * Gets if the current filter is set to filtered ESM.
  89695. */
  89696. set useBlurExponentialShadowMap(value: boolean);
  89697. /**
  89698. * Gets if the current filter is set to "close ESM" (using the inverse of the
  89699. * exponential to prevent steep falloff artifacts).
  89700. */
  89701. get useCloseExponentialShadowMap(): boolean;
  89702. /**
  89703. * Sets the current filter to "close ESM" (using the inverse of the
  89704. * exponential to prevent steep falloff artifacts).
  89705. */
  89706. set useCloseExponentialShadowMap(value: boolean);
  89707. /**
  89708. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  89709. * exponential to prevent steep falloff artifacts).
  89710. */
  89711. get useBlurCloseExponentialShadowMap(): boolean;
  89712. /**
  89713. * Sets the current filter to filtered "close ESM" (using the inverse of the
  89714. * exponential to prevent steep falloff artifacts).
  89715. */
  89716. set useBlurCloseExponentialShadowMap(value: boolean);
  89717. /**
  89718. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  89719. */
  89720. get usePercentageCloserFiltering(): boolean;
  89721. /**
  89722. * Sets the current filter to "PCF" (percentage closer filtering).
  89723. */
  89724. set usePercentageCloserFiltering(value: boolean);
  89725. protected _filteringQuality: number;
  89726. /**
  89727. * Gets the PCF or PCSS Quality.
  89728. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89729. */
  89730. get filteringQuality(): number;
  89731. /**
  89732. * Sets the PCF or PCSS Quality.
  89733. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  89734. */
  89735. set filteringQuality(filteringQuality: number);
  89736. /**
  89737. * Gets if the current filter is set to "PCSS" (contact hardening).
  89738. */
  89739. get useContactHardeningShadow(): boolean;
  89740. /**
  89741. * Sets the current filter to "PCSS" (contact hardening).
  89742. */
  89743. set useContactHardeningShadow(value: boolean);
  89744. protected _contactHardeningLightSizeUVRatio: number;
  89745. /**
  89746. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89747. * Using a ratio helps keeping shape stability independently of the map size.
  89748. *
  89749. * It does not account for the light projection as it was having too much
  89750. * instability during the light setup or during light position changes.
  89751. *
  89752. * Only valid if useContactHardeningShadow is true.
  89753. */
  89754. get contactHardeningLightSizeUVRatio(): number;
  89755. /**
  89756. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  89757. * Using a ratio helps keeping shape stability independently of the map size.
  89758. *
  89759. * It does not account for the light projection as it was having too much
  89760. * instability during the light setup or during light position changes.
  89761. *
  89762. * Only valid if useContactHardeningShadow is true.
  89763. */
  89764. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  89765. protected _darkness: number;
  89766. /** Gets or sets the actual darkness of a shadow */
  89767. get darkness(): number;
  89768. set darkness(value: number);
  89769. /**
  89770. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  89771. * 0 means strongest and 1 would means no shadow.
  89772. * @returns the darkness.
  89773. */
  89774. getDarkness(): number;
  89775. /**
  89776. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  89777. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  89778. * @returns the shadow generator allowing fluent coding.
  89779. */
  89780. setDarkness(darkness: number): ShadowGenerator;
  89781. protected _transparencyShadow: boolean;
  89782. /** Gets or sets the ability to have transparent shadow */
  89783. get transparencyShadow(): boolean;
  89784. set transparencyShadow(value: boolean);
  89785. /**
  89786. * Sets the ability to have transparent shadow (boolean).
  89787. * @param transparent True if transparent else False
  89788. * @returns the shadow generator allowing fluent coding
  89789. */
  89790. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  89791. protected _shadowMap: Nullable<RenderTargetTexture>;
  89792. protected _shadowMap2: Nullable<RenderTargetTexture>;
  89793. /**
  89794. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  89795. * @returns The render target texture if present otherwise, null
  89796. */
  89797. getShadowMap(): Nullable<RenderTargetTexture>;
  89798. /**
  89799. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  89800. * @returns The render target texture if the shadow map is present otherwise, null
  89801. */
  89802. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  89803. /**
  89804. * Gets the class name of that object
  89805. * @returns "ShadowGenerator"
  89806. */
  89807. getClassName(): string;
  89808. /**
  89809. * Helper function to add a mesh and its descendants to the list of shadow casters.
  89810. * @param mesh Mesh to add
  89811. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  89812. * @returns the Shadow Generator itself
  89813. */
  89814. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89815. /**
  89816. * Helper function to remove a mesh and its descendants from the list of shadow casters
  89817. * @param mesh Mesh to remove
  89818. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  89819. * @returns the Shadow Generator itself
  89820. */
  89821. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  89822. /**
  89823. * Controls the extent to which the shadows fade out at the edge of the frustum
  89824. */
  89825. frustumEdgeFalloff: number;
  89826. protected _light: IShadowLight;
  89827. /**
  89828. * Returns the associated light object.
  89829. * @returns the light generating the shadow
  89830. */
  89831. getLight(): IShadowLight;
  89832. /**
  89833. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  89834. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  89835. * It might on the other hand introduce peter panning.
  89836. */
  89837. forceBackFacesOnly: boolean;
  89838. protected _scene: Scene;
  89839. protected _lightDirection: Vector3;
  89840. protected _effect: Effect;
  89841. protected _viewMatrix: Matrix;
  89842. protected _projectionMatrix: Matrix;
  89843. protected _transformMatrix: Matrix;
  89844. protected _cachedPosition: Vector3;
  89845. protected _cachedDirection: Vector3;
  89846. protected _cachedDefines: string;
  89847. protected _currentRenderID: number;
  89848. protected _boxBlurPostprocess: Nullable<PostProcess>;
  89849. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  89850. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  89851. protected _blurPostProcesses: PostProcess[];
  89852. protected _mapSize: number;
  89853. protected _currentFaceIndex: number;
  89854. protected _currentFaceIndexCache: number;
  89855. protected _textureType: number;
  89856. protected _defaultTextureMatrix: Matrix;
  89857. protected _storedUniqueId: Nullable<number>;
  89858. /** @hidden */
  89859. static _SceneComponentInitialization: (scene: Scene) => void;
  89860. /**
  89861. * Creates a ShadowGenerator object.
  89862. * A ShadowGenerator is the required tool to use the shadows.
  89863. * Each light casting shadows needs to use its own ShadowGenerator.
  89864. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  89865. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  89866. * @param light The light object generating the shadows.
  89867. * @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.
  89868. */
  89869. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  89870. protected _initializeGenerator(): void;
  89871. protected _createTargetRenderTexture(): void;
  89872. protected _initializeShadowMap(): void;
  89873. protected _initializeBlurRTTAndPostProcesses(): void;
  89874. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  89875. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  89876. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  89877. protected _applyFilterValues(): void;
  89878. /**
  89879. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89880. * @param onCompiled Callback triggered at the and of the effects compilation
  89881. * @param options Sets of optional options forcing the compilation with different modes
  89882. */
  89883. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  89884. useInstances: boolean;
  89885. }>): void;
  89886. /**
  89887. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  89888. * @param options Sets of optional options forcing the compilation with different modes
  89889. * @returns A promise that resolves when the compilation completes
  89890. */
  89891. forceCompilationAsync(options?: Partial<{
  89892. useInstances: boolean;
  89893. }>): Promise<void>;
  89894. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  89895. /**
  89896. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  89897. * @param subMesh The submesh we want to render in the shadow map
  89898. * @param useInstances Defines wether will draw in the map using instances
  89899. * @returns true if ready otherwise, false
  89900. */
  89901. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  89902. /**
  89903. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  89904. * @param defines Defines of the material we want to update
  89905. * @param lightIndex Index of the light in the enabled light list of the material
  89906. */
  89907. prepareDefines(defines: any, lightIndex: number): void;
  89908. /**
  89909. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  89910. * defined in the generator but impacting the effect).
  89911. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  89912. * @param effect The effect we are binfing the information for
  89913. */
  89914. bindShadowLight(lightIndex: string, effect: Effect): void;
  89915. /**
  89916. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  89917. * (eq to shadow prjection matrix * light transform matrix)
  89918. * @returns The transform matrix used to create the shadow map
  89919. */
  89920. getTransformMatrix(): Matrix;
  89921. /**
  89922. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  89923. * Cube and 2D textures for instance.
  89924. */
  89925. recreateShadowMap(): void;
  89926. protected _disposeBlurPostProcesses(): void;
  89927. protected _disposeRTTandPostProcesses(): void;
  89928. /**
  89929. * Disposes the ShadowGenerator.
  89930. * Returns nothing.
  89931. */
  89932. dispose(): void;
  89933. /**
  89934. * Serializes the shadow generator setup to a json object.
  89935. * @returns The serialized JSON object
  89936. */
  89937. serialize(): any;
  89938. /**
  89939. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  89940. * @param parsedShadowGenerator The JSON object to parse
  89941. * @param scene The scene to create the shadow map for
  89942. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  89943. * @returns The parsed shadow generator
  89944. */
  89945. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  89946. }
  89947. }
  89948. declare module BABYLON {
  89949. /**
  89950. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  89951. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  89952. * 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.
  89953. */
  89954. export abstract class Light extends Node {
  89955. /**
  89956. * Falloff Default: light is falling off following the material specification:
  89957. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  89958. */
  89959. static readonly FALLOFF_DEFAULT: number;
  89960. /**
  89961. * Falloff Physical: light is falling off following the inverse squared distance law.
  89962. */
  89963. static readonly FALLOFF_PHYSICAL: number;
  89964. /**
  89965. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  89966. * to enhance interoperability with other engines.
  89967. */
  89968. static readonly FALLOFF_GLTF: number;
  89969. /**
  89970. * Falloff Standard: light is falling off like in the standard material
  89971. * to enhance interoperability with other materials.
  89972. */
  89973. static readonly FALLOFF_STANDARD: number;
  89974. /**
  89975. * If every light affecting the material is in this lightmapMode,
  89976. * material.lightmapTexture adds or multiplies
  89977. * (depends on material.useLightmapAsShadowmap)
  89978. * after every other light calculations.
  89979. */
  89980. static readonly LIGHTMAP_DEFAULT: number;
  89981. /**
  89982. * material.lightmapTexture as only diffuse lighting from this light
  89983. * adds only specular lighting from this light
  89984. * adds dynamic shadows
  89985. */
  89986. static readonly LIGHTMAP_SPECULAR: number;
  89987. /**
  89988. * material.lightmapTexture as only lighting
  89989. * no light calculation from this light
  89990. * only adds dynamic shadows from this light
  89991. */
  89992. static readonly LIGHTMAP_SHADOWSONLY: number;
  89993. /**
  89994. * Each light type uses the default quantity according to its type:
  89995. * point/spot lights use luminous intensity
  89996. * directional lights use illuminance
  89997. */
  89998. static readonly INTENSITYMODE_AUTOMATIC: number;
  89999. /**
  90000. * lumen (lm)
  90001. */
  90002. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  90003. /**
  90004. * candela (lm/sr)
  90005. */
  90006. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  90007. /**
  90008. * lux (lm/m^2)
  90009. */
  90010. static readonly INTENSITYMODE_ILLUMINANCE: number;
  90011. /**
  90012. * nit (cd/m^2)
  90013. */
  90014. static readonly INTENSITYMODE_LUMINANCE: number;
  90015. /**
  90016. * Light type const id of the point light.
  90017. */
  90018. static readonly LIGHTTYPEID_POINTLIGHT: number;
  90019. /**
  90020. * Light type const id of the directional light.
  90021. */
  90022. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  90023. /**
  90024. * Light type const id of the spot light.
  90025. */
  90026. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  90027. /**
  90028. * Light type const id of the hemispheric light.
  90029. */
  90030. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  90031. /**
  90032. * Diffuse gives the basic color to an object.
  90033. */
  90034. diffuse: Color3;
  90035. /**
  90036. * Specular produces a highlight color on an object.
  90037. * Note: This is note affecting PBR materials.
  90038. */
  90039. specular: Color3;
  90040. /**
  90041. * Defines the falloff type for this light. This lets overrriding how punctual light are
  90042. * falling off base on range or angle.
  90043. * This can be set to any values in Light.FALLOFF_x.
  90044. *
  90045. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  90046. * other types of materials.
  90047. */
  90048. falloffType: number;
  90049. /**
  90050. * Strength of the light.
  90051. * Note: By default it is define in the framework own unit.
  90052. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  90053. */
  90054. intensity: number;
  90055. private _range;
  90056. protected _inverseSquaredRange: number;
  90057. /**
  90058. * Defines how far from the source the light is impacting in scene units.
  90059. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90060. */
  90061. get range(): number;
  90062. /**
  90063. * Defines how far from the source the light is impacting in scene units.
  90064. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  90065. */
  90066. set range(value: number);
  90067. /**
  90068. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  90069. * of light.
  90070. */
  90071. private _photometricScale;
  90072. private _intensityMode;
  90073. /**
  90074. * Gets the photometric scale used to interpret the intensity.
  90075. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90076. */
  90077. get intensityMode(): number;
  90078. /**
  90079. * Sets the photometric scale used to interpret the intensity.
  90080. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  90081. */
  90082. set intensityMode(value: number);
  90083. private _radius;
  90084. /**
  90085. * Gets the light radius used by PBR Materials to simulate soft area lights.
  90086. */
  90087. get radius(): number;
  90088. /**
  90089. * sets the light radius used by PBR Materials to simulate soft area lights.
  90090. */
  90091. set radius(value: number);
  90092. private _renderPriority;
  90093. /**
  90094. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  90095. * exceeding the number allowed of the materials.
  90096. */
  90097. renderPriority: number;
  90098. private _shadowEnabled;
  90099. /**
  90100. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90101. * the current shadow generator.
  90102. */
  90103. get shadowEnabled(): boolean;
  90104. /**
  90105. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  90106. * the current shadow generator.
  90107. */
  90108. set shadowEnabled(value: boolean);
  90109. private _includedOnlyMeshes;
  90110. /**
  90111. * Gets the only meshes impacted by this light.
  90112. */
  90113. get includedOnlyMeshes(): AbstractMesh[];
  90114. /**
  90115. * Sets the only meshes impacted by this light.
  90116. */
  90117. set includedOnlyMeshes(value: AbstractMesh[]);
  90118. private _excludedMeshes;
  90119. /**
  90120. * Gets the meshes not impacted by this light.
  90121. */
  90122. get excludedMeshes(): AbstractMesh[];
  90123. /**
  90124. * Sets the meshes not impacted by this light.
  90125. */
  90126. set excludedMeshes(value: AbstractMesh[]);
  90127. private _excludeWithLayerMask;
  90128. /**
  90129. * Gets the layer id use to find what meshes are not impacted by the light.
  90130. * Inactive if 0
  90131. */
  90132. get excludeWithLayerMask(): number;
  90133. /**
  90134. * Sets the layer id use to find what meshes are not impacted by the light.
  90135. * Inactive if 0
  90136. */
  90137. set excludeWithLayerMask(value: number);
  90138. private _includeOnlyWithLayerMask;
  90139. /**
  90140. * Gets the layer id use to find what meshes are impacted by the light.
  90141. * Inactive if 0
  90142. */
  90143. get includeOnlyWithLayerMask(): number;
  90144. /**
  90145. * Sets the layer id use to find what meshes are impacted by the light.
  90146. * Inactive if 0
  90147. */
  90148. set includeOnlyWithLayerMask(value: number);
  90149. private _lightmapMode;
  90150. /**
  90151. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90152. */
  90153. get lightmapMode(): number;
  90154. /**
  90155. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  90156. */
  90157. set lightmapMode(value: number);
  90158. /**
  90159. * Shadow generator associted to the light.
  90160. * @hidden Internal use only.
  90161. */
  90162. _shadowGenerator: Nullable<IShadowGenerator>;
  90163. /**
  90164. * @hidden Internal use only.
  90165. */
  90166. _excludedMeshesIds: string[];
  90167. /**
  90168. * @hidden Internal use only.
  90169. */
  90170. _includedOnlyMeshesIds: string[];
  90171. /**
  90172. * The current light unifom buffer.
  90173. * @hidden Internal use only.
  90174. */
  90175. _uniformBuffer: UniformBuffer;
  90176. /** @hidden */
  90177. _renderId: number;
  90178. /**
  90179. * Creates a Light object in the scene.
  90180. * Documentation : https://doc.babylonjs.com/babylon101/lights
  90181. * @param name The firendly name of the light
  90182. * @param scene The scene the light belongs too
  90183. */
  90184. constructor(name: string, scene: Scene);
  90185. protected abstract _buildUniformLayout(): void;
  90186. /**
  90187. * Sets the passed Effect "effect" with the Light information.
  90188. * @param effect The effect to update
  90189. * @param lightIndex The index of the light in the effect to update
  90190. * @returns The light
  90191. */
  90192. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  90193. /**
  90194. * Sets the passed Effect "effect" with the Light textures.
  90195. * @param effect The effect to update
  90196. * @param lightIndex The index of the light in the effect to update
  90197. * @returns The light
  90198. */
  90199. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  90200. /**
  90201. * Binds the lights information from the scene to the effect for the given mesh.
  90202. * @param lightIndex Light index
  90203. * @param scene The scene where the light belongs to
  90204. * @param effect The effect we are binding the data to
  90205. * @param useSpecular Defines if specular is supported
  90206. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  90207. */
  90208. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  90209. /**
  90210. * Sets the passed Effect "effect" with the Light information.
  90211. * @param effect The effect to update
  90212. * @param lightDataUniformName The uniform used to store light data (position or direction)
  90213. * @returns The light
  90214. */
  90215. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  90216. /**
  90217. * Returns the string "Light".
  90218. * @returns the class name
  90219. */
  90220. getClassName(): string;
  90221. /** @hidden */
  90222. readonly _isLight: boolean;
  90223. /**
  90224. * Converts the light information to a readable string for debug purpose.
  90225. * @param fullDetails Supports for multiple levels of logging within scene loading
  90226. * @returns the human readable light info
  90227. */
  90228. toString(fullDetails?: boolean): string;
  90229. /** @hidden */
  90230. protected _syncParentEnabledState(): void;
  90231. /**
  90232. * Set the enabled state of this node.
  90233. * @param value - the new enabled state
  90234. */
  90235. setEnabled(value: boolean): void;
  90236. /**
  90237. * Returns the Light associated shadow generator if any.
  90238. * @return the associated shadow generator.
  90239. */
  90240. getShadowGenerator(): Nullable<IShadowGenerator>;
  90241. /**
  90242. * Returns a Vector3, the absolute light position in the World.
  90243. * @returns the world space position of the light
  90244. */
  90245. getAbsolutePosition(): Vector3;
  90246. /**
  90247. * Specifies if the light will affect the passed mesh.
  90248. * @param mesh The mesh to test against the light
  90249. * @return true the mesh is affected otherwise, false.
  90250. */
  90251. canAffectMesh(mesh: AbstractMesh): boolean;
  90252. /**
  90253. * Sort function to order lights for rendering.
  90254. * @param a First Light object to compare to second.
  90255. * @param b Second Light object to compare first.
  90256. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  90257. */
  90258. static CompareLightsPriority(a: Light, b: Light): number;
  90259. /**
  90260. * Releases resources associated with this node.
  90261. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90262. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90263. */
  90264. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90265. /**
  90266. * Returns the light type ID (integer).
  90267. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  90268. */
  90269. getTypeID(): number;
  90270. /**
  90271. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  90272. * @returns the scaled intensity in intensity mode unit
  90273. */
  90274. getScaledIntensity(): number;
  90275. /**
  90276. * Returns a new Light object, named "name", from the current one.
  90277. * @param name The name of the cloned light
  90278. * @returns the new created light
  90279. */
  90280. clone(name: string): Nullable<Light>;
  90281. /**
  90282. * Serializes the current light into a Serialization object.
  90283. * @returns the serialized object.
  90284. */
  90285. serialize(): any;
  90286. /**
  90287. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  90288. * This new light is named "name" and added to the passed scene.
  90289. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  90290. * @param name The friendly name of the light
  90291. * @param scene The scene the new light will belong to
  90292. * @returns the constructor function
  90293. */
  90294. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  90295. /**
  90296. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  90297. * @param parsedLight The JSON representation of the light
  90298. * @param scene The scene to create the parsed light in
  90299. * @returns the created light after parsing
  90300. */
  90301. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  90302. private _hookArrayForExcluded;
  90303. private _hookArrayForIncludedOnly;
  90304. private _resyncMeshes;
  90305. /**
  90306. * Forces the meshes to update their light related information in their rendering used effects
  90307. * @hidden Internal Use Only
  90308. */
  90309. _markMeshesAsLightDirty(): void;
  90310. /**
  90311. * Recomputes the cached photometric scale if needed.
  90312. */
  90313. private _computePhotometricScale;
  90314. /**
  90315. * Returns the Photometric Scale according to the light type and intensity mode.
  90316. */
  90317. private _getPhotometricScale;
  90318. /**
  90319. * Reorder the light in the scene according to their defined priority.
  90320. * @hidden Internal Use Only
  90321. */
  90322. _reorderLightsInScene(): void;
  90323. /**
  90324. * Prepares the list of defines specific to the light type.
  90325. * @param defines the list of defines
  90326. * @param lightIndex defines the index of the light for the effect
  90327. */
  90328. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  90329. }
  90330. }
  90331. declare module BABYLON {
  90332. /**
  90333. * Interface used to define Action
  90334. */
  90335. export interface IAction {
  90336. /**
  90337. * Trigger for the action
  90338. */
  90339. trigger: number;
  90340. /** Options of the trigger */
  90341. triggerOptions: any;
  90342. /**
  90343. * Gets the trigger parameters
  90344. * @returns the trigger parameters
  90345. */
  90346. getTriggerParameter(): any;
  90347. /**
  90348. * Internal only - executes current action event
  90349. * @hidden
  90350. */
  90351. _executeCurrent(evt?: ActionEvent): void;
  90352. /**
  90353. * Serialize placeholder for child classes
  90354. * @param parent of child
  90355. * @returns the serialized object
  90356. */
  90357. serialize(parent: any): any;
  90358. /**
  90359. * Internal only
  90360. * @hidden
  90361. */
  90362. _prepare(): void;
  90363. /**
  90364. * Internal only - manager for action
  90365. * @hidden
  90366. */
  90367. _actionManager: AbstractActionManager;
  90368. /**
  90369. * Adds action to chain of actions, may be a DoNothingAction
  90370. * @param action defines the next action to execute
  90371. * @returns The action passed in
  90372. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90373. */
  90374. then(action: IAction): IAction;
  90375. }
  90376. /**
  90377. * The action to be carried out following a trigger
  90378. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  90379. */
  90380. export class Action implements IAction {
  90381. /** the trigger, with or without parameters, for the action */
  90382. triggerOptions: any;
  90383. /**
  90384. * Trigger for the action
  90385. */
  90386. trigger: number;
  90387. /**
  90388. * Internal only - manager for action
  90389. * @hidden
  90390. */
  90391. _actionManager: ActionManager;
  90392. private _nextActiveAction;
  90393. private _child;
  90394. private _condition?;
  90395. private _triggerParameter;
  90396. /**
  90397. * An event triggered prior to action being executed.
  90398. */
  90399. onBeforeExecuteObservable: Observable<Action>;
  90400. /**
  90401. * Creates a new Action
  90402. * @param triggerOptions the trigger, with or without parameters, for the action
  90403. * @param condition an optional determinant of action
  90404. */
  90405. constructor(
  90406. /** the trigger, with or without parameters, for the action */
  90407. triggerOptions: any, condition?: Condition);
  90408. /**
  90409. * Internal only
  90410. * @hidden
  90411. */
  90412. _prepare(): void;
  90413. /**
  90414. * Gets the trigger parameters
  90415. * @returns the trigger parameters
  90416. */
  90417. getTriggerParameter(): any;
  90418. /**
  90419. * Internal only - executes current action event
  90420. * @hidden
  90421. */
  90422. _executeCurrent(evt?: ActionEvent): void;
  90423. /**
  90424. * Execute placeholder for child classes
  90425. * @param evt optional action event
  90426. */
  90427. execute(evt?: ActionEvent): void;
  90428. /**
  90429. * Skips to next active action
  90430. */
  90431. skipToNextActiveAction(): void;
  90432. /**
  90433. * Adds action to chain of actions, may be a DoNothingAction
  90434. * @param action defines the next action to execute
  90435. * @returns The action passed in
  90436. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90437. */
  90438. then(action: Action): Action;
  90439. /**
  90440. * Internal only
  90441. * @hidden
  90442. */
  90443. _getProperty(propertyPath: string): string;
  90444. /**
  90445. * Internal only
  90446. * @hidden
  90447. */
  90448. _getEffectiveTarget(target: any, propertyPath: string): any;
  90449. /**
  90450. * Serialize placeholder for child classes
  90451. * @param parent of child
  90452. * @returns the serialized object
  90453. */
  90454. serialize(parent: any): any;
  90455. /**
  90456. * Internal only called by serialize
  90457. * @hidden
  90458. */
  90459. protected _serialize(serializedAction: any, parent?: any): any;
  90460. /**
  90461. * Internal only
  90462. * @hidden
  90463. */
  90464. static _SerializeValueAsString: (value: any) => string;
  90465. /**
  90466. * Internal only
  90467. * @hidden
  90468. */
  90469. static _GetTargetProperty: (target: Node | Scene) => {
  90470. name: string;
  90471. targetType: string;
  90472. value: string;
  90473. };
  90474. }
  90475. }
  90476. declare module BABYLON {
  90477. /**
  90478. * A Condition applied to an Action
  90479. */
  90480. export class Condition {
  90481. /**
  90482. * Internal only - manager for action
  90483. * @hidden
  90484. */
  90485. _actionManager: ActionManager;
  90486. /**
  90487. * Internal only
  90488. * @hidden
  90489. */
  90490. _evaluationId: number;
  90491. /**
  90492. * Internal only
  90493. * @hidden
  90494. */
  90495. _currentResult: boolean;
  90496. /**
  90497. * Creates a new Condition
  90498. * @param actionManager the manager of the action the condition is applied to
  90499. */
  90500. constructor(actionManager: ActionManager);
  90501. /**
  90502. * Check if the current condition is valid
  90503. * @returns a boolean
  90504. */
  90505. isValid(): boolean;
  90506. /**
  90507. * Internal only
  90508. * @hidden
  90509. */
  90510. _getProperty(propertyPath: string): string;
  90511. /**
  90512. * Internal only
  90513. * @hidden
  90514. */
  90515. _getEffectiveTarget(target: any, propertyPath: string): any;
  90516. /**
  90517. * Serialize placeholder for child classes
  90518. * @returns the serialized object
  90519. */
  90520. serialize(): any;
  90521. /**
  90522. * Internal only
  90523. * @hidden
  90524. */
  90525. protected _serialize(serializedCondition: any): any;
  90526. }
  90527. /**
  90528. * Defines specific conditional operators as extensions of Condition
  90529. */
  90530. export class ValueCondition extends Condition {
  90531. /** path to specify the property of the target the conditional operator uses */
  90532. propertyPath: string;
  90533. /** the value compared by the conditional operator against the current value of the property */
  90534. value: any;
  90535. /** the conditional operator, default ValueCondition.IsEqual */
  90536. operator: number;
  90537. /**
  90538. * Internal only
  90539. * @hidden
  90540. */
  90541. private static _IsEqual;
  90542. /**
  90543. * Internal only
  90544. * @hidden
  90545. */
  90546. private static _IsDifferent;
  90547. /**
  90548. * Internal only
  90549. * @hidden
  90550. */
  90551. private static _IsGreater;
  90552. /**
  90553. * Internal only
  90554. * @hidden
  90555. */
  90556. private static _IsLesser;
  90557. /**
  90558. * returns the number for IsEqual
  90559. */
  90560. static get IsEqual(): number;
  90561. /**
  90562. * Returns the number for IsDifferent
  90563. */
  90564. static get IsDifferent(): number;
  90565. /**
  90566. * Returns the number for IsGreater
  90567. */
  90568. static get IsGreater(): number;
  90569. /**
  90570. * Returns the number for IsLesser
  90571. */
  90572. static get IsLesser(): number;
  90573. /**
  90574. * Internal only The action manager for the condition
  90575. * @hidden
  90576. */
  90577. _actionManager: ActionManager;
  90578. /**
  90579. * Internal only
  90580. * @hidden
  90581. */
  90582. private _target;
  90583. /**
  90584. * Internal only
  90585. * @hidden
  90586. */
  90587. private _effectiveTarget;
  90588. /**
  90589. * Internal only
  90590. * @hidden
  90591. */
  90592. private _property;
  90593. /**
  90594. * Creates a new ValueCondition
  90595. * @param actionManager manager for the action the condition applies to
  90596. * @param target for the action
  90597. * @param propertyPath path to specify the property of the target the conditional operator uses
  90598. * @param value the value compared by the conditional operator against the current value of the property
  90599. * @param operator the conditional operator, default ValueCondition.IsEqual
  90600. */
  90601. constructor(actionManager: ActionManager, target: any,
  90602. /** path to specify the property of the target the conditional operator uses */
  90603. propertyPath: string,
  90604. /** the value compared by the conditional operator against the current value of the property */
  90605. value: any,
  90606. /** the conditional operator, default ValueCondition.IsEqual */
  90607. operator?: number);
  90608. /**
  90609. * Compares the given value with the property value for the specified conditional operator
  90610. * @returns the result of the comparison
  90611. */
  90612. isValid(): boolean;
  90613. /**
  90614. * Serialize the ValueCondition into a JSON compatible object
  90615. * @returns serialization object
  90616. */
  90617. serialize(): any;
  90618. /**
  90619. * Gets the name of the conditional operator for the ValueCondition
  90620. * @param operator the conditional operator
  90621. * @returns the name
  90622. */
  90623. static GetOperatorName(operator: number): string;
  90624. }
  90625. /**
  90626. * Defines a predicate condition as an extension of Condition
  90627. */
  90628. export class PredicateCondition extends Condition {
  90629. /** defines the predicate function used to validate the condition */
  90630. predicate: () => boolean;
  90631. /**
  90632. * Internal only - manager for action
  90633. * @hidden
  90634. */
  90635. _actionManager: ActionManager;
  90636. /**
  90637. * Creates a new PredicateCondition
  90638. * @param actionManager manager for the action the condition applies to
  90639. * @param predicate defines the predicate function used to validate the condition
  90640. */
  90641. constructor(actionManager: ActionManager,
  90642. /** defines the predicate function used to validate the condition */
  90643. predicate: () => boolean);
  90644. /**
  90645. * @returns the validity of the predicate condition
  90646. */
  90647. isValid(): boolean;
  90648. }
  90649. /**
  90650. * Defines a state condition as an extension of Condition
  90651. */
  90652. export class StateCondition extends Condition {
  90653. /** Value to compare with target state */
  90654. value: string;
  90655. /**
  90656. * Internal only - manager for action
  90657. * @hidden
  90658. */
  90659. _actionManager: ActionManager;
  90660. /**
  90661. * Internal only
  90662. * @hidden
  90663. */
  90664. private _target;
  90665. /**
  90666. * Creates a new StateCondition
  90667. * @param actionManager manager for the action the condition applies to
  90668. * @param target of the condition
  90669. * @param value to compare with target state
  90670. */
  90671. constructor(actionManager: ActionManager, target: any,
  90672. /** Value to compare with target state */
  90673. value: string);
  90674. /**
  90675. * Gets a boolean indicating if the current condition is met
  90676. * @returns the validity of the state
  90677. */
  90678. isValid(): boolean;
  90679. /**
  90680. * Serialize the StateCondition into a JSON compatible object
  90681. * @returns serialization object
  90682. */
  90683. serialize(): any;
  90684. }
  90685. }
  90686. declare module BABYLON {
  90687. /**
  90688. * This defines an action responsible to toggle a boolean once triggered.
  90689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90690. */
  90691. export class SwitchBooleanAction extends Action {
  90692. /**
  90693. * The path to the boolean property in the target object
  90694. */
  90695. propertyPath: string;
  90696. private _target;
  90697. private _effectiveTarget;
  90698. private _property;
  90699. /**
  90700. * Instantiate the action
  90701. * @param triggerOptions defines the trigger options
  90702. * @param target defines the object containing the boolean
  90703. * @param propertyPath defines the path to the boolean property in the target object
  90704. * @param condition defines the trigger related conditions
  90705. */
  90706. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90707. /** @hidden */
  90708. _prepare(): void;
  90709. /**
  90710. * Execute the action toggle the boolean value.
  90711. */
  90712. execute(): void;
  90713. /**
  90714. * Serializes the actions and its related information.
  90715. * @param parent defines the object to serialize in
  90716. * @returns the serialized object
  90717. */
  90718. serialize(parent: any): any;
  90719. }
  90720. /**
  90721. * This defines an action responsible to set a the state field of the target
  90722. * to a desired value once triggered.
  90723. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90724. */
  90725. export class SetStateAction extends Action {
  90726. /**
  90727. * The value to store in the state field.
  90728. */
  90729. value: string;
  90730. private _target;
  90731. /**
  90732. * Instantiate the action
  90733. * @param triggerOptions defines the trigger options
  90734. * @param target defines the object containing the state property
  90735. * @param value defines the value to store in the state field
  90736. * @param condition defines the trigger related conditions
  90737. */
  90738. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90739. /**
  90740. * Execute the action and store the value on the target state property.
  90741. */
  90742. execute(): void;
  90743. /**
  90744. * Serializes the actions and its related information.
  90745. * @param parent defines the object to serialize in
  90746. * @returns the serialized object
  90747. */
  90748. serialize(parent: any): any;
  90749. }
  90750. /**
  90751. * This defines an action responsible to set a property of the target
  90752. * to a desired value once triggered.
  90753. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90754. */
  90755. export class SetValueAction extends Action {
  90756. /**
  90757. * The path of the property to set in the target.
  90758. */
  90759. propertyPath: string;
  90760. /**
  90761. * The value to set in the property
  90762. */
  90763. value: any;
  90764. private _target;
  90765. private _effectiveTarget;
  90766. private _property;
  90767. /**
  90768. * Instantiate the action
  90769. * @param triggerOptions defines the trigger options
  90770. * @param target defines the object containing the property
  90771. * @param propertyPath defines the path of the property to set in the target
  90772. * @param value defines the value to set in the property
  90773. * @param condition defines the trigger related conditions
  90774. */
  90775. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90776. /** @hidden */
  90777. _prepare(): void;
  90778. /**
  90779. * Execute the action and set the targetted property to the desired value.
  90780. */
  90781. execute(): void;
  90782. /**
  90783. * Serializes the actions and its related information.
  90784. * @param parent defines the object to serialize in
  90785. * @returns the serialized object
  90786. */
  90787. serialize(parent: any): any;
  90788. }
  90789. /**
  90790. * This defines an action responsible to increment the target value
  90791. * to a desired value once triggered.
  90792. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90793. */
  90794. export class IncrementValueAction extends Action {
  90795. /**
  90796. * The path of the property to increment in the target.
  90797. */
  90798. propertyPath: string;
  90799. /**
  90800. * The value we should increment the property by.
  90801. */
  90802. value: any;
  90803. private _target;
  90804. private _effectiveTarget;
  90805. private _property;
  90806. /**
  90807. * Instantiate the action
  90808. * @param triggerOptions defines the trigger options
  90809. * @param target defines the object containing the property
  90810. * @param propertyPath defines the path of the property to increment in the target
  90811. * @param value defines the value value we should increment the property by
  90812. * @param condition defines the trigger related conditions
  90813. */
  90814. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90815. /** @hidden */
  90816. _prepare(): void;
  90817. /**
  90818. * Execute the action and increment the target of the value amount.
  90819. */
  90820. execute(): void;
  90821. /**
  90822. * Serializes the actions and its related information.
  90823. * @param parent defines the object to serialize in
  90824. * @returns the serialized object
  90825. */
  90826. serialize(parent: any): any;
  90827. }
  90828. /**
  90829. * This defines an action responsible to start an animation once triggered.
  90830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90831. */
  90832. export class PlayAnimationAction extends Action {
  90833. /**
  90834. * Where the animation should start (animation frame)
  90835. */
  90836. from: number;
  90837. /**
  90838. * Where the animation should stop (animation frame)
  90839. */
  90840. to: number;
  90841. /**
  90842. * Define if the animation should loop or stop after the first play.
  90843. */
  90844. loop?: boolean;
  90845. private _target;
  90846. /**
  90847. * Instantiate the action
  90848. * @param triggerOptions defines the trigger options
  90849. * @param target defines the target animation or animation name
  90850. * @param from defines from where the animation should start (animation frame)
  90851. * @param end defines where the animation should stop (animation frame)
  90852. * @param loop defines if the animation should loop or stop after the first play
  90853. * @param condition defines the trigger related conditions
  90854. */
  90855. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90856. /** @hidden */
  90857. _prepare(): void;
  90858. /**
  90859. * Execute the action and play the animation.
  90860. */
  90861. execute(): void;
  90862. /**
  90863. * Serializes the actions and its related information.
  90864. * @param parent defines the object to serialize in
  90865. * @returns the serialized object
  90866. */
  90867. serialize(parent: any): any;
  90868. }
  90869. /**
  90870. * This defines an action responsible to stop an animation once triggered.
  90871. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90872. */
  90873. export class StopAnimationAction extends Action {
  90874. private _target;
  90875. /**
  90876. * Instantiate the action
  90877. * @param triggerOptions defines the trigger options
  90878. * @param target defines the target animation or animation name
  90879. * @param condition defines the trigger related conditions
  90880. */
  90881. constructor(triggerOptions: any, target: any, condition?: Condition);
  90882. /** @hidden */
  90883. _prepare(): void;
  90884. /**
  90885. * Execute the action and stop the animation.
  90886. */
  90887. execute(): void;
  90888. /**
  90889. * Serializes the actions and its related information.
  90890. * @param parent defines the object to serialize in
  90891. * @returns the serialized object
  90892. */
  90893. serialize(parent: any): any;
  90894. }
  90895. /**
  90896. * This defines an action responsible that does nothing once triggered.
  90897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90898. */
  90899. export class DoNothingAction extends Action {
  90900. /**
  90901. * Instantiate the action
  90902. * @param triggerOptions defines the trigger options
  90903. * @param condition defines the trigger related conditions
  90904. */
  90905. constructor(triggerOptions?: any, condition?: Condition);
  90906. /**
  90907. * Execute the action and do nothing.
  90908. */
  90909. execute(): void;
  90910. /**
  90911. * Serializes the actions and its related information.
  90912. * @param parent defines the object to serialize in
  90913. * @returns the serialized object
  90914. */
  90915. serialize(parent: any): any;
  90916. }
  90917. /**
  90918. * This defines an action responsible to trigger several actions once triggered.
  90919. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90920. */
  90921. export class CombineAction extends Action {
  90922. /**
  90923. * The list of aggregated animations to run.
  90924. */
  90925. children: Action[];
  90926. /**
  90927. * Instantiate the action
  90928. * @param triggerOptions defines the trigger options
  90929. * @param children defines the list of aggregated animations to run
  90930. * @param condition defines the trigger related conditions
  90931. */
  90932. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90933. /** @hidden */
  90934. _prepare(): void;
  90935. /**
  90936. * Execute the action and executes all the aggregated actions.
  90937. */
  90938. execute(evt: ActionEvent): void;
  90939. /**
  90940. * Serializes the actions and its related information.
  90941. * @param parent defines the object to serialize in
  90942. * @returns the serialized object
  90943. */
  90944. serialize(parent: any): any;
  90945. }
  90946. /**
  90947. * This defines an action responsible to run code (external event) once triggered.
  90948. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90949. */
  90950. export class ExecuteCodeAction extends Action {
  90951. /**
  90952. * The callback function to run.
  90953. */
  90954. func: (evt: ActionEvent) => void;
  90955. /**
  90956. * Instantiate the action
  90957. * @param triggerOptions defines the trigger options
  90958. * @param func defines the callback function to run
  90959. * @param condition defines the trigger related conditions
  90960. */
  90961. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90962. /**
  90963. * Execute the action and run the attached code.
  90964. */
  90965. execute(evt: ActionEvent): void;
  90966. }
  90967. /**
  90968. * This defines an action responsible to set the parent property of the target once triggered.
  90969. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  90970. */
  90971. export class SetParentAction extends Action {
  90972. private _parent;
  90973. private _target;
  90974. /**
  90975. * Instantiate the action
  90976. * @param triggerOptions defines the trigger options
  90977. * @param target defines the target containing the parent property
  90978. * @param parent defines from where the animation should start (animation frame)
  90979. * @param condition defines the trigger related conditions
  90980. */
  90981. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90982. /** @hidden */
  90983. _prepare(): void;
  90984. /**
  90985. * Execute the action and set the parent property.
  90986. */
  90987. execute(): void;
  90988. /**
  90989. * Serializes the actions and its related information.
  90990. * @param parent defines the object to serialize in
  90991. * @returns the serialized object
  90992. */
  90993. serialize(parent: any): any;
  90994. }
  90995. }
  90996. declare module BABYLON {
  90997. /**
  90998. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90999. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  91000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91001. */
  91002. export class ActionManager extends AbstractActionManager {
  91003. /**
  91004. * Nothing
  91005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91006. */
  91007. static readonly NothingTrigger: number;
  91008. /**
  91009. * On pick
  91010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91011. */
  91012. static readonly OnPickTrigger: number;
  91013. /**
  91014. * On left pick
  91015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91016. */
  91017. static readonly OnLeftPickTrigger: number;
  91018. /**
  91019. * On right pick
  91020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91021. */
  91022. static readonly OnRightPickTrigger: number;
  91023. /**
  91024. * On center pick
  91025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91026. */
  91027. static readonly OnCenterPickTrigger: number;
  91028. /**
  91029. * On pick down
  91030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91031. */
  91032. static readonly OnPickDownTrigger: number;
  91033. /**
  91034. * On double pick
  91035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91036. */
  91037. static readonly OnDoublePickTrigger: number;
  91038. /**
  91039. * On pick up
  91040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91041. */
  91042. static readonly OnPickUpTrigger: number;
  91043. /**
  91044. * On pick out.
  91045. * This trigger will only be raised if you also declared a OnPickDown
  91046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91047. */
  91048. static readonly OnPickOutTrigger: number;
  91049. /**
  91050. * On long press
  91051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91052. */
  91053. static readonly OnLongPressTrigger: number;
  91054. /**
  91055. * On pointer over
  91056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91057. */
  91058. static readonly OnPointerOverTrigger: number;
  91059. /**
  91060. * On pointer out
  91061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91062. */
  91063. static readonly OnPointerOutTrigger: number;
  91064. /**
  91065. * On every frame
  91066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91067. */
  91068. static readonly OnEveryFrameTrigger: number;
  91069. /**
  91070. * On intersection enter
  91071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91072. */
  91073. static readonly OnIntersectionEnterTrigger: number;
  91074. /**
  91075. * On intersection exit
  91076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91077. */
  91078. static readonly OnIntersectionExitTrigger: number;
  91079. /**
  91080. * On key down
  91081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91082. */
  91083. static readonly OnKeyDownTrigger: number;
  91084. /**
  91085. * On key up
  91086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  91087. */
  91088. static readonly OnKeyUpTrigger: number;
  91089. private _scene;
  91090. /**
  91091. * Creates a new action manager
  91092. * @param scene defines the hosting scene
  91093. */
  91094. constructor(scene: Scene);
  91095. /**
  91096. * Releases all associated resources
  91097. */
  91098. dispose(): void;
  91099. /**
  91100. * Gets hosting scene
  91101. * @returns the hosting scene
  91102. */
  91103. getScene(): Scene;
  91104. /**
  91105. * Does this action manager handles actions of any of the given triggers
  91106. * @param triggers defines the triggers to be tested
  91107. * @return a boolean indicating whether one (or more) of the triggers is handled
  91108. */
  91109. hasSpecificTriggers(triggers: number[]): boolean;
  91110. /**
  91111. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  91112. * speed.
  91113. * @param triggerA defines the trigger to be tested
  91114. * @param triggerB defines the trigger to be tested
  91115. * @return a boolean indicating whether one (or more) of the triggers is handled
  91116. */
  91117. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  91118. /**
  91119. * Does this action manager handles actions of a given trigger
  91120. * @param trigger defines the trigger to be tested
  91121. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  91122. * @return whether the trigger is handled
  91123. */
  91124. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  91125. /**
  91126. * Does this action manager has pointer triggers
  91127. */
  91128. get hasPointerTriggers(): boolean;
  91129. /**
  91130. * Does this action manager has pick triggers
  91131. */
  91132. get hasPickTriggers(): boolean;
  91133. /**
  91134. * Registers an action to this action manager
  91135. * @param action defines the action to be registered
  91136. * @return the action amended (prepared) after registration
  91137. */
  91138. registerAction(action: IAction): Nullable<IAction>;
  91139. /**
  91140. * Unregisters an action to this action manager
  91141. * @param action defines the action to be unregistered
  91142. * @return a boolean indicating whether the action has been unregistered
  91143. */
  91144. unregisterAction(action: IAction): Boolean;
  91145. /**
  91146. * Process a specific trigger
  91147. * @param trigger defines the trigger to process
  91148. * @param evt defines the event details to be processed
  91149. */
  91150. processTrigger(trigger: number, evt?: IActionEvent): void;
  91151. /** @hidden */
  91152. _getEffectiveTarget(target: any, propertyPath: string): any;
  91153. /** @hidden */
  91154. _getProperty(propertyPath: string): string;
  91155. /**
  91156. * Serialize this manager to a JSON object
  91157. * @param name defines the property name to store this manager
  91158. * @returns a JSON representation of this manager
  91159. */
  91160. serialize(name: string): any;
  91161. /**
  91162. * Creates a new ActionManager from a JSON data
  91163. * @param parsedActions defines the JSON data to read from
  91164. * @param object defines the hosting mesh
  91165. * @param scene defines the hosting scene
  91166. */
  91167. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  91168. /**
  91169. * Get a trigger name by index
  91170. * @param trigger defines the trigger index
  91171. * @returns a trigger name
  91172. */
  91173. static GetTriggerName(trigger: number): string;
  91174. }
  91175. }
  91176. declare module BABYLON {
  91177. /**
  91178. * Class used to represent a sprite
  91179. * @see http://doc.babylonjs.com/babylon101/sprites
  91180. */
  91181. export class Sprite {
  91182. /** defines the name */
  91183. name: string;
  91184. /** Gets or sets the current world position */
  91185. position: Vector3;
  91186. /** Gets or sets the main color */
  91187. color: Color4;
  91188. /** Gets or sets the width */
  91189. width: number;
  91190. /** Gets or sets the height */
  91191. height: number;
  91192. /** Gets or sets rotation angle */
  91193. angle: number;
  91194. /** Gets or sets the cell index in the sprite sheet */
  91195. cellIndex: number;
  91196. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  91197. cellRef: string;
  91198. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  91199. invertU: number;
  91200. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  91201. invertV: number;
  91202. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  91203. disposeWhenFinishedAnimating: boolean;
  91204. /** Gets the list of attached animations */
  91205. animations: Animation[];
  91206. /** Gets or sets a boolean indicating if the sprite can be picked */
  91207. isPickable: boolean;
  91208. /**
  91209. * Gets or sets the associated action manager
  91210. */
  91211. actionManager: Nullable<ActionManager>;
  91212. private _animationStarted;
  91213. private _loopAnimation;
  91214. private _fromIndex;
  91215. private _toIndex;
  91216. private _delay;
  91217. private _direction;
  91218. private _manager;
  91219. private _time;
  91220. private _onAnimationEnd;
  91221. /**
  91222. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  91223. */
  91224. isVisible: boolean;
  91225. /**
  91226. * Gets or sets the sprite size
  91227. */
  91228. get size(): number;
  91229. set size(value: number);
  91230. /**
  91231. * Creates a new Sprite
  91232. * @param name defines the name
  91233. * @param manager defines the manager
  91234. */
  91235. constructor(
  91236. /** defines the name */
  91237. name: string, manager: ISpriteManager);
  91238. /**
  91239. * Starts an animation
  91240. * @param from defines the initial key
  91241. * @param to defines the end key
  91242. * @param loop defines if the animation must loop
  91243. * @param delay defines the start delay (in ms)
  91244. * @param onAnimationEnd defines a callback to call when animation ends
  91245. */
  91246. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  91247. /** Stops current animation (if any) */
  91248. stopAnimation(): void;
  91249. /** @hidden */
  91250. _animate(deltaTime: number): void;
  91251. /** Release associated resources */
  91252. dispose(): void;
  91253. }
  91254. }
  91255. declare module BABYLON {
  91256. /**
  91257. * Information about the result of picking within a scene
  91258. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  91259. */
  91260. export class PickingInfo {
  91261. /** @hidden */
  91262. _pickingUnavailable: boolean;
  91263. /**
  91264. * If the pick collided with an object
  91265. */
  91266. hit: boolean;
  91267. /**
  91268. * Distance away where the pick collided
  91269. */
  91270. distance: number;
  91271. /**
  91272. * The location of pick collision
  91273. */
  91274. pickedPoint: Nullable<Vector3>;
  91275. /**
  91276. * The mesh corresponding the the pick collision
  91277. */
  91278. pickedMesh: Nullable<AbstractMesh>;
  91279. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  91280. bu: number;
  91281. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  91282. bv: number;
  91283. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  91284. faceId: number;
  91285. /** Id of the the submesh that was picked */
  91286. subMeshId: number;
  91287. /** If a sprite was picked, this will be the sprite the pick collided with */
  91288. pickedSprite: Nullable<Sprite>;
  91289. /**
  91290. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  91291. */
  91292. originMesh: Nullable<AbstractMesh>;
  91293. /**
  91294. * The ray that was used to perform the picking.
  91295. */
  91296. ray: Nullable<Ray>;
  91297. /**
  91298. * Gets the normal correspodning to the face the pick collided with
  91299. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  91300. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  91301. * @returns The normal correspodning to the face the pick collided with
  91302. */
  91303. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  91304. /**
  91305. * Gets the texture coordinates of where the pick occured
  91306. * @returns the vector containing the coordnates of the texture
  91307. */
  91308. getTextureCoordinates(): Nullable<Vector2>;
  91309. }
  91310. }
  91311. declare module BABYLON {
  91312. /**
  91313. * Gather the list of pointer event types as constants.
  91314. */
  91315. export class PointerEventTypes {
  91316. /**
  91317. * 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.
  91318. */
  91319. static readonly POINTERDOWN: number;
  91320. /**
  91321. * The pointerup event is fired when a pointer is no longer active.
  91322. */
  91323. static readonly POINTERUP: number;
  91324. /**
  91325. * The pointermove event is fired when a pointer changes coordinates.
  91326. */
  91327. static readonly POINTERMOVE: number;
  91328. /**
  91329. * The pointerwheel event is fired when a mouse wheel has been rotated.
  91330. */
  91331. static readonly POINTERWHEEL: number;
  91332. /**
  91333. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  91334. */
  91335. static readonly POINTERPICK: number;
  91336. /**
  91337. * The pointertap event is fired when a the object has been touched and released without drag.
  91338. */
  91339. static readonly POINTERTAP: number;
  91340. /**
  91341. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  91342. */
  91343. static readonly POINTERDOUBLETAP: number;
  91344. }
  91345. /**
  91346. * Base class of pointer info types.
  91347. */
  91348. export class PointerInfoBase {
  91349. /**
  91350. * Defines the type of event (PointerEventTypes)
  91351. */
  91352. type: number;
  91353. /**
  91354. * Defines the related dom event
  91355. */
  91356. event: PointerEvent | MouseWheelEvent;
  91357. /**
  91358. * Instantiates the base class of pointers info.
  91359. * @param type Defines the type of event (PointerEventTypes)
  91360. * @param event Defines the related dom event
  91361. */
  91362. constructor(
  91363. /**
  91364. * Defines the type of event (PointerEventTypes)
  91365. */
  91366. type: number,
  91367. /**
  91368. * Defines the related dom event
  91369. */
  91370. event: PointerEvent | MouseWheelEvent);
  91371. }
  91372. /**
  91373. * This class is used to store pointer related info for the onPrePointerObservable event.
  91374. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  91375. */
  91376. export class PointerInfoPre extends PointerInfoBase {
  91377. /**
  91378. * Ray from a pointer if availible (eg. 6dof controller)
  91379. */
  91380. ray: Nullable<Ray>;
  91381. /**
  91382. * Defines the local position of the pointer on the canvas.
  91383. */
  91384. localPosition: Vector2;
  91385. /**
  91386. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  91387. */
  91388. skipOnPointerObservable: boolean;
  91389. /**
  91390. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  91391. * @param type Defines the type of event (PointerEventTypes)
  91392. * @param event Defines the related dom event
  91393. * @param localX Defines the local x coordinates of the pointer when the event occured
  91394. * @param localY Defines the local y coordinates of the pointer when the event occured
  91395. */
  91396. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  91397. }
  91398. /**
  91399. * This type contains all the data related to a pointer event in Babylon.js.
  91400. * 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.
  91401. */
  91402. export class PointerInfo extends PointerInfoBase {
  91403. /**
  91404. * Defines the picking info associated to the info (if any)\
  91405. */
  91406. pickInfo: Nullable<PickingInfo>;
  91407. /**
  91408. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  91409. * @param type Defines the type of event (PointerEventTypes)
  91410. * @param event Defines the related dom event
  91411. * @param pickInfo Defines the picking info associated to the info (if any)\
  91412. */
  91413. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  91414. /**
  91415. * Defines the picking info associated to the info (if any)\
  91416. */
  91417. pickInfo: Nullable<PickingInfo>);
  91418. }
  91419. /**
  91420. * Data relating to a touch event on the screen.
  91421. */
  91422. export interface PointerTouch {
  91423. /**
  91424. * X coordinate of touch.
  91425. */
  91426. x: number;
  91427. /**
  91428. * Y coordinate of touch.
  91429. */
  91430. y: number;
  91431. /**
  91432. * Id of touch. Unique for each finger.
  91433. */
  91434. pointerId: number;
  91435. /**
  91436. * Event type passed from DOM.
  91437. */
  91438. type: any;
  91439. }
  91440. }
  91441. declare module BABYLON {
  91442. /**
  91443. * Manage the mouse inputs to control the movement of a free camera.
  91444. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91445. */
  91446. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  91447. /**
  91448. * Define if touch is enabled in the mouse input
  91449. */
  91450. touchEnabled: boolean;
  91451. /**
  91452. * Defines the camera the input is attached to.
  91453. */
  91454. camera: FreeCamera;
  91455. /**
  91456. * Defines the buttons associated with the input to handle camera move.
  91457. */
  91458. buttons: number[];
  91459. /**
  91460. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  91461. */
  91462. angularSensibility: number;
  91463. private _pointerInput;
  91464. private _onMouseMove;
  91465. private _observer;
  91466. private previousPosition;
  91467. /**
  91468. * Observable for when a pointer move event occurs containing the move offset
  91469. */
  91470. onPointerMovedObservable: Observable<{
  91471. offsetX: number;
  91472. offsetY: number;
  91473. }>;
  91474. /**
  91475. * @hidden
  91476. * If the camera should be rotated automatically based on pointer movement
  91477. */
  91478. _allowCameraRotation: boolean;
  91479. /**
  91480. * Manage the mouse inputs to control the movement of a free camera.
  91481. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91482. * @param touchEnabled Defines if touch is enabled or not
  91483. */
  91484. constructor(
  91485. /**
  91486. * Define if touch is enabled in the mouse input
  91487. */
  91488. touchEnabled?: boolean);
  91489. /**
  91490. * Attach the input controls to a specific dom element to get the input from.
  91491. * @param element Defines the element the controls should be listened from
  91492. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91493. */
  91494. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91495. /**
  91496. * Called on JS contextmenu event.
  91497. * Override this method to provide functionality.
  91498. */
  91499. protected onContextMenu(evt: PointerEvent): void;
  91500. /**
  91501. * Detach the current controls from the specified dom element.
  91502. * @param element Defines the element to stop listening the inputs from
  91503. */
  91504. detachControl(element: Nullable<HTMLElement>): void;
  91505. /**
  91506. * Gets the class name of the current intput.
  91507. * @returns the class name
  91508. */
  91509. getClassName(): string;
  91510. /**
  91511. * Get the friendly name associated with the input class.
  91512. * @returns the input friendly name
  91513. */
  91514. getSimpleName(): string;
  91515. }
  91516. }
  91517. declare module BABYLON {
  91518. /**
  91519. * Manage the touch inputs to control the movement of a free camera.
  91520. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91521. */
  91522. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  91523. /**
  91524. * Defines the camera the input is attached to.
  91525. */
  91526. camera: FreeCamera;
  91527. /**
  91528. * Defines the touch sensibility for rotation.
  91529. * The higher the faster.
  91530. */
  91531. touchAngularSensibility: number;
  91532. /**
  91533. * Defines the touch sensibility for move.
  91534. * The higher the faster.
  91535. */
  91536. touchMoveSensibility: number;
  91537. private _offsetX;
  91538. private _offsetY;
  91539. private _pointerPressed;
  91540. private _pointerInput;
  91541. private _observer;
  91542. private _onLostFocus;
  91543. /**
  91544. * Attach the input controls to a specific dom element to get the input from.
  91545. * @param element Defines the element the controls should be listened from
  91546. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91547. */
  91548. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91549. /**
  91550. * Detach the current controls from the specified dom element.
  91551. * @param element Defines the element to stop listening the inputs from
  91552. */
  91553. detachControl(element: Nullable<HTMLElement>): void;
  91554. /**
  91555. * Update the current camera state depending on the inputs that have been used this frame.
  91556. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  91557. */
  91558. checkInputs(): void;
  91559. /**
  91560. * Gets the class name of the current intput.
  91561. * @returns the class name
  91562. */
  91563. getClassName(): string;
  91564. /**
  91565. * Get the friendly name associated with the input class.
  91566. * @returns the input friendly name
  91567. */
  91568. getSimpleName(): string;
  91569. }
  91570. }
  91571. declare module BABYLON {
  91572. /**
  91573. * Default Inputs manager for the FreeCamera.
  91574. * It groups all the default supported inputs for ease of use.
  91575. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  91576. */
  91577. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  91578. /**
  91579. * @hidden
  91580. */
  91581. _mouseInput: Nullable<FreeCameraMouseInput>;
  91582. /**
  91583. * Instantiates a new FreeCameraInputsManager.
  91584. * @param camera Defines the camera the inputs belong to
  91585. */
  91586. constructor(camera: FreeCamera);
  91587. /**
  91588. * Add keyboard input support to the input manager.
  91589. * @returns the current input manager
  91590. */
  91591. addKeyboard(): FreeCameraInputsManager;
  91592. /**
  91593. * Add mouse input support to the input manager.
  91594. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  91595. * @returns the current input manager
  91596. */
  91597. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  91598. /**
  91599. * Removes the mouse input support from the manager
  91600. * @returns the current input manager
  91601. */
  91602. removeMouse(): FreeCameraInputsManager;
  91603. /**
  91604. * Add touch input support to the input manager.
  91605. * @returns the current input manager
  91606. */
  91607. addTouch(): FreeCameraInputsManager;
  91608. /**
  91609. * Remove all attached input methods from a camera
  91610. */
  91611. clear(): void;
  91612. }
  91613. }
  91614. declare module BABYLON {
  91615. /**
  91616. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91617. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  91618. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91619. */
  91620. export class FreeCamera extends TargetCamera {
  91621. /**
  91622. * Define the collision ellipsoid of the camera.
  91623. * This is helpful to simulate a camera body like the player body around the camera
  91624. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  91625. */
  91626. ellipsoid: Vector3;
  91627. /**
  91628. * Define an offset for the position of the ellipsoid around the camera.
  91629. * This can be helpful to determine the center of the body near the gravity center of the body
  91630. * instead of its head.
  91631. */
  91632. ellipsoidOffset: Vector3;
  91633. /**
  91634. * Enable or disable collisions of the camera with the rest of the scene objects.
  91635. */
  91636. checkCollisions: boolean;
  91637. /**
  91638. * Enable or disable gravity on the camera.
  91639. */
  91640. applyGravity: boolean;
  91641. /**
  91642. * Define the input manager associated to the camera.
  91643. */
  91644. inputs: FreeCameraInputsManager;
  91645. /**
  91646. * Gets the input sensibility for a mouse input. (default is 2000.0)
  91647. * Higher values reduce sensitivity.
  91648. */
  91649. get angularSensibility(): number;
  91650. /**
  91651. * Sets the input sensibility for a mouse input. (default is 2000.0)
  91652. * Higher values reduce sensitivity.
  91653. */
  91654. set angularSensibility(value: number);
  91655. /**
  91656. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  91657. */
  91658. get keysUp(): number[];
  91659. set keysUp(value: number[]);
  91660. /**
  91661. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  91662. */
  91663. get keysDown(): number[];
  91664. set keysDown(value: number[]);
  91665. /**
  91666. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  91667. */
  91668. get keysLeft(): number[];
  91669. set keysLeft(value: number[]);
  91670. /**
  91671. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  91672. */
  91673. get keysRight(): number[];
  91674. set keysRight(value: number[]);
  91675. /**
  91676. * Event raised when the camera collide with a mesh in the scene.
  91677. */
  91678. onCollide: (collidedMesh: AbstractMesh) => void;
  91679. private _collider;
  91680. private _needMoveForGravity;
  91681. private _oldPosition;
  91682. private _diffPosition;
  91683. private _newPosition;
  91684. /** @hidden */
  91685. _localDirection: Vector3;
  91686. /** @hidden */
  91687. _transformedDirection: Vector3;
  91688. /**
  91689. * Instantiates a Free Camera.
  91690. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  91691. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  91692. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  91693. * @param name Define the name of the camera in the scene
  91694. * @param position Define the start position of the camera in the scene
  91695. * @param scene Define the scene the camera belongs to
  91696. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  91697. */
  91698. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91699. /**
  91700. * Attached controls to the current camera.
  91701. * @param element Defines the element the controls should be listened from
  91702. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91703. */
  91704. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91705. /**
  91706. * Detach the current controls from the camera.
  91707. * The camera will stop reacting to inputs.
  91708. * @param element Defines the element to stop listening the inputs from
  91709. */
  91710. detachControl(element: HTMLElement): void;
  91711. private _collisionMask;
  91712. /**
  91713. * Define a collision mask to limit the list of object the camera can collide with
  91714. */
  91715. get collisionMask(): number;
  91716. set collisionMask(mask: number);
  91717. /** @hidden */
  91718. _collideWithWorld(displacement: Vector3): void;
  91719. private _onCollisionPositionChange;
  91720. /** @hidden */
  91721. _checkInputs(): void;
  91722. /** @hidden */
  91723. _decideIfNeedsToMove(): boolean;
  91724. /** @hidden */
  91725. _updatePosition(): void;
  91726. /**
  91727. * Destroy the camera and release the current resources hold by it.
  91728. */
  91729. dispose(): void;
  91730. /**
  91731. * Gets the current object class name.
  91732. * @return the class name
  91733. */
  91734. getClassName(): string;
  91735. }
  91736. }
  91737. declare module BABYLON {
  91738. /**
  91739. * Represents a gamepad control stick position
  91740. */
  91741. export class StickValues {
  91742. /**
  91743. * The x component of the control stick
  91744. */
  91745. x: number;
  91746. /**
  91747. * The y component of the control stick
  91748. */
  91749. y: number;
  91750. /**
  91751. * Initializes the gamepad x and y control stick values
  91752. * @param x The x component of the gamepad control stick value
  91753. * @param y The y component of the gamepad control stick value
  91754. */
  91755. constructor(
  91756. /**
  91757. * The x component of the control stick
  91758. */
  91759. x: number,
  91760. /**
  91761. * The y component of the control stick
  91762. */
  91763. y: number);
  91764. }
  91765. /**
  91766. * An interface which manages callbacks for gamepad button changes
  91767. */
  91768. export interface GamepadButtonChanges {
  91769. /**
  91770. * Called when a gamepad has been changed
  91771. */
  91772. changed: boolean;
  91773. /**
  91774. * Called when a gamepad press event has been triggered
  91775. */
  91776. pressChanged: boolean;
  91777. /**
  91778. * Called when a touch event has been triggered
  91779. */
  91780. touchChanged: boolean;
  91781. /**
  91782. * Called when a value has changed
  91783. */
  91784. valueChanged: boolean;
  91785. }
  91786. /**
  91787. * Represents a gamepad
  91788. */
  91789. export class Gamepad {
  91790. /**
  91791. * The id of the gamepad
  91792. */
  91793. id: string;
  91794. /**
  91795. * The index of the gamepad
  91796. */
  91797. index: number;
  91798. /**
  91799. * The browser gamepad
  91800. */
  91801. browserGamepad: any;
  91802. /**
  91803. * Specifies what type of gamepad this represents
  91804. */
  91805. type: number;
  91806. private _leftStick;
  91807. private _rightStick;
  91808. /** @hidden */
  91809. _isConnected: boolean;
  91810. private _leftStickAxisX;
  91811. private _leftStickAxisY;
  91812. private _rightStickAxisX;
  91813. private _rightStickAxisY;
  91814. /**
  91815. * Triggered when the left control stick has been changed
  91816. */
  91817. private _onleftstickchanged;
  91818. /**
  91819. * Triggered when the right control stick has been changed
  91820. */
  91821. private _onrightstickchanged;
  91822. /**
  91823. * Represents a gamepad controller
  91824. */
  91825. static GAMEPAD: number;
  91826. /**
  91827. * Represents a generic controller
  91828. */
  91829. static GENERIC: number;
  91830. /**
  91831. * Represents an XBox controller
  91832. */
  91833. static XBOX: number;
  91834. /**
  91835. * Represents a pose-enabled controller
  91836. */
  91837. static POSE_ENABLED: number;
  91838. /**
  91839. * Represents an Dual Shock controller
  91840. */
  91841. static DUALSHOCK: number;
  91842. /**
  91843. * Specifies whether the left control stick should be Y-inverted
  91844. */
  91845. protected _invertLeftStickY: boolean;
  91846. /**
  91847. * Specifies if the gamepad has been connected
  91848. */
  91849. get isConnected(): boolean;
  91850. /**
  91851. * Initializes the gamepad
  91852. * @param id The id of the gamepad
  91853. * @param index The index of the gamepad
  91854. * @param browserGamepad The browser gamepad
  91855. * @param leftStickX The x component of the left joystick
  91856. * @param leftStickY The y component of the left joystick
  91857. * @param rightStickX The x component of the right joystick
  91858. * @param rightStickY The y component of the right joystick
  91859. */
  91860. constructor(
  91861. /**
  91862. * The id of the gamepad
  91863. */
  91864. id: string,
  91865. /**
  91866. * The index of the gamepad
  91867. */
  91868. index: number,
  91869. /**
  91870. * The browser gamepad
  91871. */
  91872. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  91873. /**
  91874. * Callback triggered when the left joystick has changed
  91875. * @param callback
  91876. */
  91877. onleftstickchanged(callback: (values: StickValues) => void): void;
  91878. /**
  91879. * Callback triggered when the right joystick has changed
  91880. * @param callback
  91881. */
  91882. onrightstickchanged(callback: (values: StickValues) => void): void;
  91883. /**
  91884. * Gets the left joystick
  91885. */
  91886. get leftStick(): StickValues;
  91887. /**
  91888. * Sets the left joystick values
  91889. */
  91890. set leftStick(newValues: StickValues);
  91891. /**
  91892. * Gets the right joystick
  91893. */
  91894. get rightStick(): StickValues;
  91895. /**
  91896. * Sets the right joystick value
  91897. */
  91898. set rightStick(newValues: StickValues);
  91899. /**
  91900. * Updates the gamepad joystick positions
  91901. */
  91902. update(): void;
  91903. /**
  91904. * Disposes the gamepad
  91905. */
  91906. dispose(): void;
  91907. }
  91908. /**
  91909. * Represents a generic gamepad
  91910. */
  91911. export class GenericPad extends Gamepad {
  91912. private _buttons;
  91913. private _onbuttondown;
  91914. private _onbuttonup;
  91915. /**
  91916. * Observable triggered when a button has been pressed
  91917. */
  91918. onButtonDownObservable: Observable<number>;
  91919. /**
  91920. * Observable triggered when a button has been released
  91921. */
  91922. onButtonUpObservable: Observable<number>;
  91923. /**
  91924. * Callback triggered when a button has been pressed
  91925. * @param callback Called when a button has been pressed
  91926. */
  91927. onbuttondown(callback: (buttonPressed: number) => void): void;
  91928. /**
  91929. * Callback triggered when a button has been released
  91930. * @param callback Called when a button has been released
  91931. */
  91932. onbuttonup(callback: (buttonReleased: number) => void): void;
  91933. /**
  91934. * Initializes the generic gamepad
  91935. * @param id The id of the generic gamepad
  91936. * @param index The index of the generic gamepad
  91937. * @param browserGamepad The browser gamepad
  91938. */
  91939. constructor(id: string, index: number, browserGamepad: any);
  91940. private _setButtonValue;
  91941. /**
  91942. * Updates the generic gamepad
  91943. */
  91944. update(): void;
  91945. /**
  91946. * Disposes the generic gamepad
  91947. */
  91948. dispose(): void;
  91949. }
  91950. }
  91951. declare module BABYLON {
  91952. /**
  91953. * Defines the types of pose enabled controllers that are supported
  91954. */
  91955. export enum PoseEnabledControllerType {
  91956. /**
  91957. * HTC Vive
  91958. */
  91959. VIVE = 0,
  91960. /**
  91961. * Oculus Rift
  91962. */
  91963. OCULUS = 1,
  91964. /**
  91965. * Windows mixed reality
  91966. */
  91967. WINDOWS = 2,
  91968. /**
  91969. * Samsung gear VR
  91970. */
  91971. GEAR_VR = 3,
  91972. /**
  91973. * Google Daydream
  91974. */
  91975. DAYDREAM = 4,
  91976. /**
  91977. * Generic
  91978. */
  91979. GENERIC = 5
  91980. }
  91981. /**
  91982. * Defines the MutableGamepadButton interface for the state of a gamepad button
  91983. */
  91984. export interface MutableGamepadButton {
  91985. /**
  91986. * Value of the button/trigger
  91987. */
  91988. value: number;
  91989. /**
  91990. * If the button/trigger is currently touched
  91991. */
  91992. touched: boolean;
  91993. /**
  91994. * If the button/trigger is currently pressed
  91995. */
  91996. pressed: boolean;
  91997. }
  91998. /**
  91999. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  92000. * @hidden
  92001. */
  92002. export interface ExtendedGamepadButton extends GamepadButton {
  92003. /**
  92004. * If the button/trigger is currently pressed
  92005. */
  92006. readonly pressed: boolean;
  92007. /**
  92008. * If the button/trigger is currently touched
  92009. */
  92010. readonly touched: boolean;
  92011. /**
  92012. * Value of the button/trigger
  92013. */
  92014. readonly value: number;
  92015. }
  92016. /** @hidden */
  92017. export interface _GamePadFactory {
  92018. /**
  92019. * Returns whether or not the current gamepad can be created for this type of controller.
  92020. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92021. * @returns true if it can be created, otherwise false
  92022. */
  92023. canCreate(gamepadInfo: any): boolean;
  92024. /**
  92025. * Creates a new instance of the Gamepad.
  92026. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  92027. * @returns the new gamepad instance
  92028. */
  92029. create(gamepadInfo: any): Gamepad;
  92030. }
  92031. /**
  92032. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92033. */
  92034. export class PoseEnabledControllerHelper {
  92035. /** @hidden */
  92036. static _ControllerFactories: _GamePadFactory[];
  92037. /** @hidden */
  92038. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  92039. /**
  92040. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  92041. * @param vrGamepad the gamepad to initialized
  92042. * @returns a vr controller of the type the gamepad identified as
  92043. */
  92044. static InitiateController(vrGamepad: any): Gamepad;
  92045. }
  92046. /**
  92047. * Defines the PoseEnabledController object that contains state of a vr capable controller
  92048. */
  92049. export class PoseEnabledController extends Gamepad implements PoseControlled {
  92050. /**
  92051. * If the controller is used in a webXR session
  92052. */
  92053. isXR: boolean;
  92054. private _deviceRoomPosition;
  92055. private _deviceRoomRotationQuaternion;
  92056. /**
  92057. * The device position in babylon space
  92058. */
  92059. devicePosition: Vector3;
  92060. /**
  92061. * The device rotation in babylon space
  92062. */
  92063. deviceRotationQuaternion: Quaternion;
  92064. /**
  92065. * The scale factor of the device in babylon space
  92066. */
  92067. deviceScaleFactor: number;
  92068. /**
  92069. * (Likely devicePosition should be used instead) The device position in its room space
  92070. */
  92071. position: Vector3;
  92072. /**
  92073. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  92074. */
  92075. rotationQuaternion: Quaternion;
  92076. /**
  92077. * The type of controller (Eg. Windows mixed reality)
  92078. */
  92079. controllerType: PoseEnabledControllerType;
  92080. protected _calculatedPosition: Vector3;
  92081. private _calculatedRotation;
  92082. /**
  92083. * The raw pose from the device
  92084. */
  92085. rawPose: DevicePose;
  92086. private _trackPosition;
  92087. private _maxRotationDistFromHeadset;
  92088. private _draggedRoomRotation;
  92089. /**
  92090. * @hidden
  92091. */
  92092. _disableTrackPosition(fixedPosition: Vector3): void;
  92093. /**
  92094. * Internal, the mesh attached to the controller
  92095. * @hidden
  92096. */
  92097. _mesh: Nullable<AbstractMesh>;
  92098. private _poseControlledCamera;
  92099. private _leftHandSystemQuaternion;
  92100. /**
  92101. * Internal, matrix used to convert room space to babylon space
  92102. * @hidden
  92103. */
  92104. _deviceToWorld: Matrix;
  92105. /**
  92106. * Node to be used when casting a ray from the controller
  92107. * @hidden
  92108. */
  92109. _pointingPoseNode: Nullable<TransformNode>;
  92110. /**
  92111. * Name of the child mesh that can be used to cast a ray from the controller
  92112. */
  92113. static readonly POINTING_POSE: string;
  92114. /**
  92115. * Creates a new PoseEnabledController from a gamepad
  92116. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  92117. */
  92118. constructor(browserGamepad: any);
  92119. private _workingMatrix;
  92120. /**
  92121. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  92122. */
  92123. update(): void;
  92124. /**
  92125. * Updates only the pose device and mesh without doing any button event checking
  92126. */
  92127. protected _updatePoseAndMesh(): void;
  92128. /**
  92129. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  92130. * @param poseData raw pose fromthe device
  92131. */
  92132. updateFromDevice(poseData: DevicePose): void;
  92133. /**
  92134. * @hidden
  92135. */
  92136. _meshAttachedObservable: Observable<AbstractMesh>;
  92137. /**
  92138. * Attaches a mesh to the controller
  92139. * @param mesh the mesh to be attached
  92140. */
  92141. attachToMesh(mesh: AbstractMesh): void;
  92142. /**
  92143. * Attaches the controllers mesh to a camera
  92144. * @param camera the camera the mesh should be attached to
  92145. */
  92146. attachToPoseControlledCamera(camera: TargetCamera): void;
  92147. /**
  92148. * Disposes of the controller
  92149. */
  92150. dispose(): void;
  92151. /**
  92152. * The mesh that is attached to the controller
  92153. */
  92154. get mesh(): Nullable<AbstractMesh>;
  92155. /**
  92156. * Gets the ray of the controller in the direction the controller is pointing
  92157. * @param length the length the resulting ray should be
  92158. * @returns a ray in the direction the controller is pointing
  92159. */
  92160. getForwardRay(length?: number): Ray;
  92161. }
  92162. }
  92163. declare module BABYLON {
  92164. /**
  92165. * Defines the WebVRController object that represents controllers tracked in 3D space
  92166. */
  92167. export abstract class WebVRController extends PoseEnabledController {
  92168. /**
  92169. * Internal, the default controller model for the controller
  92170. */
  92171. protected _defaultModel: Nullable<AbstractMesh>;
  92172. /**
  92173. * Fired when the trigger state has changed
  92174. */
  92175. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  92176. /**
  92177. * Fired when the main button state has changed
  92178. */
  92179. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92180. /**
  92181. * Fired when the secondary button state has changed
  92182. */
  92183. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  92184. /**
  92185. * Fired when the pad state has changed
  92186. */
  92187. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  92188. /**
  92189. * Fired when controllers stick values have changed
  92190. */
  92191. onPadValuesChangedObservable: Observable<StickValues>;
  92192. /**
  92193. * Array of button availible on the controller
  92194. */
  92195. protected _buttons: Array<MutableGamepadButton>;
  92196. private _onButtonStateChange;
  92197. /**
  92198. * Fired when a controller button's state has changed
  92199. * @param callback the callback containing the button that was modified
  92200. */
  92201. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  92202. /**
  92203. * X and Y axis corresponding to the controllers joystick
  92204. */
  92205. pad: StickValues;
  92206. /**
  92207. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  92208. */
  92209. hand: string;
  92210. /**
  92211. * The default controller model for the controller
  92212. */
  92213. get defaultModel(): Nullable<AbstractMesh>;
  92214. /**
  92215. * Creates a new WebVRController from a gamepad
  92216. * @param vrGamepad the gamepad that the WebVRController should be created from
  92217. */
  92218. constructor(vrGamepad: any);
  92219. /**
  92220. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  92221. */
  92222. update(): void;
  92223. /**
  92224. * Function to be called when a button is modified
  92225. */
  92226. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  92227. /**
  92228. * Loads a mesh and attaches it to the controller
  92229. * @param scene the scene the mesh should be added to
  92230. * @param meshLoaded callback for when the mesh has been loaded
  92231. */
  92232. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  92233. private _setButtonValue;
  92234. private _changes;
  92235. private _checkChanges;
  92236. /**
  92237. * Disposes of th webVRCOntroller
  92238. */
  92239. dispose(): void;
  92240. }
  92241. }
  92242. declare module BABYLON {
  92243. /**
  92244. * The HemisphericLight simulates the ambient environment light,
  92245. * so the passed direction is the light reflection direction, not the incoming direction.
  92246. */
  92247. export class HemisphericLight extends Light {
  92248. /**
  92249. * The groundColor is the light in the opposite direction to the one specified during creation.
  92250. * 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.
  92251. */
  92252. groundColor: Color3;
  92253. /**
  92254. * The light reflection direction, not the incoming direction.
  92255. */
  92256. direction: Vector3;
  92257. /**
  92258. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  92259. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  92260. * The HemisphericLight can't cast shadows.
  92261. * Documentation : https://doc.babylonjs.com/babylon101/lights
  92262. * @param name The friendly name of the light
  92263. * @param direction The direction of the light reflection
  92264. * @param scene The scene the light belongs to
  92265. */
  92266. constructor(name: string, direction: Vector3, scene: Scene);
  92267. protected _buildUniformLayout(): void;
  92268. /**
  92269. * Returns the string "HemisphericLight".
  92270. * @return The class name
  92271. */
  92272. getClassName(): string;
  92273. /**
  92274. * Sets the HemisphericLight direction towards the passed target (Vector3).
  92275. * Returns the updated direction.
  92276. * @param target The target the direction should point to
  92277. * @return The computed direction
  92278. */
  92279. setDirectionToTarget(target: Vector3): Vector3;
  92280. /**
  92281. * Returns the shadow generator associated to the light.
  92282. * @returns Always null for hemispheric lights because it does not support shadows.
  92283. */
  92284. getShadowGenerator(): Nullable<IShadowGenerator>;
  92285. /**
  92286. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  92287. * @param effect The effect to update
  92288. * @param lightIndex The index of the light in the effect to update
  92289. * @returns The hemispheric light
  92290. */
  92291. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  92292. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  92293. /**
  92294. * Computes the world matrix of the node
  92295. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  92296. * @param useWasUpdatedFlag defines a reserved property
  92297. * @returns the world matrix
  92298. */
  92299. computeWorldMatrix(): Matrix;
  92300. /**
  92301. * Returns the integer 3.
  92302. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  92303. */
  92304. getTypeID(): number;
  92305. /**
  92306. * Prepares the list of defines specific to the light type.
  92307. * @param defines the list of defines
  92308. * @param lightIndex defines the index of the light for the effect
  92309. */
  92310. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  92311. }
  92312. }
  92313. declare module BABYLON {
  92314. /** @hidden */
  92315. export var vrMultiviewToSingleviewPixelShader: {
  92316. name: string;
  92317. shader: string;
  92318. };
  92319. }
  92320. declare module BABYLON {
  92321. /**
  92322. * Renders to multiple views with a single draw call
  92323. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  92324. */
  92325. export class MultiviewRenderTarget extends RenderTargetTexture {
  92326. /**
  92327. * Creates a multiview render target
  92328. * @param scene scene used with the render target
  92329. * @param size the size of the render target (used for each view)
  92330. */
  92331. constructor(scene: Scene, size?: number | {
  92332. width: number;
  92333. height: number;
  92334. } | {
  92335. ratio: number;
  92336. });
  92337. /**
  92338. * @hidden
  92339. * @param faceIndex the face index, if its a cube texture
  92340. */
  92341. _bindFrameBuffer(faceIndex?: number): void;
  92342. /**
  92343. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  92344. * @returns the view count
  92345. */
  92346. getViewCount(): number;
  92347. }
  92348. }
  92349. declare module BABYLON {
  92350. /**
  92351. * Represents a camera frustum
  92352. */
  92353. export class Frustum {
  92354. /**
  92355. * Gets the planes representing the frustum
  92356. * @param transform matrix to be applied to the returned planes
  92357. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  92358. */
  92359. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  92360. /**
  92361. * Gets the near frustum plane transformed by the transform matrix
  92362. * @param transform transformation matrix to be applied to the resulting frustum plane
  92363. * @param frustumPlane the resuling frustum plane
  92364. */
  92365. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92366. /**
  92367. * Gets the far frustum plane transformed by the transform matrix
  92368. * @param transform transformation matrix to be applied to the resulting frustum plane
  92369. * @param frustumPlane the resuling frustum plane
  92370. */
  92371. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92372. /**
  92373. * Gets the left frustum plane transformed by the transform matrix
  92374. * @param transform transformation matrix to be applied to the resulting frustum plane
  92375. * @param frustumPlane the resuling frustum plane
  92376. */
  92377. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92378. /**
  92379. * Gets the right frustum plane transformed by the transform matrix
  92380. * @param transform transformation matrix to be applied to the resulting frustum plane
  92381. * @param frustumPlane the resuling frustum plane
  92382. */
  92383. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92384. /**
  92385. * Gets the top frustum plane transformed by the transform matrix
  92386. * @param transform transformation matrix to be applied to the resulting frustum plane
  92387. * @param frustumPlane the resuling frustum plane
  92388. */
  92389. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92390. /**
  92391. * Gets the bottom frustum plane transformed by the transform matrix
  92392. * @param transform transformation matrix to be applied to the resulting frustum plane
  92393. * @param frustumPlane the resuling frustum plane
  92394. */
  92395. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  92396. /**
  92397. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  92398. * @param transform transformation matrix to be applied to the resulting frustum planes
  92399. * @param frustumPlanes the resuling frustum planes
  92400. */
  92401. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  92402. }
  92403. }
  92404. declare module BABYLON {
  92405. interface Engine {
  92406. /**
  92407. * Creates a new multiview render target
  92408. * @param width defines the width of the texture
  92409. * @param height defines the height of the texture
  92410. * @returns the created multiview texture
  92411. */
  92412. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  92413. /**
  92414. * Binds a multiview framebuffer to be drawn to
  92415. * @param multiviewTexture texture to bind
  92416. */
  92417. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  92418. }
  92419. interface Camera {
  92420. /**
  92421. * @hidden
  92422. * 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)
  92423. */
  92424. _useMultiviewToSingleView: boolean;
  92425. /**
  92426. * @hidden
  92427. * 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)
  92428. */
  92429. _multiviewTexture: Nullable<RenderTargetTexture>;
  92430. /**
  92431. * @hidden
  92432. * ensures the multiview texture of the camera exists and has the specified width/height
  92433. * @param width height to set on the multiview texture
  92434. * @param height width to set on the multiview texture
  92435. */
  92436. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  92437. }
  92438. interface Scene {
  92439. /** @hidden */
  92440. _transformMatrixR: Matrix;
  92441. /** @hidden */
  92442. _multiviewSceneUbo: Nullable<UniformBuffer>;
  92443. /** @hidden */
  92444. _createMultiviewUbo(): void;
  92445. /** @hidden */
  92446. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  92447. /** @hidden */
  92448. _renderMultiviewToSingleView(camera: Camera): void;
  92449. }
  92450. }
  92451. declare module BABYLON {
  92452. /**
  92453. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  92454. * This will not be used for webXR as it supports displaying texture arrays directly
  92455. */
  92456. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  92457. /**
  92458. * Initializes a VRMultiviewToSingleview
  92459. * @param name name of the post process
  92460. * @param camera camera to be applied to
  92461. * @param scaleFactor scaling factor to the size of the output texture
  92462. */
  92463. constructor(name: string, camera: Camera, scaleFactor: number);
  92464. }
  92465. }
  92466. declare module BABYLON {
  92467. /**
  92468. * Interface used to define additional presentation attributes
  92469. */
  92470. export interface IVRPresentationAttributes {
  92471. /**
  92472. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  92473. */
  92474. highRefreshRate: boolean;
  92475. /**
  92476. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  92477. */
  92478. foveationLevel: number;
  92479. }
  92480. interface Engine {
  92481. /** @hidden */
  92482. _vrDisplay: any;
  92483. /** @hidden */
  92484. _vrSupported: boolean;
  92485. /** @hidden */
  92486. _oldSize: Size;
  92487. /** @hidden */
  92488. _oldHardwareScaleFactor: number;
  92489. /** @hidden */
  92490. _vrExclusivePointerMode: boolean;
  92491. /** @hidden */
  92492. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  92493. /** @hidden */
  92494. _onVRDisplayPointerRestricted: () => void;
  92495. /** @hidden */
  92496. _onVRDisplayPointerUnrestricted: () => void;
  92497. /** @hidden */
  92498. _onVrDisplayConnect: Nullable<(display: any) => void>;
  92499. /** @hidden */
  92500. _onVrDisplayDisconnect: Nullable<() => void>;
  92501. /** @hidden */
  92502. _onVrDisplayPresentChange: Nullable<() => void>;
  92503. /**
  92504. * Observable signaled when VR display mode changes
  92505. */
  92506. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  92507. /**
  92508. * Observable signaled when VR request present is complete
  92509. */
  92510. onVRRequestPresentComplete: Observable<boolean>;
  92511. /**
  92512. * Observable signaled when VR request present starts
  92513. */
  92514. onVRRequestPresentStart: Observable<Engine>;
  92515. /**
  92516. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  92517. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  92518. */
  92519. isInVRExclusivePointerMode: boolean;
  92520. /**
  92521. * Gets a boolean indicating if a webVR device was detected
  92522. * @returns true if a webVR device was detected
  92523. */
  92524. isVRDevicePresent(): boolean;
  92525. /**
  92526. * Gets the current webVR device
  92527. * @returns the current webVR device (or null)
  92528. */
  92529. getVRDevice(): any;
  92530. /**
  92531. * Initializes a webVR display and starts listening to display change events
  92532. * The onVRDisplayChangedObservable will be notified upon these changes
  92533. * @returns A promise containing a VRDisplay and if vr is supported
  92534. */
  92535. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  92536. /** @hidden */
  92537. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  92538. /**
  92539. * Gets or sets the presentation attributes used to configure VR rendering
  92540. */
  92541. vrPresentationAttributes?: IVRPresentationAttributes;
  92542. /**
  92543. * Call this function to switch to webVR mode
  92544. * Will do nothing if webVR is not supported or if there is no webVR device
  92545. * @param options the webvr options provided to the camera. mainly used for multiview
  92546. * @see http://doc.babylonjs.com/how_to/webvr_camera
  92547. */
  92548. enableVR(options: WebVROptions): void;
  92549. /** @hidden */
  92550. _onVRFullScreenTriggered(): void;
  92551. }
  92552. }
  92553. declare module BABYLON {
  92554. /**
  92555. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  92556. * IMPORTANT!! The data is right-hand data.
  92557. * @export
  92558. * @interface DevicePose
  92559. */
  92560. export interface DevicePose {
  92561. /**
  92562. * The position of the device, values in array are [x,y,z].
  92563. */
  92564. readonly position: Nullable<Float32Array>;
  92565. /**
  92566. * The linearVelocity of the device, values in array are [x,y,z].
  92567. */
  92568. readonly linearVelocity: Nullable<Float32Array>;
  92569. /**
  92570. * The linearAcceleration of the device, values in array are [x,y,z].
  92571. */
  92572. readonly linearAcceleration: Nullable<Float32Array>;
  92573. /**
  92574. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  92575. */
  92576. readonly orientation: Nullable<Float32Array>;
  92577. /**
  92578. * The angularVelocity of the device, values in array are [x,y,z].
  92579. */
  92580. readonly angularVelocity: Nullable<Float32Array>;
  92581. /**
  92582. * The angularAcceleration of the device, values in array are [x,y,z].
  92583. */
  92584. readonly angularAcceleration: Nullable<Float32Array>;
  92585. }
  92586. /**
  92587. * Interface representing a pose controlled object in Babylon.
  92588. * A pose controlled object has both regular pose values as well as pose values
  92589. * from an external device such as a VR head mounted display
  92590. */
  92591. export interface PoseControlled {
  92592. /**
  92593. * The position of the object in babylon space.
  92594. */
  92595. position: Vector3;
  92596. /**
  92597. * The rotation quaternion of the object in babylon space.
  92598. */
  92599. rotationQuaternion: Quaternion;
  92600. /**
  92601. * The position of the device in babylon space.
  92602. */
  92603. devicePosition?: Vector3;
  92604. /**
  92605. * The rotation quaternion of the device in babylon space.
  92606. */
  92607. deviceRotationQuaternion: Quaternion;
  92608. /**
  92609. * The raw pose coming from the device.
  92610. */
  92611. rawPose: Nullable<DevicePose>;
  92612. /**
  92613. * The scale of the device to be used when translating from device space to babylon space.
  92614. */
  92615. deviceScaleFactor: number;
  92616. /**
  92617. * Updates the poseControlled values based on the input device pose.
  92618. * @param poseData the pose data to update the object with
  92619. */
  92620. updateFromDevice(poseData: DevicePose): void;
  92621. }
  92622. /**
  92623. * Set of options to customize the webVRCamera
  92624. */
  92625. export interface WebVROptions {
  92626. /**
  92627. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  92628. */
  92629. trackPosition?: boolean;
  92630. /**
  92631. * Sets the scale of the vrDevice in babylon space. (default: 1)
  92632. */
  92633. positionScale?: number;
  92634. /**
  92635. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  92636. */
  92637. displayName?: string;
  92638. /**
  92639. * Should the native controller meshes be initialized. (default: true)
  92640. */
  92641. controllerMeshes?: boolean;
  92642. /**
  92643. * Creating a default HemiLight only on controllers. (default: true)
  92644. */
  92645. defaultLightingOnControllers?: boolean;
  92646. /**
  92647. * If you don't want to use the default VR button of the helper. (default: false)
  92648. */
  92649. useCustomVRButton?: boolean;
  92650. /**
  92651. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  92652. */
  92653. customVRButton?: HTMLButtonElement;
  92654. /**
  92655. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  92656. */
  92657. rayLength?: number;
  92658. /**
  92659. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  92660. */
  92661. defaultHeight?: number;
  92662. /**
  92663. * If multiview should be used if availible (default: false)
  92664. */
  92665. useMultiview?: boolean;
  92666. }
  92667. /**
  92668. * This represents a WebVR camera.
  92669. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  92670. * @example http://doc.babylonjs.com/how_to/webvr_camera
  92671. */
  92672. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  92673. private webVROptions;
  92674. /**
  92675. * @hidden
  92676. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  92677. */
  92678. _vrDevice: any;
  92679. /**
  92680. * The rawPose of the vrDevice.
  92681. */
  92682. rawPose: Nullable<DevicePose>;
  92683. private _onVREnabled;
  92684. private _specsVersion;
  92685. private _attached;
  92686. private _frameData;
  92687. protected _descendants: Array<Node>;
  92688. private _deviceRoomPosition;
  92689. /** @hidden */
  92690. _deviceRoomRotationQuaternion: Quaternion;
  92691. private _standingMatrix;
  92692. /**
  92693. * Represents device position in babylon space.
  92694. */
  92695. devicePosition: Vector3;
  92696. /**
  92697. * Represents device rotation in babylon space.
  92698. */
  92699. deviceRotationQuaternion: Quaternion;
  92700. /**
  92701. * The scale of the device to be used when translating from device space to babylon space.
  92702. */
  92703. deviceScaleFactor: number;
  92704. private _deviceToWorld;
  92705. private _worldToDevice;
  92706. /**
  92707. * References to the webVR controllers for the vrDevice.
  92708. */
  92709. controllers: Array<WebVRController>;
  92710. /**
  92711. * Emits an event when a controller is attached.
  92712. */
  92713. onControllersAttachedObservable: Observable<WebVRController[]>;
  92714. /**
  92715. * Emits an event when a controller's mesh has been loaded;
  92716. */
  92717. onControllerMeshLoadedObservable: Observable<WebVRController>;
  92718. /**
  92719. * Emits an event when the HMD's pose has been updated.
  92720. */
  92721. onPoseUpdatedFromDeviceObservable: Observable<any>;
  92722. private _poseSet;
  92723. /**
  92724. * If the rig cameras be used as parent instead of this camera.
  92725. */
  92726. rigParenting: boolean;
  92727. private _lightOnControllers;
  92728. private _defaultHeight?;
  92729. /**
  92730. * Instantiates a WebVRFreeCamera.
  92731. * @param name The name of the WebVRFreeCamera
  92732. * @param position The starting anchor position for the camera
  92733. * @param scene The scene the camera belongs to
  92734. * @param webVROptions a set of customizable options for the webVRCamera
  92735. */
  92736. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  92737. /**
  92738. * Gets the device distance from the ground in meters.
  92739. * @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.
  92740. */
  92741. deviceDistanceToRoomGround(): number;
  92742. /**
  92743. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92744. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  92745. */
  92746. useStandingMatrix(callback?: (bool: boolean) => void): void;
  92747. /**
  92748. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  92749. * @returns A promise with a boolean set to if the standing matrix is supported.
  92750. */
  92751. useStandingMatrixAsync(): Promise<boolean>;
  92752. /**
  92753. * Disposes the camera
  92754. */
  92755. dispose(): void;
  92756. /**
  92757. * Gets a vrController by name.
  92758. * @param name The name of the controller to retreive
  92759. * @returns the controller matching the name specified or null if not found
  92760. */
  92761. getControllerByName(name: string): Nullable<WebVRController>;
  92762. private _leftController;
  92763. /**
  92764. * The controller corresponding to the users left hand.
  92765. */
  92766. get leftController(): Nullable<WebVRController>;
  92767. private _rightController;
  92768. /**
  92769. * The controller corresponding to the users right hand.
  92770. */
  92771. get rightController(): Nullable<WebVRController>;
  92772. /**
  92773. * Casts a ray forward from the vrCamera's gaze.
  92774. * @param length Length of the ray (default: 100)
  92775. * @returns the ray corresponding to the gaze
  92776. */
  92777. getForwardRay(length?: number): Ray;
  92778. /**
  92779. * @hidden
  92780. * Updates the camera based on device's frame data
  92781. */
  92782. _checkInputs(): void;
  92783. /**
  92784. * Updates the poseControlled values based on the input device pose.
  92785. * @param poseData Pose coming from the device
  92786. */
  92787. updateFromDevice(poseData: DevicePose): void;
  92788. private _htmlElementAttached;
  92789. private _detachIfAttached;
  92790. /**
  92791. * WebVR's attach control will start broadcasting frames to the device.
  92792. * Note that in certain browsers (chrome for example) this function must be called
  92793. * within a user-interaction callback. Example:
  92794. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  92795. *
  92796. * @param element html element to attach the vrDevice to
  92797. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  92798. */
  92799. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92800. /**
  92801. * Detaches the camera from the html element and disables VR
  92802. *
  92803. * @param element html element to detach from
  92804. */
  92805. detachControl(element: HTMLElement): void;
  92806. /**
  92807. * @returns the name of this class
  92808. */
  92809. getClassName(): string;
  92810. /**
  92811. * Calls resetPose on the vrDisplay
  92812. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  92813. */
  92814. resetToCurrentRotation(): void;
  92815. /**
  92816. * @hidden
  92817. * Updates the rig cameras (left and right eye)
  92818. */
  92819. _updateRigCameras(): void;
  92820. private _workingVector;
  92821. private _oneVector;
  92822. private _workingMatrix;
  92823. private updateCacheCalled;
  92824. private _correctPositionIfNotTrackPosition;
  92825. /**
  92826. * @hidden
  92827. * Updates the cached values of the camera
  92828. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  92829. */
  92830. _updateCache(ignoreParentClass?: boolean): void;
  92831. /**
  92832. * @hidden
  92833. * Get current device position in babylon world
  92834. */
  92835. _computeDevicePosition(): void;
  92836. /**
  92837. * Updates the current device position and rotation in the babylon world
  92838. */
  92839. update(): void;
  92840. /**
  92841. * @hidden
  92842. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  92843. * @returns an identity matrix
  92844. */
  92845. _getViewMatrix(): Matrix;
  92846. private _tmpMatrix;
  92847. /**
  92848. * This function is called by the two RIG cameras.
  92849. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  92850. * @hidden
  92851. */
  92852. _getWebVRViewMatrix(): Matrix;
  92853. /** @hidden */
  92854. _getWebVRProjectionMatrix(): Matrix;
  92855. private _onGamepadConnectedObserver;
  92856. private _onGamepadDisconnectedObserver;
  92857. private _updateCacheWhenTrackingDisabledObserver;
  92858. /**
  92859. * Initializes the controllers and their meshes
  92860. */
  92861. initControllers(): void;
  92862. }
  92863. }
  92864. declare module BABYLON {
  92865. /**
  92866. * Size options for a post process
  92867. */
  92868. export type PostProcessOptions = {
  92869. width: number;
  92870. height: number;
  92871. };
  92872. /**
  92873. * PostProcess can be used to apply a shader to a texture after it has been rendered
  92874. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  92875. */
  92876. export class PostProcess {
  92877. /** Name of the PostProcess. */
  92878. name: string;
  92879. /**
  92880. * Gets or sets the unique id of the post process
  92881. */
  92882. uniqueId: number;
  92883. /**
  92884. * Width of the texture to apply the post process on
  92885. */
  92886. width: number;
  92887. /**
  92888. * Height of the texture to apply the post process on
  92889. */
  92890. height: number;
  92891. /**
  92892. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  92893. * @hidden
  92894. */
  92895. _outputTexture: Nullable<InternalTexture>;
  92896. /**
  92897. * Sampling mode used by the shader
  92898. * See https://doc.babylonjs.com/classes/3.1/texture
  92899. */
  92900. renderTargetSamplingMode: number;
  92901. /**
  92902. * Clear color to use when screen clearing
  92903. */
  92904. clearColor: Color4;
  92905. /**
  92906. * If the buffer needs to be cleared before applying the post process. (default: true)
  92907. * Should be set to false if shader will overwrite all previous pixels.
  92908. */
  92909. autoClear: boolean;
  92910. /**
  92911. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  92912. */
  92913. alphaMode: number;
  92914. /**
  92915. * Sets the setAlphaBlendConstants of the babylon engine
  92916. */
  92917. alphaConstants: Color4;
  92918. /**
  92919. * Animations to be used for the post processing
  92920. */
  92921. animations: Animation[];
  92922. /**
  92923. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  92924. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  92925. */
  92926. enablePixelPerfectMode: boolean;
  92927. /**
  92928. * Force the postprocess to be applied without taking in account viewport
  92929. */
  92930. forceFullscreenViewport: boolean;
  92931. /**
  92932. * List of inspectable custom properties (used by the Inspector)
  92933. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  92934. */
  92935. inspectableCustomProperties: IInspectable[];
  92936. /**
  92937. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  92938. *
  92939. * | Value | Type | Description |
  92940. * | ----- | ----------------------------------- | ----------- |
  92941. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  92942. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  92943. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  92944. *
  92945. */
  92946. scaleMode: number;
  92947. /**
  92948. * Force textures to be a power of two (default: false)
  92949. */
  92950. alwaysForcePOT: boolean;
  92951. private _samples;
  92952. /**
  92953. * Number of sample textures (default: 1)
  92954. */
  92955. get samples(): number;
  92956. set samples(n: number);
  92957. /**
  92958. * Modify the scale of the post process to be the same as the viewport (default: false)
  92959. */
  92960. adaptScaleToCurrentViewport: boolean;
  92961. private _camera;
  92962. private _scene;
  92963. private _engine;
  92964. private _options;
  92965. private _reusable;
  92966. private _textureType;
  92967. private _textureFormat;
  92968. /**
  92969. * Smart array of input and output textures for the post process.
  92970. * @hidden
  92971. */
  92972. _textures: SmartArray<InternalTexture>;
  92973. /**
  92974. * The index in _textures that corresponds to the output texture.
  92975. * @hidden
  92976. */
  92977. _currentRenderTextureInd: number;
  92978. private _effect;
  92979. private _samplers;
  92980. private _fragmentUrl;
  92981. private _vertexUrl;
  92982. private _parameters;
  92983. private _scaleRatio;
  92984. protected _indexParameters: any;
  92985. private _shareOutputWithPostProcess;
  92986. private _texelSize;
  92987. private _forcedOutputTexture;
  92988. /**
  92989. * Returns the fragment url or shader name used in the post process.
  92990. * @returns the fragment url or name in the shader store.
  92991. */
  92992. getEffectName(): string;
  92993. /**
  92994. * An event triggered when the postprocess is activated.
  92995. */
  92996. onActivateObservable: Observable<Camera>;
  92997. private _onActivateObserver;
  92998. /**
  92999. * A function that is added to the onActivateObservable
  93000. */
  93001. set onActivate(callback: Nullable<(camera: Camera) => void>);
  93002. /**
  93003. * An event triggered when the postprocess changes its size.
  93004. */
  93005. onSizeChangedObservable: Observable<PostProcess>;
  93006. private _onSizeChangedObserver;
  93007. /**
  93008. * A function that is added to the onSizeChangedObservable
  93009. */
  93010. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  93011. /**
  93012. * An event triggered when the postprocess applies its effect.
  93013. */
  93014. onApplyObservable: Observable<Effect>;
  93015. private _onApplyObserver;
  93016. /**
  93017. * A function that is added to the onApplyObservable
  93018. */
  93019. set onApply(callback: (effect: Effect) => void);
  93020. /**
  93021. * An event triggered before rendering the postprocess
  93022. */
  93023. onBeforeRenderObservable: Observable<Effect>;
  93024. private _onBeforeRenderObserver;
  93025. /**
  93026. * A function that is added to the onBeforeRenderObservable
  93027. */
  93028. set onBeforeRender(callback: (effect: Effect) => void);
  93029. /**
  93030. * An event triggered after rendering the postprocess
  93031. */
  93032. onAfterRenderObservable: Observable<Effect>;
  93033. private _onAfterRenderObserver;
  93034. /**
  93035. * A function that is added to the onAfterRenderObservable
  93036. */
  93037. set onAfterRender(callback: (efect: Effect) => void);
  93038. /**
  93039. * 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
  93040. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  93041. */
  93042. get inputTexture(): InternalTexture;
  93043. set inputTexture(value: InternalTexture);
  93044. /**
  93045. * Gets the camera which post process is applied to.
  93046. * @returns The camera the post process is applied to.
  93047. */
  93048. getCamera(): Camera;
  93049. /**
  93050. * Gets the texel size of the postprocess.
  93051. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  93052. */
  93053. get texelSize(): Vector2;
  93054. /**
  93055. * Creates a new instance PostProcess
  93056. * @param name The name of the PostProcess.
  93057. * @param fragmentUrl The url of the fragment shader to be used.
  93058. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  93059. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  93060. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93061. * @param camera The camera to apply the render pass to.
  93062. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93063. * @param engine The engine which the post process will be applied. (default: current engine)
  93064. * @param reusable If the post process can be reused on the same frame. (default: false)
  93065. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  93066. * @param textureType Type of textures used when performing the post process. (default: 0)
  93067. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  93068. * @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
  93069. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  93070. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  93071. */
  93072. constructor(
  93073. /** Name of the PostProcess. */
  93074. 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);
  93075. /**
  93076. * Gets a string idenfifying the name of the class
  93077. * @returns "PostProcess" string
  93078. */
  93079. getClassName(): string;
  93080. /**
  93081. * Gets the engine which this post process belongs to.
  93082. * @returns The engine the post process was enabled with.
  93083. */
  93084. getEngine(): Engine;
  93085. /**
  93086. * The effect that is created when initializing the post process.
  93087. * @returns The created effect corresponding the the postprocess.
  93088. */
  93089. getEffect(): Effect;
  93090. /**
  93091. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  93092. * @param postProcess The post process to share the output with.
  93093. * @returns This post process.
  93094. */
  93095. shareOutputWith(postProcess: PostProcess): PostProcess;
  93096. /**
  93097. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  93098. * This should be called if the post process that shares output with this post process is disabled/disposed.
  93099. */
  93100. useOwnOutput(): void;
  93101. /**
  93102. * Updates the effect with the current post process compile time values and recompiles the shader.
  93103. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93104. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93105. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93106. * @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
  93107. * @param onCompiled Called when the shader has been compiled.
  93108. * @param onError Called if there is an error when compiling a shader.
  93109. */
  93110. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93111. /**
  93112. * The post process is reusable if it can be used multiple times within one frame.
  93113. * @returns If the post process is reusable
  93114. */
  93115. isReusable(): boolean;
  93116. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  93117. markTextureDirty(): void;
  93118. /**
  93119. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  93120. * 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.
  93121. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  93122. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  93123. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  93124. * @returns The target texture that was bound to be written to.
  93125. */
  93126. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  93127. /**
  93128. * If the post process is supported.
  93129. */
  93130. get isSupported(): boolean;
  93131. /**
  93132. * The aspect ratio of the output texture.
  93133. */
  93134. get aspectRatio(): number;
  93135. /**
  93136. * Get a value indicating if the post-process is ready to be used
  93137. * @returns true if the post-process is ready (shader is compiled)
  93138. */
  93139. isReady(): boolean;
  93140. /**
  93141. * Binds all textures and uniforms to the shader, this will be run on every pass.
  93142. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  93143. */
  93144. apply(): Nullable<Effect>;
  93145. private _disposeTextures;
  93146. /**
  93147. * Disposes the post process.
  93148. * @param camera The camera to dispose the post process on.
  93149. */
  93150. dispose(camera?: Camera): void;
  93151. }
  93152. }
  93153. declare module BABYLON {
  93154. /** @hidden */
  93155. export var kernelBlurVaryingDeclaration: {
  93156. name: string;
  93157. shader: string;
  93158. };
  93159. }
  93160. declare module BABYLON {
  93161. /** @hidden */
  93162. export var kernelBlurFragment: {
  93163. name: string;
  93164. shader: string;
  93165. };
  93166. }
  93167. declare module BABYLON {
  93168. /** @hidden */
  93169. export var kernelBlurFragment2: {
  93170. name: string;
  93171. shader: string;
  93172. };
  93173. }
  93174. declare module BABYLON {
  93175. /** @hidden */
  93176. export var kernelBlurPixelShader: {
  93177. name: string;
  93178. shader: string;
  93179. };
  93180. }
  93181. declare module BABYLON {
  93182. /** @hidden */
  93183. export var kernelBlurVertex: {
  93184. name: string;
  93185. shader: string;
  93186. };
  93187. }
  93188. declare module BABYLON {
  93189. /** @hidden */
  93190. export var kernelBlurVertexShader: {
  93191. name: string;
  93192. shader: string;
  93193. };
  93194. }
  93195. declare module BABYLON {
  93196. /**
  93197. * The Blur Post Process which blurs an image based on a kernel and direction.
  93198. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  93199. */
  93200. export class BlurPostProcess extends PostProcess {
  93201. /** The direction in which to blur the image. */
  93202. direction: Vector2;
  93203. private blockCompilation;
  93204. protected _kernel: number;
  93205. protected _idealKernel: number;
  93206. protected _packedFloat: boolean;
  93207. private _staticDefines;
  93208. /**
  93209. * Sets the length in pixels of the blur sample region
  93210. */
  93211. set kernel(v: number);
  93212. /**
  93213. * Gets the length in pixels of the blur sample region
  93214. */
  93215. get kernel(): number;
  93216. /**
  93217. * Sets wether or not the blur needs to unpack/repack floats
  93218. */
  93219. set packedFloat(v: boolean);
  93220. /**
  93221. * Gets wether or not the blur is unpacking/repacking floats
  93222. */
  93223. get packedFloat(): boolean;
  93224. /**
  93225. * Creates a new instance BlurPostProcess
  93226. * @param name The name of the effect.
  93227. * @param direction The direction in which to blur the image.
  93228. * @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.
  93229. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  93230. * @param camera The camera to apply the render pass to.
  93231. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  93232. * @param engine The engine which the post process will be applied. (default: current engine)
  93233. * @param reusable If the post process can be reused on the same frame. (default: false)
  93234. * @param textureType Type of textures used when performing the post process. (default: 0)
  93235. * @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)
  93236. */
  93237. constructor(name: string,
  93238. /** The direction in which to blur the image. */
  93239. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  93240. /**
  93241. * Updates the effect with the current post process compile time values and recompiles the shader.
  93242. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  93243. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  93244. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  93245. * @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
  93246. * @param onCompiled Called when the shader has been compiled.
  93247. * @param onError Called if there is an error when compiling a shader.
  93248. */
  93249. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93250. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  93251. /**
  93252. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  93253. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  93254. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  93255. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  93256. * The gaps between physical kernels are compensated for in the weighting of the samples
  93257. * @param idealKernel Ideal blur kernel.
  93258. * @return Nearest best kernel.
  93259. */
  93260. protected _nearestBestKernel(idealKernel: number): number;
  93261. /**
  93262. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  93263. * @param x The point on the Gaussian distribution to sample.
  93264. * @return the value of the Gaussian function at x.
  93265. */
  93266. protected _gaussianWeight(x: number): number;
  93267. /**
  93268. * Generates a string that can be used as a floating point number in GLSL.
  93269. * @param x Value to print.
  93270. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  93271. * @return GLSL float string.
  93272. */
  93273. protected _glslFloat(x: number, decimalFigures?: number): string;
  93274. }
  93275. }
  93276. declare module BABYLON {
  93277. /**
  93278. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93279. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93280. * You can then easily use it as a reflectionTexture on a flat surface.
  93281. * In case the surface is not a plane, please consider relying on reflection probes.
  93282. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93283. */
  93284. export class MirrorTexture extends RenderTargetTexture {
  93285. private scene;
  93286. /**
  93287. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  93288. * 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.
  93289. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93290. */
  93291. mirrorPlane: Plane;
  93292. /**
  93293. * Define the blur ratio used to blur the reflection if needed.
  93294. */
  93295. set blurRatio(value: number);
  93296. get blurRatio(): number;
  93297. /**
  93298. * Define the adaptive blur kernel used to blur the reflection if needed.
  93299. * This will autocompute the closest best match for the `blurKernel`
  93300. */
  93301. set adaptiveBlurKernel(value: number);
  93302. /**
  93303. * Define the blur kernel used to blur the reflection if needed.
  93304. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93305. */
  93306. set blurKernel(value: number);
  93307. /**
  93308. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  93309. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93310. */
  93311. set blurKernelX(value: number);
  93312. get blurKernelX(): number;
  93313. /**
  93314. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  93315. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  93316. */
  93317. set blurKernelY(value: number);
  93318. get blurKernelY(): number;
  93319. private _autoComputeBlurKernel;
  93320. protected _onRatioRescale(): void;
  93321. private _updateGammaSpace;
  93322. private _imageProcessingConfigChangeObserver;
  93323. private _transformMatrix;
  93324. private _mirrorMatrix;
  93325. private _savedViewMatrix;
  93326. private _blurX;
  93327. private _blurY;
  93328. private _adaptiveBlurKernel;
  93329. private _blurKernelX;
  93330. private _blurKernelY;
  93331. private _blurRatio;
  93332. /**
  93333. * Instantiates a Mirror Texture.
  93334. * Mirror texture can be used to simulate the view from a mirror in a scene.
  93335. * It will dynamically be rendered every frame to adapt to the camera point of view.
  93336. * You can then easily use it as a reflectionTexture on a flat surface.
  93337. * In case the surface is not a plane, please consider relying on reflection probes.
  93338. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  93339. * @param name
  93340. * @param size
  93341. * @param scene
  93342. * @param generateMipMaps
  93343. * @param type
  93344. * @param samplingMode
  93345. * @param generateDepthBuffer
  93346. */
  93347. constructor(name: string, size: number | {
  93348. width: number;
  93349. height: number;
  93350. } | {
  93351. ratio: number;
  93352. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  93353. private _preparePostProcesses;
  93354. /**
  93355. * Clone the mirror texture.
  93356. * @returns the cloned texture
  93357. */
  93358. clone(): MirrorTexture;
  93359. /**
  93360. * Serialize the texture to a JSON representation you could use in Parse later on
  93361. * @returns the serialized JSON representation
  93362. */
  93363. serialize(): any;
  93364. /**
  93365. * Dispose the texture and release its associated resources.
  93366. */
  93367. dispose(): void;
  93368. }
  93369. }
  93370. declare module BABYLON {
  93371. /**
  93372. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93373. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93374. */
  93375. export class Texture extends BaseTexture {
  93376. /**
  93377. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  93378. */
  93379. static SerializeBuffers: boolean;
  93380. /** @hidden */
  93381. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  93382. /** @hidden */
  93383. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  93384. /** @hidden */
  93385. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  93386. /** nearest is mag = nearest and min = nearest and mip = linear */
  93387. static readonly NEAREST_SAMPLINGMODE: number;
  93388. /** nearest is mag = nearest and min = nearest and mip = linear */
  93389. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  93390. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93391. static readonly BILINEAR_SAMPLINGMODE: number;
  93392. /** Bilinear is mag = linear and min = linear and mip = nearest */
  93393. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  93394. /** Trilinear is mag = linear and min = linear and mip = linear */
  93395. static readonly TRILINEAR_SAMPLINGMODE: number;
  93396. /** Trilinear is mag = linear and min = linear and mip = linear */
  93397. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  93398. /** mag = nearest and min = nearest and mip = nearest */
  93399. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  93400. /** mag = nearest and min = linear and mip = nearest */
  93401. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  93402. /** mag = nearest and min = linear and mip = linear */
  93403. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  93404. /** mag = nearest and min = linear and mip = none */
  93405. static readonly NEAREST_LINEAR: number;
  93406. /** mag = nearest and min = nearest and mip = none */
  93407. static readonly NEAREST_NEAREST: number;
  93408. /** mag = linear and min = nearest and mip = nearest */
  93409. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  93410. /** mag = linear and min = nearest and mip = linear */
  93411. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  93412. /** mag = linear and min = linear and mip = none */
  93413. static readonly LINEAR_LINEAR: number;
  93414. /** mag = linear and min = nearest and mip = none */
  93415. static readonly LINEAR_NEAREST: number;
  93416. /** Explicit coordinates mode */
  93417. static readonly EXPLICIT_MODE: number;
  93418. /** Spherical coordinates mode */
  93419. static readonly SPHERICAL_MODE: number;
  93420. /** Planar coordinates mode */
  93421. static readonly PLANAR_MODE: number;
  93422. /** Cubic coordinates mode */
  93423. static readonly CUBIC_MODE: number;
  93424. /** Projection coordinates mode */
  93425. static readonly PROJECTION_MODE: number;
  93426. /** Inverse Cubic coordinates mode */
  93427. static readonly SKYBOX_MODE: number;
  93428. /** Inverse Cubic coordinates mode */
  93429. static readonly INVCUBIC_MODE: number;
  93430. /** Equirectangular coordinates mode */
  93431. static readonly EQUIRECTANGULAR_MODE: number;
  93432. /** Equirectangular Fixed coordinates mode */
  93433. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  93434. /** Equirectangular Fixed Mirrored coordinates mode */
  93435. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  93436. /** Texture is not repeating outside of 0..1 UVs */
  93437. static readonly CLAMP_ADDRESSMODE: number;
  93438. /** Texture is repeating outside of 0..1 UVs */
  93439. static readonly WRAP_ADDRESSMODE: number;
  93440. /** Texture is repeating and mirrored */
  93441. static readonly MIRROR_ADDRESSMODE: number;
  93442. /**
  93443. * 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
  93444. */
  93445. static UseSerializedUrlIfAny: boolean;
  93446. /**
  93447. * Define the url of the texture.
  93448. */
  93449. url: Nullable<string>;
  93450. /**
  93451. * Define an offset on the texture to offset the u coordinates of the UVs
  93452. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93453. */
  93454. uOffset: number;
  93455. /**
  93456. * Define an offset on the texture to offset the v coordinates of the UVs
  93457. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  93458. */
  93459. vOffset: number;
  93460. /**
  93461. * Define an offset on the texture to scale the u coordinates of the UVs
  93462. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93463. */
  93464. uScale: number;
  93465. /**
  93466. * Define an offset on the texture to scale the v coordinates of the UVs
  93467. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  93468. */
  93469. vScale: number;
  93470. /**
  93471. * Define an offset on the texture to rotate around the u coordinates of the UVs
  93472. * @see http://doc.babylonjs.com/how_to/more_materials
  93473. */
  93474. uAng: number;
  93475. /**
  93476. * Define an offset on the texture to rotate around the v coordinates of the UVs
  93477. * @see http://doc.babylonjs.com/how_to/more_materials
  93478. */
  93479. vAng: number;
  93480. /**
  93481. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  93482. * @see http://doc.babylonjs.com/how_to/more_materials
  93483. */
  93484. wAng: number;
  93485. /**
  93486. * Defines the center of rotation (U)
  93487. */
  93488. uRotationCenter: number;
  93489. /**
  93490. * Defines the center of rotation (V)
  93491. */
  93492. vRotationCenter: number;
  93493. /**
  93494. * Defines the center of rotation (W)
  93495. */
  93496. wRotationCenter: number;
  93497. /**
  93498. * Are mip maps generated for this texture or not.
  93499. */
  93500. get noMipmap(): boolean;
  93501. /**
  93502. * List of inspectable custom properties (used by the Inspector)
  93503. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93504. */
  93505. inspectableCustomProperties: Nullable<IInspectable[]>;
  93506. private _noMipmap;
  93507. /** @hidden */
  93508. _invertY: boolean;
  93509. private _rowGenerationMatrix;
  93510. private _cachedTextureMatrix;
  93511. private _projectionModeMatrix;
  93512. private _t0;
  93513. private _t1;
  93514. private _t2;
  93515. private _cachedUOffset;
  93516. private _cachedVOffset;
  93517. private _cachedUScale;
  93518. private _cachedVScale;
  93519. private _cachedUAng;
  93520. private _cachedVAng;
  93521. private _cachedWAng;
  93522. private _cachedProjectionMatrixId;
  93523. private _cachedCoordinatesMode;
  93524. /** @hidden */
  93525. protected _initialSamplingMode: number;
  93526. /** @hidden */
  93527. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  93528. private _deleteBuffer;
  93529. protected _format: Nullable<number>;
  93530. private _delayedOnLoad;
  93531. private _delayedOnError;
  93532. private _mimeType?;
  93533. /**
  93534. * Observable triggered once the texture has been loaded.
  93535. */
  93536. onLoadObservable: Observable<Texture>;
  93537. protected _isBlocking: boolean;
  93538. /**
  93539. * Is the texture preventing material to render while loading.
  93540. * If false, a default texture will be used instead of the loading one during the preparation step.
  93541. */
  93542. set isBlocking(value: boolean);
  93543. get isBlocking(): boolean;
  93544. /**
  93545. * Get the current sampling mode associated with the texture.
  93546. */
  93547. get samplingMode(): number;
  93548. /**
  93549. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  93550. */
  93551. get invertY(): boolean;
  93552. /**
  93553. * Instantiates a new texture.
  93554. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  93555. * @see http://doc.babylonjs.com/babylon101/materials#texture
  93556. * @param url defines the url of the picture to load as a texture
  93557. * @param scene defines the scene or engine the texture will belong to
  93558. * @param noMipmap defines if the texture will require mip maps or not
  93559. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  93560. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93561. * @param onLoad defines a callback triggered when the texture has been loaded
  93562. * @param onError defines a callback triggered when an error occurred during the loading session
  93563. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  93564. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  93565. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93566. * @param mimeType defines an optional mime type information
  93567. */
  93568. 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);
  93569. /**
  93570. * Update the url (and optional buffer) of this texture if url was null during construction.
  93571. * @param url the url of the texture
  93572. * @param buffer the buffer of the texture (defaults to null)
  93573. * @param onLoad callback called when the texture is loaded (defaults to null)
  93574. */
  93575. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  93576. /**
  93577. * Finish the loading sequence of a texture flagged as delayed load.
  93578. * @hidden
  93579. */
  93580. delayLoad(): void;
  93581. private _prepareRowForTextureGeneration;
  93582. /**
  93583. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  93584. * @returns the transform matrix of the texture.
  93585. */
  93586. getTextureMatrix(uBase?: number): Matrix;
  93587. /**
  93588. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  93589. * @returns The reflection texture transform
  93590. */
  93591. getReflectionTextureMatrix(): Matrix;
  93592. /**
  93593. * Clones the texture.
  93594. * @returns the cloned texture
  93595. */
  93596. clone(): Texture;
  93597. /**
  93598. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  93599. * @returns The JSON representation of the texture
  93600. */
  93601. serialize(): any;
  93602. /**
  93603. * Get the current class name of the texture useful for serialization or dynamic coding.
  93604. * @returns "Texture"
  93605. */
  93606. getClassName(): string;
  93607. /**
  93608. * Dispose the texture and release its associated resources.
  93609. */
  93610. dispose(): void;
  93611. /**
  93612. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  93613. * @param parsedTexture Define the JSON representation of the texture
  93614. * @param scene Define the scene the parsed texture should be instantiated in
  93615. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  93616. * @returns The parsed texture if successful
  93617. */
  93618. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  93619. /**
  93620. * Creates a texture from its base 64 representation.
  93621. * @param data Define the base64 payload without the data: prefix
  93622. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93623. * @param scene Define the scene the texture should belong to
  93624. * @param noMipmap Forces the texture to not create mip map information if true
  93625. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93626. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93627. * @param onLoad define a callback triggered when the texture has been loaded
  93628. * @param onError define a callback triggered when an error occurred during the loading session
  93629. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93630. * @returns the created texture
  93631. */
  93632. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  93633. /**
  93634. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  93635. * @param data Define the base64 payload without the data: prefix
  93636. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  93637. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  93638. * @param scene Define the scene the texture should belong to
  93639. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  93640. * @param noMipmap Forces the texture to not create mip map information if true
  93641. * @param invertY define if the texture needs to be inverted on the y axis during loading
  93642. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  93643. * @param onLoad define a callback triggered when the texture has been loaded
  93644. * @param onError define a callback triggered when an error occurred during the loading session
  93645. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  93646. * @returns the created texture
  93647. */
  93648. 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;
  93649. }
  93650. }
  93651. declare module BABYLON {
  93652. /**
  93653. * PostProcessManager is used to manage one or more post processes or post process pipelines
  93654. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  93655. */
  93656. export class PostProcessManager {
  93657. private _scene;
  93658. private _indexBuffer;
  93659. private _vertexBuffers;
  93660. /**
  93661. * Creates a new instance PostProcess
  93662. * @param scene The scene that the post process is associated with.
  93663. */
  93664. constructor(scene: Scene);
  93665. private _prepareBuffers;
  93666. private _buildIndexBuffer;
  93667. /**
  93668. * Rebuilds the vertex buffers of the manager.
  93669. * @hidden
  93670. */
  93671. _rebuild(): void;
  93672. /**
  93673. * Prepares a frame to be run through a post process.
  93674. * @param sourceTexture The input texture to the post procesess. (default: null)
  93675. * @param postProcesses An array of post processes to be run. (default: null)
  93676. * @returns True if the post processes were able to be run.
  93677. * @hidden
  93678. */
  93679. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  93680. /**
  93681. * Manually render a set of post processes to a texture.
  93682. * @param postProcesses An array of post processes to be run.
  93683. * @param targetTexture The target texture to render to.
  93684. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  93685. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  93686. * @param lodLevel defines which lod of the texture to render to
  93687. */
  93688. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  93689. /**
  93690. * Finalize the result of the output of the postprocesses.
  93691. * @param doNotPresent If true the result will not be displayed to the screen.
  93692. * @param targetTexture The target texture to render to.
  93693. * @param faceIndex The index of the face to bind the target texture to.
  93694. * @param postProcesses The array of post processes to render.
  93695. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  93696. * @hidden
  93697. */
  93698. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  93699. /**
  93700. * Disposes of the post process manager.
  93701. */
  93702. dispose(): void;
  93703. }
  93704. }
  93705. declare module BABYLON {
  93706. /**
  93707. * This Helps creating a texture that will be created from a camera in your scene.
  93708. * It is basically a dynamic texture that could be used to create special effects for instance.
  93709. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  93710. */
  93711. export class RenderTargetTexture extends Texture {
  93712. isCube: boolean;
  93713. /**
  93714. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  93715. */
  93716. static readonly REFRESHRATE_RENDER_ONCE: number;
  93717. /**
  93718. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  93719. */
  93720. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  93721. /**
  93722. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  93723. * the central point of your effect and can save a lot of performances.
  93724. */
  93725. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  93726. /**
  93727. * Use this predicate to dynamically define the list of mesh you want to render.
  93728. * If set, the renderList property will be overwritten.
  93729. */
  93730. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  93731. private _renderList;
  93732. /**
  93733. * Use this list to define the list of mesh you want to render.
  93734. */
  93735. get renderList(): Nullable<Array<AbstractMesh>>;
  93736. set renderList(value: Nullable<Array<AbstractMesh>>);
  93737. /**
  93738. * Use this function to overload the renderList array at rendering time.
  93739. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  93740. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  93741. * the cube (if the RTT is a cube, else layerOrFace=0).
  93742. * The renderList passed to the function is the current render list (the one that will be used if the function returns null)
  93743. */
  93744. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>) => Nullable<Array<AbstractMesh>>;
  93745. private _hookArray;
  93746. /**
  93747. * Define if particles should be rendered in your texture.
  93748. */
  93749. renderParticles: boolean;
  93750. /**
  93751. * Define if sprites should be rendered in your texture.
  93752. */
  93753. renderSprites: boolean;
  93754. /**
  93755. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  93756. */
  93757. coordinatesMode: number;
  93758. /**
  93759. * Define the camera used to render the texture.
  93760. */
  93761. activeCamera: Nullable<Camera>;
  93762. /**
  93763. * Override the render function of the texture with your own one.
  93764. */
  93765. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  93766. /**
  93767. * Define if camera post processes should be use while rendering the texture.
  93768. */
  93769. useCameraPostProcesses: boolean;
  93770. /**
  93771. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  93772. */
  93773. ignoreCameraViewport: boolean;
  93774. private _postProcessManager;
  93775. private _postProcesses;
  93776. private _resizeObserver;
  93777. /**
  93778. * An event triggered when the texture is unbind.
  93779. */
  93780. onBeforeBindObservable: Observable<RenderTargetTexture>;
  93781. /**
  93782. * An event triggered when the texture is unbind.
  93783. */
  93784. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  93785. private _onAfterUnbindObserver;
  93786. /**
  93787. * Set a after unbind callback in the texture.
  93788. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  93789. */
  93790. set onAfterUnbind(callback: () => void);
  93791. /**
  93792. * An event triggered before rendering the texture
  93793. */
  93794. onBeforeRenderObservable: Observable<number>;
  93795. private _onBeforeRenderObserver;
  93796. /**
  93797. * Set a before render callback in the texture.
  93798. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  93799. */
  93800. set onBeforeRender(callback: (faceIndex: number) => void);
  93801. /**
  93802. * An event triggered after rendering the texture
  93803. */
  93804. onAfterRenderObservable: Observable<number>;
  93805. private _onAfterRenderObserver;
  93806. /**
  93807. * Set a after render callback in the texture.
  93808. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  93809. */
  93810. set onAfterRender(callback: (faceIndex: number) => void);
  93811. /**
  93812. * An event triggered after the texture clear
  93813. */
  93814. onClearObservable: Observable<Engine>;
  93815. private _onClearObserver;
  93816. /**
  93817. * Set a clear callback in the texture.
  93818. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  93819. */
  93820. set onClear(callback: (Engine: Engine) => void);
  93821. /**
  93822. * An event triggered when the texture is resized.
  93823. */
  93824. onResizeObservable: Observable<RenderTargetTexture>;
  93825. /**
  93826. * Define the clear color of the Render Target if it should be different from the scene.
  93827. */
  93828. clearColor: Color4;
  93829. protected _size: number | {
  93830. width: number;
  93831. height: number;
  93832. layers?: number;
  93833. };
  93834. protected _initialSizeParameter: number | {
  93835. width: number;
  93836. height: number;
  93837. } | {
  93838. ratio: number;
  93839. };
  93840. protected _sizeRatio: Nullable<number>;
  93841. /** @hidden */
  93842. _generateMipMaps: boolean;
  93843. protected _renderingManager: RenderingManager;
  93844. /** @hidden */
  93845. _waitingRenderList: string[];
  93846. protected _doNotChangeAspectRatio: boolean;
  93847. protected _currentRefreshId: number;
  93848. protected _refreshRate: number;
  93849. protected _textureMatrix: Matrix;
  93850. protected _samples: number;
  93851. protected _renderTargetOptions: RenderTargetCreationOptions;
  93852. /**
  93853. * Gets render target creation options that were used.
  93854. */
  93855. get renderTargetOptions(): RenderTargetCreationOptions;
  93856. protected _engine: Engine;
  93857. protected _onRatioRescale(): void;
  93858. /**
  93859. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  93860. * It must define where the camera used to render the texture is set
  93861. */
  93862. boundingBoxPosition: Vector3;
  93863. private _boundingBoxSize;
  93864. /**
  93865. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  93866. * When defined, the cubemap will switch to local mode
  93867. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  93868. * @example https://www.babylonjs-playground.com/#RNASML
  93869. */
  93870. set boundingBoxSize(value: Vector3);
  93871. get boundingBoxSize(): Vector3;
  93872. /**
  93873. * In case the RTT has been created with a depth texture, get the associated
  93874. * depth texture.
  93875. * Otherwise, return null.
  93876. */
  93877. get depthStencilTexture(): Nullable<InternalTexture>;
  93878. /**
  93879. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  93880. * or used a shadow, depth texture...
  93881. * @param name The friendly name of the texture
  93882. * @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)
  93883. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  93884. * @param generateMipMaps True if mip maps need to be generated after render.
  93885. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  93886. * @param type The type of the buffer in the RTT (int, half float, float...)
  93887. * @param isCube True if a cube texture needs to be created
  93888. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  93889. * @param generateDepthBuffer True to generate a depth buffer
  93890. * @param generateStencilBuffer True to generate a stencil buffer
  93891. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  93892. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  93893. * @param delayAllocation if the texture allocation should be delayed (default: false)
  93894. */
  93895. constructor(name: string, size: number | {
  93896. width: number;
  93897. height: number;
  93898. layers?: number;
  93899. } | {
  93900. ratio: number;
  93901. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  93902. /**
  93903. * Creates a depth stencil texture.
  93904. * This is only available in WebGL 2 or with the depth texture extension available.
  93905. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  93906. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  93907. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  93908. */
  93909. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  93910. private _processSizeParameter;
  93911. /**
  93912. * Define the number of samples to use in case of MSAA.
  93913. * It defaults to one meaning no MSAA has been enabled.
  93914. */
  93915. get samples(): number;
  93916. set samples(value: number);
  93917. /**
  93918. * Resets the refresh counter of the texture and start bak from scratch.
  93919. * Could be useful to regenerate the texture if it is setup to render only once.
  93920. */
  93921. resetRefreshCounter(): void;
  93922. /**
  93923. * Define the refresh rate of the texture or the rendering frequency.
  93924. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  93925. */
  93926. get refreshRate(): number;
  93927. set refreshRate(value: number);
  93928. /**
  93929. * Adds a post process to the render target rendering passes.
  93930. * @param postProcess define the post process to add
  93931. */
  93932. addPostProcess(postProcess: PostProcess): void;
  93933. /**
  93934. * Clear all the post processes attached to the render target
  93935. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  93936. */
  93937. clearPostProcesses(dispose?: boolean): void;
  93938. /**
  93939. * Remove one of the post process from the list of attached post processes to the texture
  93940. * @param postProcess define the post process to remove from the list
  93941. */
  93942. removePostProcess(postProcess: PostProcess): void;
  93943. /** @hidden */
  93944. _shouldRender(): boolean;
  93945. /**
  93946. * Gets the actual render size of the texture.
  93947. * @returns the width of the render size
  93948. */
  93949. getRenderSize(): number;
  93950. /**
  93951. * Gets the actual render width of the texture.
  93952. * @returns the width of the render size
  93953. */
  93954. getRenderWidth(): number;
  93955. /**
  93956. * Gets the actual render height of the texture.
  93957. * @returns the height of the render size
  93958. */
  93959. getRenderHeight(): number;
  93960. /**
  93961. * Gets the actual number of layers of the texture.
  93962. * @returns the number of layers
  93963. */
  93964. getRenderLayers(): number;
  93965. /**
  93966. * Get if the texture can be rescaled or not.
  93967. */
  93968. get canRescale(): boolean;
  93969. /**
  93970. * Resize the texture using a ratio.
  93971. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  93972. */
  93973. scale(ratio: number): void;
  93974. /**
  93975. * Get the texture reflection matrix used to rotate/transform the reflection.
  93976. * @returns the reflection matrix
  93977. */
  93978. getReflectionTextureMatrix(): Matrix;
  93979. /**
  93980. * Resize the texture to a new desired size.
  93981. * Be carrefull as it will recreate all the data in the new texture.
  93982. * @param size Define the new size. It can be:
  93983. * - a number for squared texture,
  93984. * - an object containing { width: number, height: number }
  93985. * - or an object containing a ratio { ratio: number }
  93986. */
  93987. resize(size: number | {
  93988. width: number;
  93989. height: number;
  93990. } | {
  93991. ratio: number;
  93992. }): void;
  93993. private _defaultRenderListPrepared;
  93994. /**
  93995. * Renders all the objects from the render list into the texture.
  93996. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  93997. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  93998. */
  93999. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  94000. private _bestReflectionRenderTargetDimension;
  94001. private _prepareRenderingManager;
  94002. /**
  94003. * @hidden
  94004. * @param faceIndex face index to bind to if this is a cubetexture
  94005. * @param layer defines the index of the texture to bind in the array
  94006. */
  94007. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  94008. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  94009. private renderToTarget;
  94010. /**
  94011. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  94012. * This allowed control for front to back rendering or reversly depending of the special needs.
  94013. *
  94014. * @param renderingGroupId The rendering group id corresponding to its index
  94015. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  94016. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  94017. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  94018. */
  94019. 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;
  94020. /**
  94021. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  94022. *
  94023. * @param renderingGroupId The rendering group id corresponding to its index
  94024. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  94025. */
  94026. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  94027. /**
  94028. * Clones the texture.
  94029. * @returns the cloned texture
  94030. */
  94031. clone(): RenderTargetTexture;
  94032. /**
  94033. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  94034. * @returns The JSON representation of the texture
  94035. */
  94036. serialize(): any;
  94037. /**
  94038. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  94039. */
  94040. disposeFramebufferObjects(): void;
  94041. /**
  94042. * Dispose the texture and release its associated resources.
  94043. */
  94044. dispose(): void;
  94045. /** @hidden */
  94046. _rebuild(): void;
  94047. /**
  94048. * Clear the info related to rendering groups preventing retention point in material dispose.
  94049. */
  94050. freeRenderingGroups(): void;
  94051. /**
  94052. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  94053. * @returns the view count
  94054. */
  94055. getViewCount(): number;
  94056. }
  94057. }
  94058. declare module BABYLON {
  94059. /**
  94060. * Options for compiling materials.
  94061. */
  94062. export interface IMaterialCompilationOptions {
  94063. /**
  94064. * Defines whether clip planes are enabled.
  94065. */
  94066. clipPlane: boolean;
  94067. /**
  94068. * Defines whether instances are enabled.
  94069. */
  94070. useInstances: boolean;
  94071. }
  94072. /**
  94073. * Base class for the main features of a material in Babylon.js
  94074. */
  94075. export class Material implements IAnimatable {
  94076. /**
  94077. * Returns the triangle fill mode
  94078. */
  94079. static readonly TriangleFillMode: number;
  94080. /**
  94081. * Returns the wireframe mode
  94082. */
  94083. static readonly WireFrameFillMode: number;
  94084. /**
  94085. * Returns the point fill mode
  94086. */
  94087. static readonly PointFillMode: number;
  94088. /**
  94089. * Returns the point list draw mode
  94090. */
  94091. static readonly PointListDrawMode: number;
  94092. /**
  94093. * Returns the line list draw mode
  94094. */
  94095. static readonly LineListDrawMode: number;
  94096. /**
  94097. * Returns the line loop draw mode
  94098. */
  94099. static readonly LineLoopDrawMode: number;
  94100. /**
  94101. * Returns the line strip draw mode
  94102. */
  94103. static readonly LineStripDrawMode: number;
  94104. /**
  94105. * Returns the triangle strip draw mode
  94106. */
  94107. static readonly TriangleStripDrawMode: number;
  94108. /**
  94109. * Returns the triangle fan draw mode
  94110. */
  94111. static readonly TriangleFanDrawMode: number;
  94112. /**
  94113. * Stores the clock-wise side orientation
  94114. */
  94115. static readonly ClockWiseSideOrientation: number;
  94116. /**
  94117. * Stores the counter clock-wise side orientation
  94118. */
  94119. static readonly CounterClockWiseSideOrientation: number;
  94120. /**
  94121. * The dirty texture flag value
  94122. */
  94123. static readonly TextureDirtyFlag: number;
  94124. /**
  94125. * The dirty light flag value
  94126. */
  94127. static readonly LightDirtyFlag: number;
  94128. /**
  94129. * The dirty fresnel flag value
  94130. */
  94131. static readonly FresnelDirtyFlag: number;
  94132. /**
  94133. * The dirty attribute flag value
  94134. */
  94135. static readonly AttributesDirtyFlag: number;
  94136. /**
  94137. * The dirty misc flag value
  94138. */
  94139. static readonly MiscDirtyFlag: number;
  94140. /**
  94141. * The all dirty flag value
  94142. */
  94143. static readonly AllDirtyFlag: number;
  94144. /**
  94145. * The ID of the material
  94146. */
  94147. id: string;
  94148. /**
  94149. * Gets or sets the unique id of the material
  94150. */
  94151. uniqueId: number;
  94152. /**
  94153. * The name of the material
  94154. */
  94155. name: string;
  94156. /**
  94157. * Gets or sets user defined metadata
  94158. */
  94159. metadata: any;
  94160. /**
  94161. * For internal use only. Please do not use.
  94162. */
  94163. reservedDataStore: any;
  94164. /**
  94165. * Specifies if the ready state should be checked on each call
  94166. */
  94167. checkReadyOnEveryCall: boolean;
  94168. /**
  94169. * Specifies if the ready state should be checked once
  94170. */
  94171. checkReadyOnlyOnce: boolean;
  94172. /**
  94173. * The state of the material
  94174. */
  94175. state: string;
  94176. /**
  94177. * The alpha value of the material
  94178. */
  94179. protected _alpha: number;
  94180. /**
  94181. * List of inspectable custom properties (used by the Inspector)
  94182. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94183. */
  94184. inspectableCustomProperties: IInspectable[];
  94185. /**
  94186. * Sets the alpha value of the material
  94187. */
  94188. set alpha(value: number);
  94189. /**
  94190. * Gets the alpha value of the material
  94191. */
  94192. get alpha(): number;
  94193. /**
  94194. * Specifies if back face culling is enabled
  94195. */
  94196. protected _backFaceCulling: boolean;
  94197. /**
  94198. * Sets the back-face culling state
  94199. */
  94200. set backFaceCulling(value: boolean);
  94201. /**
  94202. * Gets the back-face culling state
  94203. */
  94204. get backFaceCulling(): boolean;
  94205. /**
  94206. * Stores the value for side orientation
  94207. */
  94208. sideOrientation: number;
  94209. /**
  94210. * Callback triggered when the material is compiled
  94211. */
  94212. onCompiled: Nullable<(effect: Effect) => void>;
  94213. /**
  94214. * Callback triggered when an error occurs
  94215. */
  94216. onError: Nullable<(effect: Effect, errors: string) => void>;
  94217. /**
  94218. * Callback triggered to get the render target textures
  94219. */
  94220. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  94221. /**
  94222. * Gets a boolean indicating that current material needs to register RTT
  94223. */
  94224. get hasRenderTargetTextures(): boolean;
  94225. /**
  94226. * Specifies if the material should be serialized
  94227. */
  94228. doNotSerialize: boolean;
  94229. /**
  94230. * @hidden
  94231. */
  94232. _storeEffectOnSubMeshes: boolean;
  94233. /**
  94234. * Stores the animations for the material
  94235. */
  94236. animations: Nullable<Array<Animation>>;
  94237. /**
  94238. * An event triggered when the material is disposed
  94239. */
  94240. onDisposeObservable: Observable<Material>;
  94241. /**
  94242. * An observer which watches for dispose events
  94243. */
  94244. private _onDisposeObserver;
  94245. private _onUnBindObservable;
  94246. /**
  94247. * Called during a dispose event
  94248. */
  94249. set onDispose(callback: () => void);
  94250. private _onBindObservable;
  94251. /**
  94252. * An event triggered when the material is bound
  94253. */
  94254. get onBindObservable(): Observable<AbstractMesh>;
  94255. /**
  94256. * An observer which watches for bind events
  94257. */
  94258. private _onBindObserver;
  94259. /**
  94260. * Called during a bind event
  94261. */
  94262. set onBind(callback: (Mesh: AbstractMesh) => void);
  94263. /**
  94264. * An event triggered when the material is unbound
  94265. */
  94266. get onUnBindObservable(): Observable<Material>;
  94267. /**
  94268. * Stores the value of the alpha mode
  94269. */
  94270. private _alphaMode;
  94271. /**
  94272. * Sets the value of the alpha mode.
  94273. *
  94274. * | Value | Type | Description |
  94275. * | --- | --- | --- |
  94276. * | 0 | ALPHA_DISABLE | |
  94277. * | 1 | ALPHA_ADD | |
  94278. * | 2 | ALPHA_COMBINE | |
  94279. * | 3 | ALPHA_SUBTRACT | |
  94280. * | 4 | ALPHA_MULTIPLY | |
  94281. * | 5 | ALPHA_MAXIMIZED | |
  94282. * | 6 | ALPHA_ONEONE | |
  94283. * | 7 | ALPHA_PREMULTIPLIED | |
  94284. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  94285. * | 9 | ALPHA_INTERPOLATE | |
  94286. * | 10 | ALPHA_SCREENMODE | |
  94287. *
  94288. */
  94289. set alphaMode(value: number);
  94290. /**
  94291. * Gets the value of the alpha mode
  94292. */
  94293. get alphaMode(): number;
  94294. /**
  94295. * Stores the state of the need depth pre-pass value
  94296. */
  94297. private _needDepthPrePass;
  94298. /**
  94299. * Sets the need depth pre-pass value
  94300. */
  94301. set needDepthPrePass(value: boolean);
  94302. /**
  94303. * Gets the depth pre-pass value
  94304. */
  94305. get needDepthPrePass(): boolean;
  94306. /**
  94307. * Specifies if depth writing should be disabled
  94308. */
  94309. disableDepthWrite: boolean;
  94310. /**
  94311. * Specifies if depth writing should be forced
  94312. */
  94313. forceDepthWrite: boolean;
  94314. /**
  94315. * Specifies the depth function that should be used. 0 means the default engine function
  94316. */
  94317. depthFunction: number;
  94318. /**
  94319. * Specifies if there should be a separate pass for culling
  94320. */
  94321. separateCullingPass: boolean;
  94322. /**
  94323. * Stores the state specifing if fog should be enabled
  94324. */
  94325. private _fogEnabled;
  94326. /**
  94327. * Sets the state for enabling fog
  94328. */
  94329. set fogEnabled(value: boolean);
  94330. /**
  94331. * Gets the value of the fog enabled state
  94332. */
  94333. get fogEnabled(): boolean;
  94334. /**
  94335. * Stores the size of points
  94336. */
  94337. pointSize: number;
  94338. /**
  94339. * Stores the z offset value
  94340. */
  94341. zOffset: number;
  94342. /**
  94343. * Gets a value specifying if wireframe mode is enabled
  94344. */
  94345. get wireframe(): boolean;
  94346. /**
  94347. * Sets the state of wireframe mode
  94348. */
  94349. set wireframe(value: boolean);
  94350. /**
  94351. * Gets the value specifying if point clouds are enabled
  94352. */
  94353. get pointsCloud(): boolean;
  94354. /**
  94355. * Sets the state of point cloud mode
  94356. */
  94357. set pointsCloud(value: boolean);
  94358. /**
  94359. * Gets the material fill mode
  94360. */
  94361. get fillMode(): number;
  94362. /**
  94363. * Sets the material fill mode
  94364. */
  94365. set fillMode(value: number);
  94366. /**
  94367. * @hidden
  94368. * Stores the effects for the material
  94369. */
  94370. _effect: Nullable<Effect>;
  94371. /**
  94372. * Specifies if uniform buffers should be used
  94373. */
  94374. private _useUBO;
  94375. /**
  94376. * Stores a reference to the scene
  94377. */
  94378. private _scene;
  94379. /**
  94380. * Stores the fill mode state
  94381. */
  94382. private _fillMode;
  94383. /**
  94384. * Specifies if the depth write state should be cached
  94385. */
  94386. private _cachedDepthWriteState;
  94387. /**
  94388. * Specifies if the depth function state should be cached
  94389. */
  94390. private _cachedDepthFunctionState;
  94391. /**
  94392. * Stores the uniform buffer
  94393. */
  94394. protected _uniformBuffer: UniformBuffer;
  94395. /** @hidden */
  94396. _indexInSceneMaterialArray: number;
  94397. /** @hidden */
  94398. meshMap: Nullable<{
  94399. [id: string]: AbstractMesh | undefined;
  94400. }>;
  94401. /**
  94402. * Creates a material instance
  94403. * @param name defines the name of the material
  94404. * @param scene defines the scene to reference
  94405. * @param doNotAdd specifies if the material should be added to the scene
  94406. */
  94407. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  94408. /**
  94409. * Returns a string representation of the current material
  94410. * @param fullDetails defines a boolean indicating which levels of logging is desired
  94411. * @returns a string with material information
  94412. */
  94413. toString(fullDetails?: boolean): string;
  94414. /**
  94415. * Gets the class name of the material
  94416. * @returns a string with the class name of the material
  94417. */
  94418. getClassName(): string;
  94419. /**
  94420. * Specifies if updates for the material been locked
  94421. */
  94422. get isFrozen(): boolean;
  94423. /**
  94424. * Locks updates for the material
  94425. */
  94426. freeze(): void;
  94427. /**
  94428. * Unlocks updates for the material
  94429. */
  94430. unfreeze(): void;
  94431. /**
  94432. * Specifies if the material is ready to be used
  94433. * @param mesh defines the mesh to check
  94434. * @param useInstances specifies if instances should be used
  94435. * @returns a boolean indicating if the material is ready to be used
  94436. */
  94437. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  94438. /**
  94439. * Specifies that the submesh is ready to be used
  94440. * @param mesh defines the mesh to check
  94441. * @param subMesh defines which submesh to check
  94442. * @param useInstances specifies that instances should be used
  94443. * @returns a boolean indicating that the submesh is ready or not
  94444. */
  94445. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94446. /**
  94447. * Returns the material effect
  94448. * @returns the effect associated with the material
  94449. */
  94450. getEffect(): Nullable<Effect>;
  94451. /**
  94452. * Returns the current scene
  94453. * @returns a Scene
  94454. */
  94455. getScene(): Scene;
  94456. /**
  94457. * Specifies if the material will require alpha blending
  94458. * @returns a boolean specifying if alpha blending is needed
  94459. */
  94460. needAlphaBlending(): boolean;
  94461. /**
  94462. * Specifies if the mesh will require alpha blending
  94463. * @param mesh defines the mesh to check
  94464. * @returns a boolean specifying if alpha blending is needed for the mesh
  94465. */
  94466. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  94467. /**
  94468. * Specifies if this material should be rendered in alpha test mode
  94469. * @returns a boolean specifying if an alpha test is needed.
  94470. */
  94471. needAlphaTesting(): boolean;
  94472. /**
  94473. * Gets the texture used for the alpha test
  94474. * @returns the texture to use for alpha testing
  94475. */
  94476. getAlphaTestTexture(): Nullable<BaseTexture>;
  94477. /**
  94478. * Marks the material to indicate that it needs to be re-calculated
  94479. */
  94480. markDirty(): void;
  94481. /** @hidden */
  94482. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  94483. /**
  94484. * Binds the material to the mesh
  94485. * @param world defines the world transformation matrix
  94486. * @param mesh defines the mesh to bind the material to
  94487. */
  94488. bind(world: Matrix, mesh?: Mesh): void;
  94489. /**
  94490. * Binds the submesh to the material
  94491. * @param world defines the world transformation matrix
  94492. * @param mesh defines the mesh containing the submesh
  94493. * @param subMesh defines the submesh to bind the material to
  94494. */
  94495. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  94496. /**
  94497. * Binds the world matrix to the material
  94498. * @param world defines the world transformation matrix
  94499. */
  94500. bindOnlyWorldMatrix(world: Matrix): void;
  94501. /**
  94502. * Binds the scene's uniform buffer to the effect.
  94503. * @param effect defines the effect to bind to the scene uniform buffer
  94504. * @param sceneUbo defines the uniform buffer storing scene data
  94505. */
  94506. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  94507. /**
  94508. * Binds the view matrix to the effect
  94509. * @param effect defines the effect to bind the view matrix to
  94510. */
  94511. bindView(effect: Effect): void;
  94512. /**
  94513. * Binds the view projection matrix to the effect
  94514. * @param effect defines the effect to bind the view projection matrix to
  94515. */
  94516. bindViewProjection(effect: Effect): void;
  94517. /**
  94518. * Specifies if material alpha testing should be turned on for the mesh
  94519. * @param mesh defines the mesh to check
  94520. */
  94521. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  94522. /**
  94523. * Processes to execute after binding the material to a mesh
  94524. * @param mesh defines the rendered mesh
  94525. */
  94526. protected _afterBind(mesh?: Mesh): void;
  94527. /**
  94528. * Unbinds the material from the mesh
  94529. */
  94530. unbind(): void;
  94531. /**
  94532. * Gets the active textures from the material
  94533. * @returns an array of textures
  94534. */
  94535. getActiveTextures(): BaseTexture[];
  94536. /**
  94537. * Specifies if the material uses a texture
  94538. * @param texture defines the texture to check against the material
  94539. * @returns a boolean specifying if the material uses the texture
  94540. */
  94541. hasTexture(texture: BaseTexture): boolean;
  94542. /**
  94543. * Makes a duplicate of the material, and gives it a new name
  94544. * @param name defines the new name for the duplicated material
  94545. * @returns the cloned material
  94546. */
  94547. clone(name: string): Nullable<Material>;
  94548. /**
  94549. * Gets the meshes bound to the material
  94550. * @returns an array of meshes bound to the material
  94551. */
  94552. getBindedMeshes(): AbstractMesh[];
  94553. /**
  94554. * Force shader compilation
  94555. * @param mesh defines the mesh associated with this material
  94556. * @param onCompiled defines a function to execute once the material is compiled
  94557. * @param options defines the options to configure the compilation
  94558. * @param onError defines a function to execute if the material fails compiling
  94559. */
  94560. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  94561. /**
  94562. * Force shader compilation
  94563. * @param mesh defines the mesh that will use this material
  94564. * @param options defines additional options for compiling the shaders
  94565. * @returns a promise that resolves when the compilation completes
  94566. */
  94567. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  94568. private static readonly _AllDirtyCallBack;
  94569. private static readonly _ImageProcessingDirtyCallBack;
  94570. private static readonly _TextureDirtyCallBack;
  94571. private static readonly _FresnelDirtyCallBack;
  94572. private static readonly _MiscDirtyCallBack;
  94573. private static readonly _LightsDirtyCallBack;
  94574. private static readonly _AttributeDirtyCallBack;
  94575. private static _FresnelAndMiscDirtyCallBack;
  94576. private static _TextureAndMiscDirtyCallBack;
  94577. private static readonly _DirtyCallbackArray;
  94578. private static readonly _RunDirtyCallBacks;
  94579. /**
  94580. * Marks a define in the material to indicate that it needs to be re-computed
  94581. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  94582. */
  94583. markAsDirty(flag: number): void;
  94584. /**
  94585. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  94586. * @param func defines a function which checks material defines against the submeshes
  94587. */
  94588. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  94589. /**
  94590. * Indicates that we need to re-calculated for all submeshes
  94591. */
  94592. protected _markAllSubMeshesAsAllDirty(): void;
  94593. /**
  94594. * Indicates that image processing needs to be re-calculated for all submeshes
  94595. */
  94596. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  94597. /**
  94598. * Indicates that textures need to be re-calculated for all submeshes
  94599. */
  94600. protected _markAllSubMeshesAsTexturesDirty(): void;
  94601. /**
  94602. * Indicates that fresnel needs to be re-calculated for all submeshes
  94603. */
  94604. protected _markAllSubMeshesAsFresnelDirty(): void;
  94605. /**
  94606. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  94607. */
  94608. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  94609. /**
  94610. * Indicates that lights need to be re-calculated for all submeshes
  94611. */
  94612. protected _markAllSubMeshesAsLightsDirty(): void;
  94613. /**
  94614. * Indicates that attributes need to be re-calculated for all submeshes
  94615. */
  94616. protected _markAllSubMeshesAsAttributesDirty(): void;
  94617. /**
  94618. * Indicates that misc needs to be re-calculated for all submeshes
  94619. */
  94620. protected _markAllSubMeshesAsMiscDirty(): void;
  94621. /**
  94622. * Indicates that textures and misc need to be re-calculated for all submeshes
  94623. */
  94624. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  94625. /**
  94626. * Disposes the material
  94627. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  94628. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  94629. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  94630. */
  94631. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  94632. /** @hidden */
  94633. private releaseVertexArrayObject;
  94634. /**
  94635. * Serializes this material
  94636. * @returns the serialized material object
  94637. */
  94638. serialize(): any;
  94639. /**
  94640. * Creates a material from parsed material data
  94641. * @param parsedMaterial defines parsed material data
  94642. * @param scene defines the hosting scene
  94643. * @param rootUrl defines the root URL to use to load textures
  94644. * @returns a new material
  94645. */
  94646. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  94647. }
  94648. }
  94649. declare module BABYLON {
  94650. /**
  94651. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94652. * separate meshes. This can be use to improve performances.
  94653. * @see http://doc.babylonjs.com/how_to/multi_materials
  94654. */
  94655. export class MultiMaterial extends Material {
  94656. private _subMaterials;
  94657. /**
  94658. * Gets or Sets the list of Materials used within the multi material.
  94659. * They need to be ordered according to the submeshes order in the associated mesh
  94660. */
  94661. get subMaterials(): Nullable<Material>[];
  94662. set subMaterials(value: Nullable<Material>[]);
  94663. /**
  94664. * Function used to align with Node.getChildren()
  94665. * @returns the list of Materials used within the multi material
  94666. */
  94667. getChildren(): Nullable<Material>[];
  94668. /**
  94669. * Instantiates a new Multi Material
  94670. * A multi-material is used to apply different materials to different parts of the same object without the need of
  94671. * separate meshes. This can be use to improve performances.
  94672. * @see http://doc.babylonjs.com/how_to/multi_materials
  94673. * @param name Define the name in the scene
  94674. * @param scene Define the scene the material belongs to
  94675. */
  94676. constructor(name: string, scene: Scene);
  94677. private _hookArray;
  94678. /**
  94679. * Get one of the submaterial by its index in the submaterials array
  94680. * @param index The index to look the sub material at
  94681. * @returns The Material if the index has been defined
  94682. */
  94683. getSubMaterial(index: number): Nullable<Material>;
  94684. /**
  94685. * Get the list of active textures for the whole sub materials list.
  94686. * @returns All the textures that will be used during the rendering
  94687. */
  94688. getActiveTextures(): BaseTexture[];
  94689. /**
  94690. * Gets the current class name of the material e.g. "MultiMaterial"
  94691. * Mainly use in serialization.
  94692. * @returns the class name
  94693. */
  94694. getClassName(): string;
  94695. /**
  94696. * Checks if the material is ready to render the requested sub mesh
  94697. * @param mesh Define the mesh the submesh belongs to
  94698. * @param subMesh Define the sub mesh to look readyness for
  94699. * @param useInstances Define whether or not the material is used with instances
  94700. * @returns true if ready, otherwise false
  94701. */
  94702. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  94703. /**
  94704. * Clones the current material and its related sub materials
  94705. * @param name Define the name of the newly cloned material
  94706. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  94707. * @returns the cloned material
  94708. */
  94709. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  94710. /**
  94711. * Serializes the materials into a JSON representation.
  94712. * @returns the JSON representation
  94713. */
  94714. serialize(): any;
  94715. /**
  94716. * Dispose the material and release its associated resources
  94717. * @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)
  94718. * @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)
  94719. * @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)
  94720. */
  94721. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  94722. /**
  94723. * Creates a MultiMaterial from parsed MultiMaterial data.
  94724. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  94725. * @param scene defines the hosting scene
  94726. * @returns a new MultiMaterial
  94727. */
  94728. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  94729. }
  94730. }
  94731. declare module BABYLON {
  94732. /**
  94733. * Base class for submeshes
  94734. */
  94735. export class BaseSubMesh {
  94736. /** @hidden */
  94737. _materialDefines: Nullable<MaterialDefines>;
  94738. /** @hidden */
  94739. _materialEffect: Nullable<Effect>;
  94740. /**
  94741. * Gets material defines used by the effect associated to the sub mesh
  94742. */
  94743. get materialDefines(): Nullable<MaterialDefines>;
  94744. /**
  94745. * Sets material defines used by the effect associated to the sub mesh
  94746. */
  94747. set materialDefines(defines: Nullable<MaterialDefines>);
  94748. /**
  94749. * Gets associated effect
  94750. */
  94751. get effect(): Nullable<Effect>;
  94752. /**
  94753. * Sets associated effect (effect used to render this submesh)
  94754. * @param effect defines the effect to associate with
  94755. * @param defines defines the set of defines used to compile this effect
  94756. */
  94757. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  94758. }
  94759. /**
  94760. * Defines a subdivision inside a mesh
  94761. */
  94762. export class SubMesh extends BaseSubMesh implements ICullable {
  94763. /** the material index to use */
  94764. materialIndex: number;
  94765. /** vertex index start */
  94766. verticesStart: number;
  94767. /** vertices count */
  94768. verticesCount: number;
  94769. /** index start */
  94770. indexStart: number;
  94771. /** indices count */
  94772. indexCount: number;
  94773. /** @hidden */
  94774. _linesIndexCount: number;
  94775. private _mesh;
  94776. private _renderingMesh;
  94777. private _boundingInfo;
  94778. private _linesIndexBuffer;
  94779. /** @hidden */
  94780. _lastColliderWorldVertices: Nullable<Vector3[]>;
  94781. /** @hidden */
  94782. _trianglePlanes: Plane[];
  94783. /** @hidden */
  94784. _lastColliderTransformMatrix: Nullable<Matrix>;
  94785. /** @hidden */
  94786. _renderId: number;
  94787. /** @hidden */
  94788. _alphaIndex: number;
  94789. /** @hidden */
  94790. _distanceToCamera: number;
  94791. /** @hidden */
  94792. _id: number;
  94793. private _currentMaterial;
  94794. /**
  94795. * Add a new submesh to a mesh
  94796. * @param materialIndex defines the material index to use
  94797. * @param verticesStart defines vertex index start
  94798. * @param verticesCount defines vertices count
  94799. * @param indexStart defines index start
  94800. * @param indexCount defines indices count
  94801. * @param mesh defines the parent mesh
  94802. * @param renderingMesh defines an optional rendering mesh
  94803. * @param createBoundingBox defines if bounding box should be created for this submesh
  94804. * @returns the new submesh
  94805. */
  94806. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  94807. /**
  94808. * Creates a new submesh
  94809. * @param materialIndex defines the material index to use
  94810. * @param verticesStart defines vertex index start
  94811. * @param verticesCount defines vertices count
  94812. * @param indexStart defines index start
  94813. * @param indexCount defines indices count
  94814. * @param mesh defines the parent mesh
  94815. * @param renderingMesh defines an optional rendering mesh
  94816. * @param createBoundingBox defines if bounding box should be created for this submesh
  94817. */
  94818. constructor(
  94819. /** the material index to use */
  94820. materialIndex: number,
  94821. /** vertex index start */
  94822. verticesStart: number,
  94823. /** vertices count */
  94824. verticesCount: number,
  94825. /** index start */
  94826. indexStart: number,
  94827. /** indices count */
  94828. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  94829. /**
  94830. * Returns true if this submesh covers the entire parent mesh
  94831. * @ignorenaming
  94832. */
  94833. get IsGlobal(): boolean;
  94834. /**
  94835. * Returns the submesh BoudingInfo object
  94836. * @returns current bounding info (or mesh's one if the submesh is global)
  94837. */
  94838. getBoundingInfo(): BoundingInfo;
  94839. /**
  94840. * Sets the submesh BoundingInfo
  94841. * @param boundingInfo defines the new bounding info to use
  94842. * @returns the SubMesh
  94843. */
  94844. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  94845. /**
  94846. * Returns the mesh of the current submesh
  94847. * @return the parent mesh
  94848. */
  94849. getMesh(): AbstractMesh;
  94850. /**
  94851. * Returns the rendering mesh of the submesh
  94852. * @returns the rendering mesh (could be different from parent mesh)
  94853. */
  94854. getRenderingMesh(): Mesh;
  94855. /**
  94856. * Returns the submesh material
  94857. * @returns null or the current material
  94858. */
  94859. getMaterial(): Nullable<Material>;
  94860. /**
  94861. * Sets a new updated BoundingInfo object to the submesh
  94862. * @param data defines an optional position array to use to determine the bounding info
  94863. * @returns the SubMesh
  94864. */
  94865. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  94866. /** @hidden */
  94867. _checkCollision(collider: Collider): boolean;
  94868. /**
  94869. * Updates the submesh BoundingInfo
  94870. * @param world defines the world matrix to use to update the bounding info
  94871. * @returns the submesh
  94872. */
  94873. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  94874. /**
  94875. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  94876. * @param frustumPlanes defines the frustum planes
  94877. * @returns true if the submesh is intersecting with the frustum
  94878. */
  94879. isInFrustum(frustumPlanes: Plane[]): boolean;
  94880. /**
  94881. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  94882. * @param frustumPlanes defines the frustum planes
  94883. * @returns true if the submesh is inside the frustum
  94884. */
  94885. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  94886. /**
  94887. * Renders the submesh
  94888. * @param enableAlphaMode defines if alpha needs to be used
  94889. * @returns the submesh
  94890. */
  94891. render(enableAlphaMode: boolean): SubMesh;
  94892. /**
  94893. * @hidden
  94894. */
  94895. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  94896. /**
  94897. * Checks if the submesh intersects with a ray
  94898. * @param ray defines the ray to test
  94899. * @returns true is the passed ray intersects the submesh bounding box
  94900. */
  94901. canIntersects(ray: Ray): boolean;
  94902. /**
  94903. * Intersects current submesh with a ray
  94904. * @param ray defines the ray to test
  94905. * @param positions defines mesh's positions array
  94906. * @param indices defines mesh's indices array
  94907. * @param fastCheck defines if only bounding info should be used
  94908. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  94909. * @returns intersection info or null if no intersection
  94910. */
  94911. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  94912. /** @hidden */
  94913. private _intersectLines;
  94914. /** @hidden */
  94915. private _intersectUnIndexedLines;
  94916. /** @hidden */
  94917. private _intersectTriangles;
  94918. /** @hidden */
  94919. private _intersectUnIndexedTriangles;
  94920. /** @hidden */
  94921. _rebuild(): void;
  94922. /**
  94923. * Creates a new submesh from the passed mesh
  94924. * @param newMesh defines the new hosting mesh
  94925. * @param newRenderingMesh defines an optional rendering mesh
  94926. * @returns the new submesh
  94927. */
  94928. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  94929. /**
  94930. * Release associated resources
  94931. */
  94932. dispose(): void;
  94933. /**
  94934. * Gets the class name
  94935. * @returns the string "SubMesh".
  94936. */
  94937. getClassName(): string;
  94938. /**
  94939. * Creates a new submesh from indices data
  94940. * @param materialIndex the index of the main mesh material
  94941. * @param startIndex the index where to start the copy in the mesh indices array
  94942. * @param indexCount the number of indices to copy then from the startIndex
  94943. * @param mesh the main mesh to create the submesh from
  94944. * @param renderingMesh the optional rendering mesh
  94945. * @returns a new submesh
  94946. */
  94947. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  94948. }
  94949. }
  94950. declare module BABYLON {
  94951. /**
  94952. * Class used to represent data loading progression
  94953. */
  94954. export class SceneLoaderFlags {
  94955. private static _ForceFullSceneLoadingForIncremental;
  94956. private static _ShowLoadingScreen;
  94957. private static _CleanBoneMatrixWeights;
  94958. private static _loggingLevel;
  94959. /**
  94960. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  94961. */
  94962. static get ForceFullSceneLoadingForIncremental(): boolean;
  94963. static set ForceFullSceneLoadingForIncremental(value: boolean);
  94964. /**
  94965. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  94966. */
  94967. static get ShowLoadingScreen(): boolean;
  94968. static set ShowLoadingScreen(value: boolean);
  94969. /**
  94970. * Defines the current logging level (while loading the scene)
  94971. * @ignorenaming
  94972. */
  94973. static get loggingLevel(): number;
  94974. static set loggingLevel(value: number);
  94975. /**
  94976. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  94977. */
  94978. static get CleanBoneMatrixWeights(): boolean;
  94979. static set CleanBoneMatrixWeights(value: boolean);
  94980. }
  94981. }
  94982. declare module BABYLON {
  94983. /**
  94984. * Class used to store geometry data (vertex buffers + index buffer)
  94985. */
  94986. export class Geometry implements IGetSetVerticesData {
  94987. /**
  94988. * Gets or sets the ID of the geometry
  94989. */
  94990. id: string;
  94991. /**
  94992. * Gets or sets the unique ID of the geometry
  94993. */
  94994. uniqueId: number;
  94995. /**
  94996. * Gets the delay loading state of the geometry (none by default which means not delayed)
  94997. */
  94998. delayLoadState: number;
  94999. /**
  95000. * Gets the file containing the data to load when running in delay load state
  95001. */
  95002. delayLoadingFile: Nullable<string>;
  95003. /**
  95004. * Callback called when the geometry is updated
  95005. */
  95006. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  95007. private _scene;
  95008. private _engine;
  95009. private _meshes;
  95010. private _totalVertices;
  95011. /** @hidden */
  95012. _indices: IndicesArray;
  95013. /** @hidden */
  95014. _vertexBuffers: {
  95015. [key: string]: VertexBuffer;
  95016. };
  95017. private _isDisposed;
  95018. private _extend;
  95019. private _boundingBias;
  95020. /** @hidden */
  95021. _delayInfo: Array<string>;
  95022. private _indexBuffer;
  95023. private _indexBufferIsUpdatable;
  95024. /** @hidden */
  95025. _boundingInfo: Nullable<BoundingInfo>;
  95026. /** @hidden */
  95027. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  95028. /** @hidden */
  95029. _softwareSkinningFrameId: number;
  95030. private _vertexArrayObjects;
  95031. private _updatable;
  95032. /** @hidden */
  95033. _positions: Nullable<Vector3[]>;
  95034. /**
  95035. * 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
  95036. */
  95037. get boundingBias(): Vector2;
  95038. /**
  95039. * 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
  95040. */
  95041. set boundingBias(value: Vector2);
  95042. /**
  95043. * Static function used to attach a new empty geometry to a mesh
  95044. * @param mesh defines the mesh to attach the geometry to
  95045. * @returns the new Geometry
  95046. */
  95047. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  95048. /**
  95049. * Creates a new geometry
  95050. * @param id defines the unique ID
  95051. * @param scene defines the hosting scene
  95052. * @param vertexData defines the VertexData used to get geometry data
  95053. * @param updatable defines if geometry must be updatable (false by default)
  95054. * @param mesh defines the mesh that will be associated with the geometry
  95055. */
  95056. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  95057. /**
  95058. * Gets the current extend of the geometry
  95059. */
  95060. get extend(): {
  95061. minimum: Vector3;
  95062. maximum: Vector3;
  95063. };
  95064. /**
  95065. * Gets the hosting scene
  95066. * @returns the hosting Scene
  95067. */
  95068. getScene(): Scene;
  95069. /**
  95070. * Gets the hosting engine
  95071. * @returns the hosting Engine
  95072. */
  95073. getEngine(): Engine;
  95074. /**
  95075. * Defines if the geometry is ready to use
  95076. * @returns true if the geometry is ready to be used
  95077. */
  95078. isReady(): boolean;
  95079. /**
  95080. * Gets a value indicating that the geometry should not be serialized
  95081. */
  95082. get doNotSerialize(): boolean;
  95083. /** @hidden */
  95084. _rebuild(): void;
  95085. /**
  95086. * Affects all geometry data in one call
  95087. * @param vertexData defines the geometry data
  95088. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  95089. */
  95090. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  95091. /**
  95092. * Set specific vertex data
  95093. * @param kind defines the data kind (Position, normal, etc...)
  95094. * @param data defines the vertex data to use
  95095. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95096. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95097. */
  95098. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  95099. /**
  95100. * Removes a specific vertex data
  95101. * @param kind defines the data kind (Position, normal, etc...)
  95102. */
  95103. removeVerticesData(kind: string): void;
  95104. /**
  95105. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  95106. * @param buffer defines the vertex buffer to use
  95107. * @param totalVertices defines the total number of vertices for position kind (could be null)
  95108. */
  95109. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  95110. /**
  95111. * Update a specific vertex buffer
  95112. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  95113. * It will do nothing if the buffer is not updatable
  95114. * @param kind defines the data kind (Position, normal, etc...)
  95115. * @param data defines the data to use
  95116. * @param offset defines the offset in the target buffer where to store the data
  95117. * @param useBytes set to true if the offset is in bytes
  95118. */
  95119. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  95120. /**
  95121. * Update a specific vertex buffer
  95122. * This function will create a new buffer if the current one is not updatable
  95123. * @param kind defines the data kind (Position, normal, etc...)
  95124. * @param data defines the data to use
  95125. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  95126. */
  95127. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  95128. private _updateBoundingInfo;
  95129. /** @hidden */
  95130. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  95131. /**
  95132. * Gets total number of vertices
  95133. * @returns the total number of vertices
  95134. */
  95135. getTotalVertices(): number;
  95136. /**
  95137. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95138. * @param kind defines the data kind (Position, normal, etc...)
  95139. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95140. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95141. * @returns a float array containing vertex data
  95142. */
  95143. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95144. /**
  95145. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  95146. * @param kind defines the data kind (Position, normal, etc...)
  95147. * @returns true if the vertex buffer with the specified kind is updatable
  95148. */
  95149. isVertexBufferUpdatable(kind: string): boolean;
  95150. /**
  95151. * Gets a specific vertex buffer
  95152. * @param kind defines the data kind (Position, normal, etc...)
  95153. * @returns a VertexBuffer
  95154. */
  95155. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  95156. /**
  95157. * Returns all vertex buffers
  95158. * @return an object holding all vertex buffers indexed by kind
  95159. */
  95160. getVertexBuffers(): Nullable<{
  95161. [key: string]: VertexBuffer;
  95162. }>;
  95163. /**
  95164. * Gets a boolean indicating if specific vertex buffer is present
  95165. * @param kind defines the data kind (Position, normal, etc...)
  95166. * @returns true if data is present
  95167. */
  95168. isVerticesDataPresent(kind: string): boolean;
  95169. /**
  95170. * Gets a list of all attached data kinds (Position, normal, etc...)
  95171. * @returns a list of string containing all kinds
  95172. */
  95173. getVerticesDataKinds(): string[];
  95174. /**
  95175. * Update index buffer
  95176. * @param indices defines the indices to store in the index buffer
  95177. * @param offset defines the offset in the target buffer where to store the data
  95178. * @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)
  95179. */
  95180. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  95181. /**
  95182. * Creates a new index buffer
  95183. * @param indices defines the indices to store in the index buffer
  95184. * @param totalVertices defines the total number of vertices (could be null)
  95185. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95186. */
  95187. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  95188. /**
  95189. * Return the total number of indices
  95190. * @returns the total number of indices
  95191. */
  95192. getTotalIndices(): number;
  95193. /**
  95194. * Gets the index buffer array
  95195. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95196. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95197. * @returns the index buffer array
  95198. */
  95199. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95200. /**
  95201. * Gets the index buffer
  95202. * @return the index buffer
  95203. */
  95204. getIndexBuffer(): Nullable<DataBuffer>;
  95205. /** @hidden */
  95206. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  95207. /**
  95208. * Release the associated resources for a specific mesh
  95209. * @param mesh defines the source mesh
  95210. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  95211. */
  95212. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  95213. /**
  95214. * Apply current geometry to a given mesh
  95215. * @param mesh defines the mesh to apply geometry to
  95216. */
  95217. applyToMesh(mesh: Mesh): void;
  95218. private _updateExtend;
  95219. private _applyToMesh;
  95220. private notifyUpdate;
  95221. /**
  95222. * Load the geometry if it was flagged as delay loaded
  95223. * @param scene defines the hosting scene
  95224. * @param onLoaded defines a callback called when the geometry is loaded
  95225. */
  95226. load(scene: Scene, onLoaded?: () => void): void;
  95227. private _queueLoad;
  95228. /**
  95229. * Invert the geometry to move from a right handed system to a left handed one.
  95230. */
  95231. toLeftHanded(): void;
  95232. /** @hidden */
  95233. _resetPointsArrayCache(): void;
  95234. /** @hidden */
  95235. _generatePointsArray(): boolean;
  95236. /**
  95237. * Gets a value indicating if the geometry is disposed
  95238. * @returns true if the geometry was disposed
  95239. */
  95240. isDisposed(): boolean;
  95241. private _disposeVertexArrayObjects;
  95242. /**
  95243. * Free all associated resources
  95244. */
  95245. dispose(): void;
  95246. /**
  95247. * Clone the current geometry into a new geometry
  95248. * @param id defines the unique ID of the new geometry
  95249. * @returns a new geometry object
  95250. */
  95251. copy(id: string): Geometry;
  95252. /**
  95253. * Serialize the current geometry info (and not the vertices data) into a JSON object
  95254. * @return a JSON representation of the current geometry data (without the vertices data)
  95255. */
  95256. serialize(): any;
  95257. private toNumberArray;
  95258. /**
  95259. * Serialize all vertices data into a JSON oject
  95260. * @returns a JSON representation of the current geometry data
  95261. */
  95262. serializeVerticeData(): any;
  95263. /**
  95264. * Extracts a clone of a mesh geometry
  95265. * @param mesh defines the source mesh
  95266. * @param id defines the unique ID of the new geometry object
  95267. * @returns the new geometry object
  95268. */
  95269. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  95270. /**
  95271. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  95272. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  95273. * Be aware Math.random() could cause collisions, but:
  95274. * "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"
  95275. * @returns a string containing a new GUID
  95276. */
  95277. static RandomId(): string;
  95278. /** @hidden */
  95279. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  95280. private static _CleanMatricesWeights;
  95281. /**
  95282. * Create a new geometry from persisted data (Using .babylon file format)
  95283. * @param parsedVertexData defines the persisted data
  95284. * @param scene defines the hosting scene
  95285. * @param rootUrl defines the root url to use to load assets (like delayed data)
  95286. * @returns the new geometry object
  95287. */
  95288. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  95289. }
  95290. }
  95291. declare module BABYLON {
  95292. /**
  95293. * Define an interface for all classes that will get and set the data on vertices
  95294. */
  95295. export interface IGetSetVerticesData {
  95296. /**
  95297. * Gets a boolean indicating if specific vertex data is present
  95298. * @param kind defines the vertex data kind to use
  95299. * @returns true is data kind is present
  95300. */
  95301. isVerticesDataPresent(kind: string): boolean;
  95302. /**
  95303. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  95304. * @param kind defines the data kind (Position, normal, etc...)
  95305. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  95306. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95307. * @returns a float array containing vertex data
  95308. */
  95309. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  95310. /**
  95311. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  95312. * @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.
  95313. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  95314. * @returns the indices array or an empty array if the mesh has no geometry
  95315. */
  95316. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  95317. /**
  95318. * Set specific vertex data
  95319. * @param kind defines the data kind (Position, normal, etc...)
  95320. * @param data defines the vertex data to use
  95321. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  95322. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  95323. */
  95324. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  95325. /**
  95326. * Update a specific associated vertex buffer
  95327. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  95328. * - VertexBuffer.PositionKind
  95329. * - VertexBuffer.UVKind
  95330. * - VertexBuffer.UV2Kind
  95331. * - VertexBuffer.UV3Kind
  95332. * - VertexBuffer.UV4Kind
  95333. * - VertexBuffer.UV5Kind
  95334. * - VertexBuffer.UV6Kind
  95335. * - VertexBuffer.ColorKind
  95336. * - VertexBuffer.MatricesIndicesKind
  95337. * - VertexBuffer.MatricesIndicesExtraKind
  95338. * - VertexBuffer.MatricesWeightsKind
  95339. * - VertexBuffer.MatricesWeightsExtraKind
  95340. * @param data defines the data source
  95341. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  95342. * @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)
  95343. */
  95344. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  95345. /**
  95346. * Creates a new index buffer
  95347. * @param indices defines the indices to store in the index buffer
  95348. * @param totalVertices defines the total number of vertices (could be null)
  95349. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  95350. */
  95351. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  95352. }
  95353. /**
  95354. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  95355. */
  95356. export class VertexData {
  95357. /**
  95358. * Mesh side orientation : usually the external or front surface
  95359. */
  95360. static readonly FRONTSIDE: number;
  95361. /**
  95362. * Mesh side orientation : usually the internal or back surface
  95363. */
  95364. static readonly BACKSIDE: number;
  95365. /**
  95366. * Mesh side orientation : both internal and external or front and back surfaces
  95367. */
  95368. static readonly DOUBLESIDE: number;
  95369. /**
  95370. * Mesh side orientation : by default, `FRONTSIDE`
  95371. */
  95372. static readonly DEFAULTSIDE: number;
  95373. /**
  95374. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  95375. */
  95376. positions: Nullable<FloatArray>;
  95377. /**
  95378. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  95379. */
  95380. normals: Nullable<FloatArray>;
  95381. /**
  95382. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  95383. */
  95384. tangents: Nullable<FloatArray>;
  95385. /**
  95386. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95387. */
  95388. uvs: Nullable<FloatArray>;
  95389. /**
  95390. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95391. */
  95392. uvs2: Nullable<FloatArray>;
  95393. /**
  95394. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95395. */
  95396. uvs3: Nullable<FloatArray>;
  95397. /**
  95398. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95399. */
  95400. uvs4: Nullable<FloatArray>;
  95401. /**
  95402. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95403. */
  95404. uvs5: Nullable<FloatArray>;
  95405. /**
  95406. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  95407. */
  95408. uvs6: Nullable<FloatArray>;
  95409. /**
  95410. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  95411. */
  95412. colors: Nullable<FloatArray>;
  95413. /**
  95414. * 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).
  95415. */
  95416. matricesIndices: Nullable<FloatArray>;
  95417. /**
  95418. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  95419. */
  95420. matricesWeights: Nullable<FloatArray>;
  95421. /**
  95422. * An array extending the number of possible indices
  95423. */
  95424. matricesIndicesExtra: Nullable<FloatArray>;
  95425. /**
  95426. * An array extending the number of possible weights when the number of indices is extended
  95427. */
  95428. matricesWeightsExtra: Nullable<FloatArray>;
  95429. /**
  95430. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  95431. */
  95432. indices: Nullable<IndicesArray>;
  95433. /**
  95434. * Uses the passed data array to set the set the values for the specified kind of data
  95435. * @param data a linear array of floating numbers
  95436. * @param kind the type of data that is being set, eg positions, colors etc
  95437. */
  95438. set(data: FloatArray, kind: string): void;
  95439. /**
  95440. * Associates the vertexData to the passed Mesh.
  95441. * Sets it as updatable or not (default `false`)
  95442. * @param mesh the mesh the vertexData is applied to
  95443. * @param updatable when used and having the value true allows new data to update the vertexData
  95444. * @returns the VertexData
  95445. */
  95446. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  95447. /**
  95448. * Associates the vertexData to the passed Geometry.
  95449. * Sets it as updatable or not (default `false`)
  95450. * @param geometry the geometry the vertexData is applied to
  95451. * @param updatable when used and having the value true allows new data to update the vertexData
  95452. * @returns VertexData
  95453. */
  95454. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  95455. /**
  95456. * Updates the associated mesh
  95457. * @param mesh the mesh to be updated
  95458. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95459. * @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
  95460. * @returns VertexData
  95461. */
  95462. updateMesh(mesh: Mesh): VertexData;
  95463. /**
  95464. * Updates the associated geometry
  95465. * @param geometry the geometry to be updated
  95466. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  95467. * @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
  95468. * @returns VertexData.
  95469. */
  95470. updateGeometry(geometry: Geometry): VertexData;
  95471. private _applyTo;
  95472. private _update;
  95473. /**
  95474. * Transforms each position and each normal of the vertexData according to the passed Matrix
  95475. * @param matrix the transforming matrix
  95476. * @returns the VertexData
  95477. */
  95478. transform(matrix: Matrix): VertexData;
  95479. /**
  95480. * Merges the passed VertexData into the current one
  95481. * @param other the VertexData to be merged into the current one
  95482. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  95483. * @returns the modified VertexData
  95484. */
  95485. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  95486. private _mergeElement;
  95487. private _validate;
  95488. /**
  95489. * Serializes the VertexData
  95490. * @returns a serialized object
  95491. */
  95492. serialize(): any;
  95493. /**
  95494. * Extracts the vertexData from a mesh
  95495. * @param mesh the mesh from which to extract the VertexData
  95496. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  95497. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95498. * @returns the object VertexData associated to the passed mesh
  95499. */
  95500. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95501. /**
  95502. * Extracts the vertexData from the geometry
  95503. * @param geometry the geometry from which to extract the VertexData
  95504. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  95505. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  95506. * @returns the object VertexData associated to the passed mesh
  95507. */
  95508. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  95509. private static _ExtractFrom;
  95510. /**
  95511. * Creates the VertexData for a Ribbon
  95512. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  95513. * * pathArray array of paths, each of which an array of successive Vector3
  95514. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  95515. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  95516. * * 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
  95517. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95518. * * 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)
  95519. * * 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)
  95520. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  95521. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  95522. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  95523. * @returns the VertexData of the ribbon
  95524. */
  95525. static CreateRibbon(options: {
  95526. pathArray: Vector3[][];
  95527. closeArray?: boolean;
  95528. closePath?: boolean;
  95529. offset?: number;
  95530. sideOrientation?: number;
  95531. frontUVs?: Vector4;
  95532. backUVs?: Vector4;
  95533. invertUV?: boolean;
  95534. uvs?: Vector2[];
  95535. colors?: Color4[];
  95536. }): VertexData;
  95537. /**
  95538. * Creates the VertexData for a box
  95539. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95540. * * size sets the width, height and depth of the box to the value of size, optional default 1
  95541. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  95542. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  95543. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  95544. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95545. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95546. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95547. * * 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)
  95548. * * 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)
  95549. * @returns the VertexData of the box
  95550. */
  95551. static CreateBox(options: {
  95552. size?: number;
  95553. width?: number;
  95554. height?: number;
  95555. depth?: number;
  95556. faceUV?: Vector4[];
  95557. faceColors?: Color4[];
  95558. sideOrientation?: number;
  95559. frontUVs?: Vector4;
  95560. backUVs?: Vector4;
  95561. }): VertexData;
  95562. /**
  95563. * Creates the VertexData for a tiled box
  95564. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95565. * * faceTiles sets the pattern, tile size and number of tiles for a face
  95566. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  95567. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  95568. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95569. * @returns the VertexData of the box
  95570. */
  95571. static CreateTiledBox(options: {
  95572. pattern?: number;
  95573. width?: number;
  95574. height?: number;
  95575. depth?: number;
  95576. tileSize?: number;
  95577. tileWidth?: number;
  95578. tileHeight?: number;
  95579. alignHorizontal?: number;
  95580. alignVertical?: number;
  95581. faceUV?: Vector4[];
  95582. faceColors?: Color4[];
  95583. sideOrientation?: number;
  95584. }): VertexData;
  95585. /**
  95586. * Creates the VertexData for a tiled plane
  95587. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95588. * * pattern a limited pattern arrangement depending on the number
  95589. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  95590. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  95591. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  95592. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95593. * * 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)
  95594. * * 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)
  95595. * @returns the VertexData of the tiled plane
  95596. */
  95597. static CreateTiledPlane(options: {
  95598. pattern?: number;
  95599. tileSize?: number;
  95600. tileWidth?: number;
  95601. tileHeight?: number;
  95602. size?: number;
  95603. width?: number;
  95604. height?: number;
  95605. alignHorizontal?: number;
  95606. alignVertical?: number;
  95607. sideOrientation?: number;
  95608. frontUVs?: Vector4;
  95609. backUVs?: Vector4;
  95610. }): VertexData;
  95611. /**
  95612. * Creates the VertexData for an ellipsoid, defaults to a sphere
  95613. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95614. * * segments sets the number of horizontal strips optional, default 32
  95615. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  95616. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  95617. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  95618. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  95619. * * 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
  95620. * * 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
  95621. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95622. * * 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)
  95623. * * 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)
  95624. * @returns the VertexData of the ellipsoid
  95625. */
  95626. static CreateSphere(options: {
  95627. segments?: number;
  95628. diameter?: number;
  95629. diameterX?: number;
  95630. diameterY?: number;
  95631. diameterZ?: number;
  95632. arc?: number;
  95633. slice?: number;
  95634. sideOrientation?: number;
  95635. frontUVs?: Vector4;
  95636. backUVs?: Vector4;
  95637. }): VertexData;
  95638. /**
  95639. * Creates the VertexData for a cylinder, cone or prism
  95640. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95641. * * height sets the height (y direction) of the cylinder, optional, default 2
  95642. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  95643. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  95644. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  95645. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95646. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  95647. * * 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
  95648. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95649. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95650. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  95651. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  95652. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95653. * * 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)
  95654. * * 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)
  95655. * @returns the VertexData of the cylinder, cone or prism
  95656. */
  95657. static CreateCylinder(options: {
  95658. height?: number;
  95659. diameterTop?: number;
  95660. diameterBottom?: number;
  95661. diameter?: number;
  95662. tessellation?: number;
  95663. subdivisions?: number;
  95664. arc?: number;
  95665. faceColors?: Color4[];
  95666. faceUV?: Vector4[];
  95667. hasRings?: boolean;
  95668. enclose?: boolean;
  95669. sideOrientation?: number;
  95670. frontUVs?: Vector4;
  95671. backUVs?: Vector4;
  95672. }): VertexData;
  95673. /**
  95674. * Creates the VertexData for a torus
  95675. * @param options an object used to set the following optional parameters for the box, required but can be empty
  95676. * * diameter the diameter of the torus, optional default 1
  95677. * * thickness the diameter of the tube forming the torus, optional default 0.5
  95678. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  95679. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95680. * * 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)
  95681. * * 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)
  95682. * @returns the VertexData of the torus
  95683. */
  95684. static CreateTorus(options: {
  95685. diameter?: number;
  95686. thickness?: number;
  95687. tessellation?: number;
  95688. sideOrientation?: number;
  95689. frontUVs?: Vector4;
  95690. backUVs?: Vector4;
  95691. }): VertexData;
  95692. /**
  95693. * Creates the VertexData of the LineSystem
  95694. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  95695. * - lines an array of lines, each line being an array of successive Vector3
  95696. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  95697. * @returns the VertexData of the LineSystem
  95698. */
  95699. static CreateLineSystem(options: {
  95700. lines: Vector3[][];
  95701. colors?: Nullable<Color4[][]>;
  95702. }): VertexData;
  95703. /**
  95704. * Create the VertexData for a DashedLines
  95705. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  95706. * - points an array successive Vector3
  95707. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  95708. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  95709. * - dashNb the intended total number of dashes, optional, default 200
  95710. * @returns the VertexData for the DashedLines
  95711. */
  95712. static CreateDashedLines(options: {
  95713. points: Vector3[];
  95714. dashSize?: number;
  95715. gapSize?: number;
  95716. dashNb?: number;
  95717. }): VertexData;
  95718. /**
  95719. * Creates the VertexData for a Ground
  95720. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95721. * - width the width (x direction) of the ground, optional, default 1
  95722. * - height the height (z direction) of the ground, optional, default 1
  95723. * - subdivisions the number of subdivisions per side, optional, default 1
  95724. * @returns the VertexData of the Ground
  95725. */
  95726. static CreateGround(options: {
  95727. width?: number;
  95728. height?: number;
  95729. subdivisions?: number;
  95730. subdivisionsX?: number;
  95731. subdivisionsY?: number;
  95732. }): VertexData;
  95733. /**
  95734. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  95735. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  95736. * * xmin the ground minimum X coordinate, optional, default -1
  95737. * * zmin the ground minimum Z coordinate, optional, default -1
  95738. * * xmax the ground maximum X coordinate, optional, default 1
  95739. * * zmax the ground maximum Z coordinate, optional, default 1
  95740. * * 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}
  95741. * * 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}
  95742. * @returns the VertexData of the TiledGround
  95743. */
  95744. static CreateTiledGround(options: {
  95745. xmin: number;
  95746. zmin: number;
  95747. xmax: number;
  95748. zmax: number;
  95749. subdivisions?: {
  95750. w: number;
  95751. h: number;
  95752. };
  95753. precision?: {
  95754. w: number;
  95755. h: number;
  95756. };
  95757. }): VertexData;
  95758. /**
  95759. * Creates the VertexData of the Ground designed from a heightmap
  95760. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  95761. * * width the width (x direction) of the ground
  95762. * * height the height (z direction) of the ground
  95763. * * subdivisions the number of subdivisions per side
  95764. * * minHeight the minimum altitude on the ground, optional, default 0
  95765. * * maxHeight the maximum altitude on the ground, optional default 1
  95766. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  95767. * * buffer the array holding the image color data
  95768. * * bufferWidth the width of image
  95769. * * bufferHeight the height of image
  95770. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  95771. * @returns the VertexData of the Ground designed from a heightmap
  95772. */
  95773. static CreateGroundFromHeightMap(options: {
  95774. width: number;
  95775. height: number;
  95776. subdivisions: number;
  95777. minHeight: number;
  95778. maxHeight: number;
  95779. colorFilter: Color3;
  95780. buffer: Uint8Array;
  95781. bufferWidth: number;
  95782. bufferHeight: number;
  95783. alphaFilter: number;
  95784. }): VertexData;
  95785. /**
  95786. * Creates the VertexData for a Plane
  95787. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  95788. * * size sets the width and height of the plane to the value of size, optional default 1
  95789. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  95790. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  95791. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95792. * * 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)
  95793. * * 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)
  95794. * @returns the VertexData of the box
  95795. */
  95796. static CreatePlane(options: {
  95797. size?: number;
  95798. width?: number;
  95799. height?: number;
  95800. sideOrientation?: number;
  95801. frontUVs?: Vector4;
  95802. backUVs?: Vector4;
  95803. }): VertexData;
  95804. /**
  95805. * Creates the VertexData of the Disc or regular Polygon
  95806. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  95807. * * radius the radius of the disc, optional default 0.5
  95808. * * tessellation the number of polygon sides, optional, default 64
  95809. * * 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
  95810. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95811. * * 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)
  95812. * * 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)
  95813. * @returns the VertexData of the box
  95814. */
  95815. static CreateDisc(options: {
  95816. radius?: number;
  95817. tessellation?: number;
  95818. arc?: number;
  95819. sideOrientation?: number;
  95820. frontUVs?: Vector4;
  95821. backUVs?: Vector4;
  95822. }): VertexData;
  95823. /**
  95824. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  95825. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  95826. * @param polygon a mesh built from polygonTriangulation.build()
  95827. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95828. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95829. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95830. * @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)
  95831. * @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)
  95832. * @returns the VertexData of the Polygon
  95833. */
  95834. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  95835. /**
  95836. * Creates the VertexData of the IcoSphere
  95837. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  95838. * * radius the radius of the IcoSphere, optional default 1
  95839. * * radiusX allows stretching in the x direction, optional, default radius
  95840. * * radiusY allows stretching in the y direction, optional, default radius
  95841. * * radiusZ allows stretching in the z direction, optional, default radius
  95842. * * flat when true creates a flat shaded mesh, optional, default true
  95843. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95844. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95845. * * 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)
  95846. * * 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)
  95847. * @returns the VertexData of the IcoSphere
  95848. */
  95849. static CreateIcoSphere(options: {
  95850. radius?: number;
  95851. radiusX?: number;
  95852. radiusY?: number;
  95853. radiusZ?: number;
  95854. flat?: boolean;
  95855. subdivisions?: number;
  95856. sideOrientation?: number;
  95857. frontUVs?: Vector4;
  95858. backUVs?: Vector4;
  95859. }): VertexData;
  95860. /**
  95861. * Creates the VertexData for a Polyhedron
  95862. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  95863. * * type provided types are:
  95864. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  95865. * * 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)
  95866. * * size the size of the IcoSphere, optional default 1
  95867. * * sizeX allows stretching in the x direction, optional, default size
  95868. * * sizeY allows stretching in the y direction, optional, default size
  95869. * * sizeZ allows stretching in the z direction, optional, default size
  95870. * * 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
  95871. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  95872. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  95873. * * flat when true creates a flat shaded mesh, optional, default true
  95874. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  95875. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95876. * * 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)
  95877. * * 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)
  95878. * @returns the VertexData of the Polyhedron
  95879. */
  95880. static CreatePolyhedron(options: {
  95881. type?: number;
  95882. size?: number;
  95883. sizeX?: number;
  95884. sizeY?: number;
  95885. sizeZ?: number;
  95886. custom?: any;
  95887. faceUV?: Vector4[];
  95888. faceColors?: Color4[];
  95889. flat?: boolean;
  95890. sideOrientation?: number;
  95891. frontUVs?: Vector4;
  95892. backUVs?: Vector4;
  95893. }): VertexData;
  95894. /**
  95895. * Creates the VertexData for a TorusKnot
  95896. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  95897. * * radius the radius of the torus knot, optional, default 2
  95898. * * tube the thickness of the tube, optional, default 0.5
  95899. * * radialSegments the number of sides on each tube segments, optional, default 32
  95900. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  95901. * * p the number of windings around the z axis, optional, default 2
  95902. * * q the number of windings around the x axis, optional, default 3
  95903. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  95904. * * 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)
  95905. * * 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)
  95906. * @returns the VertexData of the Torus Knot
  95907. */
  95908. static CreateTorusKnot(options: {
  95909. radius?: number;
  95910. tube?: number;
  95911. radialSegments?: number;
  95912. tubularSegments?: number;
  95913. p?: number;
  95914. q?: number;
  95915. sideOrientation?: number;
  95916. frontUVs?: Vector4;
  95917. backUVs?: Vector4;
  95918. }): VertexData;
  95919. /**
  95920. * Compute normals for given positions and indices
  95921. * @param positions an array of vertex positions, [...., x, y, z, ......]
  95922. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  95923. * @param normals an array of vertex normals, [...., x, y, z, ......]
  95924. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  95925. * * facetNormals : optional array of facet normals (vector3)
  95926. * * facetPositions : optional array of facet positions (vector3)
  95927. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  95928. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  95929. * * bInfo : optional bounding info, required for facetPartitioning computation
  95930. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  95931. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  95932. * * useRightHandedSystem: optional boolean to for right handed system computation
  95933. * * depthSort : optional boolean to enable the facet depth sort computation
  95934. * * distanceTo : optional Vector3 to compute the facet depth from this location
  95935. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  95936. */
  95937. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  95938. facetNormals?: any;
  95939. facetPositions?: any;
  95940. facetPartitioning?: any;
  95941. ratio?: number;
  95942. bInfo?: any;
  95943. bbSize?: Vector3;
  95944. subDiv?: any;
  95945. useRightHandedSystem?: boolean;
  95946. depthSort?: boolean;
  95947. distanceTo?: Vector3;
  95948. depthSortedFacets?: any;
  95949. }): void;
  95950. /** @hidden */
  95951. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  95952. /**
  95953. * Applies VertexData created from the imported parameters to the geometry
  95954. * @param parsedVertexData the parsed data from an imported file
  95955. * @param geometry the geometry to apply the VertexData to
  95956. */
  95957. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  95958. }
  95959. }
  95960. declare module BABYLON {
  95961. /**
  95962. * Defines a target to use with MorphTargetManager
  95963. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  95964. */
  95965. export class MorphTarget implements IAnimatable {
  95966. /** defines the name of the target */
  95967. name: string;
  95968. /**
  95969. * Gets or sets the list of animations
  95970. */
  95971. animations: Animation[];
  95972. private _scene;
  95973. private _positions;
  95974. private _normals;
  95975. private _tangents;
  95976. private _uvs;
  95977. private _influence;
  95978. private _uniqueId;
  95979. /**
  95980. * Observable raised when the influence changes
  95981. */
  95982. onInfluenceChanged: Observable<boolean>;
  95983. /** @hidden */
  95984. _onDataLayoutChanged: Observable<void>;
  95985. /**
  95986. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  95987. */
  95988. get influence(): number;
  95989. set influence(influence: number);
  95990. /**
  95991. * Gets or sets the id of the morph Target
  95992. */
  95993. id: string;
  95994. private _animationPropertiesOverride;
  95995. /**
  95996. * Gets or sets the animation properties override
  95997. */
  95998. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95999. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96000. /**
  96001. * Creates a new MorphTarget
  96002. * @param name defines the name of the target
  96003. * @param influence defines the influence to use
  96004. * @param scene defines the scene the morphtarget belongs to
  96005. */
  96006. constructor(
  96007. /** defines the name of the target */
  96008. name: string, influence?: number, scene?: Nullable<Scene>);
  96009. /**
  96010. * Gets the unique ID of this manager
  96011. */
  96012. get uniqueId(): number;
  96013. /**
  96014. * Gets a boolean defining if the target contains position data
  96015. */
  96016. get hasPositions(): boolean;
  96017. /**
  96018. * Gets a boolean defining if the target contains normal data
  96019. */
  96020. get hasNormals(): boolean;
  96021. /**
  96022. * Gets a boolean defining if the target contains tangent data
  96023. */
  96024. get hasTangents(): boolean;
  96025. /**
  96026. * Gets a boolean defining if the target contains texture coordinates data
  96027. */
  96028. get hasUVs(): boolean;
  96029. /**
  96030. * Affects position data to this target
  96031. * @param data defines the position data to use
  96032. */
  96033. setPositions(data: Nullable<FloatArray>): void;
  96034. /**
  96035. * Gets the position data stored in this target
  96036. * @returns a FloatArray containing the position data (or null if not present)
  96037. */
  96038. getPositions(): Nullable<FloatArray>;
  96039. /**
  96040. * Affects normal data to this target
  96041. * @param data defines the normal data to use
  96042. */
  96043. setNormals(data: Nullable<FloatArray>): void;
  96044. /**
  96045. * Gets the normal data stored in this target
  96046. * @returns a FloatArray containing the normal data (or null if not present)
  96047. */
  96048. getNormals(): Nullable<FloatArray>;
  96049. /**
  96050. * Affects tangent data to this target
  96051. * @param data defines the tangent data to use
  96052. */
  96053. setTangents(data: Nullable<FloatArray>): void;
  96054. /**
  96055. * Gets the tangent data stored in this target
  96056. * @returns a FloatArray containing the tangent data (or null if not present)
  96057. */
  96058. getTangents(): Nullable<FloatArray>;
  96059. /**
  96060. * Affects texture coordinates data to this target
  96061. * @param data defines the texture coordinates data to use
  96062. */
  96063. setUVs(data: Nullable<FloatArray>): void;
  96064. /**
  96065. * Gets the texture coordinates data stored in this target
  96066. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  96067. */
  96068. getUVs(): Nullable<FloatArray>;
  96069. /**
  96070. * Clone the current target
  96071. * @returns a new MorphTarget
  96072. */
  96073. clone(): MorphTarget;
  96074. /**
  96075. * Serializes the current target into a Serialization object
  96076. * @returns the serialized object
  96077. */
  96078. serialize(): any;
  96079. /**
  96080. * Returns the string "MorphTarget"
  96081. * @returns "MorphTarget"
  96082. */
  96083. getClassName(): string;
  96084. /**
  96085. * Creates a new target from serialized data
  96086. * @param serializationObject defines the serialized data to use
  96087. * @returns a new MorphTarget
  96088. */
  96089. static Parse(serializationObject: any): MorphTarget;
  96090. /**
  96091. * Creates a MorphTarget from mesh data
  96092. * @param mesh defines the source mesh
  96093. * @param name defines the name to use for the new target
  96094. * @param influence defines the influence to attach to the target
  96095. * @returns a new MorphTarget
  96096. */
  96097. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  96098. }
  96099. }
  96100. declare module BABYLON {
  96101. /**
  96102. * This class is used to deform meshes using morphing between different targets
  96103. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  96104. */
  96105. export class MorphTargetManager {
  96106. private _targets;
  96107. private _targetInfluenceChangedObservers;
  96108. private _targetDataLayoutChangedObservers;
  96109. private _activeTargets;
  96110. private _scene;
  96111. private _influences;
  96112. private _supportsNormals;
  96113. private _supportsTangents;
  96114. private _supportsUVs;
  96115. private _vertexCount;
  96116. private _uniqueId;
  96117. private _tempInfluences;
  96118. /**
  96119. * Gets or sets a boolean indicating if normals must be morphed
  96120. */
  96121. enableNormalMorphing: boolean;
  96122. /**
  96123. * Gets or sets a boolean indicating if tangents must be morphed
  96124. */
  96125. enableTangentMorphing: boolean;
  96126. /**
  96127. * Gets or sets a boolean indicating if UV must be morphed
  96128. */
  96129. enableUVMorphing: boolean;
  96130. /**
  96131. * Creates a new MorphTargetManager
  96132. * @param scene defines the current scene
  96133. */
  96134. constructor(scene?: Nullable<Scene>);
  96135. /**
  96136. * Gets the unique ID of this manager
  96137. */
  96138. get uniqueId(): number;
  96139. /**
  96140. * Gets the number of vertices handled by this manager
  96141. */
  96142. get vertexCount(): number;
  96143. /**
  96144. * Gets a boolean indicating if this manager supports morphing of normals
  96145. */
  96146. get supportsNormals(): boolean;
  96147. /**
  96148. * Gets a boolean indicating if this manager supports morphing of tangents
  96149. */
  96150. get supportsTangents(): boolean;
  96151. /**
  96152. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  96153. */
  96154. get supportsUVs(): boolean;
  96155. /**
  96156. * Gets the number of targets stored in this manager
  96157. */
  96158. get numTargets(): number;
  96159. /**
  96160. * Gets the number of influencers (ie. the number of targets with influences > 0)
  96161. */
  96162. get numInfluencers(): number;
  96163. /**
  96164. * Gets the list of influences (one per target)
  96165. */
  96166. get influences(): Float32Array;
  96167. /**
  96168. * Gets the active target at specified index. An active target is a target with an influence > 0
  96169. * @param index defines the index to check
  96170. * @returns the requested target
  96171. */
  96172. getActiveTarget(index: number): MorphTarget;
  96173. /**
  96174. * Gets the target at specified index
  96175. * @param index defines the index to check
  96176. * @returns the requested target
  96177. */
  96178. getTarget(index: number): MorphTarget;
  96179. /**
  96180. * Add a new target to this manager
  96181. * @param target defines the target to add
  96182. */
  96183. addTarget(target: MorphTarget): void;
  96184. /**
  96185. * Removes a target from the manager
  96186. * @param target defines the target to remove
  96187. */
  96188. removeTarget(target: MorphTarget): void;
  96189. /**
  96190. * Clone the current manager
  96191. * @returns a new MorphTargetManager
  96192. */
  96193. clone(): MorphTargetManager;
  96194. /**
  96195. * Serializes the current manager into a Serialization object
  96196. * @returns the serialized object
  96197. */
  96198. serialize(): any;
  96199. private _syncActiveTargets;
  96200. /**
  96201. * Syncrhonize the targets with all the meshes using this morph target manager
  96202. */
  96203. synchronize(): void;
  96204. /**
  96205. * Creates a new MorphTargetManager from serialized data
  96206. * @param serializationObject defines the serialized data
  96207. * @param scene defines the hosting scene
  96208. * @returns the new MorphTargetManager
  96209. */
  96210. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  96211. }
  96212. }
  96213. declare module BABYLON {
  96214. /**
  96215. * Class used to represent a specific level of detail of a mesh
  96216. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  96217. */
  96218. export class MeshLODLevel {
  96219. /** Defines the distance where this level should start being displayed */
  96220. distance: number;
  96221. /** Defines the mesh to use to render this level */
  96222. mesh: Nullable<Mesh>;
  96223. /**
  96224. * Creates a new LOD level
  96225. * @param distance defines the distance where this level should star being displayed
  96226. * @param mesh defines the mesh to use to render this level
  96227. */
  96228. constructor(
  96229. /** Defines the distance where this level should start being displayed */
  96230. distance: number,
  96231. /** Defines the mesh to use to render this level */
  96232. mesh: Nullable<Mesh>);
  96233. }
  96234. }
  96235. declare module BABYLON {
  96236. /**
  96237. * Mesh representing the gorund
  96238. */
  96239. export class GroundMesh extends Mesh {
  96240. /** If octree should be generated */
  96241. generateOctree: boolean;
  96242. private _heightQuads;
  96243. /** @hidden */
  96244. _subdivisionsX: number;
  96245. /** @hidden */
  96246. _subdivisionsY: number;
  96247. /** @hidden */
  96248. _width: number;
  96249. /** @hidden */
  96250. _height: number;
  96251. /** @hidden */
  96252. _minX: number;
  96253. /** @hidden */
  96254. _maxX: number;
  96255. /** @hidden */
  96256. _minZ: number;
  96257. /** @hidden */
  96258. _maxZ: number;
  96259. constructor(name: string, scene: Scene);
  96260. /**
  96261. * "GroundMesh"
  96262. * @returns "GroundMesh"
  96263. */
  96264. getClassName(): string;
  96265. /**
  96266. * The minimum of x and y subdivisions
  96267. */
  96268. get subdivisions(): number;
  96269. /**
  96270. * X subdivisions
  96271. */
  96272. get subdivisionsX(): number;
  96273. /**
  96274. * Y subdivisions
  96275. */
  96276. get subdivisionsY(): number;
  96277. /**
  96278. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  96279. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  96280. * @param chunksCount the number of subdivisions for x and y
  96281. * @param octreeBlocksSize (Default: 32)
  96282. */
  96283. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  96284. /**
  96285. * Returns a height (y) value in the Worl system :
  96286. * the ground altitude at the coordinates (x, z) expressed in the World system.
  96287. * @param x x coordinate
  96288. * @param z z coordinate
  96289. * @returns the ground y position if (x, z) are outside the ground surface.
  96290. */
  96291. getHeightAtCoordinates(x: number, z: number): number;
  96292. /**
  96293. * Returns a normalized vector (Vector3) orthogonal to the ground
  96294. * at the ground coordinates (x, z) expressed in the World system.
  96295. * @param x x coordinate
  96296. * @param z z coordinate
  96297. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  96298. */
  96299. getNormalAtCoordinates(x: number, z: number): Vector3;
  96300. /**
  96301. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  96302. * at the ground coordinates (x, z) expressed in the World system.
  96303. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  96304. * @param x x coordinate
  96305. * @param z z coordinate
  96306. * @param ref vector to store the result
  96307. * @returns the GroundMesh.
  96308. */
  96309. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  96310. /**
  96311. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  96312. * if the ground has been updated.
  96313. * This can be used in the render loop.
  96314. * @returns the GroundMesh.
  96315. */
  96316. updateCoordinateHeights(): GroundMesh;
  96317. private _getFacetAt;
  96318. private _initHeightQuads;
  96319. private _computeHeightQuads;
  96320. /**
  96321. * Serializes this ground mesh
  96322. * @param serializationObject object to write serialization to
  96323. */
  96324. serialize(serializationObject: any): void;
  96325. /**
  96326. * Parses a serialized ground mesh
  96327. * @param parsedMesh the serialized mesh
  96328. * @param scene the scene to create the ground mesh in
  96329. * @returns the created ground mesh
  96330. */
  96331. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  96332. }
  96333. }
  96334. declare module BABYLON {
  96335. /**
  96336. * Interface for Physics-Joint data
  96337. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96338. */
  96339. export interface PhysicsJointData {
  96340. /**
  96341. * The main pivot of the joint
  96342. */
  96343. mainPivot?: Vector3;
  96344. /**
  96345. * The connected pivot of the joint
  96346. */
  96347. connectedPivot?: Vector3;
  96348. /**
  96349. * The main axis of the joint
  96350. */
  96351. mainAxis?: Vector3;
  96352. /**
  96353. * The connected axis of the joint
  96354. */
  96355. connectedAxis?: Vector3;
  96356. /**
  96357. * The collision of the joint
  96358. */
  96359. collision?: boolean;
  96360. /**
  96361. * Native Oimo/Cannon/Energy data
  96362. */
  96363. nativeParams?: any;
  96364. }
  96365. /**
  96366. * This is a holder class for the physics joint created by the physics plugin
  96367. * It holds a set of functions to control the underlying joint
  96368. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96369. */
  96370. export class PhysicsJoint {
  96371. /**
  96372. * The type of the physics joint
  96373. */
  96374. type: number;
  96375. /**
  96376. * The data for the physics joint
  96377. */
  96378. jointData: PhysicsJointData;
  96379. private _physicsJoint;
  96380. protected _physicsPlugin: IPhysicsEnginePlugin;
  96381. /**
  96382. * Initializes the physics joint
  96383. * @param type The type of the physics joint
  96384. * @param jointData The data for the physics joint
  96385. */
  96386. constructor(
  96387. /**
  96388. * The type of the physics joint
  96389. */
  96390. type: number,
  96391. /**
  96392. * The data for the physics joint
  96393. */
  96394. jointData: PhysicsJointData);
  96395. /**
  96396. * Gets the physics joint
  96397. */
  96398. get physicsJoint(): any;
  96399. /**
  96400. * Sets the physics joint
  96401. */
  96402. set physicsJoint(newJoint: any);
  96403. /**
  96404. * Sets the physics plugin
  96405. */
  96406. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  96407. /**
  96408. * Execute a function that is physics-plugin specific.
  96409. * @param {Function} func the function that will be executed.
  96410. * It accepts two parameters: the physics world and the physics joint
  96411. */
  96412. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  96413. /**
  96414. * Distance-Joint type
  96415. */
  96416. static DistanceJoint: number;
  96417. /**
  96418. * Hinge-Joint type
  96419. */
  96420. static HingeJoint: number;
  96421. /**
  96422. * Ball-and-Socket joint type
  96423. */
  96424. static BallAndSocketJoint: number;
  96425. /**
  96426. * Wheel-Joint type
  96427. */
  96428. static WheelJoint: number;
  96429. /**
  96430. * Slider-Joint type
  96431. */
  96432. static SliderJoint: number;
  96433. /**
  96434. * Prismatic-Joint type
  96435. */
  96436. static PrismaticJoint: number;
  96437. /**
  96438. * Universal-Joint type
  96439. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  96440. */
  96441. static UniversalJoint: number;
  96442. /**
  96443. * Hinge-Joint 2 type
  96444. */
  96445. static Hinge2Joint: number;
  96446. /**
  96447. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  96448. */
  96449. static PointToPointJoint: number;
  96450. /**
  96451. * Spring-Joint type
  96452. */
  96453. static SpringJoint: number;
  96454. /**
  96455. * Lock-Joint type
  96456. */
  96457. static LockJoint: number;
  96458. }
  96459. /**
  96460. * A class representing a physics distance joint
  96461. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96462. */
  96463. export class DistanceJoint extends PhysicsJoint {
  96464. /**
  96465. *
  96466. * @param jointData The data for the Distance-Joint
  96467. */
  96468. constructor(jointData: DistanceJointData);
  96469. /**
  96470. * Update the predefined distance.
  96471. * @param maxDistance The maximum preferred distance
  96472. * @param minDistance The minimum preferred distance
  96473. */
  96474. updateDistance(maxDistance: number, minDistance?: number): void;
  96475. }
  96476. /**
  96477. * Represents a Motor-Enabled Joint
  96478. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96479. */
  96480. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  96481. /**
  96482. * Initializes the Motor-Enabled Joint
  96483. * @param type The type of the joint
  96484. * @param jointData The physica joint data for the joint
  96485. */
  96486. constructor(type: number, jointData: PhysicsJointData);
  96487. /**
  96488. * Set the motor values.
  96489. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96490. * @param force the force to apply
  96491. * @param maxForce max force for this motor.
  96492. */
  96493. setMotor(force?: number, maxForce?: number): void;
  96494. /**
  96495. * Set the motor's limits.
  96496. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96497. * @param upperLimit The upper limit of the motor
  96498. * @param lowerLimit The lower limit of the motor
  96499. */
  96500. setLimit(upperLimit: number, lowerLimit?: number): void;
  96501. }
  96502. /**
  96503. * This class represents a single physics Hinge-Joint
  96504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96505. */
  96506. export class HingeJoint extends MotorEnabledJoint {
  96507. /**
  96508. * Initializes the Hinge-Joint
  96509. * @param jointData The joint data for the Hinge-Joint
  96510. */
  96511. constructor(jointData: PhysicsJointData);
  96512. /**
  96513. * Set the motor values.
  96514. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96515. * @param {number} force the force to apply
  96516. * @param {number} maxForce max force for this motor.
  96517. */
  96518. setMotor(force?: number, maxForce?: number): void;
  96519. /**
  96520. * Set the motor's limits.
  96521. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96522. * @param upperLimit The upper limit of the motor
  96523. * @param lowerLimit The lower limit of the motor
  96524. */
  96525. setLimit(upperLimit: number, lowerLimit?: number): void;
  96526. }
  96527. /**
  96528. * This class represents a dual hinge physics joint (same as wheel joint)
  96529. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96530. */
  96531. export class Hinge2Joint extends MotorEnabledJoint {
  96532. /**
  96533. * Initializes the Hinge2-Joint
  96534. * @param jointData The joint data for the Hinge2-Joint
  96535. */
  96536. constructor(jointData: PhysicsJointData);
  96537. /**
  96538. * Set the motor values.
  96539. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96540. * @param {number} targetSpeed the speed the motor is to reach
  96541. * @param {number} maxForce max force for this motor.
  96542. * @param {motorIndex} the motor's index, 0 or 1.
  96543. */
  96544. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  96545. /**
  96546. * Set the motor limits.
  96547. * Attention, this function is plugin specific. Engines won't react 100% the same.
  96548. * @param {number} upperLimit the upper limit
  96549. * @param {number} lowerLimit lower limit
  96550. * @param {motorIndex} the motor's index, 0 or 1.
  96551. */
  96552. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96553. }
  96554. /**
  96555. * Interface for a motor enabled joint
  96556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96557. */
  96558. export interface IMotorEnabledJoint {
  96559. /**
  96560. * Physics joint
  96561. */
  96562. physicsJoint: any;
  96563. /**
  96564. * Sets the motor of the motor-enabled joint
  96565. * @param force The force of the motor
  96566. * @param maxForce The maximum force of the motor
  96567. * @param motorIndex The index of the motor
  96568. */
  96569. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  96570. /**
  96571. * Sets the limit of the motor
  96572. * @param upperLimit The upper limit of the motor
  96573. * @param lowerLimit The lower limit of the motor
  96574. * @param motorIndex The index of the motor
  96575. */
  96576. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96577. }
  96578. /**
  96579. * Joint data for a Distance-Joint
  96580. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96581. */
  96582. export interface DistanceJointData extends PhysicsJointData {
  96583. /**
  96584. * Max distance the 2 joint objects can be apart
  96585. */
  96586. maxDistance: number;
  96587. }
  96588. /**
  96589. * Joint data from a spring joint
  96590. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96591. */
  96592. export interface SpringJointData extends PhysicsJointData {
  96593. /**
  96594. * Length of the spring
  96595. */
  96596. length: number;
  96597. /**
  96598. * Stiffness of the spring
  96599. */
  96600. stiffness: number;
  96601. /**
  96602. * Damping of the spring
  96603. */
  96604. damping: number;
  96605. /** this callback will be called when applying the force to the impostors. */
  96606. forceApplicationCallback: () => void;
  96607. }
  96608. }
  96609. declare module BABYLON {
  96610. /**
  96611. * Holds the data for the raycast result
  96612. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96613. */
  96614. export class PhysicsRaycastResult {
  96615. private _hasHit;
  96616. private _hitDistance;
  96617. private _hitNormalWorld;
  96618. private _hitPointWorld;
  96619. private _rayFromWorld;
  96620. private _rayToWorld;
  96621. /**
  96622. * Gets if there was a hit
  96623. */
  96624. get hasHit(): boolean;
  96625. /**
  96626. * Gets the distance from the hit
  96627. */
  96628. get hitDistance(): number;
  96629. /**
  96630. * Gets the hit normal/direction in the world
  96631. */
  96632. get hitNormalWorld(): Vector3;
  96633. /**
  96634. * Gets the hit point in the world
  96635. */
  96636. get hitPointWorld(): Vector3;
  96637. /**
  96638. * Gets the ray "start point" of the ray in the world
  96639. */
  96640. get rayFromWorld(): Vector3;
  96641. /**
  96642. * Gets the ray "end point" of the ray in the world
  96643. */
  96644. get rayToWorld(): Vector3;
  96645. /**
  96646. * Sets the hit data (normal & point in world space)
  96647. * @param hitNormalWorld defines the normal in world space
  96648. * @param hitPointWorld defines the point in world space
  96649. */
  96650. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  96651. /**
  96652. * Sets the distance from the start point to the hit point
  96653. * @param distance
  96654. */
  96655. setHitDistance(distance: number): void;
  96656. /**
  96657. * Calculates the distance manually
  96658. */
  96659. calculateHitDistance(): void;
  96660. /**
  96661. * Resets all the values to default
  96662. * @param from The from point on world space
  96663. * @param to The to point on world space
  96664. */
  96665. reset(from?: Vector3, to?: Vector3): void;
  96666. }
  96667. /**
  96668. * Interface for the size containing width and height
  96669. */
  96670. interface IXYZ {
  96671. /**
  96672. * X
  96673. */
  96674. x: number;
  96675. /**
  96676. * Y
  96677. */
  96678. y: number;
  96679. /**
  96680. * Z
  96681. */
  96682. z: number;
  96683. }
  96684. }
  96685. declare module BABYLON {
  96686. /**
  96687. * Interface used to describe a physics joint
  96688. */
  96689. export interface PhysicsImpostorJoint {
  96690. /** Defines the main impostor to which the joint is linked */
  96691. mainImpostor: PhysicsImpostor;
  96692. /** Defines the impostor that is connected to the main impostor using this joint */
  96693. connectedImpostor: PhysicsImpostor;
  96694. /** Defines the joint itself */
  96695. joint: PhysicsJoint;
  96696. }
  96697. /** @hidden */
  96698. export interface IPhysicsEnginePlugin {
  96699. world: any;
  96700. name: string;
  96701. setGravity(gravity: Vector3): void;
  96702. setTimeStep(timeStep: number): void;
  96703. getTimeStep(): number;
  96704. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  96705. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96706. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  96707. generatePhysicsBody(impostor: PhysicsImpostor): void;
  96708. removePhysicsBody(impostor: PhysicsImpostor): void;
  96709. generateJoint(joint: PhysicsImpostorJoint): void;
  96710. removeJoint(joint: PhysicsImpostorJoint): void;
  96711. isSupported(): boolean;
  96712. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  96713. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  96714. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96715. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  96716. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96717. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  96718. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  96719. getBodyMass(impostor: PhysicsImpostor): number;
  96720. getBodyFriction(impostor: PhysicsImpostor): number;
  96721. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  96722. getBodyRestitution(impostor: PhysicsImpostor): number;
  96723. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  96724. getBodyPressure?(impostor: PhysicsImpostor): number;
  96725. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  96726. getBodyStiffness?(impostor: PhysicsImpostor): number;
  96727. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  96728. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  96729. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  96730. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  96731. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  96732. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96733. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  96734. sleepBody(impostor: PhysicsImpostor): void;
  96735. wakeUpBody(impostor: PhysicsImpostor): void;
  96736. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96737. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  96738. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  96739. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  96740. getRadius(impostor: PhysicsImpostor): number;
  96741. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  96742. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  96743. dispose(): void;
  96744. }
  96745. /**
  96746. * Interface used to define a physics engine
  96747. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  96748. */
  96749. export interface IPhysicsEngine {
  96750. /**
  96751. * Gets the gravity vector used by the simulation
  96752. */
  96753. gravity: Vector3;
  96754. /**
  96755. * Sets the gravity vector used by the simulation
  96756. * @param gravity defines the gravity vector to use
  96757. */
  96758. setGravity(gravity: Vector3): void;
  96759. /**
  96760. * Set the time step of the physics engine.
  96761. * Default is 1/60.
  96762. * To slow it down, enter 1/600 for example.
  96763. * To speed it up, 1/30
  96764. * @param newTimeStep the new timestep to apply to this world.
  96765. */
  96766. setTimeStep(newTimeStep: number): void;
  96767. /**
  96768. * Get the time step of the physics engine.
  96769. * @returns the current time step
  96770. */
  96771. getTimeStep(): number;
  96772. /**
  96773. * Set the sub time step of the physics engine.
  96774. * Default is 0 meaning there is no sub steps
  96775. * To increase physics resolution precision, set a small value (like 1 ms)
  96776. * @param subTimeStep defines the new sub timestep used for physics resolution.
  96777. */
  96778. setSubTimeStep(subTimeStep: number): void;
  96779. /**
  96780. * Get the sub time step of the physics engine.
  96781. * @returns the current sub time step
  96782. */
  96783. getSubTimeStep(): number;
  96784. /**
  96785. * Release all resources
  96786. */
  96787. dispose(): void;
  96788. /**
  96789. * Gets the name of the current physics plugin
  96790. * @returns the name of the plugin
  96791. */
  96792. getPhysicsPluginName(): string;
  96793. /**
  96794. * Adding a new impostor for the impostor tracking.
  96795. * This will be done by the impostor itself.
  96796. * @param impostor the impostor to add
  96797. */
  96798. addImpostor(impostor: PhysicsImpostor): void;
  96799. /**
  96800. * Remove an impostor from the engine.
  96801. * This impostor and its mesh will not longer be updated by the physics engine.
  96802. * @param impostor the impostor to remove
  96803. */
  96804. removeImpostor(impostor: PhysicsImpostor): void;
  96805. /**
  96806. * Add a joint to the physics engine
  96807. * @param mainImpostor defines the main impostor to which the joint is added.
  96808. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  96809. * @param joint defines the joint that will connect both impostors.
  96810. */
  96811. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96812. /**
  96813. * Removes a joint from the simulation
  96814. * @param mainImpostor defines the impostor used with the joint
  96815. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  96816. * @param joint defines the joint to remove
  96817. */
  96818. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  96819. /**
  96820. * Gets the current plugin used to run the simulation
  96821. * @returns current plugin
  96822. */
  96823. getPhysicsPlugin(): IPhysicsEnginePlugin;
  96824. /**
  96825. * Gets the list of physic impostors
  96826. * @returns an array of PhysicsImpostor
  96827. */
  96828. getImpostors(): Array<PhysicsImpostor>;
  96829. /**
  96830. * Gets the impostor for a physics enabled object
  96831. * @param object defines the object impersonated by the impostor
  96832. * @returns the PhysicsImpostor or null if not found
  96833. */
  96834. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  96835. /**
  96836. * Gets the impostor for a physics body object
  96837. * @param body defines physics body used by the impostor
  96838. * @returns the PhysicsImpostor or null if not found
  96839. */
  96840. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  96841. /**
  96842. * Does a raycast in the physics world
  96843. * @param from when should the ray start?
  96844. * @param to when should the ray end?
  96845. * @returns PhysicsRaycastResult
  96846. */
  96847. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  96848. /**
  96849. * Called by the scene. No need to call it.
  96850. * @param delta defines the timespam between frames
  96851. */
  96852. _step(delta: number): void;
  96853. }
  96854. }
  96855. declare module BABYLON {
  96856. /**
  96857. * The interface for the physics imposter parameters
  96858. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96859. */
  96860. export interface PhysicsImpostorParameters {
  96861. /**
  96862. * The mass of the physics imposter
  96863. */
  96864. mass: number;
  96865. /**
  96866. * The friction of the physics imposter
  96867. */
  96868. friction?: number;
  96869. /**
  96870. * The coefficient of restitution of the physics imposter
  96871. */
  96872. restitution?: number;
  96873. /**
  96874. * The native options of the physics imposter
  96875. */
  96876. nativeOptions?: any;
  96877. /**
  96878. * Specifies if the parent should be ignored
  96879. */
  96880. ignoreParent?: boolean;
  96881. /**
  96882. * Specifies if bi-directional transformations should be disabled
  96883. */
  96884. disableBidirectionalTransformation?: boolean;
  96885. /**
  96886. * The pressure inside the physics imposter, soft object only
  96887. */
  96888. pressure?: number;
  96889. /**
  96890. * The stiffness the physics imposter, soft object only
  96891. */
  96892. stiffness?: number;
  96893. /**
  96894. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  96895. */
  96896. velocityIterations?: number;
  96897. /**
  96898. * The number of iterations used in maintaining consistent vertex positions, soft object only
  96899. */
  96900. positionIterations?: number;
  96901. /**
  96902. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  96903. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  96904. * Add to fix multiple points
  96905. */
  96906. fixedPoints?: number;
  96907. /**
  96908. * The collision margin around a soft object
  96909. */
  96910. margin?: number;
  96911. /**
  96912. * The collision margin around a soft object
  96913. */
  96914. damping?: number;
  96915. /**
  96916. * The path for a rope based on an extrusion
  96917. */
  96918. path?: any;
  96919. /**
  96920. * The shape of an extrusion used for a rope based on an extrusion
  96921. */
  96922. shape?: any;
  96923. }
  96924. /**
  96925. * Interface for a physics-enabled object
  96926. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  96927. */
  96928. export interface IPhysicsEnabledObject {
  96929. /**
  96930. * The position of the physics-enabled object
  96931. */
  96932. position: Vector3;
  96933. /**
  96934. * The rotation of the physics-enabled object
  96935. */
  96936. rotationQuaternion: Nullable<Quaternion>;
  96937. /**
  96938. * The scale of the physics-enabled object
  96939. */
  96940. scaling: Vector3;
  96941. /**
  96942. * The rotation of the physics-enabled object
  96943. */
  96944. rotation?: Vector3;
  96945. /**
  96946. * The parent of the physics-enabled object
  96947. */
  96948. parent?: any;
  96949. /**
  96950. * The bounding info of the physics-enabled object
  96951. * @returns The bounding info of the physics-enabled object
  96952. */
  96953. getBoundingInfo(): BoundingInfo;
  96954. /**
  96955. * Computes the world matrix
  96956. * @param force Specifies if the world matrix should be computed by force
  96957. * @returns A world matrix
  96958. */
  96959. computeWorldMatrix(force: boolean): Matrix;
  96960. /**
  96961. * Gets the world matrix
  96962. * @returns A world matrix
  96963. */
  96964. getWorldMatrix?(): Matrix;
  96965. /**
  96966. * Gets the child meshes
  96967. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  96968. * @returns An array of abstract meshes
  96969. */
  96970. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  96971. /**
  96972. * Gets the vertex data
  96973. * @param kind The type of vertex data
  96974. * @returns A nullable array of numbers, or a float32 array
  96975. */
  96976. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  96977. /**
  96978. * Gets the indices from the mesh
  96979. * @returns A nullable array of index arrays
  96980. */
  96981. getIndices?(): Nullable<IndicesArray>;
  96982. /**
  96983. * Gets the scene from the mesh
  96984. * @returns the indices array or null
  96985. */
  96986. getScene?(): Scene;
  96987. /**
  96988. * Gets the absolute position from the mesh
  96989. * @returns the absolute position
  96990. */
  96991. getAbsolutePosition(): Vector3;
  96992. /**
  96993. * Gets the absolute pivot point from the mesh
  96994. * @returns the absolute pivot point
  96995. */
  96996. getAbsolutePivotPoint(): Vector3;
  96997. /**
  96998. * Rotates the mesh
  96999. * @param axis The axis of rotation
  97000. * @param amount The amount of rotation
  97001. * @param space The space of the rotation
  97002. * @returns The rotation transform node
  97003. */
  97004. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  97005. /**
  97006. * Translates the mesh
  97007. * @param axis The axis of translation
  97008. * @param distance The distance of translation
  97009. * @param space The space of the translation
  97010. * @returns The transform node
  97011. */
  97012. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  97013. /**
  97014. * Sets the absolute position of the mesh
  97015. * @param absolutePosition The absolute position of the mesh
  97016. * @returns The transform node
  97017. */
  97018. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  97019. /**
  97020. * Gets the class name of the mesh
  97021. * @returns The class name
  97022. */
  97023. getClassName(): string;
  97024. }
  97025. /**
  97026. * Represents a physics imposter
  97027. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97028. */
  97029. export class PhysicsImpostor {
  97030. /**
  97031. * The physics-enabled object used as the physics imposter
  97032. */
  97033. object: IPhysicsEnabledObject;
  97034. /**
  97035. * The type of the physics imposter
  97036. */
  97037. type: number;
  97038. private _options;
  97039. private _scene?;
  97040. /**
  97041. * The default object size of the imposter
  97042. */
  97043. static DEFAULT_OBJECT_SIZE: Vector3;
  97044. /**
  97045. * The identity quaternion of the imposter
  97046. */
  97047. static IDENTITY_QUATERNION: Quaternion;
  97048. /** @hidden */
  97049. _pluginData: any;
  97050. private _physicsEngine;
  97051. private _physicsBody;
  97052. private _bodyUpdateRequired;
  97053. private _onBeforePhysicsStepCallbacks;
  97054. private _onAfterPhysicsStepCallbacks;
  97055. /** @hidden */
  97056. _onPhysicsCollideCallbacks: Array<{
  97057. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  97058. otherImpostors: Array<PhysicsImpostor>;
  97059. }>;
  97060. private _deltaPosition;
  97061. private _deltaRotation;
  97062. private _deltaRotationConjugated;
  97063. /** @hidden */
  97064. _isFromLine: boolean;
  97065. private _parent;
  97066. private _isDisposed;
  97067. private static _tmpVecs;
  97068. private static _tmpQuat;
  97069. /**
  97070. * Specifies if the physics imposter is disposed
  97071. */
  97072. get isDisposed(): boolean;
  97073. /**
  97074. * Gets the mass of the physics imposter
  97075. */
  97076. get mass(): number;
  97077. set mass(value: number);
  97078. /**
  97079. * Gets the coefficient of friction
  97080. */
  97081. get friction(): number;
  97082. /**
  97083. * Sets the coefficient of friction
  97084. */
  97085. set friction(value: number);
  97086. /**
  97087. * Gets the coefficient of restitution
  97088. */
  97089. get restitution(): number;
  97090. /**
  97091. * Sets the coefficient of restitution
  97092. */
  97093. set restitution(value: number);
  97094. /**
  97095. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  97096. */
  97097. get pressure(): number;
  97098. /**
  97099. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  97100. */
  97101. set pressure(value: number);
  97102. /**
  97103. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97104. */
  97105. get stiffness(): number;
  97106. /**
  97107. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  97108. */
  97109. set stiffness(value: number);
  97110. /**
  97111. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97112. */
  97113. get velocityIterations(): number;
  97114. /**
  97115. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  97116. */
  97117. set velocityIterations(value: number);
  97118. /**
  97119. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97120. */
  97121. get positionIterations(): number;
  97122. /**
  97123. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  97124. */
  97125. set positionIterations(value: number);
  97126. /**
  97127. * The unique id of the physics imposter
  97128. * set by the physics engine when adding this impostor to the array
  97129. */
  97130. uniqueId: number;
  97131. /**
  97132. * @hidden
  97133. */
  97134. soft: boolean;
  97135. /**
  97136. * @hidden
  97137. */
  97138. segments: number;
  97139. private _joints;
  97140. /**
  97141. * Initializes the physics imposter
  97142. * @param object The physics-enabled object used as the physics imposter
  97143. * @param type The type of the physics imposter
  97144. * @param _options The options for the physics imposter
  97145. * @param _scene The Babylon scene
  97146. */
  97147. constructor(
  97148. /**
  97149. * The physics-enabled object used as the physics imposter
  97150. */
  97151. object: IPhysicsEnabledObject,
  97152. /**
  97153. * The type of the physics imposter
  97154. */
  97155. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  97156. /**
  97157. * This function will completly initialize this impostor.
  97158. * It will create a new body - but only if this mesh has no parent.
  97159. * If it has, this impostor will not be used other than to define the impostor
  97160. * of the child mesh.
  97161. * @hidden
  97162. */
  97163. _init(): void;
  97164. private _getPhysicsParent;
  97165. /**
  97166. * Should a new body be generated.
  97167. * @returns boolean specifying if body initialization is required
  97168. */
  97169. isBodyInitRequired(): boolean;
  97170. /**
  97171. * Sets the updated scaling
  97172. * @param updated Specifies if the scaling is updated
  97173. */
  97174. setScalingUpdated(): void;
  97175. /**
  97176. * Force a regeneration of this or the parent's impostor's body.
  97177. * Use under cautious - This will remove all joints already implemented.
  97178. */
  97179. forceUpdate(): void;
  97180. /**
  97181. * Gets the body that holds this impostor. Either its own, or its parent.
  97182. */
  97183. get physicsBody(): any;
  97184. /**
  97185. * Get the parent of the physics imposter
  97186. * @returns Physics imposter or null
  97187. */
  97188. get parent(): Nullable<PhysicsImpostor>;
  97189. /**
  97190. * Sets the parent of the physics imposter
  97191. */
  97192. set parent(value: Nullable<PhysicsImpostor>);
  97193. /**
  97194. * Set the physics body. Used mainly by the physics engine/plugin
  97195. */
  97196. set physicsBody(physicsBody: any);
  97197. /**
  97198. * Resets the update flags
  97199. */
  97200. resetUpdateFlags(): void;
  97201. /**
  97202. * Gets the object extend size
  97203. * @returns the object extend size
  97204. */
  97205. getObjectExtendSize(): Vector3;
  97206. /**
  97207. * Gets the object center
  97208. * @returns The object center
  97209. */
  97210. getObjectCenter(): Vector3;
  97211. /**
  97212. * Get a specific parameter from the options parameters
  97213. * @param paramName The object parameter name
  97214. * @returns The object parameter
  97215. */
  97216. getParam(paramName: string): any;
  97217. /**
  97218. * Sets a specific parameter in the options given to the physics plugin
  97219. * @param paramName The parameter name
  97220. * @param value The value of the parameter
  97221. */
  97222. setParam(paramName: string, value: number): void;
  97223. /**
  97224. * Specifically change the body's mass option. Won't recreate the physics body object
  97225. * @param mass The mass of the physics imposter
  97226. */
  97227. setMass(mass: number): void;
  97228. /**
  97229. * Gets the linear velocity
  97230. * @returns linear velocity or null
  97231. */
  97232. getLinearVelocity(): Nullable<Vector3>;
  97233. /**
  97234. * Sets the linear velocity
  97235. * @param velocity linear velocity or null
  97236. */
  97237. setLinearVelocity(velocity: Nullable<Vector3>): void;
  97238. /**
  97239. * Gets the angular velocity
  97240. * @returns angular velocity or null
  97241. */
  97242. getAngularVelocity(): Nullable<Vector3>;
  97243. /**
  97244. * Sets the angular velocity
  97245. * @param velocity The velocity or null
  97246. */
  97247. setAngularVelocity(velocity: Nullable<Vector3>): void;
  97248. /**
  97249. * Execute a function with the physics plugin native code
  97250. * Provide a function the will have two variables - the world object and the physics body object
  97251. * @param func The function to execute with the physics plugin native code
  97252. */
  97253. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  97254. /**
  97255. * Register a function that will be executed before the physics world is stepping forward
  97256. * @param func The function to execute before the physics world is stepped forward
  97257. */
  97258. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97259. /**
  97260. * Unregister a function that will be executed before the physics world is stepping forward
  97261. * @param func The function to execute before the physics world is stepped forward
  97262. */
  97263. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97264. /**
  97265. * Register a function that will be executed after the physics step
  97266. * @param func The function to execute after physics step
  97267. */
  97268. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97269. /**
  97270. * Unregisters a function that will be executed after the physics step
  97271. * @param func The function to execute after physics step
  97272. */
  97273. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  97274. /**
  97275. * register a function that will be executed when this impostor collides against a different body
  97276. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  97277. * @param func Callback that is executed on collision
  97278. */
  97279. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  97280. /**
  97281. * Unregisters the physics imposter on contact
  97282. * @param collideAgainst The physics object to collide against
  97283. * @param func Callback to execute on collision
  97284. */
  97285. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  97286. private _tmpQuat;
  97287. private _tmpQuat2;
  97288. /**
  97289. * Get the parent rotation
  97290. * @returns The parent rotation
  97291. */
  97292. getParentsRotation(): Quaternion;
  97293. /**
  97294. * this function is executed by the physics engine.
  97295. */
  97296. beforeStep: () => void;
  97297. /**
  97298. * this function is executed by the physics engine
  97299. */
  97300. afterStep: () => void;
  97301. /**
  97302. * Legacy collision detection event support
  97303. */
  97304. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  97305. /**
  97306. * event and body object due to cannon's event-based architecture.
  97307. */
  97308. onCollide: (e: {
  97309. body: any;
  97310. }) => void;
  97311. /**
  97312. * Apply a force
  97313. * @param force The force to apply
  97314. * @param contactPoint The contact point for the force
  97315. * @returns The physics imposter
  97316. */
  97317. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97318. /**
  97319. * Apply an impulse
  97320. * @param force The impulse force
  97321. * @param contactPoint The contact point for the impulse force
  97322. * @returns The physics imposter
  97323. */
  97324. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  97325. /**
  97326. * A help function to create a joint
  97327. * @param otherImpostor A physics imposter used to create a joint
  97328. * @param jointType The type of joint
  97329. * @param jointData The data for the joint
  97330. * @returns The physics imposter
  97331. */
  97332. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  97333. /**
  97334. * Add a joint to this impostor with a different impostor
  97335. * @param otherImpostor A physics imposter used to add a joint
  97336. * @param joint The joint to add
  97337. * @returns The physics imposter
  97338. */
  97339. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  97340. /**
  97341. * Add an anchor to a cloth impostor
  97342. * @param otherImpostor rigid impostor to anchor to
  97343. * @param width ratio across width from 0 to 1
  97344. * @param height ratio up height from 0 to 1
  97345. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  97346. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  97347. * @returns impostor the soft imposter
  97348. */
  97349. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97350. /**
  97351. * Add a hook to a rope impostor
  97352. * @param otherImpostor rigid impostor to anchor to
  97353. * @param length ratio across rope from 0 to 1
  97354. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  97355. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  97356. * @returns impostor the rope imposter
  97357. */
  97358. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  97359. /**
  97360. * Will keep this body still, in a sleep mode.
  97361. * @returns the physics imposter
  97362. */
  97363. sleep(): PhysicsImpostor;
  97364. /**
  97365. * Wake the body up.
  97366. * @returns The physics imposter
  97367. */
  97368. wakeUp(): PhysicsImpostor;
  97369. /**
  97370. * Clones the physics imposter
  97371. * @param newObject The physics imposter clones to this physics-enabled object
  97372. * @returns A nullable physics imposter
  97373. */
  97374. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  97375. /**
  97376. * Disposes the physics imposter
  97377. */
  97378. dispose(): void;
  97379. /**
  97380. * Sets the delta position
  97381. * @param position The delta position amount
  97382. */
  97383. setDeltaPosition(position: Vector3): void;
  97384. /**
  97385. * Sets the delta rotation
  97386. * @param rotation The delta rotation amount
  97387. */
  97388. setDeltaRotation(rotation: Quaternion): void;
  97389. /**
  97390. * Gets the box size of the physics imposter and stores the result in the input parameter
  97391. * @param result Stores the box size
  97392. * @returns The physics imposter
  97393. */
  97394. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  97395. /**
  97396. * Gets the radius of the physics imposter
  97397. * @returns Radius of the physics imposter
  97398. */
  97399. getRadius(): number;
  97400. /**
  97401. * Sync a bone with this impostor
  97402. * @param bone The bone to sync to the impostor.
  97403. * @param boneMesh The mesh that the bone is influencing.
  97404. * @param jointPivot The pivot of the joint / bone in local space.
  97405. * @param distToJoint Optional distance from the impostor to the joint.
  97406. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97407. */
  97408. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  97409. /**
  97410. * Sync impostor to a bone
  97411. * @param bone The bone that the impostor will be synced to.
  97412. * @param boneMesh The mesh that the bone is influencing.
  97413. * @param jointPivot The pivot of the joint / bone in local space.
  97414. * @param distToJoint Optional distance from the impostor to the joint.
  97415. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  97416. * @param boneAxis Optional vector3 axis the bone is aligned with
  97417. */
  97418. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  97419. /**
  97420. * No-Imposter type
  97421. */
  97422. static NoImpostor: number;
  97423. /**
  97424. * Sphere-Imposter type
  97425. */
  97426. static SphereImpostor: number;
  97427. /**
  97428. * Box-Imposter type
  97429. */
  97430. static BoxImpostor: number;
  97431. /**
  97432. * Plane-Imposter type
  97433. */
  97434. static PlaneImpostor: number;
  97435. /**
  97436. * Mesh-imposter type
  97437. */
  97438. static MeshImpostor: number;
  97439. /**
  97440. * Capsule-Impostor type (Ammo.js plugin only)
  97441. */
  97442. static CapsuleImpostor: number;
  97443. /**
  97444. * Cylinder-Imposter type
  97445. */
  97446. static CylinderImpostor: number;
  97447. /**
  97448. * Particle-Imposter type
  97449. */
  97450. static ParticleImpostor: number;
  97451. /**
  97452. * Heightmap-Imposter type
  97453. */
  97454. static HeightmapImpostor: number;
  97455. /**
  97456. * ConvexHull-Impostor type (Ammo.js plugin only)
  97457. */
  97458. static ConvexHullImpostor: number;
  97459. /**
  97460. * Custom-Imposter type (Ammo.js plugin only)
  97461. */
  97462. static CustomImpostor: number;
  97463. /**
  97464. * Rope-Imposter type
  97465. */
  97466. static RopeImpostor: number;
  97467. /**
  97468. * Cloth-Imposter type
  97469. */
  97470. static ClothImpostor: number;
  97471. /**
  97472. * Softbody-Imposter type
  97473. */
  97474. static SoftbodyImpostor: number;
  97475. }
  97476. }
  97477. declare module BABYLON {
  97478. /**
  97479. * @hidden
  97480. **/
  97481. export class _CreationDataStorage {
  97482. closePath?: boolean;
  97483. closeArray?: boolean;
  97484. idx: number[];
  97485. dashSize: number;
  97486. gapSize: number;
  97487. path3D: Path3D;
  97488. pathArray: Vector3[][];
  97489. arc: number;
  97490. radius: number;
  97491. cap: number;
  97492. tessellation: number;
  97493. }
  97494. /**
  97495. * @hidden
  97496. **/
  97497. class _InstanceDataStorage {
  97498. visibleInstances: any;
  97499. batchCache: _InstancesBatch;
  97500. instancesBufferSize: number;
  97501. instancesBuffer: Nullable<Buffer>;
  97502. instancesData: Float32Array;
  97503. overridenInstanceCount: number;
  97504. isFrozen: boolean;
  97505. previousBatch: Nullable<_InstancesBatch>;
  97506. hardwareInstancedRendering: boolean;
  97507. sideOrientation: number;
  97508. manualUpdate: boolean;
  97509. }
  97510. /**
  97511. * @hidden
  97512. **/
  97513. export class _InstancesBatch {
  97514. mustReturn: boolean;
  97515. visibleInstances: Nullable<InstancedMesh[]>[];
  97516. renderSelf: boolean[];
  97517. hardwareInstancedRendering: boolean[];
  97518. }
  97519. /**
  97520. * Class used to represent renderable models
  97521. */
  97522. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  97523. /**
  97524. * Mesh side orientation : usually the external or front surface
  97525. */
  97526. static readonly FRONTSIDE: number;
  97527. /**
  97528. * Mesh side orientation : usually the internal or back surface
  97529. */
  97530. static readonly BACKSIDE: number;
  97531. /**
  97532. * Mesh side orientation : both internal and external or front and back surfaces
  97533. */
  97534. static readonly DOUBLESIDE: number;
  97535. /**
  97536. * Mesh side orientation : by default, `FRONTSIDE`
  97537. */
  97538. static readonly DEFAULTSIDE: number;
  97539. /**
  97540. * Mesh cap setting : no cap
  97541. */
  97542. static readonly NO_CAP: number;
  97543. /**
  97544. * Mesh cap setting : one cap at the beginning of the mesh
  97545. */
  97546. static readonly CAP_START: number;
  97547. /**
  97548. * Mesh cap setting : one cap at the end of the mesh
  97549. */
  97550. static readonly CAP_END: number;
  97551. /**
  97552. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  97553. */
  97554. static readonly CAP_ALL: number;
  97555. /**
  97556. * Mesh pattern setting : no flip or rotate
  97557. */
  97558. static readonly NO_FLIP: number;
  97559. /**
  97560. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  97561. */
  97562. static readonly FLIP_TILE: number;
  97563. /**
  97564. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  97565. */
  97566. static readonly ROTATE_TILE: number;
  97567. /**
  97568. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  97569. */
  97570. static readonly FLIP_ROW: number;
  97571. /**
  97572. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  97573. */
  97574. static readonly ROTATE_ROW: number;
  97575. /**
  97576. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  97577. */
  97578. static readonly FLIP_N_ROTATE_TILE: number;
  97579. /**
  97580. * Mesh pattern setting : rotate pattern and rotate
  97581. */
  97582. static readonly FLIP_N_ROTATE_ROW: number;
  97583. /**
  97584. * Mesh tile positioning : part tiles same on left/right or top/bottom
  97585. */
  97586. static readonly CENTER: number;
  97587. /**
  97588. * Mesh tile positioning : part tiles on left
  97589. */
  97590. static readonly LEFT: number;
  97591. /**
  97592. * Mesh tile positioning : part tiles on right
  97593. */
  97594. static readonly RIGHT: number;
  97595. /**
  97596. * Mesh tile positioning : part tiles on top
  97597. */
  97598. static readonly TOP: number;
  97599. /**
  97600. * Mesh tile positioning : part tiles on bottom
  97601. */
  97602. static readonly BOTTOM: number;
  97603. /**
  97604. * Gets the default side orientation.
  97605. * @param orientation the orientation to value to attempt to get
  97606. * @returns the default orientation
  97607. * @hidden
  97608. */
  97609. static _GetDefaultSideOrientation(orientation?: number): number;
  97610. private _internalMeshDataInfo;
  97611. /**
  97612. * An event triggered before rendering the mesh
  97613. */
  97614. get onBeforeRenderObservable(): Observable<Mesh>;
  97615. /**
  97616. * An event triggered before binding the mesh
  97617. */
  97618. get onBeforeBindObservable(): Observable<Mesh>;
  97619. /**
  97620. * An event triggered after rendering the mesh
  97621. */
  97622. get onAfterRenderObservable(): Observable<Mesh>;
  97623. /**
  97624. * An event triggered before drawing the mesh
  97625. */
  97626. get onBeforeDrawObservable(): Observable<Mesh>;
  97627. private _onBeforeDrawObserver;
  97628. /**
  97629. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  97630. */
  97631. set onBeforeDraw(callback: () => void);
  97632. get hasInstances(): boolean;
  97633. /**
  97634. * Gets the delay loading state of the mesh (when delay loading is turned on)
  97635. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  97636. */
  97637. delayLoadState: number;
  97638. /**
  97639. * Gets the list of instances created from this mesh
  97640. * it is not supposed to be modified manually.
  97641. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  97642. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  97643. */
  97644. instances: InstancedMesh[];
  97645. /**
  97646. * Gets the file containing delay loading data for this mesh
  97647. */
  97648. delayLoadingFile: string;
  97649. /** @hidden */
  97650. _binaryInfo: any;
  97651. /**
  97652. * User defined function used to change how LOD level selection is done
  97653. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97654. */
  97655. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  97656. /**
  97657. * Gets or sets the morph target manager
  97658. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97659. */
  97660. get morphTargetManager(): Nullable<MorphTargetManager>;
  97661. set morphTargetManager(value: Nullable<MorphTargetManager>);
  97662. /** @hidden */
  97663. _creationDataStorage: Nullable<_CreationDataStorage>;
  97664. /** @hidden */
  97665. _geometry: Nullable<Geometry>;
  97666. /** @hidden */
  97667. _delayInfo: Array<string>;
  97668. /** @hidden */
  97669. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  97670. /** @hidden */
  97671. _instanceDataStorage: _InstanceDataStorage;
  97672. private _effectiveMaterial;
  97673. /** @hidden */
  97674. _shouldGenerateFlatShading: boolean;
  97675. /** @hidden */
  97676. _originalBuilderSideOrientation: number;
  97677. /**
  97678. * Use this property to change the original side orientation defined at construction time
  97679. */
  97680. overrideMaterialSideOrientation: Nullable<number>;
  97681. /**
  97682. * Gets the source mesh (the one used to clone this one from)
  97683. */
  97684. get source(): Nullable<Mesh>;
  97685. /**
  97686. * Gets or sets a boolean indicating that this mesh does not use index buffer
  97687. */
  97688. get isUnIndexed(): boolean;
  97689. set isUnIndexed(value: boolean);
  97690. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  97691. get worldMatrixInstancedBuffer(): Float32Array;
  97692. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  97693. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  97694. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  97695. /**
  97696. * @constructor
  97697. * @param name The value used by scene.getMeshByName() to do a lookup.
  97698. * @param scene The scene to add this mesh to.
  97699. * @param parent The parent of this mesh, if it has one
  97700. * @param source An optional Mesh from which geometry is shared, cloned.
  97701. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97702. * When false, achieved by calling a clone(), also passing False.
  97703. * This will make creation of children, recursive.
  97704. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  97705. */
  97706. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  97707. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  97708. doNotInstantiate: boolean;
  97709. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  97710. /**
  97711. * Gets the class name
  97712. * @returns the string "Mesh".
  97713. */
  97714. getClassName(): string;
  97715. /** @hidden */
  97716. get _isMesh(): boolean;
  97717. /**
  97718. * Returns a description of this mesh
  97719. * @param fullDetails define if full details about this mesh must be used
  97720. * @returns a descriptive string representing this mesh
  97721. */
  97722. toString(fullDetails?: boolean): string;
  97723. /** @hidden */
  97724. _unBindEffect(): void;
  97725. /**
  97726. * Gets a boolean indicating if this mesh has LOD
  97727. */
  97728. get hasLODLevels(): boolean;
  97729. /**
  97730. * Gets the list of MeshLODLevel associated with the current mesh
  97731. * @returns an array of MeshLODLevel
  97732. */
  97733. getLODLevels(): MeshLODLevel[];
  97734. private _sortLODLevels;
  97735. /**
  97736. * Add a mesh as LOD level triggered at the given distance.
  97737. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97738. * @param distance The distance from the center of the object to show this level
  97739. * @param mesh The mesh to be added as LOD level (can be null)
  97740. * @return This mesh (for chaining)
  97741. */
  97742. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  97743. /**
  97744. * Returns the LOD level mesh at the passed distance or null if not found.
  97745. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97746. * @param distance The distance from the center of the object to show this level
  97747. * @returns a Mesh or `null`
  97748. */
  97749. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  97750. /**
  97751. * Remove a mesh from the LOD array
  97752. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97753. * @param mesh defines the mesh to be removed
  97754. * @return This mesh (for chaining)
  97755. */
  97756. removeLODLevel(mesh: Mesh): Mesh;
  97757. /**
  97758. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  97759. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  97760. * @param camera defines the camera to use to compute distance
  97761. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  97762. * @return This mesh (for chaining)
  97763. */
  97764. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  97765. /**
  97766. * Gets the mesh internal Geometry object
  97767. */
  97768. get geometry(): Nullable<Geometry>;
  97769. /**
  97770. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  97771. * @returns the total number of vertices
  97772. */
  97773. getTotalVertices(): number;
  97774. /**
  97775. * Returns the content of an associated vertex buffer
  97776. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97777. * - VertexBuffer.PositionKind
  97778. * - VertexBuffer.UVKind
  97779. * - VertexBuffer.UV2Kind
  97780. * - VertexBuffer.UV3Kind
  97781. * - VertexBuffer.UV4Kind
  97782. * - VertexBuffer.UV5Kind
  97783. * - VertexBuffer.UV6Kind
  97784. * - VertexBuffer.ColorKind
  97785. * - VertexBuffer.MatricesIndicesKind
  97786. * - VertexBuffer.MatricesIndicesExtraKind
  97787. * - VertexBuffer.MatricesWeightsKind
  97788. * - VertexBuffer.MatricesWeightsExtraKind
  97789. * @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
  97790. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  97791. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  97792. */
  97793. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  97794. /**
  97795. * Returns the mesh VertexBuffer object from the requested `kind`
  97796. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97797. * - VertexBuffer.PositionKind
  97798. * - VertexBuffer.NormalKind
  97799. * - VertexBuffer.UVKind
  97800. * - VertexBuffer.UV2Kind
  97801. * - VertexBuffer.UV3Kind
  97802. * - VertexBuffer.UV4Kind
  97803. * - VertexBuffer.UV5Kind
  97804. * - VertexBuffer.UV6Kind
  97805. * - VertexBuffer.ColorKind
  97806. * - VertexBuffer.MatricesIndicesKind
  97807. * - VertexBuffer.MatricesIndicesExtraKind
  97808. * - VertexBuffer.MatricesWeightsKind
  97809. * - VertexBuffer.MatricesWeightsExtraKind
  97810. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  97811. */
  97812. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  97813. /**
  97814. * Tests if a specific vertex buffer is associated with this mesh
  97815. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97816. * - VertexBuffer.PositionKind
  97817. * - VertexBuffer.NormalKind
  97818. * - VertexBuffer.UVKind
  97819. * - VertexBuffer.UV2Kind
  97820. * - VertexBuffer.UV3Kind
  97821. * - VertexBuffer.UV4Kind
  97822. * - VertexBuffer.UV5Kind
  97823. * - VertexBuffer.UV6Kind
  97824. * - VertexBuffer.ColorKind
  97825. * - VertexBuffer.MatricesIndicesKind
  97826. * - VertexBuffer.MatricesIndicesExtraKind
  97827. * - VertexBuffer.MatricesWeightsKind
  97828. * - VertexBuffer.MatricesWeightsExtraKind
  97829. * @returns a boolean
  97830. */
  97831. isVerticesDataPresent(kind: string): boolean;
  97832. /**
  97833. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  97834. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  97835. * - VertexBuffer.PositionKind
  97836. * - VertexBuffer.UVKind
  97837. * - VertexBuffer.UV2Kind
  97838. * - VertexBuffer.UV3Kind
  97839. * - VertexBuffer.UV4Kind
  97840. * - VertexBuffer.UV5Kind
  97841. * - VertexBuffer.UV6Kind
  97842. * - VertexBuffer.ColorKind
  97843. * - VertexBuffer.MatricesIndicesKind
  97844. * - VertexBuffer.MatricesIndicesExtraKind
  97845. * - VertexBuffer.MatricesWeightsKind
  97846. * - VertexBuffer.MatricesWeightsExtraKind
  97847. * @returns a boolean
  97848. */
  97849. isVertexBufferUpdatable(kind: string): boolean;
  97850. /**
  97851. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  97852. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  97853. * - VertexBuffer.PositionKind
  97854. * - VertexBuffer.NormalKind
  97855. * - VertexBuffer.UVKind
  97856. * - VertexBuffer.UV2Kind
  97857. * - VertexBuffer.UV3Kind
  97858. * - VertexBuffer.UV4Kind
  97859. * - VertexBuffer.UV5Kind
  97860. * - VertexBuffer.UV6Kind
  97861. * - VertexBuffer.ColorKind
  97862. * - VertexBuffer.MatricesIndicesKind
  97863. * - VertexBuffer.MatricesIndicesExtraKind
  97864. * - VertexBuffer.MatricesWeightsKind
  97865. * - VertexBuffer.MatricesWeightsExtraKind
  97866. * @returns an array of strings
  97867. */
  97868. getVerticesDataKinds(): string[];
  97869. /**
  97870. * Returns a positive integer : the total number of indices in this mesh geometry.
  97871. * @returns the numner of indices or zero if the mesh has no geometry.
  97872. */
  97873. getTotalIndices(): number;
  97874. /**
  97875. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  97876. * @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.
  97877. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  97878. * @returns the indices array or an empty array if the mesh has no geometry
  97879. */
  97880. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  97881. get isBlocked(): boolean;
  97882. /**
  97883. * Determine if the current mesh is ready to be rendered
  97884. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  97885. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  97886. * @returns true if all associated assets are ready (material, textures, shaders)
  97887. */
  97888. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  97889. /**
  97890. * 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.
  97891. */
  97892. get areNormalsFrozen(): boolean;
  97893. /**
  97894. * 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.
  97895. * @returns the current mesh
  97896. */
  97897. freezeNormals(): Mesh;
  97898. /**
  97899. * 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
  97900. * @returns the current mesh
  97901. */
  97902. unfreezeNormals(): Mesh;
  97903. /**
  97904. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  97905. */
  97906. set overridenInstanceCount(count: number);
  97907. /** @hidden */
  97908. _preActivate(): Mesh;
  97909. /** @hidden */
  97910. _preActivateForIntermediateRendering(renderId: number): Mesh;
  97911. /** @hidden */
  97912. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  97913. /**
  97914. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  97915. * This means the mesh underlying bounding box and sphere are recomputed.
  97916. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  97917. * @returns the current mesh
  97918. */
  97919. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  97920. /** @hidden */
  97921. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  97922. /**
  97923. * This function will subdivide the mesh into multiple submeshes
  97924. * @param count defines the expected number of submeshes
  97925. */
  97926. subdivide(count: number): void;
  97927. /**
  97928. * Copy a FloatArray into a specific associated vertex buffer
  97929. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97930. * - VertexBuffer.PositionKind
  97931. * - VertexBuffer.UVKind
  97932. * - VertexBuffer.UV2Kind
  97933. * - VertexBuffer.UV3Kind
  97934. * - VertexBuffer.UV4Kind
  97935. * - VertexBuffer.UV5Kind
  97936. * - VertexBuffer.UV6Kind
  97937. * - VertexBuffer.ColorKind
  97938. * - VertexBuffer.MatricesIndicesKind
  97939. * - VertexBuffer.MatricesIndicesExtraKind
  97940. * - VertexBuffer.MatricesWeightsKind
  97941. * - VertexBuffer.MatricesWeightsExtraKind
  97942. * @param data defines the data source
  97943. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97944. * @param stride defines the data stride size (can be null)
  97945. * @returns the current mesh
  97946. */
  97947. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  97948. /**
  97949. * Delete a vertex buffer associated with this mesh
  97950. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  97951. * - VertexBuffer.PositionKind
  97952. * - VertexBuffer.UVKind
  97953. * - VertexBuffer.UV2Kind
  97954. * - VertexBuffer.UV3Kind
  97955. * - VertexBuffer.UV4Kind
  97956. * - VertexBuffer.UV5Kind
  97957. * - VertexBuffer.UV6Kind
  97958. * - VertexBuffer.ColorKind
  97959. * - VertexBuffer.MatricesIndicesKind
  97960. * - VertexBuffer.MatricesIndicesExtraKind
  97961. * - VertexBuffer.MatricesWeightsKind
  97962. * - VertexBuffer.MatricesWeightsExtraKind
  97963. */
  97964. removeVerticesData(kind: string): void;
  97965. /**
  97966. * Flags an associated vertex buffer as updatable
  97967. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  97968. * - VertexBuffer.PositionKind
  97969. * - VertexBuffer.UVKind
  97970. * - VertexBuffer.UV2Kind
  97971. * - VertexBuffer.UV3Kind
  97972. * - VertexBuffer.UV4Kind
  97973. * - VertexBuffer.UV5Kind
  97974. * - VertexBuffer.UV6Kind
  97975. * - VertexBuffer.ColorKind
  97976. * - VertexBuffer.MatricesIndicesKind
  97977. * - VertexBuffer.MatricesIndicesExtraKind
  97978. * - VertexBuffer.MatricesWeightsKind
  97979. * - VertexBuffer.MatricesWeightsExtraKind
  97980. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  97981. */
  97982. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  97983. /**
  97984. * Sets the mesh global Vertex Buffer
  97985. * @param buffer defines the buffer to use
  97986. * @returns the current mesh
  97987. */
  97988. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  97989. /**
  97990. * Update a specific associated vertex buffer
  97991. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  97992. * - VertexBuffer.PositionKind
  97993. * - VertexBuffer.UVKind
  97994. * - VertexBuffer.UV2Kind
  97995. * - VertexBuffer.UV3Kind
  97996. * - VertexBuffer.UV4Kind
  97997. * - VertexBuffer.UV5Kind
  97998. * - VertexBuffer.UV6Kind
  97999. * - VertexBuffer.ColorKind
  98000. * - VertexBuffer.MatricesIndicesKind
  98001. * - VertexBuffer.MatricesIndicesExtraKind
  98002. * - VertexBuffer.MatricesWeightsKind
  98003. * - VertexBuffer.MatricesWeightsExtraKind
  98004. * @param data defines the data source
  98005. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  98006. * @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)
  98007. * @returns the current mesh
  98008. */
  98009. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  98010. /**
  98011. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  98012. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  98013. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  98014. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  98015. * @returns the current mesh
  98016. */
  98017. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  98018. /**
  98019. * Creates a un-shared specific occurence of the geometry for the mesh.
  98020. * @returns the current mesh
  98021. */
  98022. makeGeometryUnique(): Mesh;
  98023. /**
  98024. * Set the index buffer of this mesh
  98025. * @param indices defines the source data
  98026. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  98027. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  98028. * @returns the current mesh
  98029. */
  98030. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  98031. /**
  98032. * Update the current index buffer
  98033. * @param indices defines the source data
  98034. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  98035. * @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)
  98036. * @returns the current mesh
  98037. */
  98038. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  98039. /**
  98040. * Invert the geometry to move from a right handed system to a left handed one.
  98041. * @returns the current mesh
  98042. */
  98043. toLeftHanded(): Mesh;
  98044. /** @hidden */
  98045. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  98046. /** @hidden */
  98047. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  98048. /**
  98049. * Registers for this mesh a javascript function called just before the rendering process
  98050. * @param func defines the function to call before rendering this mesh
  98051. * @returns the current mesh
  98052. */
  98053. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98054. /**
  98055. * Disposes a previously registered javascript function called before the rendering
  98056. * @param func defines the function to remove
  98057. * @returns the current mesh
  98058. */
  98059. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  98060. /**
  98061. * Registers for this mesh a javascript function called just after the rendering is complete
  98062. * @param func defines the function to call after rendering this mesh
  98063. * @returns the current mesh
  98064. */
  98065. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98066. /**
  98067. * Disposes a previously registered javascript function called after the rendering.
  98068. * @param func defines the function to remove
  98069. * @returns the current mesh
  98070. */
  98071. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  98072. /** @hidden */
  98073. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  98074. /** @hidden */
  98075. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  98076. /** @hidden */
  98077. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  98078. /** @hidden */
  98079. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  98080. /** @hidden */
  98081. _rebuild(): void;
  98082. /** @hidden */
  98083. _freeze(): void;
  98084. /** @hidden */
  98085. _unFreeze(): void;
  98086. /**
  98087. * 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
  98088. * @param subMesh defines the subMesh to render
  98089. * @param enableAlphaMode defines if alpha mode can be changed
  98090. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  98091. * @returns the current mesh
  98092. */
  98093. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  98094. private _onBeforeDraw;
  98095. /**
  98096. * Renormalize the mesh and patch it up if there are no weights
  98097. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  98098. * However in the case of zero weights then we set just a single influence to 1.
  98099. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  98100. */
  98101. cleanMatrixWeights(): void;
  98102. private normalizeSkinFourWeights;
  98103. private normalizeSkinWeightsAndExtra;
  98104. /**
  98105. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  98106. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  98107. * the user know there was an issue with importing the mesh
  98108. * @returns a validation object with skinned, valid and report string
  98109. */
  98110. validateSkinning(): {
  98111. skinned: boolean;
  98112. valid: boolean;
  98113. report: string;
  98114. };
  98115. /** @hidden */
  98116. _checkDelayState(): Mesh;
  98117. private _queueLoad;
  98118. /**
  98119. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  98120. * A mesh is in the frustum if its bounding box intersects the frustum
  98121. * @param frustumPlanes defines the frustum to test
  98122. * @returns true if the mesh is in the frustum planes
  98123. */
  98124. isInFrustum(frustumPlanes: Plane[]): boolean;
  98125. /**
  98126. * Sets the mesh material by the material or multiMaterial `id` property
  98127. * @param id is a string identifying the material or the multiMaterial
  98128. * @returns the current mesh
  98129. */
  98130. setMaterialByID(id: string): Mesh;
  98131. /**
  98132. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  98133. * @returns an array of IAnimatable
  98134. */
  98135. getAnimatables(): IAnimatable[];
  98136. /**
  98137. * Modifies the mesh geometry according to the passed transformation matrix.
  98138. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  98139. * The mesh normals are modified using the same transformation.
  98140. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98141. * @param transform defines the transform matrix to use
  98142. * @see http://doc.babylonjs.com/resources/baking_transformations
  98143. * @returns the current mesh
  98144. */
  98145. bakeTransformIntoVertices(transform: Matrix): Mesh;
  98146. /**
  98147. * Modifies the mesh geometry according to its own current World Matrix.
  98148. * The mesh World Matrix is then reset.
  98149. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  98150. * Note that, under the hood, this method sets a new VertexBuffer each call.
  98151. * @see http://doc.babylonjs.com/resources/baking_transformations
  98152. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  98153. * @returns the current mesh
  98154. */
  98155. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  98156. /** @hidden */
  98157. get _positions(): Nullable<Vector3[]>;
  98158. /** @hidden */
  98159. _resetPointsArrayCache(): Mesh;
  98160. /** @hidden */
  98161. _generatePointsArray(): boolean;
  98162. /**
  98163. * Returns a new Mesh object generated from the current mesh properties.
  98164. * This method must not get confused with createInstance()
  98165. * @param name is a string, the name given to the new mesh
  98166. * @param newParent can be any Node object (default `null`)
  98167. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  98168. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  98169. * @returns a new mesh
  98170. */
  98171. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  98172. /**
  98173. * Releases resources associated with this mesh.
  98174. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98175. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98176. */
  98177. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98178. /** @hidden */
  98179. _disposeInstanceSpecificData(): void;
  98180. /**
  98181. * Modifies the mesh geometry according to a displacement map.
  98182. * 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.
  98183. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98184. * @param url is a string, the URL from the image file is to be downloaded.
  98185. * @param minHeight is the lower limit of the displacement.
  98186. * @param maxHeight is the upper limit of the displacement.
  98187. * @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.
  98188. * @param uvOffset is an optional vector2 used to offset UV.
  98189. * @param uvScale is an optional vector2 used to scale UV.
  98190. * @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.
  98191. * @returns the Mesh.
  98192. */
  98193. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98194. /**
  98195. * Modifies the mesh geometry according to a displacementMap buffer.
  98196. * 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.
  98197. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  98198. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  98199. * @param heightMapWidth is the width of the buffer image.
  98200. * @param heightMapHeight is the height of the buffer image.
  98201. * @param minHeight is the lower limit of the displacement.
  98202. * @param maxHeight is the upper limit of the displacement.
  98203. * @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.
  98204. * @param uvOffset is an optional vector2 used to offset UV.
  98205. * @param uvScale is an optional vector2 used to scale UV.
  98206. * @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.
  98207. * @returns the Mesh.
  98208. */
  98209. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  98210. /**
  98211. * Modify the mesh to get a flat shading rendering.
  98212. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  98213. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  98214. * @returns current mesh
  98215. */
  98216. convertToFlatShadedMesh(): Mesh;
  98217. /**
  98218. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  98219. * In other words, more vertices, no more indices and a single bigger VBO.
  98220. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  98221. * @returns current mesh
  98222. */
  98223. convertToUnIndexedMesh(): Mesh;
  98224. /**
  98225. * Inverses facet orientations.
  98226. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98227. * @param flipNormals will also inverts the normals
  98228. * @returns current mesh
  98229. */
  98230. flipFaces(flipNormals?: boolean): Mesh;
  98231. /**
  98232. * Increase the number of facets and hence vertices in a mesh
  98233. * Vertex normals are interpolated from existing vertex normals
  98234. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98235. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  98236. */
  98237. increaseVertices(numberPerEdge: number): void;
  98238. /**
  98239. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  98240. * This will undo any application of covertToFlatShadedMesh
  98241. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  98242. */
  98243. forceSharedVertices(): void;
  98244. /** @hidden */
  98245. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  98246. /** @hidden */
  98247. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  98248. /**
  98249. * Creates a new InstancedMesh object from the mesh model.
  98250. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98251. * @param name defines the name of the new instance
  98252. * @returns a new InstancedMesh
  98253. */
  98254. createInstance(name: string): InstancedMesh;
  98255. /**
  98256. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  98257. * After this call, all the mesh instances have the same submeshes than the current mesh.
  98258. * @returns the current mesh
  98259. */
  98260. synchronizeInstances(): Mesh;
  98261. /**
  98262. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  98263. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  98264. * This should be used together with the simplification to avoid disappearing triangles.
  98265. * @param successCallback an optional success callback to be called after the optimization finished.
  98266. * @returns the current mesh
  98267. */
  98268. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  98269. /**
  98270. * Serialize current mesh
  98271. * @param serializationObject defines the object which will receive the serialization data
  98272. */
  98273. serialize(serializationObject: any): void;
  98274. /** @hidden */
  98275. _syncGeometryWithMorphTargetManager(): void;
  98276. /** @hidden */
  98277. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  98278. /**
  98279. * Returns a new Mesh object parsed from the source provided.
  98280. * @param parsedMesh is the source
  98281. * @param scene defines the hosting scene
  98282. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  98283. * @returns a new Mesh
  98284. */
  98285. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  98286. /**
  98287. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  98288. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98289. * @param name defines the name of the mesh to create
  98290. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  98291. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  98292. * @param closePath creates a seam between the first and the last points of each path of the path array
  98293. * @param offset is taken in account only if the `pathArray` is containing a single path
  98294. * @param scene defines the hosting scene
  98295. * @param updatable defines if the mesh must be flagged as updatable
  98296. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98297. * @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)
  98298. * @returns a new Mesh
  98299. */
  98300. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98301. /**
  98302. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  98303. * @param name defines the name of the mesh to create
  98304. * @param radius sets the radius size (float) of the polygon (default 0.5)
  98305. * @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
  98306. * @param scene defines the hosting scene
  98307. * @param updatable defines if the mesh must be flagged as updatable
  98308. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98309. * @returns a new Mesh
  98310. */
  98311. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98312. /**
  98313. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  98314. * @param name defines the name of the mesh to create
  98315. * @param size sets the size (float) of each box side (default 1)
  98316. * @param scene defines the hosting scene
  98317. * @param updatable defines if the mesh must be flagged as updatable
  98318. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98319. * @returns a new Mesh
  98320. */
  98321. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  98322. /**
  98323. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  98324. * @param name defines the name of the mesh to create
  98325. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98326. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98327. * @param scene defines the hosting scene
  98328. * @param updatable defines if the mesh must be flagged as updatable
  98329. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98330. * @returns a new Mesh
  98331. */
  98332. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98333. /**
  98334. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  98335. * @param name defines the name of the mesh to create
  98336. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  98337. * @param diameter sets the diameter size (float) of the sphere (default 1)
  98338. * @param scene defines the hosting scene
  98339. * @returns a new Mesh
  98340. */
  98341. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  98342. /**
  98343. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  98344. * @param name defines the name of the mesh to create
  98345. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  98346. * @param diameterTop set the top cap diameter (floats, default 1)
  98347. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  98348. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  98349. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  98350. * @param scene defines the hosting scene
  98351. * @param updatable defines if the mesh must be flagged as updatable
  98352. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98353. * @returns a new Mesh
  98354. */
  98355. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  98356. /**
  98357. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  98358. * @param name defines the name of the mesh to create
  98359. * @param diameter sets the diameter size (float) of the torus (default 1)
  98360. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  98361. * @param tessellation sets the number of torus sides (postive integer, default 16)
  98362. * @param scene defines the hosting scene
  98363. * @param updatable defines if the mesh must be flagged as updatable
  98364. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98365. * @returns a new Mesh
  98366. */
  98367. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98368. /**
  98369. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  98370. * @param name defines the name of the mesh to create
  98371. * @param radius sets the global radius size (float) of the torus knot (default 2)
  98372. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  98373. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  98374. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  98375. * @param p the number of windings on X axis (positive integers, default 2)
  98376. * @param q the number of windings on Y axis (positive integers, default 3)
  98377. * @param scene defines the hosting scene
  98378. * @param updatable defines if the mesh must be flagged as updatable
  98379. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98380. * @returns a new Mesh
  98381. */
  98382. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98383. /**
  98384. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  98385. * @param name defines the name of the mesh to create
  98386. * @param points is an array successive Vector3
  98387. * @param scene defines the hosting scene
  98388. * @param updatable defines if the mesh must be flagged as updatable
  98389. * @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).
  98390. * @returns a new Mesh
  98391. */
  98392. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  98393. /**
  98394. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  98395. * @param name defines the name of the mesh to create
  98396. * @param points is an array successive Vector3
  98397. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  98398. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  98399. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  98400. * @param scene defines the hosting scene
  98401. * @param updatable defines if the mesh must be flagged as updatable
  98402. * @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)
  98403. * @returns a new Mesh
  98404. */
  98405. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  98406. /**
  98407. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  98408. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  98409. * 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.
  98410. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98411. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98412. * Remember you can only change the shape positions, not their number when updating a polygon.
  98413. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  98414. * @param name defines the name of the mesh to create
  98415. * @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
  98416. * @param scene defines the hosting scene
  98417. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98418. * @param updatable defines if the mesh must be flagged as updatable
  98419. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98420. * @param earcutInjection can be used to inject your own earcut reference
  98421. * @returns a new Mesh
  98422. */
  98423. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98424. /**
  98425. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  98426. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  98427. * @param name defines the name of the mesh to create
  98428. * @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
  98429. * @param depth defines the height of extrusion
  98430. * @param scene defines the hosting scene
  98431. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  98432. * @param updatable defines if the mesh must be flagged as updatable
  98433. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98434. * @param earcutInjection can be used to inject your own earcut reference
  98435. * @returns a new Mesh
  98436. */
  98437. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  98438. /**
  98439. * Creates an extruded shape mesh.
  98440. * 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
  98441. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98442. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98443. * @param name defines the name of the mesh to create
  98444. * @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
  98445. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98446. * @param scale is the value to scale the shape
  98447. * @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
  98448. * @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
  98449. * @param scene defines the hosting scene
  98450. * @param updatable defines if the mesh must be flagged as updatable
  98451. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98452. * @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)
  98453. * @returns a new Mesh
  98454. */
  98455. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98456. /**
  98457. * Creates an custom extruded shape mesh.
  98458. * The custom extrusion is a parametric shape.
  98459. * It has no predefined shape. Its final shape will depend on the input parameters.
  98460. * Please consider using the same method from the MeshBuilder class instead
  98461. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  98462. * @param name defines the name of the mesh to create
  98463. * @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
  98464. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  98465. * @param scaleFunction is a custom Javascript function called on each path point
  98466. * @param rotationFunction is a custom Javascript function called on each path point
  98467. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  98468. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  98469. * @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
  98470. * @param scene defines the hosting scene
  98471. * @param updatable defines if the mesh must be flagged as updatable
  98472. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98473. * @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)
  98474. * @returns a new Mesh
  98475. */
  98476. 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;
  98477. /**
  98478. * Creates lathe mesh.
  98479. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  98480. * Please consider using the same method from the MeshBuilder class instead
  98481. * @param name defines the name of the mesh to create
  98482. * @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
  98483. * @param radius is the radius value of the lathe
  98484. * @param tessellation is the side number of the lathe.
  98485. * @param scene defines the hosting scene
  98486. * @param updatable defines if the mesh must be flagged as updatable
  98487. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98488. * @returns a new Mesh
  98489. */
  98490. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98491. /**
  98492. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  98493. * @param name defines the name of the mesh to create
  98494. * @param size sets the size (float) of both sides of the plane at once (default 1)
  98495. * @param scene defines the hosting scene
  98496. * @param updatable defines if the mesh must be flagged as updatable
  98497. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98498. * @returns a new Mesh
  98499. */
  98500. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  98501. /**
  98502. * Creates a ground mesh.
  98503. * Please consider using the same method from the MeshBuilder class instead
  98504. * @param name defines the name of the mesh to create
  98505. * @param width set the width of the ground
  98506. * @param height set the height of the ground
  98507. * @param subdivisions sets the number of subdivisions per side
  98508. * @param scene defines the hosting scene
  98509. * @param updatable defines if the mesh must be flagged as updatable
  98510. * @returns a new Mesh
  98511. */
  98512. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  98513. /**
  98514. * Creates a tiled ground mesh.
  98515. * Please consider using the same method from the MeshBuilder class instead
  98516. * @param name defines the name of the mesh to create
  98517. * @param xmin set the ground minimum X coordinate
  98518. * @param zmin set the ground minimum Y coordinate
  98519. * @param xmax set the ground maximum X coordinate
  98520. * @param zmax set the ground maximum Z coordinate
  98521. * @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
  98522. * @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
  98523. * @param scene defines the hosting scene
  98524. * @param updatable defines if the mesh must be flagged as updatable
  98525. * @returns a new Mesh
  98526. */
  98527. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  98528. w: number;
  98529. h: number;
  98530. }, precision: {
  98531. w: number;
  98532. h: number;
  98533. }, scene: Scene, updatable?: boolean): Mesh;
  98534. /**
  98535. * Creates a ground mesh from a height map.
  98536. * Please consider using the same method from the MeshBuilder class instead
  98537. * @see http://doc.babylonjs.com/babylon101/height_map
  98538. * @param name defines the name of the mesh to create
  98539. * @param url sets the URL of the height map image resource
  98540. * @param width set the ground width size
  98541. * @param height set the ground height size
  98542. * @param subdivisions sets the number of subdivision per side
  98543. * @param minHeight is the minimum altitude on the ground
  98544. * @param maxHeight is the maximum altitude on the ground
  98545. * @param scene defines the hosting scene
  98546. * @param updatable defines if the mesh must be flagged as updatable
  98547. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  98548. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98549. * @returns a new Mesh
  98550. */
  98551. 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;
  98552. /**
  98553. * Creates a tube mesh.
  98554. * The tube is a parametric shape.
  98555. * It has no predefined shape. Its final shape will depend on the input parameters.
  98556. * Please consider using the same method from the MeshBuilder class instead
  98557. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  98558. * @param name defines the name of the mesh to create
  98559. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  98560. * @param radius sets the tube radius size
  98561. * @param tessellation is the number of sides on the tubular surface
  98562. * @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
  98563. * @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
  98564. * @param scene defines the hosting scene
  98565. * @param updatable defines if the mesh must be flagged as updatable
  98566. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  98567. * @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)
  98568. * @returns a new Mesh
  98569. */
  98570. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  98571. (i: number, distance: number): number;
  98572. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  98573. /**
  98574. * Creates a polyhedron mesh.
  98575. * Please consider using the same method from the MeshBuilder class instead.
  98576. * * 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
  98577. * * The parameter `size` (positive float, default 1) sets the polygon size
  98578. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  98579. * * 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`
  98580. * * 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
  98581. * * 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)`)
  98582. * * 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
  98583. * * 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
  98584. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98585. * * If you create a double-sided mesh, you can choose what parts of 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
  98586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98587. * @param name defines the name of the mesh to create
  98588. * @param options defines the options used to create the mesh
  98589. * @param scene defines the hosting scene
  98590. * @returns a new Mesh
  98591. */
  98592. static CreatePolyhedron(name: string, options: {
  98593. type?: number;
  98594. size?: number;
  98595. sizeX?: number;
  98596. sizeY?: number;
  98597. sizeZ?: number;
  98598. custom?: any;
  98599. faceUV?: Vector4[];
  98600. faceColors?: Color4[];
  98601. updatable?: boolean;
  98602. sideOrientation?: number;
  98603. }, scene: Scene): Mesh;
  98604. /**
  98605. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  98606. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  98607. * * 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`)
  98608. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  98609. * * 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
  98610. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  98611. * * If you create a double-sided mesh, you can choose what parts of 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
  98612. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98613. * @param name defines the name of the mesh
  98614. * @param options defines the options used to create the mesh
  98615. * @param scene defines the hosting scene
  98616. * @returns a new Mesh
  98617. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  98618. */
  98619. static CreateIcoSphere(name: string, options: {
  98620. radius?: number;
  98621. flat?: boolean;
  98622. subdivisions?: number;
  98623. sideOrientation?: number;
  98624. updatable?: boolean;
  98625. }, scene: Scene): Mesh;
  98626. /**
  98627. * Creates a decal mesh.
  98628. * Please consider using the same method from the MeshBuilder class instead.
  98629. * A decal is a mesh usually applied as a model onto the surface of another mesh
  98630. * @param name defines the name of the mesh
  98631. * @param sourceMesh defines the mesh receiving the decal
  98632. * @param position sets the position of the decal in world coordinates
  98633. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  98634. * @param size sets the decal scaling
  98635. * @param angle sets the angle to rotate the decal
  98636. * @returns a new Mesh
  98637. */
  98638. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  98639. /**
  98640. * Prepare internal position array for software CPU skinning
  98641. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  98642. */
  98643. setPositionsForCPUSkinning(): Float32Array;
  98644. /**
  98645. * Prepare internal normal array for software CPU skinning
  98646. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  98647. */
  98648. setNormalsForCPUSkinning(): Float32Array;
  98649. /**
  98650. * Updates the vertex buffer by applying transformation from the bones
  98651. * @param skeleton defines the skeleton to apply to current mesh
  98652. * @returns the current mesh
  98653. */
  98654. applySkeleton(skeleton: Skeleton): Mesh;
  98655. /**
  98656. * 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
  98657. * @param meshes defines the list of meshes to scan
  98658. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  98659. */
  98660. static MinMax(meshes: AbstractMesh[]): {
  98661. min: Vector3;
  98662. max: Vector3;
  98663. };
  98664. /**
  98665. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  98666. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  98667. * @returns a vector3
  98668. */
  98669. static Center(meshesOrMinMaxVector: {
  98670. min: Vector3;
  98671. max: Vector3;
  98672. } | AbstractMesh[]): Vector3;
  98673. /**
  98674. * Merge the array of meshes into a single mesh for performance reasons.
  98675. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  98676. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  98677. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  98678. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  98679. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  98680. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  98681. * @returns a new mesh
  98682. */
  98683. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  98684. /** @hidden */
  98685. addInstance(instance: InstancedMesh): void;
  98686. /** @hidden */
  98687. removeInstance(instance: InstancedMesh): void;
  98688. }
  98689. }
  98690. declare module BABYLON {
  98691. /**
  98692. * This is the base class of all the camera used in the application.
  98693. * @see http://doc.babylonjs.com/features/cameras
  98694. */
  98695. export class Camera extends Node {
  98696. /** @hidden */
  98697. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  98698. /**
  98699. * This is the default projection mode used by the cameras.
  98700. * It helps recreating a feeling of perspective and better appreciate depth.
  98701. * This is the best way to simulate real life cameras.
  98702. */
  98703. static readonly PERSPECTIVE_CAMERA: number;
  98704. /**
  98705. * This helps creating camera with an orthographic mode.
  98706. * 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.
  98707. */
  98708. static readonly ORTHOGRAPHIC_CAMERA: number;
  98709. /**
  98710. * This is the default FOV mode for perspective cameras.
  98711. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  98712. */
  98713. static readonly FOVMODE_VERTICAL_FIXED: number;
  98714. /**
  98715. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  98716. */
  98717. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  98718. /**
  98719. * This specifies ther is no need for a camera rig.
  98720. * Basically only one eye is rendered corresponding to the camera.
  98721. */
  98722. static readonly RIG_MODE_NONE: number;
  98723. /**
  98724. * Simulates a camera Rig with one blue eye and one red eye.
  98725. * This can be use with 3d blue and red glasses.
  98726. */
  98727. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  98728. /**
  98729. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  98730. */
  98731. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  98732. /**
  98733. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  98734. */
  98735. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  98736. /**
  98737. * Defines that both eyes of the camera will be rendered over under each other.
  98738. */
  98739. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  98740. /**
  98741. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  98742. */
  98743. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  98744. /**
  98745. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  98746. */
  98747. static readonly RIG_MODE_VR: number;
  98748. /**
  98749. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  98750. */
  98751. static readonly RIG_MODE_WEBVR: number;
  98752. /**
  98753. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  98754. */
  98755. static readonly RIG_MODE_CUSTOM: number;
  98756. /**
  98757. * Defines if by default attaching controls should prevent the default javascript event to continue.
  98758. */
  98759. static ForceAttachControlToAlwaysPreventDefault: boolean;
  98760. /**
  98761. * Define the input manager associated with the camera.
  98762. */
  98763. inputs: CameraInputsManager<Camera>;
  98764. /** @hidden */
  98765. _position: Vector3;
  98766. /**
  98767. * Define the current local position of the camera in the scene
  98768. */
  98769. get position(): Vector3;
  98770. set position(newPosition: Vector3);
  98771. /**
  98772. * The vector the camera should consider as up.
  98773. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  98774. */
  98775. upVector: Vector3;
  98776. /**
  98777. * Define the current limit on the left side for an orthographic camera
  98778. * In scene unit
  98779. */
  98780. orthoLeft: Nullable<number>;
  98781. /**
  98782. * Define the current limit on the right side for an orthographic camera
  98783. * In scene unit
  98784. */
  98785. orthoRight: Nullable<number>;
  98786. /**
  98787. * Define the current limit on the bottom side for an orthographic camera
  98788. * In scene unit
  98789. */
  98790. orthoBottom: Nullable<number>;
  98791. /**
  98792. * Define the current limit on the top side for an orthographic camera
  98793. * In scene unit
  98794. */
  98795. orthoTop: Nullable<number>;
  98796. /**
  98797. * Field Of View is set in Radians. (default is 0.8)
  98798. */
  98799. fov: number;
  98800. /**
  98801. * Define the minimum distance the camera can see from.
  98802. * This is important to note that the depth buffer are not infinite and the closer it starts
  98803. * the more your scene might encounter depth fighting issue.
  98804. */
  98805. minZ: number;
  98806. /**
  98807. * Define the maximum distance the camera can see to.
  98808. * This is important to note that the depth buffer are not infinite and the further it end
  98809. * the more your scene might encounter depth fighting issue.
  98810. */
  98811. maxZ: number;
  98812. /**
  98813. * Define the default inertia of the camera.
  98814. * This helps giving a smooth feeling to the camera movement.
  98815. */
  98816. inertia: number;
  98817. /**
  98818. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  98819. */
  98820. mode: number;
  98821. /**
  98822. * Define whether the camera is intermediate.
  98823. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  98824. */
  98825. isIntermediate: boolean;
  98826. /**
  98827. * Define the viewport of the camera.
  98828. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  98829. */
  98830. viewport: Viewport;
  98831. /**
  98832. * Restricts the camera to viewing objects with the same layerMask.
  98833. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  98834. */
  98835. layerMask: number;
  98836. /**
  98837. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  98838. */
  98839. fovMode: number;
  98840. /**
  98841. * Rig mode of the camera.
  98842. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  98843. * This is normally controlled byt the camera themselves as internal use.
  98844. */
  98845. cameraRigMode: number;
  98846. /**
  98847. * Defines the distance between both "eyes" in case of a RIG
  98848. */
  98849. interaxialDistance: number;
  98850. /**
  98851. * Defines if stereoscopic rendering is done side by side or over under.
  98852. */
  98853. isStereoscopicSideBySide: boolean;
  98854. /**
  98855. * 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
  98856. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  98857. * else in the scene. (Eg. security camera)
  98858. *
  98859. * 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)
  98860. */
  98861. customRenderTargets: RenderTargetTexture[];
  98862. /**
  98863. * When set, the camera will render to this render target instead of the default canvas
  98864. *
  98865. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  98866. */
  98867. outputRenderTarget: Nullable<RenderTargetTexture>;
  98868. /**
  98869. * Observable triggered when the camera view matrix has changed.
  98870. */
  98871. onViewMatrixChangedObservable: Observable<Camera>;
  98872. /**
  98873. * Observable triggered when the camera Projection matrix has changed.
  98874. */
  98875. onProjectionMatrixChangedObservable: Observable<Camera>;
  98876. /**
  98877. * Observable triggered when the inputs have been processed.
  98878. */
  98879. onAfterCheckInputsObservable: Observable<Camera>;
  98880. /**
  98881. * Observable triggered when reset has been called and applied to the camera.
  98882. */
  98883. onRestoreStateObservable: Observable<Camera>;
  98884. /**
  98885. * Is this camera a part of a rig system?
  98886. */
  98887. isRigCamera: boolean;
  98888. /**
  98889. * If isRigCamera set to true this will be set with the parent camera.
  98890. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  98891. */
  98892. rigParent?: Camera;
  98893. /** @hidden */
  98894. _cameraRigParams: any;
  98895. /** @hidden */
  98896. _rigCameras: Camera[];
  98897. /** @hidden */
  98898. _rigPostProcess: Nullable<PostProcess>;
  98899. protected _webvrViewMatrix: Matrix;
  98900. /** @hidden */
  98901. _skipRendering: boolean;
  98902. /** @hidden */
  98903. _projectionMatrix: Matrix;
  98904. /** @hidden */
  98905. _postProcesses: Nullable<PostProcess>[];
  98906. /** @hidden */
  98907. _activeMeshes: SmartArray<AbstractMesh>;
  98908. protected _globalPosition: Vector3;
  98909. /** @hidden */
  98910. _computedViewMatrix: Matrix;
  98911. private _doNotComputeProjectionMatrix;
  98912. private _transformMatrix;
  98913. private _frustumPlanes;
  98914. private _refreshFrustumPlanes;
  98915. private _storedFov;
  98916. private _stateStored;
  98917. /**
  98918. * Instantiates a new camera object.
  98919. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  98920. * @see http://doc.babylonjs.com/features/cameras
  98921. * @param name Defines the name of the camera in the scene
  98922. * @param position Defines the position of the camera
  98923. * @param scene Defines the scene the camera belongs too
  98924. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  98925. */
  98926. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98927. /**
  98928. * Store current camera state (fov, position, etc..)
  98929. * @returns the camera
  98930. */
  98931. storeState(): Camera;
  98932. /**
  98933. * Restores the camera state values if it has been stored. You must call storeState() first
  98934. */
  98935. protected _restoreStateValues(): boolean;
  98936. /**
  98937. * Restored camera state. You must call storeState() first.
  98938. * @returns true if restored and false otherwise
  98939. */
  98940. restoreState(): boolean;
  98941. /**
  98942. * Gets the class name of the camera.
  98943. * @returns the class name
  98944. */
  98945. getClassName(): string;
  98946. /** @hidden */
  98947. readonly _isCamera: boolean;
  98948. /**
  98949. * Gets a string representation of the camera useful for debug purpose.
  98950. * @param fullDetails Defines that a more verboe level of logging is required
  98951. * @returns the string representation
  98952. */
  98953. toString(fullDetails?: boolean): string;
  98954. /**
  98955. * Gets the current world space position of the camera.
  98956. */
  98957. get globalPosition(): Vector3;
  98958. /**
  98959. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  98960. * @returns the active meshe list
  98961. */
  98962. getActiveMeshes(): SmartArray<AbstractMesh>;
  98963. /**
  98964. * Check whether a mesh is part of the current active mesh list of the camera
  98965. * @param mesh Defines the mesh to check
  98966. * @returns true if active, false otherwise
  98967. */
  98968. isActiveMesh(mesh: Mesh): boolean;
  98969. /**
  98970. * Is this camera ready to be used/rendered
  98971. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  98972. * @return true if the camera is ready
  98973. */
  98974. isReady(completeCheck?: boolean): boolean;
  98975. /** @hidden */
  98976. _initCache(): void;
  98977. /** @hidden */
  98978. _updateCache(ignoreParentClass?: boolean): void;
  98979. /** @hidden */
  98980. _isSynchronized(): boolean;
  98981. /** @hidden */
  98982. _isSynchronizedViewMatrix(): boolean;
  98983. /** @hidden */
  98984. _isSynchronizedProjectionMatrix(): boolean;
  98985. /**
  98986. * Attach the input controls to a specific dom element to get the input from.
  98987. * @param element Defines the element the controls should be listened from
  98988. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98989. */
  98990. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98991. /**
  98992. * Detach the current controls from the specified dom element.
  98993. * @param element Defines the element to stop listening the inputs from
  98994. */
  98995. detachControl(element: HTMLElement): void;
  98996. /**
  98997. * Update the camera state according to the different inputs gathered during the frame.
  98998. */
  98999. update(): void;
  99000. /** @hidden */
  99001. _checkInputs(): void;
  99002. /** @hidden */
  99003. get rigCameras(): Camera[];
  99004. /**
  99005. * Gets the post process used by the rig cameras
  99006. */
  99007. get rigPostProcess(): Nullable<PostProcess>;
  99008. /**
  99009. * Internal, gets the first post proces.
  99010. * @returns the first post process to be run on this camera.
  99011. */
  99012. _getFirstPostProcess(): Nullable<PostProcess>;
  99013. private _cascadePostProcessesToRigCams;
  99014. /**
  99015. * Attach a post process to the camera.
  99016. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  99017. * @param postProcess The post process to attach to the camera
  99018. * @param insertAt The position of the post process in case several of them are in use in the scene
  99019. * @returns the position the post process has been inserted at
  99020. */
  99021. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  99022. /**
  99023. * Detach a post process to the camera.
  99024. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  99025. * @param postProcess The post process to detach from the camera
  99026. */
  99027. detachPostProcess(postProcess: PostProcess): void;
  99028. /**
  99029. * Gets the current world matrix of the camera
  99030. */
  99031. getWorldMatrix(): Matrix;
  99032. /** @hidden */
  99033. _getViewMatrix(): Matrix;
  99034. /**
  99035. * Gets the current view matrix of the camera.
  99036. * @param force forces the camera to recompute the matrix without looking at the cached state
  99037. * @returns the view matrix
  99038. */
  99039. getViewMatrix(force?: boolean): Matrix;
  99040. /**
  99041. * Freeze the projection matrix.
  99042. * It will prevent the cache check of the camera projection compute and can speed up perf
  99043. * if no parameter of the camera are meant to change
  99044. * @param projection Defines manually a projection if necessary
  99045. */
  99046. freezeProjectionMatrix(projection?: Matrix): void;
  99047. /**
  99048. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  99049. */
  99050. unfreezeProjectionMatrix(): void;
  99051. /**
  99052. * Gets the current projection matrix of the camera.
  99053. * @param force forces the camera to recompute the matrix without looking at the cached state
  99054. * @returns the projection matrix
  99055. */
  99056. getProjectionMatrix(force?: boolean): Matrix;
  99057. /**
  99058. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  99059. * @returns a Matrix
  99060. */
  99061. getTransformationMatrix(): Matrix;
  99062. private _updateFrustumPlanes;
  99063. /**
  99064. * Checks if a cullable object (mesh...) is in the camera frustum
  99065. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  99066. * @param target The object to check
  99067. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  99068. * @returns true if the object is in frustum otherwise false
  99069. */
  99070. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  99071. /**
  99072. * Checks if a cullable object (mesh...) is in the camera frustum
  99073. * Unlike isInFrustum this cheks the full bounding box
  99074. * @param target The object to check
  99075. * @returns true if the object is in frustum otherwise false
  99076. */
  99077. isCompletelyInFrustum(target: ICullable): boolean;
  99078. /**
  99079. * Gets a ray in the forward direction from the camera.
  99080. * @param length Defines the length of the ray to create
  99081. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  99082. * @param origin Defines the start point of the ray which defaults to the camera position
  99083. * @returns the forward ray
  99084. */
  99085. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  99086. /**
  99087. * Releases resources associated with this node.
  99088. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99089. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99090. */
  99091. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99092. /** @hidden */
  99093. _isLeftCamera: boolean;
  99094. /**
  99095. * Gets the left camera of a rig setup in case of Rigged Camera
  99096. */
  99097. get isLeftCamera(): boolean;
  99098. /** @hidden */
  99099. _isRightCamera: boolean;
  99100. /**
  99101. * Gets the right camera of a rig setup in case of Rigged Camera
  99102. */
  99103. get isRightCamera(): boolean;
  99104. /**
  99105. * Gets the left camera of a rig setup in case of Rigged Camera
  99106. */
  99107. get leftCamera(): Nullable<FreeCamera>;
  99108. /**
  99109. * Gets the right camera of a rig setup in case of Rigged Camera
  99110. */
  99111. get rightCamera(): Nullable<FreeCamera>;
  99112. /**
  99113. * Gets the left camera target of a rig setup in case of Rigged Camera
  99114. * @returns the target position
  99115. */
  99116. getLeftTarget(): Nullable<Vector3>;
  99117. /**
  99118. * Gets the right camera target of a rig setup in case of Rigged Camera
  99119. * @returns the target position
  99120. */
  99121. getRightTarget(): Nullable<Vector3>;
  99122. /**
  99123. * @hidden
  99124. */
  99125. setCameraRigMode(mode: number, rigParams: any): void;
  99126. /** @hidden */
  99127. static _setStereoscopicRigMode(camera: Camera): void;
  99128. /** @hidden */
  99129. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  99130. /** @hidden */
  99131. static _setVRRigMode(camera: Camera, rigParams: any): void;
  99132. /** @hidden */
  99133. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  99134. /** @hidden */
  99135. _getVRProjectionMatrix(): Matrix;
  99136. protected _updateCameraRotationMatrix(): void;
  99137. protected _updateWebVRCameraRotationMatrix(): void;
  99138. /**
  99139. * This function MUST be overwritten by the different WebVR cameras available.
  99140. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99141. * @hidden
  99142. */
  99143. _getWebVRProjectionMatrix(): Matrix;
  99144. /**
  99145. * This function MUST be overwritten by the different WebVR cameras available.
  99146. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  99147. * @hidden
  99148. */
  99149. _getWebVRViewMatrix(): Matrix;
  99150. /** @hidden */
  99151. setCameraRigParameter(name: string, value: any): void;
  99152. /**
  99153. * needs to be overridden by children so sub has required properties to be copied
  99154. * @hidden
  99155. */
  99156. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99157. /**
  99158. * May need to be overridden by children
  99159. * @hidden
  99160. */
  99161. _updateRigCameras(): void;
  99162. /** @hidden */
  99163. _setupInputs(): void;
  99164. /**
  99165. * Serialiaze the camera setup to a json represention
  99166. * @returns the JSON representation
  99167. */
  99168. serialize(): any;
  99169. /**
  99170. * Clones the current camera.
  99171. * @param name The cloned camera name
  99172. * @returns the cloned camera
  99173. */
  99174. clone(name: string): Camera;
  99175. /**
  99176. * Gets the direction of the camera relative to a given local axis.
  99177. * @param localAxis Defines the reference axis to provide a relative direction.
  99178. * @return the direction
  99179. */
  99180. getDirection(localAxis: Vector3): Vector3;
  99181. /**
  99182. * Returns the current camera absolute rotation
  99183. */
  99184. get absoluteRotation(): Quaternion;
  99185. /**
  99186. * Gets the direction of the camera relative to a given local axis into a passed vector.
  99187. * @param localAxis Defines the reference axis to provide a relative direction.
  99188. * @param result Defines the vector to store the result in
  99189. */
  99190. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  99191. /**
  99192. * Gets a camera constructor for a given camera type
  99193. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  99194. * @param name The name of the camera the result will be able to instantiate
  99195. * @param scene The scene the result will construct the camera in
  99196. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  99197. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  99198. * @returns a factory method to construc the camera
  99199. */
  99200. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  99201. /**
  99202. * Compute the world matrix of the camera.
  99203. * @returns the camera world matrix
  99204. */
  99205. computeWorldMatrix(): Matrix;
  99206. /**
  99207. * Parse a JSON and creates the camera from the parsed information
  99208. * @param parsedCamera The JSON to parse
  99209. * @param scene The scene to instantiate the camera in
  99210. * @returns the newly constructed camera
  99211. */
  99212. static Parse(parsedCamera: any, scene: Scene): Camera;
  99213. }
  99214. }
  99215. declare module BABYLON {
  99216. /**
  99217. * Class containing static functions to help procedurally build meshes
  99218. */
  99219. export class DiscBuilder {
  99220. /**
  99221. * Creates a plane polygonal mesh. By default, this is a disc
  99222. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  99223. * * 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
  99224. * * 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
  99225. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  99226. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  99227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99228. * @param name defines the name of the mesh
  99229. * @param options defines the options used to create the mesh
  99230. * @param scene defines the hosting scene
  99231. * @returns the plane polygonal mesh
  99232. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  99233. */
  99234. static CreateDisc(name: string, options: {
  99235. radius?: number;
  99236. tessellation?: number;
  99237. arc?: number;
  99238. updatable?: boolean;
  99239. sideOrientation?: number;
  99240. frontUVs?: Vector4;
  99241. backUVs?: Vector4;
  99242. }, scene?: Nullable<Scene>): Mesh;
  99243. }
  99244. }
  99245. declare module BABYLON {
  99246. /**
  99247. * This represents all the required information to add a fresnel effect on a material:
  99248. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99249. */
  99250. export class FresnelParameters {
  99251. private _isEnabled;
  99252. /**
  99253. * Define if the fresnel effect is enable or not.
  99254. */
  99255. get isEnabled(): boolean;
  99256. set isEnabled(value: boolean);
  99257. /**
  99258. * Define the color used on edges (grazing angle)
  99259. */
  99260. leftColor: Color3;
  99261. /**
  99262. * Define the color used on center
  99263. */
  99264. rightColor: Color3;
  99265. /**
  99266. * Define bias applied to computed fresnel term
  99267. */
  99268. bias: number;
  99269. /**
  99270. * Defined the power exponent applied to fresnel term
  99271. */
  99272. power: number;
  99273. /**
  99274. * Clones the current fresnel and its valuues
  99275. * @returns a clone fresnel configuration
  99276. */
  99277. clone(): FresnelParameters;
  99278. /**
  99279. * Serializes the current fresnel parameters to a JSON representation.
  99280. * @return the JSON serialization
  99281. */
  99282. serialize(): any;
  99283. /**
  99284. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  99285. * @param parsedFresnelParameters Define the JSON representation
  99286. * @returns the parsed parameters
  99287. */
  99288. static Parse(parsedFresnelParameters: any): FresnelParameters;
  99289. }
  99290. }
  99291. declare module BABYLON {
  99292. /**
  99293. * Base class of materials working in push mode in babylon JS
  99294. * @hidden
  99295. */
  99296. export class PushMaterial extends Material {
  99297. protected _activeEffect: Effect;
  99298. protected _normalMatrix: Matrix;
  99299. /**
  99300. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  99301. * This means that the material can keep using a previous shader while a new one is being compiled.
  99302. * This is mostly used when shader parallel compilation is supported (true by default)
  99303. */
  99304. allowShaderHotSwapping: boolean;
  99305. constructor(name: string, scene: Scene);
  99306. getEffect(): Effect;
  99307. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  99308. /**
  99309. * Binds the given world matrix to the active effect
  99310. *
  99311. * @param world the matrix to bind
  99312. */
  99313. bindOnlyWorldMatrix(world: Matrix): void;
  99314. /**
  99315. * Binds the given normal matrix to the active effect
  99316. *
  99317. * @param normalMatrix the matrix to bind
  99318. */
  99319. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  99320. bind(world: Matrix, mesh?: Mesh): void;
  99321. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  99322. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  99323. }
  99324. }
  99325. declare module BABYLON {
  99326. /**
  99327. * This groups all the flags used to control the materials channel.
  99328. */
  99329. export class MaterialFlags {
  99330. private static _DiffuseTextureEnabled;
  99331. /**
  99332. * Are diffuse textures enabled in the application.
  99333. */
  99334. static get DiffuseTextureEnabled(): boolean;
  99335. static set DiffuseTextureEnabled(value: boolean);
  99336. private static _AmbientTextureEnabled;
  99337. /**
  99338. * Are ambient textures enabled in the application.
  99339. */
  99340. static get AmbientTextureEnabled(): boolean;
  99341. static set AmbientTextureEnabled(value: boolean);
  99342. private static _OpacityTextureEnabled;
  99343. /**
  99344. * Are opacity textures enabled in the application.
  99345. */
  99346. static get OpacityTextureEnabled(): boolean;
  99347. static set OpacityTextureEnabled(value: boolean);
  99348. private static _ReflectionTextureEnabled;
  99349. /**
  99350. * Are reflection textures enabled in the application.
  99351. */
  99352. static get ReflectionTextureEnabled(): boolean;
  99353. static set ReflectionTextureEnabled(value: boolean);
  99354. private static _EmissiveTextureEnabled;
  99355. /**
  99356. * Are emissive textures enabled in the application.
  99357. */
  99358. static get EmissiveTextureEnabled(): boolean;
  99359. static set EmissiveTextureEnabled(value: boolean);
  99360. private static _SpecularTextureEnabled;
  99361. /**
  99362. * Are specular textures enabled in the application.
  99363. */
  99364. static get SpecularTextureEnabled(): boolean;
  99365. static set SpecularTextureEnabled(value: boolean);
  99366. private static _BumpTextureEnabled;
  99367. /**
  99368. * Are bump textures enabled in the application.
  99369. */
  99370. static get BumpTextureEnabled(): boolean;
  99371. static set BumpTextureEnabled(value: boolean);
  99372. private static _LightmapTextureEnabled;
  99373. /**
  99374. * Are lightmap textures enabled in the application.
  99375. */
  99376. static get LightmapTextureEnabled(): boolean;
  99377. static set LightmapTextureEnabled(value: boolean);
  99378. private static _RefractionTextureEnabled;
  99379. /**
  99380. * Are refraction textures enabled in the application.
  99381. */
  99382. static get RefractionTextureEnabled(): boolean;
  99383. static set RefractionTextureEnabled(value: boolean);
  99384. private static _ColorGradingTextureEnabled;
  99385. /**
  99386. * Are color grading textures enabled in the application.
  99387. */
  99388. static get ColorGradingTextureEnabled(): boolean;
  99389. static set ColorGradingTextureEnabled(value: boolean);
  99390. private static _FresnelEnabled;
  99391. /**
  99392. * Are fresnels enabled in the application.
  99393. */
  99394. static get FresnelEnabled(): boolean;
  99395. static set FresnelEnabled(value: boolean);
  99396. private static _ClearCoatTextureEnabled;
  99397. /**
  99398. * Are clear coat textures enabled in the application.
  99399. */
  99400. static get ClearCoatTextureEnabled(): boolean;
  99401. static set ClearCoatTextureEnabled(value: boolean);
  99402. private static _ClearCoatBumpTextureEnabled;
  99403. /**
  99404. * Are clear coat bump textures enabled in the application.
  99405. */
  99406. static get ClearCoatBumpTextureEnabled(): boolean;
  99407. static set ClearCoatBumpTextureEnabled(value: boolean);
  99408. private static _ClearCoatTintTextureEnabled;
  99409. /**
  99410. * Are clear coat tint textures enabled in the application.
  99411. */
  99412. static get ClearCoatTintTextureEnabled(): boolean;
  99413. static set ClearCoatTintTextureEnabled(value: boolean);
  99414. private static _SheenTextureEnabled;
  99415. /**
  99416. * Are sheen textures enabled in the application.
  99417. */
  99418. static get SheenTextureEnabled(): boolean;
  99419. static set SheenTextureEnabled(value: boolean);
  99420. private static _AnisotropicTextureEnabled;
  99421. /**
  99422. * Are anisotropic textures enabled in the application.
  99423. */
  99424. static get AnisotropicTextureEnabled(): boolean;
  99425. static set AnisotropicTextureEnabled(value: boolean);
  99426. private static _ThicknessTextureEnabled;
  99427. /**
  99428. * Are thickness textures enabled in the application.
  99429. */
  99430. static get ThicknessTextureEnabled(): boolean;
  99431. static set ThicknessTextureEnabled(value: boolean);
  99432. }
  99433. }
  99434. declare module BABYLON {
  99435. /** @hidden */
  99436. export var defaultFragmentDeclaration: {
  99437. name: string;
  99438. shader: string;
  99439. };
  99440. }
  99441. declare module BABYLON {
  99442. /** @hidden */
  99443. export var defaultUboDeclaration: {
  99444. name: string;
  99445. shader: string;
  99446. };
  99447. }
  99448. declare module BABYLON {
  99449. /** @hidden */
  99450. export var lightFragmentDeclaration: {
  99451. name: string;
  99452. shader: string;
  99453. };
  99454. }
  99455. declare module BABYLON {
  99456. /** @hidden */
  99457. export var lightUboDeclaration: {
  99458. name: string;
  99459. shader: string;
  99460. };
  99461. }
  99462. declare module BABYLON {
  99463. /** @hidden */
  99464. export var lightsFragmentFunctions: {
  99465. name: string;
  99466. shader: string;
  99467. };
  99468. }
  99469. declare module BABYLON {
  99470. /** @hidden */
  99471. export var shadowsFragmentFunctions: {
  99472. name: string;
  99473. shader: string;
  99474. };
  99475. }
  99476. declare module BABYLON {
  99477. /** @hidden */
  99478. export var fresnelFunction: {
  99479. name: string;
  99480. shader: string;
  99481. };
  99482. }
  99483. declare module BABYLON {
  99484. /** @hidden */
  99485. export var reflectionFunction: {
  99486. name: string;
  99487. shader: string;
  99488. };
  99489. }
  99490. declare module BABYLON {
  99491. /** @hidden */
  99492. export var bumpFragmentFunctions: {
  99493. name: string;
  99494. shader: string;
  99495. };
  99496. }
  99497. declare module BABYLON {
  99498. /** @hidden */
  99499. export var logDepthDeclaration: {
  99500. name: string;
  99501. shader: string;
  99502. };
  99503. }
  99504. declare module BABYLON {
  99505. /** @hidden */
  99506. export var bumpFragment: {
  99507. name: string;
  99508. shader: string;
  99509. };
  99510. }
  99511. declare module BABYLON {
  99512. /** @hidden */
  99513. export var depthPrePass: {
  99514. name: string;
  99515. shader: string;
  99516. };
  99517. }
  99518. declare module BABYLON {
  99519. /** @hidden */
  99520. export var lightFragment: {
  99521. name: string;
  99522. shader: string;
  99523. };
  99524. }
  99525. declare module BABYLON {
  99526. /** @hidden */
  99527. export var logDepthFragment: {
  99528. name: string;
  99529. shader: string;
  99530. };
  99531. }
  99532. declare module BABYLON {
  99533. /** @hidden */
  99534. export var defaultPixelShader: {
  99535. name: string;
  99536. shader: string;
  99537. };
  99538. }
  99539. declare module BABYLON {
  99540. /** @hidden */
  99541. export var defaultVertexDeclaration: {
  99542. name: string;
  99543. shader: string;
  99544. };
  99545. }
  99546. declare module BABYLON {
  99547. /** @hidden */
  99548. export var bumpVertexDeclaration: {
  99549. name: string;
  99550. shader: string;
  99551. };
  99552. }
  99553. declare module BABYLON {
  99554. /** @hidden */
  99555. export var bumpVertex: {
  99556. name: string;
  99557. shader: string;
  99558. };
  99559. }
  99560. declare module BABYLON {
  99561. /** @hidden */
  99562. export var fogVertex: {
  99563. name: string;
  99564. shader: string;
  99565. };
  99566. }
  99567. declare module BABYLON {
  99568. /** @hidden */
  99569. export var shadowsVertex: {
  99570. name: string;
  99571. shader: string;
  99572. };
  99573. }
  99574. declare module BABYLON {
  99575. /** @hidden */
  99576. export var pointCloudVertex: {
  99577. name: string;
  99578. shader: string;
  99579. };
  99580. }
  99581. declare module BABYLON {
  99582. /** @hidden */
  99583. export var logDepthVertex: {
  99584. name: string;
  99585. shader: string;
  99586. };
  99587. }
  99588. declare module BABYLON {
  99589. /** @hidden */
  99590. export var defaultVertexShader: {
  99591. name: string;
  99592. shader: string;
  99593. };
  99594. }
  99595. declare module BABYLON {
  99596. /** @hidden */
  99597. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  99598. MAINUV1: boolean;
  99599. MAINUV2: boolean;
  99600. DIFFUSE: boolean;
  99601. DIFFUSEDIRECTUV: number;
  99602. AMBIENT: boolean;
  99603. AMBIENTDIRECTUV: number;
  99604. OPACITY: boolean;
  99605. OPACITYDIRECTUV: number;
  99606. OPACITYRGB: boolean;
  99607. REFLECTION: boolean;
  99608. EMISSIVE: boolean;
  99609. EMISSIVEDIRECTUV: number;
  99610. SPECULAR: boolean;
  99611. SPECULARDIRECTUV: number;
  99612. BUMP: boolean;
  99613. BUMPDIRECTUV: number;
  99614. PARALLAX: boolean;
  99615. PARALLAXOCCLUSION: boolean;
  99616. SPECULAROVERALPHA: boolean;
  99617. CLIPPLANE: boolean;
  99618. CLIPPLANE2: boolean;
  99619. CLIPPLANE3: boolean;
  99620. CLIPPLANE4: boolean;
  99621. CLIPPLANE5: boolean;
  99622. CLIPPLANE6: boolean;
  99623. ALPHATEST: boolean;
  99624. DEPTHPREPASS: boolean;
  99625. ALPHAFROMDIFFUSE: boolean;
  99626. POINTSIZE: boolean;
  99627. FOG: boolean;
  99628. SPECULARTERM: boolean;
  99629. DIFFUSEFRESNEL: boolean;
  99630. OPACITYFRESNEL: boolean;
  99631. REFLECTIONFRESNEL: boolean;
  99632. REFRACTIONFRESNEL: boolean;
  99633. EMISSIVEFRESNEL: boolean;
  99634. FRESNEL: boolean;
  99635. NORMAL: boolean;
  99636. UV1: boolean;
  99637. UV2: boolean;
  99638. VERTEXCOLOR: boolean;
  99639. VERTEXALPHA: boolean;
  99640. NUM_BONE_INFLUENCERS: number;
  99641. BonesPerMesh: number;
  99642. BONETEXTURE: boolean;
  99643. INSTANCES: boolean;
  99644. GLOSSINESS: boolean;
  99645. ROUGHNESS: boolean;
  99646. EMISSIVEASILLUMINATION: boolean;
  99647. LINKEMISSIVEWITHDIFFUSE: boolean;
  99648. REFLECTIONFRESNELFROMSPECULAR: boolean;
  99649. LIGHTMAP: boolean;
  99650. LIGHTMAPDIRECTUV: number;
  99651. OBJECTSPACE_NORMALMAP: boolean;
  99652. USELIGHTMAPASSHADOWMAP: boolean;
  99653. REFLECTIONMAP_3D: boolean;
  99654. REFLECTIONMAP_SPHERICAL: boolean;
  99655. REFLECTIONMAP_PLANAR: boolean;
  99656. REFLECTIONMAP_CUBIC: boolean;
  99657. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  99658. REFLECTIONMAP_PROJECTION: boolean;
  99659. REFLECTIONMAP_SKYBOX: boolean;
  99660. REFLECTIONMAP_EXPLICIT: boolean;
  99661. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  99662. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  99663. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  99664. INVERTCUBICMAP: boolean;
  99665. LOGARITHMICDEPTH: boolean;
  99666. REFRACTION: boolean;
  99667. REFRACTIONMAP_3D: boolean;
  99668. REFLECTIONOVERALPHA: boolean;
  99669. TWOSIDEDLIGHTING: boolean;
  99670. SHADOWFLOAT: boolean;
  99671. MORPHTARGETS: boolean;
  99672. MORPHTARGETS_NORMAL: boolean;
  99673. MORPHTARGETS_TANGENT: boolean;
  99674. MORPHTARGETS_UV: boolean;
  99675. NUM_MORPH_INFLUENCERS: number;
  99676. NONUNIFORMSCALING: boolean;
  99677. PREMULTIPLYALPHA: boolean;
  99678. IMAGEPROCESSING: boolean;
  99679. VIGNETTE: boolean;
  99680. VIGNETTEBLENDMODEMULTIPLY: boolean;
  99681. VIGNETTEBLENDMODEOPAQUE: boolean;
  99682. TONEMAPPING: boolean;
  99683. TONEMAPPING_ACES: boolean;
  99684. CONTRAST: boolean;
  99685. COLORCURVES: boolean;
  99686. COLORGRADING: boolean;
  99687. COLORGRADING3D: boolean;
  99688. SAMPLER3DGREENDEPTH: boolean;
  99689. SAMPLER3DBGRMAP: boolean;
  99690. IMAGEPROCESSINGPOSTPROCESS: boolean;
  99691. MULTIVIEW: boolean;
  99692. /**
  99693. * If the reflection texture on this material is in linear color space
  99694. * @hidden
  99695. */
  99696. IS_REFLECTION_LINEAR: boolean;
  99697. /**
  99698. * If the refraction texture on this material is in linear color space
  99699. * @hidden
  99700. */
  99701. IS_REFRACTION_LINEAR: boolean;
  99702. EXPOSURE: boolean;
  99703. constructor();
  99704. setReflectionMode(modeToEnable: string): void;
  99705. }
  99706. /**
  99707. * This is the default material used in Babylon. It is the best trade off between quality
  99708. * and performances.
  99709. * @see http://doc.babylonjs.com/babylon101/materials
  99710. */
  99711. export class StandardMaterial extends PushMaterial {
  99712. private _diffuseTexture;
  99713. /**
  99714. * The basic texture of the material as viewed under a light.
  99715. */
  99716. diffuseTexture: Nullable<BaseTexture>;
  99717. private _ambientTexture;
  99718. /**
  99719. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  99720. */
  99721. ambientTexture: Nullable<BaseTexture>;
  99722. private _opacityTexture;
  99723. /**
  99724. * Define the transparency of the material from a texture.
  99725. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  99726. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  99727. */
  99728. opacityTexture: Nullable<BaseTexture>;
  99729. private _reflectionTexture;
  99730. /**
  99731. * Define the texture used to display the reflection.
  99732. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99733. */
  99734. reflectionTexture: Nullable<BaseTexture>;
  99735. private _emissiveTexture;
  99736. /**
  99737. * Define texture of the material as if self lit.
  99738. * This will be mixed in the final result even in the absence of light.
  99739. */
  99740. emissiveTexture: Nullable<BaseTexture>;
  99741. private _specularTexture;
  99742. /**
  99743. * Define how the color and intensity of the highlight given by the light in the material.
  99744. */
  99745. specularTexture: Nullable<BaseTexture>;
  99746. private _bumpTexture;
  99747. /**
  99748. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  99749. * 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.
  99750. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  99751. */
  99752. bumpTexture: Nullable<BaseTexture>;
  99753. private _lightmapTexture;
  99754. /**
  99755. * Complex lighting can be computationally expensive to compute at runtime.
  99756. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  99757. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  99758. */
  99759. lightmapTexture: Nullable<BaseTexture>;
  99760. private _refractionTexture;
  99761. /**
  99762. * Define the texture used to display the refraction.
  99763. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99764. */
  99765. refractionTexture: Nullable<BaseTexture>;
  99766. /**
  99767. * The color of the material lit by the environmental background lighting.
  99768. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  99769. */
  99770. ambientColor: Color3;
  99771. /**
  99772. * The basic color of the material as viewed under a light.
  99773. */
  99774. diffuseColor: Color3;
  99775. /**
  99776. * Define how the color and intensity of the highlight given by the light in the material.
  99777. */
  99778. specularColor: Color3;
  99779. /**
  99780. * Define the color of the material as if self lit.
  99781. * This will be mixed in the final result even in the absence of light.
  99782. */
  99783. emissiveColor: Color3;
  99784. /**
  99785. * Defines how sharp are the highlights in the material.
  99786. * The bigger the value the sharper giving a more glossy feeling to the result.
  99787. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  99788. */
  99789. specularPower: number;
  99790. private _useAlphaFromDiffuseTexture;
  99791. /**
  99792. * Does the transparency come from the diffuse texture alpha channel.
  99793. */
  99794. useAlphaFromDiffuseTexture: boolean;
  99795. private _useEmissiveAsIllumination;
  99796. /**
  99797. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  99798. */
  99799. useEmissiveAsIllumination: boolean;
  99800. private _linkEmissiveWithDiffuse;
  99801. /**
  99802. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  99803. * the emissive level when the final color is close to one.
  99804. */
  99805. linkEmissiveWithDiffuse: boolean;
  99806. private _useSpecularOverAlpha;
  99807. /**
  99808. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  99809. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  99810. */
  99811. useSpecularOverAlpha: boolean;
  99812. private _useReflectionOverAlpha;
  99813. /**
  99814. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  99815. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  99816. */
  99817. useReflectionOverAlpha: boolean;
  99818. private _disableLighting;
  99819. /**
  99820. * Does lights from the scene impacts this material.
  99821. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  99822. */
  99823. disableLighting: boolean;
  99824. private _useObjectSpaceNormalMap;
  99825. /**
  99826. * Allows using an object space normal map (instead of tangent space).
  99827. */
  99828. useObjectSpaceNormalMap: boolean;
  99829. private _useParallax;
  99830. /**
  99831. * Is parallax enabled or not.
  99832. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99833. */
  99834. useParallax: boolean;
  99835. private _useParallaxOcclusion;
  99836. /**
  99837. * Is parallax occlusion enabled or not.
  99838. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  99839. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  99840. */
  99841. useParallaxOcclusion: boolean;
  99842. /**
  99843. * 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.
  99844. */
  99845. parallaxScaleBias: number;
  99846. private _roughness;
  99847. /**
  99848. * Helps to define how blurry the reflections should appears in the material.
  99849. */
  99850. roughness: number;
  99851. /**
  99852. * In case of refraction, define the value of the index of refraction.
  99853. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99854. */
  99855. indexOfRefraction: number;
  99856. /**
  99857. * Invert the refraction texture alongside the y axis.
  99858. * It can be useful with procedural textures or probe for instance.
  99859. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  99860. */
  99861. invertRefractionY: boolean;
  99862. /**
  99863. * Defines the alpha limits in alpha test mode.
  99864. */
  99865. alphaCutOff: number;
  99866. private _useLightmapAsShadowmap;
  99867. /**
  99868. * In case of light mapping, define whether the map contains light or shadow informations.
  99869. */
  99870. useLightmapAsShadowmap: boolean;
  99871. private _diffuseFresnelParameters;
  99872. /**
  99873. * Define the diffuse fresnel parameters of the material.
  99874. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99875. */
  99876. diffuseFresnelParameters: FresnelParameters;
  99877. private _opacityFresnelParameters;
  99878. /**
  99879. * Define the opacity fresnel parameters of the material.
  99880. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99881. */
  99882. opacityFresnelParameters: FresnelParameters;
  99883. private _reflectionFresnelParameters;
  99884. /**
  99885. * Define the reflection fresnel parameters of the material.
  99886. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99887. */
  99888. reflectionFresnelParameters: FresnelParameters;
  99889. private _refractionFresnelParameters;
  99890. /**
  99891. * Define the refraction fresnel parameters of the material.
  99892. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99893. */
  99894. refractionFresnelParameters: FresnelParameters;
  99895. private _emissiveFresnelParameters;
  99896. /**
  99897. * Define the emissive fresnel parameters of the material.
  99898. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99899. */
  99900. emissiveFresnelParameters: FresnelParameters;
  99901. private _useReflectionFresnelFromSpecular;
  99902. /**
  99903. * If true automatically deducts the fresnels values from the material specularity.
  99904. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  99905. */
  99906. useReflectionFresnelFromSpecular: boolean;
  99907. private _useGlossinessFromSpecularMapAlpha;
  99908. /**
  99909. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  99910. */
  99911. useGlossinessFromSpecularMapAlpha: boolean;
  99912. private _maxSimultaneousLights;
  99913. /**
  99914. * Defines the maximum number of lights that can be used in the material
  99915. */
  99916. maxSimultaneousLights: number;
  99917. private _invertNormalMapX;
  99918. /**
  99919. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  99920. */
  99921. invertNormalMapX: boolean;
  99922. private _invertNormalMapY;
  99923. /**
  99924. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  99925. */
  99926. invertNormalMapY: boolean;
  99927. private _twoSidedLighting;
  99928. /**
  99929. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  99930. */
  99931. twoSidedLighting: boolean;
  99932. /**
  99933. * Default configuration related to image processing available in the standard Material.
  99934. */
  99935. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99936. /**
  99937. * Gets the image processing configuration used either in this material.
  99938. */
  99939. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  99940. /**
  99941. * Sets the Default image processing configuration used either in the this material.
  99942. *
  99943. * If sets to null, the scene one is in use.
  99944. */
  99945. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  99946. /**
  99947. * Keep track of the image processing observer to allow dispose and replace.
  99948. */
  99949. private _imageProcessingObserver;
  99950. /**
  99951. * Attaches a new image processing configuration to the Standard Material.
  99952. * @param configuration
  99953. */
  99954. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  99955. /**
  99956. * Gets wether the color curves effect is enabled.
  99957. */
  99958. get cameraColorCurvesEnabled(): boolean;
  99959. /**
  99960. * Sets wether the color curves effect is enabled.
  99961. */
  99962. set cameraColorCurvesEnabled(value: boolean);
  99963. /**
  99964. * Gets wether the color grading effect is enabled.
  99965. */
  99966. get cameraColorGradingEnabled(): boolean;
  99967. /**
  99968. * Gets wether the color grading effect is enabled.
  99969. */
  99970. set cameraColorGradingEnabled(value: boolean);
  99971. /**
  99972. * Gets wether tonemapping is enabled or not.
  99973. */
  99974. get cameraToneMappingEnabled(): boolean;
  99975. /**
  99976. * Sets wether tonemapping is enabled or not
  99977. */
  99978. set cameraToneMappingEnabled(value: boolean);
  99979. /**
  99980. * The camera exposure used on this material.
  99981. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99982. * This corresponds to a photographic exposure.
  99983. */
  99984. get cameraExposure(): number;
  99985. /**
  99986. * The camera exposure used on this material.
  99987. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  99988. * This corresponds to a photographic exposure.
  99989. */
  99990. set cameraExposure(value: number);
  99991. /**
  99992. * Gets The camera contrast used on this material.
  99993. */
  99994. get cameraContrast(): number;
  99995. /**
  99996. * Sets The camera contrast used on this material.
  99997. */
  99998. set cameraContrast(value: number);
  99999. /**
  100000. * Gets the Color Grading 2D Lookup Texture.
  100001. */
  100002. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  100003. /**
  100004. * Sets the Color Grading 2D Lookup Texture.
  100005. */
  100006. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  100007. /**
  100008. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100009. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100010. * 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;
  100011. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100012. */
  100013. get cameraColorCurves(): Nullable<ColorCurves>;
  100014. /**
  100015. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  100016. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  100017. * 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;
  100018. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  100019. */
  100020. set cameraColorCurves(value: Nullable<ColorCurves>);
  100021. /**
  100022. * Custom callback helping to override the default shader used in the material.
  100023. */
  100024. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  100025. protected _renderTargets: SmartArray<RenderTargetTexture>;
  100026. protected _worldViewProjectionMatrix: Matrix;
  100027. protected _globalAmbientColor: Color3;
  100028. protected _useLogarithmicDepth: boolean;
  100029. protected _rebuildInParallel: boolean;
  100030. /**
  100031. * Instantiates a new standard material.
  100032. * This is the default material used in Babylon. It is the best trade off between quality
  100033. * and performances.
  100034. * @see http://doc.babylonjs.com/babylon101/materials
  100035. * @param name Define the name of the material in the scene
  100036. * @param scene Define the scene the material belong to
  100037. */
  100038. constructor(name: string, scene: Scene);
  100039. /**
  100040. * Gets a boolean indicating that current material needs to register RTT
  100041. */
  100042. get hasRenderTargetTextures(): boolean;
  100043. /**
  100044. * Gets the current class name of the material e.g. "StandardMaterial"
  100045. * Mainly use in serialization.
  100046. * @returns the class name
  100047. */
  100048. getClassName(): string;
  100049. /**
  100050. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  100051. * You can try switching to logarithmic depth.
  100052. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  100053. */
  100054. get useLogarithmicDepth(): boolean;
  100055. set useLogarithmicDepth(value: boolean);
  100056. /**
  100057. * Specifies if the material will require alpha blending
  100058. * @returns a boolean specifying if alpha blending is needed
  100059. */
  100060. needAlphaBlending(): boolean;
  100061. /**
  100062. * Specifies if this material should be rendered in alpha test mode
  100063. * @returns a boolean specifying if an alpha test is needed.
  100064. */
  100065. needAlphaTesting(): boolean;
  100066. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  100067. /**
  100068. * Get the texture used for alpha test purpose.
  100069. * @returns the diffuse texture in case of the standard material.
  100070. */
  100071. getAlphaTestTexture(): Nullable<BaseTexture>;
  100072. /**
  100073. * Get if the submesh is ready to be used and all its information available.
  100074. * Child classes can use it to update shaders
  100075. * @param mesh defines the mesh to check
  100076. * @param subMesh defines which submesh to check
  100077. * @param useInstances specifies that instances should be used
  100078. * @returns a boolean indicating that the submesh is ready or not
  100079. */
  100080. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  100081. /**
  100082. * Builds the material UBO layouts.
  100083. * Used internally during the effect preparation.
  100084. */
  100085. buildUniformLayout(): void;
  100086. /**
  100087. * Unbinds the material from the mesh
  100088. */
  100089. unbind(): void;
  100090. /**
  100091. * Binds the submesh to this material by preparing the effect and shader to draw
  100092. * @param world defines the world transformation matrix
  100093. * @param mesh defines the mesh containing the submesh
  100094. * @param subMesh defines the submesh to bind the material to
  100095. */
  100096. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  100097. /**
  100098. * Get the list of animatables in the material.
  100099. * @returns the list of animatables object used in the material
  100100. */
  100101. getAnimatables(): IAnimatable[];
  100102. /**
  100103. * Gets the active textures from the material
  100104. * @returns an array of textures
  100105. */
  100106. getActiveTextures(): BaseTexture[];
  100107. /**
  100108. * Specifies if the material uses a texture
  100109. * @param texture defines the texture to check against the material
  100110. * @returns a boolean specifying if the material uses the texture
  100111. */
  100112. hasTexture(texture: BaseTexture): boolean;
  100113. /**
  100114. * Disposes the material
  100115. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  100116. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  100117. */
  100118. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  100119. /**
  100120. * Makes a duplicate of the material, and gives it a new name
  100121. * @param name defines the new name for the duplicated material
  100122. * @returns the cloned material
  100123. */
  100124. clone(name: string): StandardMaterial;
  100125. /**
  100126. * Serializes this material in a JSON representation
  100127. * @returns the serialized material object
  100128. */
  100129. serialize(): any;
  100130. /**
  100131. * Creates a standard material from parsed material data
  100132. * @param source defines the JSON representation of the material
  100133. * @param scene defines the hosting scene
  100134. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  100135. * @returns a new standard material
  100136. */
  100137. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  100138. /**
  100139. * Are diffuse textures enabled in the application.
  100140. */
  100141. static get DiffuseTextureEnabled(): boolean;
  100142. static set DiffuseTextureEnabled(value: boolean);
  100143. /**
  100144. * Are ambient textures enabled in the application.
  100145. */
  100146. static get AmbientTextureEnabled(): boolean;
  100147. static set AmbientTextureEnabled(value: boolean);
  100148. /**
  100149. * Are opacity textures enabled in the application.
  100150. */
  100151. static get OpacityTextureEnabled(): boolean;
  100152. static set OpacityTextureEnabled(value: boolean);
  100153. /**
  100154. * Are reflection textures enabled in the application.
  100155. */
  100156. static get ReflectionTextureEnabled(): boolean;
  100157. static set ReflectionTextureEnabled(value: boolean);
  100158. /**
  100159. * Are emissive textures enabled in the application.
  100160. */
  100161. static get EmissiveTextureEnabled(): boolean;
  100162. static set EmissiveTextureEnabled(value: boolean);
  100163. /**
  100164. * Are specular textures enabled in the application.
  100165. */
  100166. static get SpecularTextureEnabled(): boolean;
  100167. static set SpecularTextureEnabled(value: boolean);
  100168. /**
  100169. * Are bump textures enabled in the application.
  100170. */
  100171. static get BumpTextureEnabled(): boolean;
  100172. static set BumpTextureEnabled(value: boolean);
  100173. /**
  100174. * Are lightmap textures enabled in the application.
  100175. */
  100176. static get LightmapTextureEnabled(): boolean;
  100177. static set LightmapTextureEnabled(value: boolean);
  100178. /**
  100179. * Are refraction textures enabled in the application.
  100180. */
  100181. static get RefractionTextureEnabled(): boolean;
  100182. static set RefractionTextureEnabled(value: boolean);
  100183. /**
  100184. * Are color grading textures enabled in the application.
  100185. */
  100186. static get ColorGradingTextureEnabled(): boolean;
  100187. static set ColorGradingTextureEnabled(value: boolean);
  100188. /**
  100189. * Are fresnels enabled in the application.
  100190. */
  100191. static get FresnelEnabled(): boolean;
  100192. static set FresnelEnabled(value: boolean);
  100193. }
  100194. }
  100195. declare module BABYLON {
  100196. /**
  100197. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  100198. *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.
  100199. * The SPS is also a particle system. It provides some methods to manage the particles.
  100200. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  100201. *
  100202. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  100203. */
  100204. export class SolidParticleSystem implements IDisposable {
  100205. /**
  100206. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  100207. * Example : var p = SPS.particles[i];
  100208. */
  100209. particles: SolidParticle[];
  100210. /**
  100211. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  100212. */
  100213. nbParticles: number;
  100214. /**
  100215. * If the particles must ever face the camera (default false). Useful for planar particles.
  100216. */
  100217. billboard: boolean;
  100218. /**
  100219. * Recompute normals when adding a shape
  100220. */
  100221. recomputeNormals: boolean;
  100222. /**
  100223. * This a counter ofr your own usage. It's not set by any SPS functions.
  100224. */
  100225. counter: number;
  100226. /**
  100227. * The SPS name. This name is also given to the underlying mesh.
  100228. */
  100229. name: string;
  100230. /**
  100231. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  100232. */
  100233. mesh: Mesh;
  100234. /**
  100235. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  100236. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  100237. */
  100238. vars: any;
  100239. /**
  100240. * This array is populated when the SPS is set as 'pickable'.
  100241. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  100242. * Each element of this array is an object `{idx: int, faceId: int}`.
  100243. * `idx` is the picked particle index in the `SPS.particles` array
  100244. * `faceId` is the picked face index counted within this particle.
  100245. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  100246. */
  100247. pickedParticles: {
  100248. idx: number;
  100249. faceId: number;
  100250. }[];
  100251. /**
  100252. * This array is populated when `enableDepthSort` is set to true.
  100253. * Each element of this array is an instance of the class DepthSortedParticle.
  100254. */
  100255. depthSortedParticles: DepthSortedParticle[];
  100256. /**
  100257. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  100258. * @hidden
  100259. */
  100260. _bSphereOnly: boolean;
  100261. /**
  100262. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  100263. * @hidden
  100264. */
  100265. _bSphereRadiusFactor: number;
  100266. private _scene;
  100267. private _positions;
  100268. private _indices;
  100269. private _normals;
  100270. private _colors;
  100271. private _uvs;
  100272. private _indices32;
  100273. private _positions32;
  100274. private _normals32;
  100275. private _fixedNormal32;
  100276. private _colors32;
  100277. private _uvs32;
  100278. private _index;
  100279. private _updatable;
  100280. private _pickable;
  100281. private _isVisibilityBoxLocked;
  100282. private _alwaysVisible;
  100283. private _depthSort;
  100284. private _expandable;
  100285. private _shapeCounter;
  100286. private _copy;
  100287. private _color;
  100288. private _computeParticleColor;
  100289. private _computeParticleTexture;
  100290. private _computeParticleRotation;
  100291. private _computeParticleVertex;
  100292. private _computeBoundingBox;
  100293. private _depthSortParticles;
  100294. private _camera;
  100295. private _mustUnrotateFixedNormals;
  100296. private _particlesIntersect;
  100297. private _needs32Bits;
  100298. private _isNotBuilt;
  100299. private _lastParticleId;
  100300. private _idxOfId;
  100301. private _multimaterialEnabled;
  100302. private _useModelMaterial;
  100303. private _indicesByMaterial;
  100304. private _materialIndexes;
  100305. private _depthSortFunction;
  100306. private _materialSortFunction;
  100307. private _materials;
  100308. private _multimaterial;
  100309. private _materialIndexesById;
  100310. private _defaultMaterial;
  100311. private _autoUpdateSubMeshes;
  100312. /**
  100313. * Creates a SPS (Solid Particle System) object.
  100314. * @param name (String) is the SPS name, this will be the underlying mesh name.
  100315. * @param scene (Scene) is the scene in which the SPS is added.
  100316. * @param options defines the options of the sps e.g.
  100317. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  100318. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  100319. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  100320. * * 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.
  100321. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  100322. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  100323. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  100324. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  100325. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  100326. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  100327. */
  100328. constructor(name: string, scene: Scene, options?: {
  100329. updatable?: boolean;
  100330. isPickable?: boolean;
  100331. enableDepthSort?: boolean;
  100332. particleIntersection?: boolean;
  100333. boundingSphereOnly?: boolean;
  100334. bSphereRadiusFactor?: number;
  100335. expandable?: boolean;
  100336. useModelMaterial?: boolean;
  100337. enableMultiMaterial?: boolean;
  100338. });
  100339. /**
  100340. * Builds the SPS underlying mesh. Returns a standard Mesh.
  100341. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  100342. * @returns the created mesh
  100343. */
  100344. buildMesh(): Mesh;
  100345. /**
  100346. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  100347. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  100348. * Thus the particles generated from `digest()` have their property `position` set yet.
  100349. * @param mesh ( Mesh ) is the mesh to be digested
  100350. * @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
  100351. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  100352. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  100353. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100354. * @returns the current SPS
  100355. */
  100356. digest(mesh: Mesh, options?: {
  100357. facetNb?: number;
  100358. number?: number;
  100359. delta?: number;
  100360. storage?: [];
  100361. }): SolidParticleSystem;
  100362. /**
  100363. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  100364. * @hidden
  100365. */
  100366. private _unrotateFixedNormals;
  100367. /**
  100368. * Resets the temporary working copy particle
  100369. * @hidden
  100370. */
  100371. private _resetCopy;
  100372. /**
  100373. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  100374. * @param p the current index in the positions array to be updated
  100375. * @param ind the current index in the indices array
  100376. * @param shape a Vector3 array, the shape geometry
  100377. * @param positions the positions array to be updated
  100378. * @param meshInd the shape indices array
  100379. * @param indices the indices array to be updated
  100380. * @param meshUV the shape uv array
  100381. * @param uvs the uv array to be updated
  100382. * @param meshCol the shape color array
  100383. * @param colors the color array to be updated
  100384. * @param meshNor the shape normals array
  100385. * @param normals the normals array to be updated
  100386. * @param idx the particle index
  100387. * @param idxInShape the particle index in its shape
  100388. * @param options the addShape() method passed options
  100389. * @model the particle model
  100390. * @hidden
  100391. */
  100392. private _meshBuilder;
  100393. /**
  100394. * Returns a shape Vector3 array from positions float array
  100395. * @param positions float array
  100396. * @returns a vector3 array
  100397. * @hidden
  100398. */
  100399. private _posToShape;
  100400. /**
  100401. * Returns a shapeUV array from a float uvs (array deep copy)
  100402. * @param uvs as a float array
  100403. * @returns a shapeUV array
  100404. * @hidden
  100405. */
  100406. private _uvsToShapeUV;
  100407. /**
  100408. * Adds a new particle object in the particles array
  100409. * @param idx particle index in particles array
  100410. * @param id particle id
  100411. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  100412. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  100413. * @param model particle ModelShape object
  100414. * @param shapeId model shape identifier
  100415. * @param idxInShape index of the particle in the current model
  100416. * @param bInfo model bounding info object
  100417. * @param storage target storage array, if any
  100418. * @hidden
  100419. */
  100420. private _addParticle;
  100421. /**
  100422. * Adds some particles to the SPS from the model shape. Returns the shape id.
  100423. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  100424. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  100425. * @param nb (positive integer) the number of particles to be created from this model
  100426. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  100427. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  100428. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  100429. * @returns the number of shapes in the system
  100430. */
  100431. addShape(mesh: Mesh, nb: number, options?: {
  100432. positionFunction?: any;
  100433. vertexFunction?: any;
  100434. storage?: [];
  100435. }): number;
  100436. /**
  100437. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  100438. * @hidden
  100439. */
  100440. private _rebuildParticle;
  100441. /**
  100442. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  100443. * @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.
  100444. * @returns the SPS.
  100445. */
  100446. rebuildMesh(reset?: boolean): SolidParticleSystem;
  100447. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  100448. * Returns an array with the removed particles.
  100449. * 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.
  100450. * The SPS can't be empty so at least one particle needs to remain in place.
  100451. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  100452. * @param start index of the first particle to remove
  100453. * @param end index of the last particle to remove (included)
  100454. * @returns an array populated with the removed particles
  100455. */
  100456. removeParticles(start: number, end: number): SolidParticle[];
  100457. /**
  100458. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  100459. * @param solidParticleArray an array populated with Solid Particles objects
  100460. * @returns the SPS
  100461. */
  100462. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  100463. /**
  100464. * Creates a new particle and modifies the SPS mesh geometry :
  100465. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  100466. * - calls _addParticle() to populate the particle array
  100467. * factorized code from addShape() and insertParticlesFromArray()
  100468. * @param idx particle index in the particles array
  100469. * @param i particle index in its shape
  100470. * @param modelShape particle ModelShape object
  100471. * @param shape shape vertex array
  100472. * @param meshInd shape indices array
  100473. * @param meshUV shape uv array
  100474. * @param meshCol shape color array
  100475. * @param meshNor shape normals array
  100476. * @param bbInfo shape bounding info
  100477. * @param storage target particle storage
  100478. * @options addShape() passed options
  100479. * @hidden
  100480. */
  100481. private _insertNewParticle;
  100482. /**
  100483. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  100484. * This method calls `updateParticle()` for each particle of the SPS.
  100485. * For an animated SPS, it is usually called within the render loop.
  100486. * 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.
  100487. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  100488. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  100489. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  100490. * @returns the SPS.
  100491. */
  100492. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  100493. /**
  100494. * Disposes the SPS.
  100495. */
  100496. dispose(): void;
  100497. /**
  100498. * Returns a SolidParticle object from its identifier : particle.id
  100499. * @param id (integer) the particle Id
  100500. * @returns the searched particle or null if not found in the SPS.
  100501. */
  100502. getParticleById(id: number): Nullable<SolidParticle>;
  100503. /**
  100504. * Returns a new array populated with the particles having the passed shapeId.
  100505. * @param shapeId (integer) the shape identifier
  100506. * @returns a new solid particle array
  100507. */
  100508. getParticlesByShapeId(shapeId: number): SolidParticle[];
  100509. /**
  100510. * Populates the passed array "ref" with the particles having the passed shapeId.
  100511. * @param shapeId the shape identifier
  100512. * @returns the SPS
  100513. * @param ref
  100514. */
  100515. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  100516. /**
  100517. * Computes the required SubMeshes according the materials assigned to the particles.
  100518. * @returns the solid particle system.
  100519. * Does nothing if called before the SPS mesh is built.
  100520. */
  100521. computeSubMeshes(): SolidParticleSystem;
  100522. /**
  100523. * Sorts the solid particles by material when MultiMaterial is enabled.
  100524. * Updates the indices32 array.
  100525. * Updates the indicesByMaterial array.
  100526. * Updates the mesh indices array.
  100527. * @returns the SPS
  100528. * @hidden
  100529. */
  100530. private _sortParticlesByMaterial;
  100531. /**
  100532. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  100533. * @hidden
  100534. */
  100535. private _setMaterialIndexesById;
  100536. /**
  100537. * Returns an array with unique values of Materials from the passed array
  100538. * @param array the material array to be checked and filtered
  100539. * @hidden
  100540. */
  100541. private _filterUniqueMaterialId;
  100542. /**
  100543. * Sets a new Standard Material as _defaultMaterial if not already set.
  100544. * @hidden
  100545. */
  100546. private _setDefaultMaterial;
  100547. /**
  100548. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  100549. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100550. * @returns the SPS.
  100551. */
  100552. refreshVisibleSize(): SolidParticleSystem;
  100553. /**
  100554. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  100555. * @param size the size (float) of the visibility box
  100556. * note : this doesn't lock the SPS mesh bounding box.
  100557. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100558. */
  100559. setVisibilityBox(size: number): void;
  100560. /**
  100561. * Gets whether the SPS as always visible or not
  100562. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100563. */
  100564. get isAlwaysVisible(): boolean;
  100565. /**
  100566. * Sets the SPS as always visible or not
  100567. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100568. */
  100569. set isAlwaysVisible(val: boolean);
  100570. /**
  100571. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100572. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100573. */
  100574. set isVisibilityBoxLocked(val: boolean);
  100575. /**
  100576. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  100577. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  100578. */
  100579. get isVisibilityBoxLocked(): boolean;
  100580. /**
  100581. * Tells to `setParticles()` to compute the particle rotations or not.
  100582. * Default value : true. The SPS is faster when it's set to false.
  100583. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100584. */
  100585. set computeParticleRotation(val: boolean);
  100586. /**
  100587. * Tells to `setParticles()` to compute the particle colors or not.
  100588. * Default value : true. The SPS is faster when it's set to false.
  100589. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100590. */
  100591. set computeParticleColor(val: boolean);
  100592. set computeParticleTexture(val: boolean);
  100593. /**
  100594. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  100595. * Default value : false. The SPS is faster when it's set to false.
  100596. * Note : the particle custom vertex positions aren't stored values.
  100597. */
  100598. set computeParticleVertex(val: boolean);
  100599. /**
  100600. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  100601. */
  100602. set computeBoundingBox(val: boolean);
  100603. /**
  100604. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  100605. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100606. * Default : `true`
  100607. */
  100608. set depthSortParticles(val: boolean);
  100609. /**
  100610. * Gets if `setParticles()` computes the particle rotations or not.
  100611. * Default value : true. The SPS is faster when it's set to false.
  100612. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  100613. */
  100614. get computeParticleRotation(): boolean;
  100615. /**
  100616. * Gets if `setParticles()` computes the particle colors or not.
  100617. * Default value : true. The SPS is faster when it's set to false.
  100618. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  100619. */
  100620. get computeParticleColor(): boolean;
  100621. /**
  100622. * Gets if `setParticles()` computes the particle textures or not.
  100623. * Default value : true. The SPS is faster when it's set to false.
  100624. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  100625. */
  100626. get computeParticleTexture(): boolean;
  100627. /**
  100628. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  100629. * Default value : false. The SPS is faster when it's set to false.
  100630. * Note : the particle custom vertex positions aren't stored values.
  100631. */
  100632. get computeParticleVertex(): boolean;
  100633. /**
  100634. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  100635. */
  100636. get computeBoundingBox(): boolean;
  100637. /**
  100638. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  100639. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  100640. * Default : `true`
  100641. */
  100642. get depthSortParticles(): boolean;
  100643. /**
  100644. * Gets if the SPS is created as expandable at construction time.
  100645. * Default : `false`
  100646. */
  100647. get expandable(): boolean;
  100648. /**
  100649. * Gets if the SPS supports the Multi Materials
  100650. */
  100651. get multimaterialEnabled(): boolean;
  100652. /**
  100653. * Gets if the SPS uses the model materials for its own multimaterial.
  100654. */
  100655. get useModelMaterial(): boolean;
  100656. /**
  100657. * The SPS used material array.
  100658. */
  100659. get materials(): Material[];
  100660. /**
  100661. * Sets the SPS MultiMaterial from the passed materials.
  100662. * Note : the passed array is internally copied and not used then by reference.
  100663. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  100664. */
  100665. setMultiMaterial(materials: Material[]): void;
  100666. /**
  100667. * The SPS computed multimaterial object
  100668. */
  100669. get multimaterial(): MultiMaterial;
  100670. set multimaterial(mm: MultiMaterial);
  100671. /**
  100672. * If the subMeshes must be updated on the next call to setParticles()
  100673. */
  100674. get autoUpdateSubMeshes(): boolean;
  100675. set autoUpdateSubMeshes(val: boolean);
  100676. /**
  100677. * This function does nothing. It may be overwritten to set all the particle first values.
  100678. * The SPS doesn't call this function, you may have to call it by your own.
  100679. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100680. */
  100681. initParticles(): void;
  100682. /**
  100683. * This function does nothing. It may be overwritten to recycle a particle.
  100684. * The SPS doesn't call this function, you may have to call it by your own.
  100685. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100686. * @param particle The particle to recycle
  100687. * @returns the recycled particle
  100688. */
  100689. recycleParticle(particle: SolidParticle): SolidParticle;
  100690. /**
  100691. * Updates a particle : this function should be overwritten by the user.
  100692. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  100693. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  100694. * @example : just set a particle position or velocity and recycle conditions
  100695. * @param particle The particle to update
  100696. * @returns the updated particle
  100697. */
  100698. updateParticle(particle: SolidParticle): SolidParticle;
  100699. /**
  100700. * Updates a vertex of a particle : it can be overwritten by the user.
  100701. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  100702. * @param particle the current particle
  100703. * @param vertex the current index of the current particle
  100704. * @param pt the index of the current vertex in the particle shape
  100705. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  100706. * @example : just set a vertex particle position
  100707. * @returns the updated vertex
  100708. */
  100709. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  100710. /**
  100711. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  100712. * This does nothing and may be overwritten by the user.
  100713. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100714. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100715. * @param update the boolean update value actually passed to setParticles()
  100716. */
  100717. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100718. /**
  100719. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  100720. * This will be passed three parameters.
  100721. * This does nothing and may be overwritten by the user.
  100722. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100723. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  100724. * @param update the boolean update value actually passed to setParticles()
  100725. */
  100726. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  100727. }
  100728. }
  100729. declare module BABYLON {
  100730. /**
  100731. * Represents one particle of a solid particle system.
  100732. */
  100733. export class SolidParticle {
  100734. /**
  100735. * particle global index
  100736. */
  100737. idx: number;
  100738. /**
  100739. * particle identifier
  100740. */
  100741. id: number;
  100742. /**
  100743. * The color of the particle
  100744. */
  100745. color: Nullable<Color4>;
  100746. /**
  100747. * The world space position of the particle.
  100748. */
  100749. position: Vector3;
  100750. /**
  100751. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  100752. */
  100753. rotation: Vector3;
  100754. /**
  100755. * The world space rotation quaternion of the particle.
  100756. */
  100757. rotationQuaternion: Nullable<Quaternion>;
  100758. /**
  100759. * The scaling of the particle.
  100760. */
  100761. scaling: Vector3;
  100762. /**
  100763. * The uvs of the particle.
  100764. */
  100765. uvs: Vector4;
  100766. /**
  100767. * The current speed of the particle.
  100768. */
  100769. velocity: Vector3;
  100770. /**
  100771. * The pivot point in the particle local space.
  100772. */
  100773. pivot: Vector3;
  100774. /**
  100775. * Must the particle be translated from its pivot point in its local space ?
  100776. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  100777. * Default : false
  100778. */
  100779. translateFromPivot: boolean;
  100780. /**
  100781. * Is the particle active or not ?
  100782. */
  100783. alive: boolean;
  100784. /**
  100785. * Is the particle visible or not ?
  100786. */
  100787. isVisible: boolean;
  100788. /**
  100789. * Index of this particle in the global "positions" array (Internal use)
  100790. * @hidden
  100791. */
  100792. _pos: number;
  100793. /**
  100794. * @hidden Index of this particle in the global "indices" array (Internal use)
  100795. */
  100796. _ind: number;
  100797. /**
  100798. * @hidden ModelShape of this particle (Internal use)
  100799. */
  100800. _model: ModelShape;
  100801. /**
  100802. * ModelShape id of this particle
  100803. */
  100804. shapeId: number;
  100805. /**
  100806. * Index of the particle in its shape id
  100807. */
  100808. idxInShape: number;
  100809. /**
  100810. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  100811. */
  100812. _modelBoundingInfo: BoundingInfo;
  100813. /**
  100814. * @hidden Particle BoundingInfo object (Internal use)
  100815. */
  100816. _boundingInfo: BoundingInfo;
  100817. /**
  100818. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  100819. */
  100820. _sps: SolidParticleSystem;
  100821. /**
  100822. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  100823. */
  100824. _stillInvisible: boolean;
  100825. /**
  100826. * @hidden Last computed particle rotation matrix
  100827. */
  100828. _rotationMatrix: number[];
  100829. /**
  100830. * Parent particle Id, if any.
  100831. * Default null.
  100832. */
  100833. parentId: Nullable<number>;
  100834. /**
  100835. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  100836. */
  100837. materialIndex: Nullable<number>;
  100838. /**
  100839. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  100840. * The possible values are :
  100841. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  100842. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100843. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  100844. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  100845. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  100846. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  100847. * */
  100848. cullingStrategy: number;
  100849. /**
  100850. * @hidden Internal global position in the SPS.
  100851. */
  100852. _globalPosition: Vector3;
  100853. /**
  100854. * Creates a Solid Particle object.
  100855. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  100856. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  100857. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  100858. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  100859. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  100860. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  100861. * @param shapeId (integer) is the model shape identifier in the SPS.
  100862. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  100863. * @param sps defines the sps it is associated to
  100864. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  100865. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  100866. */
  100867. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  100868. /**
  100869. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  100870. * @param target the particle target
  100871. * @returns the current particle
  100872. */
  100873. copyToRef(target: SolidParticle): SolidParticle;
  100874. /**
  100875. * Legacy support, changed scale to scaling
  100876. */
  100877. get scale(): Vector3;
  100878. /**
  100879. * Legacy support, changed scale to scaling
  100880. */
  100881. set scale(scale: Vector3);
  100882. /**
  100883. * Legacy support, changed quaternion to rotationQuaternion
  100884. */
  100885. get quaternion(): Nullable<Quaternion>;
  100886. /**
  100887. * Legacy support, changed quaternion to rotationQuaternion
  100888. */
  100889. set quaternion(q: Nullable<Quaternion>);
  100890. /**
  100891. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  100892. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  100893. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  100894. * @returns true if it intersects
  100895. */
  100896. intersectsMesh(target: Mesh | SolidParticle): boolean;
  100897. /**
  100898. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  100899. * A particle is in the frustum if its bounding box intersects the frustum
  100900. * @param frustumPlanes defines the frustum to test
  100901. * @returns true if the particle is in the frustum planes
  100902. */
  100903. isInFrustum(frustumPlanes: Plane[]): boolean;
  100904. /**
  100905. * get the rotation matrix of the particle
  100906. * @hidden
  100907. */
  100908. getRotationMatrix(m: Matrix): void;
  100909. }
  100910. /**
  100911. * Represents the shape of the model used by one particle of a solid particle system.
  100912. * SPS internal tool, don't use it manually.
  100913. */
  100914. export class ModelShape {
  100915. /**
  100916. * The shape id
  100917. * @hidden
  100918. */
  100919. shapeID: number;
  100920. /**
  100921. * flat array of model positions (internal use)
  100922. * @hidden
  100923. */
  100924. _shape: Vector3[];
  100925. /**
  100926. * flat array of model UVs (internal use)
  100927. * @hidden
  100928. */
  100929. _shapeUV: number[];
  100930. /**
  100931. * color array of the model
  100932. * @hidden
  100933. */
  100934. _shapeColors: number[];
  100935. /**
  100936. * indices array of the model
  100937. * @hidden
  100938. */
  100939. _indices: number[];
  100940. /**
  100941. * normals array of the model
  100942. * @hidden
  100943. */
  100944. _normals: number[];
  100945. /**
  100946. * length of the shape in the model indices array (internal use)
  100947. * @hidden
  100948. */
  100949. _indicesLength: number;
  100950. /**
  100951. * Custom position function (internal use)
  100952. * @hidden
  100953. */
  100954. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  100955. /**
  100956. * Custom vertex function (internal use)
  100957. * @hidden
  100958. */
  100959. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  100960. /**
  100961. * Model material (internal use)
  100962. * @hidden
  100963. */
  100964. _material: Nullable<Material>;
  100965. /**
  100966. * 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.
  100967. * SPS internal tool, don't use it manually.
  100968. * @hidden
  100969. */
  100970. 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>);
  100971. }
  100972. /**
  100973. * Represents a Depth Sorted Particle in the solid particle system.
  100974. * @hidden
  100975. */
  100976. export class DepthSortedParticle {
  100977. /**
  100978. * Index of the particle in the "indices" array
  100979. */
  100980. ind: number;
  100981. /**
  100982. * Length of the particle shape in the "indices" array
  100983. */
  100984. indicesLength: number;
  100985. /**
  100986. * Squared distance from the particle to the camera
  100987. */
  100988. sqDistance: number;
  100989. /**
  100990. * Material index when used with MultiMaterials
  100991. */
  100992. materialIndex: number;
  100993. /**
  100994. * Creates a new sorted particle
  100995. * @param materialIndex
  100996. */
  100997. constructor(ind: number, indLength: number, materialIndex: number);
  100998. }
  100999. }
  101000. declare module BABYLON {
  101001. /**
  101002. * @hidden
  101003. */
  101004. export class _MeshCollisionData {
  101005. _checkCollisions: boolean;
  101006. _collisionMask: number;
  101007. _collisionGroup: number;
  101008. _collider: Nullable<Collider>;
  101009. _oldPositionForCollisions: Vector3;
  101010. _diffPositionForCollisions: Vector3;
  101011. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  101012. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  101013. }
  101014. }
  101015. declare module BABYLON {
  101016. /** @hidden */
  101017. class _FacetDataStorage {
  101018. facetPositions: Vector3[];
  101019. facetNormals: Vector3[];
  101020. facetPartitioning: number[][];
  101021. facetNb: number;
  101022. partitioningSubdivisions: number;
  101023. partitioningBBoxRatio: number;
  101024. facetDataEnabled: boolean;
  101025. facetParameters: any;
  101026. bbSize: Vector3;
  101027. subDiv: {
  101028. max: number;
  101029. X: number;
  101030. Y: number;
  101031. Z: number;
  101032. };
  101033. facetDepthSort: boolean;
  101034. facetDepthSortEnabled: boolean;
  101035. depthSortedIndices: IndicesArray;
  101036. depthSortedFacets: {
  101037. ind: number;
  101038. sqDistance: number;
  101039. }[];
  101040. facetDepthSortFunction: (f1: {
  101041. ind: number;
  101042. sqDistance: number;
  101043. }, f2: {
  101044. ind: number;
  101045. sqDistance: number;
  101046. }) => number;
  101047. facetDepthSortFrom: Vector3;
  101048. facetDepthSortOrigin: Vector3;
  101049. invertedMatrix: Matrix;
  101050. }
  101051. /**
  101052. * @hidden
  101053. **/
  101054. class _InternalAbstractMeshDataInfo {
  101055. _hasVertexAlpha: boolean;
  101056. _useVertexColors: boolean;
  101057. _numBoneInfluencers: number;
  101058. _applyFog: boolean;
  101059. _receiveShadows: boolean;
  101060. _facetData: _FacetDataStorage;
  101061. _visibility: number;
  101062. _skeleton: Nullable<Skeleton>;
  101063. _layerMask: number;
  101064. _computeBonesUsingShaders: boolean;
  101065. _isActive: boolean;
  101066. _onlyForInstances: boolean;
  101067. _isActiveIntermediate: boolean;
  101068. _onlyForInstancesIntermediate: boolean;
  101069. _actAsRegularMesh: boolean;
  101070. }
  101071. /**
  101072. * Class used to store all common mesh properties
  101073. */
  101074. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  101075. /** No occlusion */
  101076. static OCCLUSION_TYPE_NONE: number;
  101077. /** Occlusion set to optimisitic */
  101078. static OCCLUSION_TYPE_OPTIMISTIC: number;
  101079. /** Occlusion set to strict */
  101080. static OCCLUSION_TYPE_STRICT: number;
  101081. /** Use an accurante occlusion algorithm */
  101082. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  101083. /** Use a conservative occlusion algorithm */
  101084. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  101085. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  101086. * Test order :
  101087. * Is the bounding sphere outside the frustum ?
  101088. * If not, are the bounding box vertices outside the frustum ?
  101089. * It not, then the cullable object is in the frustum.
  101090. */
  101091. static readonly CULLINGSTRATEGY_STANDARD: number;
  101092. /** Culling strategy : Bounding Sphere Only.
  101093. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  101094. * It's also less accurate than the standard because some not visible objects can still be selected.
  101095. * Test : is the bounding sphere outside the frustum ?
  101096. * If not, then the cullable object is in the frustum.
  101097. */
  101098. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  101099. /** Culling strategy : Optimistic Inclusion.
  101100. * This in an inclusion test first, then the standard exclusion test.
  101101. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  101102. * 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.
  101103. * Anyway, it's as accurate as the standard strategy.
  101104. * Test :
  101105. * Is the cullable object bounding sphere center in the frustum ?
  101106. * If not, apply the default culling strategy.
  101107. */
  101108. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  101109. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  101110. * This in an inclusion test first, then the bounding sphere only exclusion test.
  101111. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  101112. * 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.
  101113. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  101114. * Test :
  101115. * Is the cullable object bounding sphere center in the frustum ?
  101116. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  101117. */
  101118. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  101119. /**
  101120. * No billboard
  101121. */
  101122. static get BILLBOARDMODE_NONE(): number;
  101123. /** Billboard on X axis */
  101124. static get BILLBOARDMODE_X(): number;
  101125. /** Billboard on Y axis */
  101126. static get BILLBOARDMODE_Y(): number;
  101127. /** Billboard on Z axis */
  101128. static get BILLBOARDMODE_Z(): number;
  101129. /** Billboard on all axes */
  101130. static get BILLBOARDMODE_ALL(): number;
  101131. /** Billboard on using position instead of orientation */
  101132. static get BILLBOARDMODE_USE_POSITION(): number;
  101133. /** @hidden */
  101134. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  101135. /**
  101136. * The culling strategy to use to check whether the mesh must be rendered or not.
  101137. * This value can be changed at any time and will be used on the next render mesh selection.
  101138. * The possible values are :
  101139. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  101140. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  101141. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  101142. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  101143. * Please read each static variable documentation to get details about the culling process.
  101144. * */
  101145. cullingStrategy: number;
  101146. /**
  101147. * Gets the number of facets in the mesh
  101148. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101149. */
  101150. get facetNb(): number;
  101151. /**
  101152. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  101153. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101154. */
  101155. get partitioningSubdivisions(): number;
  101156. set partitioningSubdivisions(nb: number);
  101157. /**
  101158. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  101159. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  101160. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  101161. */
  101162. get partitioningBBoxRatio(): number;
  101163. set partitioningBBoxRatio(ratio: number);
  101164. /**
  101165. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  101166. * Works only for updatable meshes.
  101167. * Doesn't work with multi-materials
  101168. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101169. */
  101170. get mustDepthSortFacets(): boolean;
  101171. set mustDepthSortFacets(sort: boolean);
  101172. /**
  101173. * The location (Vector3) where the facet depth sort must be computed from.
  101174. * By default, the active camera position.
  101175. * Used only when facet depth sort is enabled
  101176. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  101177. */
  101178. get facetDepthSortFrom(): Vector3;
  101179. set facetDepthSortFrom(location: Vector3);
  101180. /**
  101181. * gets a boolean indicating if facetData is enabled
  101182. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  101183. */
  101184. get isFacetDataEnabled(): boolean;
  101185. /** @hidden */
  101186. _updateNonUniformScalingState(value: boolean): boolean;
  101187. /**
  101188. * An event triggered when this mesh collides with another one
  101189. */
  101190. onCollideObservable: Observable<AbstractMesh>;
  101191. /** Set a function to call when this mesh collides with another one */
  101192. set onCollide(callback: () => void);
  101193. /**
  101194. * An event triggered when the collision's position changes
  101195. */
  101196. onCollisionPositionChangeObservable: Observable<Vector3>;
  101197. /** Set a function to call when the collision's position changes */
  101198. set onCollisionPositionChange(callback: () => void);
  101199. /**
  101200. * An event triggered when material is changed
  101201. */
  101202. onMaterialChangedObservable: Observable<AbstractMesh>;
  101203. /**
  101204. * Gets or sets the orientation for POV movement & rotation
  101205. */
  101206. definedFacingForward: boolean;
  101207. /** @hidden */
  101208. _occlusionQuery: Nullable<WebGLQuery>;
  101209. /** @hidden */
  101210. _renderingGroup: Nullable<RenderingGroup>;
  101211. /**
  101212. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101213. */
  101214. get visibility(): number;
  101215. /**
  101216. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  101217. */
  101218. set visibility(value: number);
  101219. /** Gets or sets the alpha index used to sort transparent meshes
  101220. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  101221. */
  101222. alphaIndex: number;
  101223. /**
  101224. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  101225. */
  101226. isVisible: boolean;
  101227. /**
  101228. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  101229. */
  101230. isPickable: boolean;
  101231. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  101232. showSubMeshesBoundingBox: boolean;
  101233. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  101234. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  101235. */
  101236. isBlocker: boolean;
  101237. /**
  101238. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  101239. */
  101240. enablePointerMoveEvents: boolean;
  101241. /**
  101242. * Specifies the rendering group id for this mesh (0 by default)
  101243. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  101244. */
  101245. renderingGroupId: number;
  101246. private _material;
  101247. /** Gets or sets current material */
  101248. get material(): Nullable<Material>;
  101249. set material(value: Nullable<Material>);
  101250. /**
  101251. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  101252. * @see http://doc.babylonjs.com/babylon101/shadows
  101253. */
  101254. get receiveShadows(): boolean;
  101255. set receiveShadows(value: boolean);
  101256. /** Defines color to use when rendering outline */
  101257. outlineColor: Color3;
  101258. /** Define width to use when rendering outline */
  101259. outlineWidth: number;
  101260. /** Defines color to use when rendering overlay */
  101261. overlayColor: Color3;
  101262. /** Defines alpha to use when rendering overlay */
  101263. overlayAlpha: number;
  101264. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  101265. get hasVertexAlpha(): boolean;
  101266. set hasVertexAlpha(value: boolean);
  101267. /** 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) */
  101268. get useVertexColors(): boolean;
  101269. set useVertexColors(value: boolean);
  101270. /**
  101271. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  101272. */
  101273. get computeBonesUsingShaders(): boolean;
  101274. set computeBonesUsingShaders(value: boolean);
  101275. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  101276. get numBoneInfluencers(): number;
  101277. set numBoneInfluencers(value: number);
  101278. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  101279. get applyFog(): boolean;
  101280. set applyFog(value: boolean);
  101281. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  101282. useOctreeForRenderingSelection: boolean;
  101283. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  101284. useOctreeForPicking: boolean;
  101285. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  101286. useOctreeForCollisions: boolean;
  101287. /**
  101288. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  101289. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  101290. */
  101291. get layerMask(): number;
  101292. set layerMask(value: number);
  101293. /**
  101294. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  101295. */
  101296. alwaysSelectAsActiveMesh: boolean;
  101297. /**
  101298. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  101299. */
  101300. doNotSyncBoundingInfo: boolean;
  101301. /**
  101302. * Gets or sets the current action manager
  101303. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101304. */
  101305. actionManager: Nullable<AbstractActionManager>;
  101306. private _meshCollisionData;
  101307. /**
  101308. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  101309. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101310. */
  101311. ellipsoid: Vector3;
  101312. /**
  101313. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  101314. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101315. */
  101316. ellipsoidOffset: Vector3;
  101317. /**
  101318. * Gets or sets a collision mask used to mask collisions (default is -1).
  101319. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101320. */
  101321. get collisionMask(): number;
  101322. set collisionMask(mask: number);
  101323. /**
  101324. * Gets or sets the current collision group mask (-1 by default).
  101325. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  101326. */
  101327. get collisionGroup(): number;
  101328. set collisionGroup(mask: number);
  101329. /**
  101330. * Defines edge width used when edgesRenderer is enabled
  101331. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101332. */
  101333. edgesWidth: number;
  101334. /**
  101335. * Defines edge color used when edgesRenderer is enabled
  101336. * @see https://www.babylonjs-playground.com/#10OJSG#13
  101337. */
  101338. edgesColor: Color4;
  101339. /** @hidden */
  101340. _edgesRenderer: Nullable<IEdgesRenderer>;
  101341. /** @hidden */
  101342. _masterMesh: Nullable<AbstractMesh>;
  101343. /** @hidden */
  101344. _boundingInfo: Nullable<BoundingInfo>;
  101345. /** @hidden */
  101346. _renderId: number;
  101347. /**
  101348. * Gets or sets the list of subMeshes
  101349. * @see http://doc.babylonjs.com/how_to/multi_materials
  101350. */
  101351. subMeshes: SubMesh[];
  101352. /** @hidden */
  101353. _intersectionsInProgress: AbstractMesh[];
  101354. /** @hidden */
  101355. _unIndexed: boolean;
  101356. /** @hidden */
  101357. _lightSources: Light[];
  101358. /** Gets the list of lights affecting that mesh */
  101359. get lightSources(): Light[];
  101360. /** @hidden */
  101361. get _positions(): Nullable<Vector3[]>;
  101362. /** @hidden */
  101363. _waitingData: {
  101364. lods: Nullable<any>;
  101365. actions: Nullable<any>;
  101366. freezeWorldMatrix: Nullable<boolean>;
  101367. };
  101368. /** @hidden */
  101369. _bonesTransformMatrices: Nullable<Float32Array>;
  101370. /** @hidden */
  101371. _transformMatrixTexture: Nullable<RawTexture>;
  101372. /**
  101373. * Gets or sets a skeleton to apply skining transformations
  101374. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101375. */
  101376. set skeleton(value: Nullable<Skeleton>);
  101377. get skeleton(): Nullable<Skeleton>;
  101378. /**
  101379. * An event triggered when the mesh is rebuilt.
  101380. */
  101381. onRebuildObservable: Observable<AbstractMesh>;
  101382. /**
  101383. * Creates a new AbstractMesh
  101384. * @param name defines the name of the mesh
  101385. * @param scene defines the hosting scene
  101386. */
  101387. constructor(name: string, scene?: Nullable<Scene>);
  101388. /**
  101389. * Returns the string "AbstractMesh"
  101390. * @returns "AbstractMesh"
  101391. */
  101392. getClassName(): string;
  101393. /**
  101394. * Gets a string representation of the current mesh
  101395. * @param fullDetails defines a boolean indicating if full details must be included
  101396. * @returns a string representation of the current mesh
  101397. */
  101398. toString(fullDetails?: boolean): string;
  101399. /**
  101400. * @hidden
  101401. */
  101402. protected _getEffectiveParent(): Nullable<Node>;
  101403. /** @hidden */
  101404. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  101405. /** @hidden */
  101406. _rebuild(): void;
  101407. /** @hidden */
  101408. _resyncLightSources(): void;
  101409. /** @hidden */
  101410. _resyncLightSource(light: Light): void;
  101411. /** @hidden */
  101412. _unBindEffect(): void;
  101413. /** @hidden */
  101414. _removeLightSource(light: Light, dispose: boolean): void;
  101415. private _markSubMeshesAsDirty;
  101416. /** @hidden */
  101417. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  101418. /** @hidden */
  101419. _markSubMeshesAsAttributesDirty(): void;
  101420. /** @hidden */
  101421. _markSubMeshesAsMiscDirty(): void;
  101422. /**
  101423. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  101424. */
  101425. get scaling(): Vector3;
  101426. set scaling(newScaling: Vector3);
  101427. /**
  101428. * Returns true if the mesh is blocked. Implemented by child classes
  101429. */
  101430. get isBlocked(): boolean;
  101431. /**
  101432. * Returns the mesh itself by default. Implemented by child classes
  101433. * @param camera defines the camera to use to pick the right LOD level
  101434. * @returns the currentAbstractMesh
  101435. */
  101436. getLOD(camera: Camera): Nullable<AbstractMesh>;
  101437. /**
  101438. * Returns 0 by default. Implemented by child classes
  101439. * @returns an integer
  101440. */
  101441. getTotalVertices(): number;
  101442. /**
  101443. * Returns a positive integer : the total number of indices in this mesh geometry.
  101444. * @returns the numner of indices or zero if the mesh has no geometry.
  101445. */
  101446. getTotalIndices(): number;
  101447. /**
  101448. * Returns null by default. Implemented by child classes
  101449. * @returns null
  101450. */
  101451. getIndices(): Nullable<IndicesArray>;
  101452. /**
  101453. * Returns the array of the requested vertex data kind. Implemented by child classes
  101454. * @param kind defines the vertex data kind to use
  101455. * @returns null
  101456. */
  101457. getVerticesData(kind: string): Nullable<FloatArray>;
  101458. /**
  101459. * Sets the vertex data of the mesh geometry for the requested `kind`.
  101460. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  101461. * Note that a new underlying VertexBuffer object is created each call.
  101462. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  101463. * @param kind defines vertex data kind:
  101464. * * VertexBuffer.PositionKind
  101465. * * VertexBuffer.UVKind
  101466. * * VertexBuffer.UV2Kind
  101467. * * VertexBuffer.UV3Kind
  101468. * * VertexBuffer.UV4Kind
  101469. * * VertexBuffer.UV5Kind
  101470. * * VertexBuffer.UV6Kind
  101471. * * VertexBuffer.ColorKind
  101472. * * VertexBuffer.MatricesIndicesKind
  101473. * * VertexBuffer.MatricesIndicesExtraKind
  101474. * * VertexBuffer.MatricesWeightsKind
  101475. * * VertexBuffer.MatricesWeightsExtraKind
  101476. * @param data defines the data source
  101477. * @param updatable defines if the data must be flagged as updatable (or static)
  101478. * @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
  101479. * @returns the current mesh
  101480. */
  101481. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  101482. /**
  101483. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  101484. * If the mesh has no geometry, it is simply returned as it is.
  101485. * @param kind defines vertex data kind:
  101486. * * VertexBuffer.PositionKind
  101487. * * VertexBuffer.UVKind
  101488. * * VertexBuffer.UV2Kind
  101489. * * VertexBuffer.UV3Kind
  101490. * * VertexBuffer.UV4Kind
  101491. * * VertexBuffer.UV5Kind
  101492. * * VertexBuffer.UV6Kind
  101493. * * VertexBuffer.ColorKind
  101494. * * VertexBuffer.MatricesIndicesKind
  101495. * * VertexBuffer.MatricesIndicesExtraKind
  101496. * * VertexBuffer.MatricesWeightsKind
  101497. * * VertexBuffer.MatricesWeightsExtraKind
  101498. * @param data defines the data source
  101499. * @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
  101500. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  101501. * @returns the current mesh
  101502. */
  101503. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  101504. /**
  101505. * Sets the mesh indices,
  101506. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  101507. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  101508. * @param totalVertices Defines the total number of vertices
  101509. * @returns the current mesh
  101510. */
  101511. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  101512. /**
  101513. * Gets a boolean indicating if specific vertex data is present
  101514. * @param kind defines the vertex data kind to use
  101515. * @returns true is data kind is present
  101516. */
  101517. isVerticesDataPresent(kind: string): boolean;
  101518. /**
  101519. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  101520. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  101521. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  101522. * @returns a BoundingInfo
  101523. */
  101524. getBoundingInfo(): BoundingInfo;
  101525. /**
  101526. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  101527. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  101528. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  101529. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  101530. * @returns the current mesh
  101531. */
  101532. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  101533. /**
  101534. * Overwrite the current bounding info
  101535. * @param boundingInfo defines the new bounding info
  101536. * @returns the current mesh
  101537. */
  101538. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  101539. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  101540. get useBones(): boolean;
  101541. /** @hidden */
  101542. _preActivate(): void;
  101543. /** @hidden */
  101544. _preActivateForIntermediateRendering(renderId: number): void;
  101545. /** @hidden */
  101546. _activate(renderId: number, intermediateRendering: boolean): boolean;
  101547. /** @hidden */
  101548. _postActivate(): void;
  101549. /** @hidden */
  101550. _freeze(): void;
  101551. /** @hidden */
  101552. _unFreeze(): void;
  101553. /**
  101554. * Gets the current world matrix
  101555. * @returns a Matrix
  101556. */
  101557. getWorldMatrix(): Matrix;
  101558. /** @hidden */
  101559. _getWorldMatrixDeterminant(): number;
  101560. /**
  101561. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  101562. */
  101563. get isAnInstance(): boolean;
  101564. /**
  101565. * Gets a boolean indicating if this mesh has instances
  101566. */
  101567. get hasInstances(): boolean;
  101568. /**
  101569. * Perform relative position change from the point of view of behind the front of the mesh.
  101570. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101571. * Supports definition of mesh facing forward or backward
  101572. * @param amountRight defines the distance on the right axis
  101573. * @param amountUp defines the distance on the up axis
  101574. * @param amountForward defines the distance on the forward axis
  101575. * @returns the current mesh
  101576. */
  101577. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  101578. /**
  101579. * Calculate relative position change from the point of view of behind the front of the mesh.
  101580. * This is performed taking into account the meshes current rotation, so you do not have to care.
  101581. * Supports definition of mesh facing forward or backward
  101582. * @param amountRight defines the distance on the right axis
  101583. * @param amountUp defines the distance on the up axis
  101584. * @param amountForward defines the distance on the forward axis
  101585. * @returns the new displacement vector
  101586. */
  101587. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  101588. /**
  101589. * Perform relative rotation change from the point of view of behind the front of the mesh.
  101590. * Supports definition of mesh facing forward or backward
  101591. * @param flipBack defines the flip
  101592. * @param twirlClockwise defines the twirl
  101593. * @param tiltRight defines the tilt
  101594. * @returns the current mesh
  101595. */
  101596. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  101597. /**
  101598. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  101599. * Supports definition of mesh facing forward or backward.
  101600. * @param flipBack defines the flip
  101601. * @param twirlClockwise defines the twirl
  101602. * @param tiltRight defines the tilt
  101603. * @returns the new rotation vector
  101604. */
  101605. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  101606. /**
  101607. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  101608. * This means the mesh underlying bounding box and sphere are recomputed.
  101609. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  101610. * @returns the current mesh
  101611. */
  101612. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  101613. /** @hidden */
  101614. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  101615. /** @hidden */
  101616. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  101617. /** @hidden */
  101618. _updateBoundingInfo(): AbstractMesh;
  101619. /** @hidden */
  101620. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  101621. /** @hidden */
  101622. protected _afterComputeWorldMatrix(): void;
  101623. /** @hidden */
  101624. get _effectiveMesh(): AbstractMesh;
  101625. /**
  101626. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  101627. * A mesh is in the frustum if its bounding box intersects the frustum
  101628. * @param frustumPlanes defines the frustum to test
  101629. * @returns true if the mesh is in the frustum planes
  101630. */
  101631. isInFrustum(frustumPlanes: Plane[]): boolean;
  101632. /**
  101633. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  101634. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  101635. * @param frustumPlanes defines the frustum to test
  101636. * @returns true if the mesh is completely in the frustum planes
  101637. */
  101638. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  101639. /**
  101640. * True if the mesh intersects another mesh or a SolidParticle object
  101641. * @param mesh defines a target mesh or SolidParticle to test
  101642. * @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)
  101643. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  101644. * @returns true if there is an intersection
  101645. */
  101646. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  101647. /**
  101648. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  101649. * @param point defines the point to test
  101650. * @returns true if there is an intersection
  101651. */
  101652. intersectsPoint(point: Vector3): boolean;
  101653. /**
  101654. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  101655. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101656. */
  101657. get checkCollisions(): boolean;
  101658. set checkCollisions(collisionEnabled: boolean);
  101659. /**
  101660. * Gets Collider object used to compute collisions (not physics)
  101661. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101662. */
  101663. get collider(): Nullable<Collider>;
  101664. /**
  101665. * Move the mesh using collision engine
  101666. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  101667. * @param displacement defines the requested displacement vector
  101668. * @returns the current mesh
  101669. */
  101670. moveWithCollisions(displacement: Vector3): AbstractMesh;
  101671. private _onCollisionPositionChange;
  101672. /** @hidden */
  101673. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  101674. /** @hidden */
  101675. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  101676. /** @hidden */
  101677. _checkCollision(collider: Collider): AbstractMesh;
  101678. /** @hidden */
  101679. _generatePointsArray(): boolean;
  101680. /**
  101681. * Checks if the passed Ray intersects with the mesh
  101682. * @param ray defines the ray to use
  101683. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  101684. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101685. * @returns the picking info
  101686. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  101687. */
  101688. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  101689. /**
  101690. * Clones the current mesh
  101691. * @param name defines the mesh name
  101692. * @param newParent defines the new mesh parent
  101693. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  101694. * @returns the new mesh
  101695. */
  101696. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  101697. /**
  101698. * Disposes all the submeshes of the current meshnp
  101699. * @returns the current mesh
  101700. */
  101701. releaseSubMeshes(): AbstractMesh;
  101702. /**
  101703. * Releases resources associated with this abstract mesh.
  101704. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  101705. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  101706. */
  101707. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  101708. /**
  101709. * Adds the passed mesh as a child to the current mesh
  101710. * @param mesh defines the child mesh
  101711. * @returns the current mesh
  101712. */
  101713. addChild(mesh: AbstractMesh): AbstractMesh;
  101714. /**
  101715. * Removes the passed mesh from the current mesh children list
  101716. * @param mesh defines the child mesh
  101717. * @returns the current mesh
  101718. */
  101719. removeChild(mesh: AbstractMesh): AbstractMesh;
  101720. /** @hidden */
  101721. private _initFacetData;
  101722. /**
  101723. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  101724. * This method can be called within the render loop.
  101725. * 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
  101726. * @returns the current mesh
  101727. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101728. */
  101729. updateFacetData(): AbstractMesh;
  101730. /**
  101731. * Returns the facetLocalNormals array.
  101732. * The normals are expressed in the mesh local spac
  101733. * @returns an array of Vector3
  101734. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101735. */
  101736. getFacetLocalNormals(): Vector3[];
  101737. /**
  101738. * Returns the facetLocalPositions array.
  101739. * The facet positions are expressed in the mesh local space
  101740. * @returns an array of Vector3
  101741. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101742. */
  101743. getFacetLocalPositions(): Vector3[];
  101744. /**
  101745. * Returns the facetLocalPartioning array
  101746. * @returns an array of array of numbers
  101747. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101748. */
  101749. getFacetLocalPartitioning(): number[][];
  101750. /**
  101751. * Returns the i-th facet position in the world system.
  101752. * This method allocates a new Vector3 per call
  101753. * @param i defines the facet index
  101754. * @returns a new Vector3
  101755. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101756. */
  101757. getFacetPosition(i: number): Vector3;
  101758. /**
  101759. * Sets the reference Vector3 with the i-th facet position in the world system
  101760. * @param i defines the facet index
  101761. * @param ref defines the target vector
  101762. * @returns the current mesh
  101763. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101764. */
  101765. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  101766. /**
  101767. * Returns the i-th facet normal in the world system.
  101768. * This method allocates a new Vector3 per call
  101769. * @param i defines the facet index
  101770. * @returns a new Vector3
  101771. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101772. */
  101773. getFacetNormal(i: number): Vector3;
  101774. /**
  101775. * Sets the reference Vector3 with the i-th facet normal in the world system
  101776. * @param i defines the facet index
  101777. * @param ref defines the target vector
  101778. * @returns the current mesh
  101779. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101780. */
  101781. getFacetNormalToRef(i: number, ref: Vector3): this;
  101782. /**
  101783. * 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)
  101784. * @param x defines x coordinate
  101785. * @param y defines y coordinate
  101786. * @param z defines z coordinate
  101787. * @returns the array of facet indexes
  101788. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101789. */
  101790. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  101791. /**
  101792. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  101793. * @param projected sets as the (x,y,z) world projection on the facet
  101794. * @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
  101795. * @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
  101796. * @param x defines x coordinate
  101797. * @param y defines y coordinate
  101798. * @param z defines z coordinate
  101799. * @returns the face index if found (or null instead)
  101800. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101801. */
  101802. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101803. /**
  101804. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  101805. * @param projected sets as the (x,y,z) local projection on the facet
  101806. * @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
  101807. * @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
  101808. * @param x defines x coordinate
  101809. * @param y defines y coordinate
  101810. * @param z defines z coordinate
  101811. * @returns the face index if found (or null instead)
  101812. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101813. */
  101814. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  101815. /**
  101816. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  101817. * @returns the parameters
  101818. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101819. */
  101820. getFacetDataParameters(): any;
  101821. /**
  101822. * Disables the feature FacetData and frees the related memory
  101823. * @returns the current mesh
  101824. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  101825. */
  101826. disableFacetData(): AbstractMesh;
  101827. /**
  101828. * Updates the AbstractMesh indices array
  101829. * @param indices defines the data source
  101830. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  101831. * @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)
  101832. * @returns the current mesh
  101833. */
  101834. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  101835. /**
  101836. * Creates new normals data for the mesh
  101837. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  101838. * @returns the current mesh
  101839. */
  101840. createNormals(updatable: boolean): AbstractMesh;
  101841. /**
  101842. * Align the mesh with a normal
  101843. * @param normal defines the normal to use
  101844. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  101845. * @returns the current mesh
  101846. */
  101847. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  101848. /** @hidden */
  101849. _checkOcclusionQuery(): boolean;
  101850. /**
  101851. * Disables the mesh edge rendering mode
  101852. * @returns the currentAbstractMesh
  101853. */
  101854. disableEdgesRendering(): AbstractMesh;
  101855. /**
  101856. * Enables the edge rendering mode on the mesh.
  101857. * This mode makes the mesh edges visible
  101858. * @param epsilon defines the maximal distance between two angles to detect a face
  101859. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  101860. * @returns the currentAbstractMesh
  101861. * @see https://www.babylonjs-playground.com/#19O9TU#0
  101862. */
  101863. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  101864. }
  101865. }
  101866. declare module BABYLON {
  101867. /**
  101868. * Interface used to define ActionEvent
  101869. */
  101870. export interface IActionEvent {
  101871. /** The mesh or sprite that triggered the action */
  101872. source: any;
  101873. /** The X mouse cursor position at the time of the event */
  101874. pointerX: number;
  101875. /** The Y mouse cursor position at the time of the event */
  101876. pointerY: number;
  101877. /** The mesh that is currently pointed at (can be null) */
  101878. meshUnderPointer: Nullable<AbstractMesh>;
  101879. /** the original (browser) event that triggered the ActionEvent */
  101880. sourceEvent?: any;
  101881. /** additional data for the event */
  101882. additionalData?: any;
  101883. }
  101884. /**
  101885. * ActionEvent is the event being sent when an action is triggered.
  101886. */
  101887. export class ActionEvent implements IActionEvent {
  101888. /** The mesh or sprite that triggered the action */
  101889. source: any;
  101890. /** The X mouse cursor position at the time of the event */
  101891. pointerX: number;
  101892. /** The Y mouse cursor position at the time of the event */
  101893. pointerY: number;
  101894. /** The mesh that is currently pointed at (can be null) */
  101895. meshUnderPointer: Nullable<AbstractMesh>;
  101896. /** the original (browser) event that triggered the ActionEvent */
  101897. sourceEvent?: any;
  101898. /** additional data for the event */
  101899. additionalData?: any;
  101900. /**
  101901. * Creates a new ActionEvent
  101902. * @param source The mesh or sprite that triggered the action
  101903. * @param pointerX The X mouse cursor position at the time of the event
  101904. * @param pointerY The Y mouse cursor position at the time of the event
  101905. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  101906. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  101907. * @param additionalData additional data for the event
  101908. */
  101909. constructor(
  101910. /** The mesh or sprite that triggered the action */
  101911. source: any,
  101912. /** The X mouse cursor position at the time of the event */
  101913. pointerX: number,
  101914. /** The Y mouse cursor position at the time of the event */
  101915. pointerY: number,
  101916. /** The mesh that is currently pointed at (can be null) */
  101917. meshUnderPointer: Nullable<AbstractMesh>,
  101918. /** the original (browser) event that triggered the ActionEvent */
  101919. sourceEvent?: any,
  101920. /** additional data for the event */
  101921. additionalData?: any);
  101922. /**
  101923. * Helper function to auto-create an ActionEvent from a source mesh.
  101924. * @param source The source mesh that triggered the event
  101925. * @param evt The original (browser) event
  101926. * @param additionalData additional data for the event
  101927. * @returns the new ActionEvent
  101928. */
  101929. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  101930. /**
  101931. * Helper function to auto-create an ActionEvent from a source sprite
  101932. * @param source The source sprite that triggered the event
  101933. * @param scene Scene associated with the sprite
  101934. * @param evt The original (browser) event
  101935. * @param additionalData additional data for the event
  101936. * @returns the new ActionEvent
  101937. */
  101938. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  101939. /**
  101940. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  101941. * @param scene the scene where the event occurred
  101942. * @param evt The original (browser) event
  101943. * @returns the new ActionEvent
  101944. */
  101945. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  101946. /**
  101947. * Helper function to auto-create an ActionEvent from a primitive
  101948. * @param prim defines the target primitive
  101949. * @param pointerPos defines the pointer position
  101950. * @param evt The original (browser) event
  101951. * @param additionalData additional data for the event
  101952. * @returns the new ActionEvent
  101953. */
  101954. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  101955. }
  101956. }
  101957. declare module BABYLON {
  101958. /**
  101959. * Abstract class used to decouple action Manager from scene and meshes.
  101960. * Do not instantiate.
  101961. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  101962. */
  101963. export abstract class AbstractActionManager implements IDisposable {
  101964. /** Gets the list of active triggers */
  101965. static Triggers: {
  101966. [key: string]: number;
  101967. };
  101968. /** Gets the cursor to use when hovering items */
  101969. hoverCursor: string;
  101970. /** Gets the list of actions */
  101971. actions: IAction[];
  101972. /**
  101973. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  101974. */
  101975. isRecursive: boolean;
  101976. /**
  101977. * Releases all associated resources
  101978. */
  101979. abstract dispose(): void;
  101980. /**
  101981. * Does this action manager has pointer triggers
  101982. */
  101983. abstract get hasPointerTriggers(): boolean;
  101984. /**
  101985. * Does this action manager has pick triggers
  101986. */
  101987. abstract get hasPickTriggers(): boolean;
  101988. /**
  101989. * Process a specific trigger
  101990. * @param trigger defines the trigger to process
  101991. * @param evt defines the event details to be processed
  101992. */
  101993. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  101994. /**
  101995. * Does this action manager handles actions of any of the given triggers
  101996. * @param triggers defines the triggers to be tested
  101997. * @return a boolean indicating whether one (or more) of the triggers is handled
  101998. */
  101999. abstract hasSpecificTriggers(triggers: number[]): boolean;
  102000. /**
  102001. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  102002. * speed.
  102003. * @param triggerA defines the trigger to be tested
  102004. * @param triggerB defines the trigger to be tested
  102005. * @return a boolean indicating whether one (or more) of the triggers is handled
  102006. */
  102007. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  102008. /**
  102009. * Does this action manager handles actions of a given trigger
  102010. * @param trigger defines the trigger to be tested
  102011. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  102012. * @return whether the trigger is handled
  102013. */
  102014. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  102015. /**
  102016. * Serialize this manager to a JSON object
  102017. * @param name defines the property name to store this manager
  102018. * @returns a JSON representation of this manager
  102019. */
  102020. abstract serialize(name: string): any;
  102021. /**
  102022. * Registers an action to this action manager
  102023. * @param action defines the action to be registered
  102024. * @return the action amended (prepared) after registration
  102025. */
  102026. abstract registerAction(action: IAction): Nullable<IAction>;
  102027. /**
  102028. * Unregisters an action to this action manager
  102029. * @param action defines the action to be unregistered
  102030. * @return a boolean indicating whether the action has been unregistered
  102031. */
  102032. abstract unregisterAction(action: IAction): Boolean;
  102033. /**
  102034. * Does exist one action manager with at least one trigger
  102035. **/
  102036. static get HasTriggers(): boolean;
  102037. /**
  102038. * Does exist one action manager with at least one pick trigger
  102039. **/
  102040. static get HasPickTriggers(): boolean;
  102041. /**
  102042. * Does exist one action manager that handles actions of a given trigger
  102043. * @param trigger defines the trigger to be tested
  102044. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  102045. **/
  102046. static HasSpecificTrigger(trigger: number): boolean;
  102047. }
  102048. }
  102049. declare module BABYLON {
  102050. /**
  102051. * Defines how a node can be built from a string name.
  102052. */
  102053. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  102054. /**
  102055. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  102056. */
  102057. export class Node implements IBehaviorAware<Node> {
  102058. /** @hidden */
  102059. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  102060. private static _NodeConstructors;
  102061. /**
  102062. * Add a new node constructor
  102063. * @param type defines the type name of the node to construct
  102064. * @param constructorFunc defines the constructor function
  102065. */
  102066. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  102067. /**
  102068. * Returns a node constructor based on type name
  102069. * @param type defines the type name
  102070. * @param name defines the new node name
  102071. * @param scene defines the hosting scene
  102072. * @param options defines optional options to transmit to constructors
  102073. * @returns the new constructor or null
  102074. */
  102075. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  102076. /**
  102077. * Gets or sets the name of the node
  102078. */
  102079. name: string;
  102080. /**
  102081. * Gets or sets the id of the node
  102082. */
  102083. id: string;
  102084. /**
  102085. * Gets or sets the unique id of the node
  102086. */
  102087. uniqueId: number;
  102088. /**
  102089. * Gets or sets a string used to store user defined state for the node
  102090. */
  102091. state: string;
  102092. /**
  102093. * Gets or sets an object used to store user defined information for the node
  102094. */
  102095. metadata: any;
  102096. /**
  102097. * For internal use only. Please do not use.
  102098. */
  102099. reservedDataStore: any;
  102100. /**
  102101. * List of inspectable custom properties (used by the Inspector)
  102102. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  102103. */
  102104. inspectableCustomProperties: IInspectable[];
  102105. private _doNotSerialize;
  102106. /**
  102107. * Gets or sets a boolean used to define if the node must be serialized
  102108. */
  102109. get doNotSerialize(): boolean;
  102110. set doNotSerialize(value: boolean);
  102111. /** @hidden */
  102112. _isDisposed: boolean;
  102113. /**
  102114. * Gets a list of Animations associated with the node
  102115. */
  102116. animations: Animation[];
  102117. protected _ranges: {
  102118. [name: string]: Nullable<AnimationRange>;
  102119. };
  102120. /**
  102121. * Callback raised when the node is ready to be used
  102122. */
  102123. onReady: Nullable<(node: Node) => void>;
  102124. private _isEnabled;
  102125. private _isParentEnabled;
  102126. private _isReady;
  102127. /** @hidden */
  102128. _currentRenderId: number;
  102129. private _parentUpdateId;
  102130. /** @hidden */
  102131. _childUpdateId: number;
  102132. /** @hidden */
  102133. _waitingParentId: Nullable<string>;
  102134. /** @hidden */
  102135. _scene: Scene;
  102136. /** @hidden */
  102137. _cache: any;
  102138. private _parentNode;
  102139. private _children;
  102140. /** @hidden */
  102141. _worldMatrix: Matrix;
  102142. /** @hidden */
  102143. _worldMatrixDeterminant: number;
  102144. /** @hidden */
  102145. _worldMatrixDeterminantIsDirty: boolean;
  102146. /** @hidden */
  102147. private _sceneRootNodesIndex;
  102148. /**
  102149. * Gets a boolean indicating if the node has been disposed
  102150. * @returns true if the node was disposed
  102151. */
  102152. isDisposed(): boolean;
  102153. /**
  102154. * Gets or sets the parent of the node (without keeping the current position in the scene)
  102155. * @see https://doc.babylonjs.com/how_to/parenting
  102156. */
  102157. set parent(parent: Nullable<Node>);
  102158. get parent(): Nullable<Node>;
  102159. /** @hidden */
  102160. _addToSceneRootNodes(): void;
  102161. /** @hidden */
  102162. _removeFromSceneRootNodes(): void;
  102163. private _animationPropertiesOverride;
  102164. /**
  102165. * Gets or sets the animation properties override
  102166. */
  102167. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  102168. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  102169. /**
  102170. * Gets a string idenfifying the name of the class
  102171. * @returns "Node" string
  102172. */
  102173. getClassName(): string;
  102174. /** @hidden */
  102175. readonly _isNode: boolean;
  102176. /**
  102177. * An event triggered when the mesh is disposed
  102178. */
  102179. onDisposeObservable: Observable<Node>;
  102180. private _onDisposeObserver;
  102181. /**
  102182. * Sets a callback that will be raised when the node will be disposed
  102183. */
  102184. set onDispose(callback: () => void);
  102185. /**
  102186. * Creates a new Node
  102187. * @param name the name and id to be given to this node
  102188. * @param scene the scene this node will be added to
  102189. */
  102190. constructor(name: string, scene?: Nullable<Scene>);
  102191. /**
  102192. * Gets the scene of the node
  102193. * @returns a scene
  102194. */
  102195. getScene(): Scene;
  102196. /**
  102197. * Gets the engine of the node
  102198. * @returns a Engine
  102199. */
  102200. getEngine(): Engine;
  102201. private _behaviors;
  102202. /**
  102203. * Attach a behavior to the node
  102204. * @see http://doc.babylonjs.com/features/behaviour
  102205. * @param behavior defines the behavior to attach
  102206. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  102207. * @returns the current Node
  102208. */
  102209. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  102210. /**
  102211. * Remove an attached behavior
  102212. * @see http://doc.babylonjs.com/features/behaviour
  102213. * @param behavior defines the behavior to attach
  102214. * @returns the current Node
  102215. */
  102216. removeBehavior(behavior: Behavior<Node>): Node;
  102217. /**
  102218. * Gets the list of attached behaviors
  102219. * @see http://doc.babylonjs.com/features/behaviour
  102220. */
  102221. get behaviors(): Behavior<Node>[];
  102222. /**
  102223. * Gets an attached behavior by name
  102224. * @param name defines the name of the behavior to look for
  102225. * @see http://doc.babylonjs.com/features/behaviour
  102226. * @returns null if behavior was not found else the requested behavior
  102227. */
  102228. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  102229. /**
  102230. * Returns the latest update of the World matrix
  102231. * @returns a Matrix
  102232. */
  102233. getWorldMatrix(): Matrix;
  102234. /** @hidden */
  102235. _getWorldMatrixDeterminant(): number;
  102236. /**
  102237. * Returns directly the latest state of the mesh World matrix.
  102238. * A Matrix is returned.
  102239. */
  102240. get worldMatrixFromCache(): Matrix;
  102241. /** @hidden */
  102242. _initCache(): void;
  102243. /** @hidden */
  102244. updateCache(force?: boolean): void;
  102245. /** @hidden */
  102246. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102247. /** @hidden */
  102248. _updateCache(ignoreParentClass?: boolean): void;
  102249. /** @hidden */
  102250. _isSynchronized(): boolean;
  102251. /** @hidden */
  102252. _markSyncedWithParent(): void;
  102253. /** @hidden */
  102254. isSynchronizedWithParent(): boolean;
  102255. /** @hidden */
  102256. isSynchronized(): boolean;
  102257. /**
  102258. * Is this node ready to be used/rendered
  102259. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  102260. * @return true if the node is ready
  102261. */
  102262. isReady(completeCheck?: boolean): boolean;
  102263. /**
  102264. * Is this node enabled?
  102265. * 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
  102266. * @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
  102267. * @return whether this node (and its parent) is enabled
  102268. */
  102269. isEnabled(checkAncestors?: boolean): boolean;
  102270. /** @hidden */
  102271. protected _syncParentEnabledState(): void;
  102272. /**
  102273. * Set the enabled state of this node
  102274. * @param value defines the new enabled state
  102275. */
  102276. setEnabled(value: boolean): void;
  102277. /**
  102278. * Is this node a descendant of the given node?
  102279. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  102280. * @param ancestor defines the parent node to inspect
  102281. * @returns a boolean indicating if this node is a descendant of the given node
  102282. */
  102283. isDescendantOf(ancestor: Node): boolean;
  102284. /** @hidden */
  102285. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  102286. /**
  102287. * Will return all nodes that have this node as ascendant
  102288. * @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
  102289. * @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
  102290. * @return all children nodes of all types
  102291. */
  102292. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  102293. /**
  102294. * Get all child-meshes of this node
  102295. * @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)
  102296. * @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
  102297. * @returns an array of AbstractMesh
  102298. */
  102299. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  102300. /**
  102301. * Get all direct children of this node
  102302. * @param predicate defines an optional predicate that will be called on every evaluated child, the predicate must return true for a given child to be part of the result, otherwise it will be ignored
  102303. * @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)
  102304. * @returns an array of Node
  102305. */
  102306. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  102307. /** @hidden */
  102308. _setReady(state: boolean): void;
  102309. /**
  102310. * Get an animation by name
  102311. * @param name defines the name of the animation to look for
  102312. * @returns null if not found else the requested animation
  102313. */
  102314. getAnimationByName(name: string): Nullable<Animation>;
  102315. /**
  102316. * Creates an animation range for this node
  102317. * @param name defines the name of the range
  102318. * @param from defines the starting key
  102319. * @param to defines the end key
  102320. */
  102321. createAnimationRange(name: string, from: number, to: number): void;
  102322. /**
  102323. * Delete a specific animation range
  102324. * @param name defines the name of the range to delete
  102325. * @param deleteFrames defines if animation frames from the range must be deleted as well
  102326. */
  102327. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  102328. /**
  102329. * Get an animation range by name
  102330. * @param name defines the name of the animation range to look for
  102331. * @returns null if not found else the requested animation range
  102332. */
  102333. getAnimationRange(name: string): Nullable<AnimationRange>;
  102334. /**
  102335. * Gets the list of all animation ranges defined on this node
  102336. * @returns an array
  102337. */
  102338. getAnimationRanges(): Nullable<AnimationRange>[];
  102339. /**
  102340. * Will start the animation sequence
  102341. * @param name defines the range frames for animation sequence
  102342. * @param loop defines if the animation should loop (false by default)
  102343. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  102344. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  102345. * @returns the object created for this animation. If range does not exist, it will return null
  102346. */
  102347. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  102348. /**
  102349. * Serialize animation ranges into a JSON compatible object
  102350. * @returns serialization object
  102351. */
  102352. serializeAnimationRanges(): any;
  102353. /**
  102354. * Computes the world matrix of the node
  102355. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  102356. * @returns the world matrix
  102357. */
  102358. computeWorldMatrix(force?: boolean): Matrix;
  102359. /**
  102360. * Releases resources associated with this node.
  102361. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  102362. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  102363. */
  102364. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  102365. /**
  102366. * Parse animation range data from a serialization object and store them into a given node
  102367. * @param node defines where to store the animation ranges
  102368. * @param parsedNode defines the serialization object to read data from
  102369. * @param scene defines the hosting scene
  102370. */
  102371. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  102372. /**
  102373. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  102374. * @param includeDescendants Include bounding info from descendants as well (true by default)
  102375. * @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
  102376. * @returns the new bounding vectors
  102377. */
  102378. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  102379. min: Vector3;
  102380. max: Vector3;
  102381. };
  102382. }
  102383. }
  102384. declare module BABYLON {
  102385. /**
  102386. * @hidden
  102387. */
  102388. export class _IAnimationState {
  102389. key: number;
  102390. repeatCount: number;
  102391. workValue?: any;
  102392. loopMode?: number;
  102393. offsetValue?: any;
  102394. highLimitValue?: any;
  102395. }
  102396. /**
  102397. * Class used to store any kind of animation
  102398. */
  102399. export class Animation {
  102400. /**Name of the animation */
  102401. name: string;
  102402. /**Property to animate */
  102403. targetProperty: string;
  102404. /**The frames per second of the animation */
  102405. framePerSecond: number;
  102406. /**The data type of the animation */
  102407. dataType: number;
  102408. /**The loop mode of the animation */
  102409. loopMode?: number | undefined;
  102410. /**Specifies if blending should be enabled */
  102411. enableBlending?: boolean | undefined;
  102412. /**
  102413. * Use matrix interpolation instead of using direct key value when animating matrices
  102414. */
  102415. static AllowMatricesInterpolation: boolean;
  102416. /**
  102417. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  102418. */
  102419. static AllowMatrixDecomposeForInterpolation: boolean;
  102420. /**
  102421. * Stores the key frames of the animation
  102422. */
  102423. private _keys;
  102424. /**
  102425. * Stores the easing function of the animation
  102426. */
  102427. private _easingFunction;
  102428. /**
  102429. * @hidden Internal use only
  102430. */
  102431. _runtimeAnimations: RuntimeAnimation[];
  102432. /**
  102433. * The set of event that will be linked to this animation
  102434. */
  102435. private _events;
  102436. /**
  102437. * Stores an array of target property paths
  102438. */
  102439. targetPropertyPath: string[];
  102440. /**
  102441. * Stores the blending speed of the animation
  102442. */
  102443. blendingSpeed: number;
  102444. /**
  102445. * Stores the animation ranges for the animation
  102446. */
  102447. private _ranges;
  102448. /**
  102449. * @hidden Internal use
  102450. */
  102451. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  102452. /**
  102453. * Sets up an animation
  102454. * @param property The property to animate
  102455. * @param animationType The animation type to apply
  102456. * @param framePerSecond The frames per second of the animation
  102457. * @param easingFunction The easing function used in the animation
  102458. * @returns The created animation
  102459. */
  102460. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  102461. /**
  102462. * Create and start an animation on a node
  102463. * @param name defines the name of the global animation that will be run on all nodes
  102464. * @param node defines the root node where the animation will take place
  102465. * @param targetProperty defines property to animate
  102466. * @param framePerSecond defines the number of frame per second yo use
  102467. * @param totalFrame defines the number of frames in total
  102468. * @param from defines the initial value
  102469. * @param to defines the final value
  102470. * @param loopMode defines which loop mode you want to use (off by default)
  102471. * @param easingFunction defines the easing function to use (linear by default)
  102472. * @param onAnimationEnd defines the callback to call when animation end
  102473. * @returns the animatable created for this animation
  102474. */
  102475. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102476. /**
  102477. * Create and start an animation on a node and its descendants
  102478. * @param name defines the name of the global animation that will be run on all nodes
  102479. * @param node defines the root node where the animation will take place
  102480. * @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
  102481. * @param targetProperty defines property to animate
  102482. * @param framePerSecond defines the number of frame per second to use
  102483. * @param totalFrame defines the number of frames in total
  102484. * @param from defines the initial value
  102485. * @param to defines the final value
  102486. * @param loopMode defines which loop mode you want to use (off by default)
  102487. * @param easingFunction defines the easing function to use (linear by default)
  102488. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  102489. * @returns the list of animatables created for all nodes
  102490. * @example https://www.babylonjs-playground.com/#MH0VLI
  102491. */
  102492. 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[]>;
  102493. /**
  102494. * Creates a new animation, merges it with the existing animations and starts it
  102495. * @param name Name of the animation
  102496. * @param node Node which contains the scene that begins the animations
  102497. * @param targetProperty Specifies which property to animate
  102498. * @param framePerSecond The frames per second of the animation
  102499. * @param totalFrame The total number of frames
  102500. * @param from The frame at the beginning of the animation
  102501. * @param to The frame at the end of the animation
  102502. * @param loopMode Specifies the loop mode of the animation
  102503. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  102504. * @param onAnimationEnd Callback to run once the animation is complete
  102505. * @returns Nullable animation
  102506. */
  102507. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  102508. /**
  102509. * Transition property of an host to the target Value
  102510. * @param property The property to transition
  102511. * @param targetValue The target Value of the property
  102512. * @param host The object where the property to animate belongs
  102513. * @param scene Scene used to run the animation
  102514. * @param frameRate Framerate (in frame/s) to use
  102515. * @param transition The transition type we want to use
  102516. * @param duration The duration of the animation, in milliseconds
  102517. * @param onAnimationEnd Callback trigger at the end of the animation
  102518. * @returns Nullable animation
  102519. */
  102520. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  102521. /**
  102522. * Return the array of runtime animations currently using this animation
  102523. */
  102524. get runtimeAnimations(): RuntimeAnimation[];
  102525. /**
  102526. * Specifies if any of the runtime animations are currently running
  102527. */
  102528. get hasRunningRuntimeAnimations(): boolean;
  102529. /**
  102530. * Initializes the animation
  102531. * @param name Name of the animation
  102532. * @param targetProperty Property to animate
  102533. * @param framePerSecond The frames per second of the animation
  102534. * @param dataType The data type of the animation
  102535. * @param loopMode The loop mode of the animation
  102536. * @param enableBlending Specifies if blending should be enabled
  102537. */
  102538. constructor(
  102539. /**Name of the animation */
  102540. name: string,
  102541. /**Property to animate */
  102542. targetProperty: string,
  102543. /**The frames per second of the animation */
  102544. framePerSecond: number,
  102545. /**The data type of the animation */
  102546. dataType: number,
  102547. /**The loop mode of the animation */
  102548. loopMode?: number | undefined,
  102549. /**Specifies if blending should be enabled */
  102550. enableBlending?: boolean | undefined);
  102551. /**
  102552. * Converts the animation to a string
  102553. * @param fullDetails support for multiple levels of logging within scene loading
  102554. * @returns String form of the animation
  102555. */
  102556. toString(fullDetails?: boolean): string;
  102557. /**
  102558. * Add an event to this animation
  102559. * @param event Event to add
  102560. */
  102561. addEvent(event: AnimationEvent): void;
  102562. /**
  102563. * Remove all events found at the given frame
  102564. * @param frame The frame to remove events from
  102565. */
  102566. removeEvents(frame: number): void;
  102567. /**
  102568. * Retrieves all the events from the animation
  102569. * @returns Events from the animation
  102570. */
  102571. getEvents(): AnimationEvent[];
  102572. /**
  102573. * Creates an animation range
  102574. * @param name Name of the animation range
  102575. * @param from Starting frame of the animation range
  102576. * @param to Ending frame of the animation
  102577. */
  102578. createRange(name: string, from: number, to: number): void;
  102579. /**
  102580. * Deletes an animation range by name
  102581. * @param name Name of the animation range to delete
  102582. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  102583. */
  102584. deleteRange(name: string, deleteFrames?: boolean): void;
  102585. /**
  102586. * Gets the animation range by name, or null if not defined
  102587. * @param name Name of the animation range
  102588. * @returns Nullable animation range
  102589. */
  102590. getRange(name: string): Nullable<AnimationRange>;
  102591. /**
  102592. * Gets the key frames from the animation
  102593. * @returns The key frames of the animation
  102594. */
  102595. getKeys(): Array<IAnimationKey>;
  102596. /**
  102597. * Gets the highest frame rate of the animation
  102598. * @returns Highest frame rate of the animation
  102599. */
  102600. getHighestFrame(): number;
  102601. /**
  102602. * Gets the easing function of the animation
  102603. * @returns Easing function of the animation
  102604. */
  102605. getEasingFunction(): IEasingFunction;
  102606. /**
  102607. * Sets the easing function of the animation
  102608. * @param easingFunction A custom mathematical formula for animation
  102609. */
  102610. setEasingFunction(easingFunction: EasingFunction): void;
  102611. /**
  102612. * Interpolates a scalar linearly
  102613. * @param startValue Start value of the animation curve
  102614. * @param endValue End value of the animation curve
  102615. * @param gradient Scalar amount to interpolate
  102616. * @returns Interpolated scalar value
  102617. */
  102618. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  102619. /**
  102620. * Interpolates a scalar cubically
  102621. * @param startValue Start value of the animation curve
  102622. * @param outTangent End tangent of the animation
  102623. * @param endValue End value of the animation curve
  102624. * @param inTangent Start tangent of the animation curve
  102625. * @param gradient Scalar amount to interpolate
  102626. * @returns Interpolated scalar value
  102627. */
  102628. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  102629. /**
  102630. * Interpolates a quaternion using a spherical linear interpolation
  102631. * @param startValue Start value of the animation curve
  102632. * @param endValue End value of the animation curve
  102633. * @param gradient Scalar amount to interpolate
  102634. * @returns Interpolated quaternion value
  102635. */
  102636. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  102637. /**
  102638. * Interpolates a quaternion cubically
  102639. * @param startValue Start value of the animation curve
  102640. * @param outTangent End tangent of the animation curve
  102641. * @param endValue End value of the animation curve
  102642. * @param inTangent Start tangent of the animation curve
  102643. * @param gradient Scalar amount to interpolate
  102644. * @returns Interpolated quaternion value
  102645. */
  102646. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  102647. /**
  102648. * Interpolates a Vector3 linearl
  102649. * @param startValue Start value of the animation curve
  102650. * @param endValue End value of the animation curve
  102651. * @param gradient Scalar amount to interpolate
  102652. * @returns Interpolated scalar value
  102653. */
  102654. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  102655. /**
  102656. * Interpolates a Vector3 cubically
  102657. * @param startValue Start value of the animation curve
  102658. * @param outTangent End tangent of the animation
  102659. * @param endValue End value of the animation curve
  102660. * @param inTangent Start tangent of the animation curve
  102661. * @param gradient Scalar amount to interpolate
  102662. * @returns InterpolatedVector3 value
  102663. */
  102664. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  102665. /**
  102666. * Interpolates a Vector2 linearly
  102667. * @param startValue Start value of the animation curve
  102668. * @param endValue End value of the animation curve
  102669. * @param gradient Scalar amount to interpolate
  102670. * @returns Interpolated Vector2 value
  102671. */
  102672. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  102673. /**
  102674. * Interpolates a Vector2 cubically
  102675. * @param startValue Start value of the animation curve
  102676. * @param outTangent End tangent of the animation
  102677. * @param endValue End value of the animation curve
  102678. * @param inTangent Start tangent of the animation curve
  102679. * @param gradient Scalar amount to interpolate
  102680. * @returns Interpolated Vector2 value
  102681. */
  102682. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  102683. /**
  102684. * Interpolates a size linearly
  102685. * @param startValue Start value of the animation curve
  102686. * @param endValue End value of the animation curve
  102687. * @param gradient Scalar amount to interpolate
  102688. * @returns Interpolated Size value
  102689. */
  102690. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  102691. /**
  102692. * Interpolates a Color3 linearly
  102693. * @param startValue Start value of the animation curve
  102694. * @param endValue End value of the animation curve
  102695. * @param gradient Scalar amount to interpolate
  102696. * @returns Interpolated Color3 value
  102697. */
  102698. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  102699. /**
  102700. * Interpolates a Color4 linearly
  102701. * @param startValue Start value of the animation curve
  102702. * @param endValue End value of the animation curve
  102703. * @param gradient Scalar amount to interpolate
  102704. * @returns Interpolated Color3 value
  102705. */
  102706. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  102707. /**
  102708. * @hidden Internal use only
  102709. */
  102710. _getKeyValue(value: any): any;
  102711. /**
  102712. * @hidden Internal use only
  102713. */
  102714. _interpolate(currentFrame: number, state: _IAnimationState): any;
  102715. /**
  102716. * Defines the function to use to interpolate matrices
  102717. * @param startValue defines the start matrix
  102718. * @param endValue defines the end matrix
  102719. * @param gradient defines the gradient between both matrices
  102720. * @param result defines an optional target matrix where to store the interpolation
  102721. * @returns the interpolated matrix
  102722. */
  102723. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  102724. /**
  102725. * Makes a copy of the animation
  102726. * @returns Cloned animation
  102727. */
  102728. clone(): Animation;
  102729. /**
  102730. * Sets the key frames of the animation
  102731. * @param values The animation key frames to set
  102732. */
  102733. setKeys(values: Array<IAnimationKey>): void;
  102734. /**
  102735. * Serializes the animation to an object
  102736. * @returns Serialized object
  102737. */
  102738. serialize(): any;
  102739. /**
  102740. * Float animation type
  102741. */
  102742. static readonly ANIMATIONTYPE_FLOAT: number;
  102743. /**
  102744. * Vector3 animation type
  102745. */
  102746. static readonly ANIMATIONTYPE_VECTOR3: number;
  102747. /**
  102748. * Quaternion animation type
  102749. */
  102750. static readonly ANIMATIONTYPE_QUATERNION: number;
  102751. /**
  102752. * Matrix animation type
  102753. */
  102754. static readonly ANIMATIONTYPE_MATRIX: number;
  102755. /**
  102756. * Color3 animation type
  102757. */
  102758. static readonly ANIMATIONTYPE_COLOR3: number;
  102759. /**
  102760. * Color3 animation type
  102761. */
  102762. static readonly ANIMATIONTYPE_COLOR4: number;
  102763. /**
  102764. * Vector2 animation type
  102765. */
  102766. static readonly ANIMATIONTYPE_VECTOR2: number;
  102767. /**
  102768. * Size animation type
  102769. */
  102770. static readonly ANIMATIONTYPE_SIZE: number;
  102771. /**
  102772. * Relative Loop Mode
  102773. */
  102774. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  102775. /**
  102776. * Cycle Loop Mode
  102777. */
  102778. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  102779. /**
  102780. * Constant Loop Mode
  102781. */
  102782. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  102783. /** @hidden */
  102784. static _UniversalLerp(left: any, right: any, amount: number): any;
  102785. /**
  102786. * Parses an animation object and creates an animation
  102787. * @param parsedAnimation Parsed animation object
  102788. * @returns Animation object
  102789. */
  102790. static Parse(parsedAnimation: any): Animation;
  102791. /**
  102792. * Appends the serialized animations from the source animations
  102793. * @param source Source containing the animations
  102794. * @param destination Target to store the animations
  102795. */
  102796. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102797. }
  102798. }
  102799. declare module BABYLON {
  102800. /**
  102801. * Interface containing an array of animations
  102802. */
  102803. export interface IAnimatable {
  102804. /**
  102805. * Array of animations
  102806. */
  102807. animations: Nullable<Array<Animation>>;
  102808. }
  102809. }
  102810. declare module BABYLON {
  102811. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  102812. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102813. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102814. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102815. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102816. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102817. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102818. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102819. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102820. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102821. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102822. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102823. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102824. /**
  102825. * Decorator used to define property that can be serialized as reference to a camera
  102826. * @param sourceName defines the name of the property to decorate
  102827. */
  102828. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  102829. /**
  102830. * Class used to help serialization objects
  102831. */
  102832. export class SerializationHelper {
  102833. /** @hidden */
  102834. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  102835. /** @hidden */
  102836. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  102837. /** @hidden */
  102838. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  102839. /** @hidden */
  102840. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  102841. /**
  102842. * Appends the serialized animations from the source animations
  102843. * @param source Source containing the animations
  102844. * @param destination Target to store the animations
  102845. */
  102846. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  102847. /**
  102848. * Static function used to serialized a specific entity
  102849. * @param entity defines the entity to serialize
  102850. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  102851. * @returns a JSON compatible object representing the serialization of the entity
  102852. */
  102853. static Serialize<T>(entity: T, serializationObject?: any): any;
  102854. /**
  102855. * Creates a new entity from a serialization data object
  102856. * @param creationFunction defines a function used to instanciated the new entity
  102857. * @param source defines the source serialization data
  102858. * @param scene defines the hosting scene
  102859. * @param rootUrl defines the root url for resources
  102860. * @returns a new entity
  102861. */
  102862. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  102863. /**
  102864. * Clones an object
  102865. * @param creationFunction defines the function used to instanciate the new object
  102866. * @param source defines the source object
  102867. * @returns the cloned object
  102868. */
  102869. static Clone<T>(creationFunction: () => T, source: T): T;
  102870. /**
  102871. * Instanciates a new object based on a source one (some data will be shared between both object)
  102872. * @param creationFunction defines the function used to instanciate the new object
  102873. * @param source defines the source object
  102874. * @returns the new object
  102875. */
  102876. static Instanciate<T>(creationFunction: () => T, source: T): T;
  102877. }
  102878. }
  102879. declare module BABYLON {
  102880. /**
  102881. * Class used to manipulate GUIDs
  102882. */
  102883. export class GUID {
  102884. /**
  102885. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  102886. * Be aware Math.random() could cause collisions, but:
  102887. * "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"
  102888. * @returns a pseudo random id
  102889. */
  102890. static RandomId(): string;
  102891. }
  102892. }
  102893. declare module BABYLON {
  102894. /**
  102895. * Base class of all the textures in babylon.
  102896. * It groups all the common properties the materials, post process, lights... might need
  102897. * in order to make a correct use of the texture.
  102898. */
  102899. export class BaseTexture implements IAnimatable {
  102900. /**
  102901. * Default anisotropic filtering level for the application.
  102902. * It is set to 4 as a good tradeoff between perf and quality.
  102903. */
  102904. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  102905. /**
  102906. * Gets or sets the unique id of the texture
  102907. */
  102908. uniqueId: number;
  102909. /**
  102910. * Define the name of the texture.
  102911. */
  102912. name: string;
  102913. /**
  102914. * Gets or sets an object used to store user defined information.
  102915. */
  102916. metadata: any;
  102917. /**
  102918. * For internal use only. Please do not use.
  102919. */
  102920. reservedDataStore: any;
  102921. private _hasAlpha;
  102922. /**
  102923. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  102924. */
  102925. set hasAlpha(value: boolean);
  102926. get hasAlpha(): boolean;
  102927. /**
  102928. * Defines if the alpha value should be determined via the rgb values.
  102929. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  102930. */
  102931. getAlphaFromRGB: boolean;
  102932. /**
  102933. * Intensity or strength of the texture.
  102934. * It is commonly used by materials to fine tune the intensity of the texture
  102935. */
  102936. level: number;
  102937. /**
  102938. * Define the UV chanel to use starting from 0 and defaulting to 0.
  102939. * This is part of the texture as textures usually maps to one uv set.
  102940. */
  102941. coordinatesIndex: number;
  102942. private _coordinatesMode;
  102943. /**
  102944. * How a texture is mapped.
  102945. *
  102946. * | Value | Type | Description |
  102947. * | ----- | ----------------------------------- | ----------- |
  102948. * | 0 | EXPLICIT_MODE | |
  102949. * | 1 | SPHERICAL_MODE | |
  102950. * | 2 | PLANAR_MODE | |
  102951. * | 3 | CUBIC_MODE | |
  102952. * | 4 | PROJECTION_MODE | |
  102953. * | 5 | SKYBOX_MODE | |
  102954. * | 6 | INVCUBIC_MODE | |
  102955. * | 7 | EQUIRECTANGULAR_MODE | |
  102956. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  102957. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  102958. */
  102959. set coordinatesMode(value: number);
  102960. get coordinatesMode(): number;
  102961. /**
  102962. * | Value | Type | Description |
  102963. * | ----- | ------------------ | ----------- |
  102964. * | 0 | CLAMP_ADDRESSMODE | |
  102965. * | 1 | WRAP_ADDRESSMODE | |
  102966. * | 2 | MIRROR_ADDRESSMODE | |
  102967. */
  102968. wrapU: number;
  102969. /**
  102970. * | Value | Type | Description |
  102971. * | ----- | ------------------ | ----------- |
  102972. * | 0 | CLAMP_ADDRESSMODE | |
  102973. * | 1 | WRAP_ADDRESSMODE | |
  102974. * | 2 | MIRROR_ADDRESSMODE | |
  102975. */
  102976. wrapV: number;
  102977. /**
  102978. * | Value | Type | Description |
  102979. * | ----- | ------------------ | ----------- |
  102980. * | 0 | CLAMP_ADDRESSMODE | |
  102981. * | 1 | WRAP_ADDRESSMODE | |
  102982. * | 2 | MIRROR_ADDRESSMODE | |
  102983. */
  102984. wrapR: number;
  102985. /**
  102986. * With compliant hardware and browser (supporting anisotropic filtering)
  102987. * this defines the level of anisotropic filtering in the texture.
  102988. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  102989. */
  102990. anisotropicFilteringLevel: number;
  102991. /**
  102992. * Define if the texture is a cube texture or if false a 2d texture.
  102993. */
  102994. get isCube(): boolean;
  102995. set isCube(value: boolean);
  102996. /**
  102997. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  102998. */
  102999. get is3D(): boolean;
  103000. set is3D(value: boolean);
  103001. /**
  103002. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  103003. */
  103004. get is2DArray(): boolean;
  103005. set is2DArray(value: boolean);
  103006. /**
  103007. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  103008. * HDR texture are usually stored in linear space.
  103009. * This only impacts the PBR and Background materials
  103010. */
  103011. gammaSpace: boolean;
  103012. /**
  103013. * Gets or sets whether or not the texture contains RGBD data.
  103014. */
  103015. get isRGBD(): boolean;
  103016. set isRGBD(value: boolean);
  103017. /**
  103018. * Is Z inverted in the texture (useful in a cube texture).
  103019. */
  103020. invertZ: boolean;
  103021. /**
  103022. * Are mip maps generated for this texture or not.
  103023. */
  103024. get noMipmap(): boolean;
  103025. /**
  103026. * @hidden
  103027. */
  103028. lodLevelInAlpha: boolean;
  103029. /**
  103030. * With prefiltered texture, defined the offset used during the prefiltering steps.
  103031. */
  103032. get lodGenerationOffset(): number;
  103033. set lodGenerationOffset(value: number);
  103034. /**
  103035. * With prefiltered texture, defined the scale used during the prefiltering steps.
  103036. */
  103037. get lodGenerationScale(): number;
  103038. set lodGenerationScale(value: number);
  103039. /**
  103040. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  103041. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  103042. * average roughness values.
  103043. */
  103044. get linearSpecularLOD(): boolean;
  103045. set linearSpecularLOD(value: boolean);
  103046. /**
  103047. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  103048. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  103049. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  103050. */
  103051. get irradianceTexture(): Nullable<BaseTexture>;
  103052. set irradianceTexture(value: Nullable<BaseTexture>);
  103053. /**
  103054. * Define if the texture is a render target.
  103055. */
  103056. isRenderTarget: boolean;
  103057. /**
  103058. * Define the unique id of the texture in the scene.
  103059. */
  103060. get uid(): string;
  103061. /**
  103062. * Return a string representation of the texture.
  103063. * @returns the texture as a string
  103064. */
  103065. toString(): string;
  103066. /**
  103067. * Get the class name of the texture.
  103068. * @returns "BaseTexture"
  103069. */
  103070. getClassName(): string;
  103071. /**
  103072. * Define the list of animation attached to the texture.
  103073. */
  103074. animations: Animation[];
  103075. /**
  103076. * An event triggered when the texture is disposed.
  103077. */
  103078. onDisposeObservable: Observable<BaseTexture>;
  103079. private _onDisposeObserver;
  103080. /**
  103081. * Callback triggered when the texture has been disposed.
  103082. * Kept for back compatibility, you can use the onDisposeObservable instead.
  103083. */
  103084. set onDispose(callback: () => void);
  103085. /**
  103086. * Define the current state of the loading sequence when in delayed load mode.
  103087. */
  103088. delayLoadState: number;
  103089. private _scene;
  103090. /** @hidden */
  103091. _texture: Nullable<InternalTexture>;
  103092. private _uid;
  103093. /**
  103094. * Define if the texture is preventinga material to render or not.
  103095. * If not and the texture is not ready, the engine will use a default black texture instead.
  103096. */
  103097. get isBlocking(): boolean;
  103098. /**
  103099. * Instantiates a new BaseTexture.
  103100. * Base class of all the textures in babylon.
  103101. * It groups all the common properties the materials, post process, lights... might need
  103102. * in order to make a correct use of the texture.
  103103. * @param scene Define the scene the texture blongs to
  103104. */
  103105. constructor(scene: Nullable<Scene>);
  103106. /**
  103107. * Get the scene the texture belongs to.
  103108. * @returns the scene or null if undefined
  103109. */
  103110. getScene(): Nullable<Scene>;
  103111. /**
  103112. * Get the texture transform matrix used to offset tile the texture for istance.
  103113. * @returns the transformation matrix
  103114. */
  103115. getTextureMatrix(): Matrix;
  103116. /**
  103117. * Get the texture reflection matrix used to rotate/transform the reflection.
  103118. * @returns the reflection matrix
  103119. */
  103120. getReflectionTextureMatrix(): Matrix;
  103121. /**
  103122. * Get the underlying lower level texture from Babylon.
  103123. * @returns the insternal texture
  103124. */
  103125. getInternalTexture(): Nullable<InternalTexture>;
  103126. /**
  103127. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  103128. * @returns true if ready or not blocking
  103129. */
  103130. isReadyOrNotBlocking(): boolean;
  103131. /**
  103132. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  103133. * @returns true if fully ready
  103134. */
  103135. isReady(): boolean;
  103136. private _cachedSize;
  103137. /**
  103138. * Get the size of the texture.
  103139. * @returns the texture size.
  103140. */
  103141. getSize(): ISize;
  103142. /**
  103143. * Get the base size of the texture.
  103144. * It can be different from the size if the texture has been resized for POT for instance
  103145. * @returns the base size
  103146. */
  103147. getBaseSize(): ISize;
  103148. /**
  103149. * Update the sampling mode of the texture.
  103150. * Default is Trilinear mode.
  103151. *
  103152. * | Value | Type | Description |
  103153. * | ----- | ------------------ | ----------- |
  103154. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  103155. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  103156. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  103157. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  103158. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  103159. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  103160. * | 7 | NEAREST_LINEAR | |
  103161. * | 8 | NEAREST_NEAREST | |
  103162. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  103163. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  103164. * | 11 | LINEAR_LINEAR | |
  103165. * | 12 | LINEAR_NEAREST | |
  103166. *
  103167. * > _mag_: magnification filter (close to the viewer)
  103168. * > _min_: minification filter (far from the viewer)
  103169. * > _mip_: filter used between mip map levels
  103170. *@param samplingMode Define the new sampling mode of the texture
  103171. */
  103172. updateSamplingMode(samplingMode: number): void;
  103173. /**
  103174. * Scales the texture if is `canRescale()`
  103175. * @param ratio the resize factor we want to use to rescale
  103176. */
  103177. scale(ratio: number): void;
  103178. /**
  103179. * Get if the texture can rescale.
  103180. */
  103181. get canRescale(): boolean;
  103182. /** @hidden */
  103183. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  103184. /** @hidden */
  103185. _rebuild(): void;
  103186. /**
  103187. * Triggers the load sequence in delayed load mode.
  103188. */
  103189. delayLoad(): void;
  103190. /**
  103191. * Clones the texture.
  103192. * @returns the cloned texture
  103193. */
  103194. clone(): Nullable<BaseTexture>;
  103195. /**
  103196. * Get the texture underlying type (INT, FLOAT...)
  103197. */
  103198. get textureType(): number;
  103199. /**
  103200. * Get the texture underlying format (RGB, RGBA...)
  103201. */
  103202. get textureFormat(): number;
  103203. /**
  103204. * Indicates that textures need to be re-calculated for all materials
  103205. */
  103206. protected _markAllSubMeshesAsTexturesDirty(): void;
  103207. /**
  103208. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  103209. * This will returns an RGBA array buffer containing either in values (0-255) or
  103210. * float values (0-1) depending of the underlying buffer type.
  103211. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  103212. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  103213. * @param buffer defines a user defined buffer to fill with data (can be null)
  103214. * @returns The Array buffer containing the pixels data.
  103215. */
  103216. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  103217. /**
  103218. * Release and destroy the underlying lower level texture aka internalTexture.
  103219. */
  103220. releaseInternalTexture(): void;
  103221. /** @hidden */
  103222. get _lodTextureHigh(): Nullable<BaseTexture>;
  103223. /** @hidden */
  103224. get _lodTextureMid(): Nullable<BaseTexture>;
  103225. /** @hidden */
  103226. get _lodTextureLow(): Nullable<BaseTexture>;
  103227. /**
  103228. * Dispose the texture and release its associated resources.
  103229. */
  103230. dispose(): void;
  103231. /**
  103232. * Serialize the texture into a JSON representation that can be parsed later on.
  103233. * @returns the JSON representation of the texture
  103234. */
  103235. serialize(): any;
  103236. /**
  103237. * Helper function to be called back once a list of texture contains only ready textures.
  103238. * @param textures Define the list of textures to wait for
  103239. * @param callback Define the callback triggered once the entire list will be ready
  103240. */
  103241. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  103242. }
  103243. }
  103244. declare module BABYLON {
  103245. /**
  103246. * Options to be used when creating an effect.
  103247. */
  103248. export interface IEffectCreationOptions {
  103249. /**
  103250. * Atrributes that will be used in the shader.
  103251. */
  103252. attributes: string[];
  103253. /**
  103254. * Uniform varible names that will be set in the shader.
  103255. */
  103256. uniformsNames: string[];
  103257. /**
  103258. * Uniform buffer variable names that will be set in the shader.
  103259. */
  103260. uniformBuffersNames: string[];
  103261. /**
  103262. * Sampler texture variable names that will be set in the shader.
  103263. */
  103264. samplers: string[];
  103265. /**
  103266. * Define statements that will be set in the shader.
  103267. */
  103268. defines: any;
  103269. /**
  103270. * Possible fallbacks for this effect to improve performance when needed.
  103271. */
  103272. fallbacks: Nullable<IEffectFallbacks>;
  103273. /**
  103274. * Callback that will be called when the shader is compiled.
  103275. */
  103276. onCompiled: Nullable<(effect: Effect) => void>;
  103277. /**
  103278. * Callback that will be called if an error occurs during shader compilation.
  103279. */
  103280. onError: Nullable<(effect: Effect, errors: string) => void>;
  103281. /**
  103282. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103283. */
  103284. indexParameters?: any;
  103285. /**
  103286. * Max number of lights that can be used in the shader.
  103287. */
  103288. maxSimultaneousLights?: number;
  103289. /**
  103290. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  103291. */
  103292. transformFeedbackVaryings?: Nullable<string[]>;
  103293. }
  103294. /**
  103295. * Effect containing vertex and fragment shader that can be executed on an object.
  103296. */
  103297. export class Effect implements IDisposable {
  103298. /**
  103299. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  103300. */
  103301. static ShadersRepository: string;
  103302. /**
  103303. * Name of the effect.
  103304. */
  103305. name: any;
  103306. /**
  103307. * String container all the define statements that should be set on the shader.
  103308. */
  103309. defines: string;
  103310. /**
  103311. * Callback that will be called when the shader is compiled.
  103312. */
  103313. onCompiled: Nullable<(effect: Effect) => void>;
  103314. /**
  103315. * Callback that will be called if an error occurs during shader compilation.
  103316. */
  103317. onError: Nullable<(effect: Effect, errors: string) => void>;
  103318. /**
  103319. * Callback that will be called when effect is bound.
  103320. */
  103321. onBind: Nullable<(effect: Effect) => void>;
  103322. /**
  103323. * Unique ID of the effect.
  103324. */
  103325. uniqueId: number;
  103326. /**
  103327. * Observable that will be called when the shader is compiled.
  103328. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  103329. */
  103330. onCompileObservable: Observable<Effect>;
  103331. /**
  103332. * Observable that will be called if an error occurs during shader compilation.
  103333. */
  103334. onErrorObservable: Observable<Effect>;
  103335. /** @hidden */
  103336. _onBindObservable: Nullable<Observable<Effect>>;
  103337. /**
  103338. * @hidden
  103339. * Specifies if the effect was previously ready
  103340. */
  103341. _wasPreviouslyReady: boolean;
  103342. /**
  103343. * Observable that will be called when effect is bound.
  103344. */
  103345. get onBindObservable(): Observable<Effect>;
  103346. /** @hidden */
  103347. _bonesComputationForcedToCPU: boolean;
  103348. private static _uniqueIdSeed;
  103349. private _engine;
  103350. private _uniformBuffersNames;
  103351. private _uniformsNames;
  103352. private _samplerList;
  103353. private _samplers;
  103354. private _isReady;
  103355. private _compilationError;
  103356. private _allFallbacksProcessed;
  103357. private _attributesNames;
  103358. private _attributes;
  103359. private _attributeLocationByName;
  103360. private _uniforms;
  103361. /**
  103362. * Key for the effect.
  103363. * @hidden
  103364. */
  103365. _key: string;
  103366. private _indexParameters;
  103367. private _fallbacks;
  103368. private _vertexSourceCode;
  103369. private _fragmentSourceCode;
  103370. private _vertexSourceCodeOverride;
  103371. private _fragmentSourceCodeOverride;
  103372. private _transformFeedbackVaryings;
  103373. /**
  103374. * Compiled shader to webGL program.
  103375. * @hidden
  103376. */
  103377. _pipelineContext: Nullable<IPipelineContext>;
  103378. private _valueCache;
  103379. private static _baseCache;
  103380. /**
  103381. * Instantiates an effect.
  103382. * An effect can be used to create/manage/execute vertex and fragment shaders.
  103383. * @param baseName Name of the effect.
  103384. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  103385. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  103386. * @param samplers List of sampler variables that will be passed to the shader.
  103387. * @param engine Engine to be used to render the effect
  103388. * @param defines Define statements to be added to the shader.
  103389. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  103390. * @param onCompiled Callback that will be called when the shader is compiled.
  103391. * @param onError Callback that will be called if an error occurs during shader compilation.
  103392. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  103393. */
  103394. 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);
  103395. private _useFinalCode;
  103396. /**
  103397. * Unique key for this effect
  103398. */
  103399. get key(): string;
  103400. /**
  103401. * If the effect has been compiled and prepared.
  103402. * @returns if the effect is compiled and prepared.
  103403. */
  103404. isReady(): boolean;
  103405. private _isReadyInternal;
  103406. /**
  103407. * The engine the effect was initialized with.
  103408. * @returns the engine.
  103409. */
  103410. getEngine(): Engine;
  103411. /**
  103412. * The pipeline context for this effect
  103413. * @returns the associated pipeline context
  103414. */
  103415. getPipelineContext(): Nullable<IPipelineContext>;
  103416. /**
  103417. * The set of names of attribute variables for the shader.
  103418. * @returns An array of attribute names.
  103419. */
  103420. getAttributesNames(): string[];
  103421. /**
  103422. * Returns the attribute at the given index.
  103423. * @param index The index of the attribute.
  103424. * @returns The location of the attribute.
  103425. */
  103426. getAttributeLocation(index: number): number;
  103427. /**
  103428. * Returns the attribute based on the name of the variable.
  103429. * @param name of the attribute to look up.
  103430. * @returns the attribute location.
  103431. */
  103432. getAttributeLocationByName(name: string): number;
  103433. /**
  103434. * The number of attributes.
  103435. * @returns the numnber of attributes.
  103436. */
  103437. getAttributesCount(): number;
  103438. /**
  103439. * Gets the index of a uniform variable.
  103440. * @param uniformName of the uniform to look up.
  103441. * @returns the index.
  103442. */
  103443. getUniformIndex(uniformName: string): number;
  103444. /**
  103445. * Returns the attribute based on the name of the variable.
  103446. * @param uniformName of the uniform to look up.
  103447. * @returns the location of the uniform.
  103448. */
  103449. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  103450. /**
  103451. * Returns an array of sampler variable names
  103452. * @returns The array of sampler variable neames.
  103453. */
  103454. getSamplers(): string[];
  103455. /**
  103456. * The error from the last compilation.
  103457. * @returns the error string.
  103458. */
  103459. getCompilationError(): string;
  103460. /**
  103461. * Gets a boolean indicating that all fallbacks were used during compilation
  103462. * @returns true if all fallbacks were used
  103463. */
  103464. allFallbacksProcessed(): boolean;
  103465. /**
  103466. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  103467. * @param func The callback to be used.
  103468. */
  103469. executeWhenCompiled(func: (effect: Effect) => void): void;
  103470. private _checkIsReady;
  103471. private _loadShader;
  103472. /**
  103473. * Recompiles the webGL program
  103474. * @param vertexSourceCode The source code for the vertex shader.
  103475. * @param fragmentSourceCode The source code for the fragment shader.
  103476. * @param onCompiled Callback called when completed.
  103477. * @param onError Callback called on error.
  103478. * @hidden
  103479. */
  103480. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  103481. /**
  103482. * Prepares the effect
  103483. * @hidden
  103484. */
  103485. _prepareEffect(): void;
  103486. private _processCompilationErrors;
  103487. /**
  103488. * Checks if the effect is supported. (Must be called after compilation)
  103489. */
  103490. get isSupported(): boolean;
  103491. /**
  103492. * Binds a texture to the engine to be used as output of the shader.
  103493. * @param channel Name of the output variable.
  103494. * @param texture Texture to bind.
  103495. * @hidden
  103496. */
  103497. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  103498. /**
  103499. * Sets a texture on the engine to be used in the shader.
  103500. * @param channel Name of the sampler variable.
  103501. * @param texture Texture to set.
  103502. */
  103503. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  103504. /**
  103505. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  103506. * @param channel Name of the sampler variable.
  103507. * @param texture Texture to set.
  103508. */
  103509. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  103510. /**
  103511. * Sets an array of textures on the engine to be used in the shader.
  103512. * @param channel Name of the variable.
  103513. * @param textures Textures to set.
  103514. */
  103515. setTextureArray(channel: string, textures: BaseTexture[]): void;
  103516. /**
  103517. * 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)
  103518. * @param channel Name of the sampler variable.
  103519. * @param postProcess Post process to get the input texture from.
  103520. */
  103521. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  103522. /**
  103523. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  103524. * 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)
  103525. * @param channel Name of the sampler variable.
  103526. * @param postProcess Post process to get the output texture from.
  103527. */
  103528. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  103529. /** @hidden */
  103530. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  103531. /** @hidden */
  103532. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  103533. /** @hidden */
  103534. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  103535. /** @hidden */
  103536. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  103537. /**
  103538. * Binds a buffer to a uniform.
  103539. * @param buffer Buffer to bind.
  103540. * @param name Name of the uniform variable to bind to.
  103541. */
  103542. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  103543. /**
  103544. * Binds block to a uniform.
  103545. * @param blockName Name of the block to bind.
  103546. * @param index Index to bind.
  103547. */
  103548. bindUniformBlock(blockName: string, index: number): void;
  103549. /**
  103550. * Sets an interger value on a uniform variable.
  103551. * @param uniformName Name of the variable.
  103552. * @param value Value to be set.
  103553. * @returns this effect.
  103554. */
  103555. setInt(uniformName: string, value: number): Effect;
  103556. /**
  103557. * Sets an int array on a uniform variable.
  103558. * @param uniformName Name of the variable.
  103559. * @param array array to be set.
  103560. * @returns this effect.
  103561. */
  103562. setIntArray(uniformName: string, array: Int32Array): Effect;
  103563. /**
  103564. * 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)
  103565. * @param uniformName Name of the variable.
  103566. * @param array array to be set.
  103567. * @returns this effect.
  103568. */
  103569. setIntArray2(uniformName: string, array: Int32Array): Effect;
  103570. /**
  103571. * 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)
  103572. * @param uniformName Name of the variable.
  103573. * @param array array to be set.
  103574. * @returns this effect.
  103575. */
  103576. setIntArray3(uniformName: string, array: Int32Array): Effect;
  103577. /**
  103578. * 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)
  103579. * @param uniformName Name of the variable.
  103580. * @param array array to be set.
  103581. * @returns this effect.
  103582. */
  103583. setIntArray4(uniformName: string, array: Int32Array): Effect;
  103584. /**
  103585. * Sets an float array on a uniform variable.
  103586. * @param uniformName Name of the variable.
  103587. * @param array array to be set.
  103588. * @returns this effect.
  103589. */
  103590. setFloatArray(uniformName: string, array: Float32Array): Effect;
  103591. /**
  103592. * 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)
  103593. * @param uniformName Name of the variable.
  103594. * @param array array to be set.
  103595. * @returns this effect.
  103596. */
  103597. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  103598. /**
  103599. * 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)
  103600. * @param uniformName Name of the variable.
  103601. * @param array array to be set.
  103602. * @returns this effect.
  103603. */
  103604. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  103605. /**
  103606. * 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)
  103607. * @param uniformName Name of the variable.
  103608. * @param array array to be set.
  103609. * @returns this effect.
  103610. */
  103611. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  103612. /**
  103613. * Sets an array on a uniform variable.
  103614. * @param uniformName Name of the variable.
  103615. * @param array array to be set.
  103616. * @returns this effect.
  103617. */
  103618. setArray(uniformName: string, array: number[]): Effect;
  103619. /**
  103620. * 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)
  103621. * @param uniformName Name of the variable.
  103622. * @param array array to be set.
  103623. * @returns this effect.
  103624. */
  103625. setArray2(uniformName: string, array: number[]): Effect;
  103626. /**
  103627. * 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)
  103628. * @param uniformName Name of the variable.
  103629. * @param array array to be set.
  103630. * @returns this effect.
  103631. */
  103632. setArray3(uniformName: string, array: number[]): Effect;
  103633. /**
  103634. * 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)
  103635. * @param uniformName Name of the variable.
  103636. * @param array array to be set.
  103637. * @returns this effect.
  103638. */
  103639. setArray4(uniformName: string, array: number[]): Effect;
  103640. /**
  103641. * Sets matrices on a uniform variable.
  103642. * @param uniformName Name of the variable.
  103643. * @param matrices matrices to be set.
  103644. * @returns this effect.
  103645. */
  103646. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  103647. /**
  103648. * Sets matrix on a uniform variable.
  103649. * @param uniformName Name of the variable.
  103650. * @param matrix matrix to be set.
  103651. * @returns this effect.
  103652. */
  103653. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  103654. /**
  103655. * 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)
  103656. * @param uniformName Name of the variable.
  103657. * @param matrix matrix to be set.
  103658. * @returns this effect.
  103659. */
  103660. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  103661. /**
  103662. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  103663. * @param uniformName Name of the variable.
  103664. * @param matrix matrix to be set.
  103665. * @returns this effect.
  103666. */
  103667. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  103668. /**
  103669. * Sets a float on a uniform variable.
  103670. * @param uniformName Name of the variable.
  103671. * @param value value to be set.
  103672. * @returns this effect.
  103673. */
  103674. setFloat(uniformName: string, value: number): Effect;
  103675. /**
  103676. * Sets a boolean on a uniform variable.
  103677. * @param uniformName Name of the variable.
  103678. * @param bool value to be set.
  103679. * @returns this effect.
  103680. */
  103681. setBool(uniformName: string, bool: boolean): Effect;
  103682. /**
  103683. * Sets a Vector2 on a uniform variable.
  103684. * @param uniformName Name of the variable.
  103685. * @param vector2 vector2 to be set.
  103686. * @returns this effect.
  103687. */
  103688. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  103689. /**
  103690. * Sets a float2 on a uniform variable.
  103691. * @param uniformName Name of the variable.
  103692. * @param x First float in float2.
  103693. * @param y Second float in float2.
  103694. * @returns this effect.
  103695. */
  103696. setFloat2(uniformName: string, x: number, y: number): Effect;
  103697. /**
  103698. * Sets a Vector3 on a uniform variable.
  103699. * @param uniformName Name of the variable.
  103700. * @param vector3 Value to be set.
  103701. * @returns this effect.
  103702. */
  103703. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  103704. /**
  103705. * Sets a float3 on a uniform variable.
  103706. * @param uniformName Name of the variable.
  103707. * @param x First float in float3.
  103708. * @param y Second float in float3.
  103709. * @param z Third float in float3.
  103710. * @returns this effect.
  103711. */
  103712. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  103713. /**
  103714. * Sets a Vector4 on a uniform variable.
  103715. * @param uniformName Name of the variable.
  103716. * @param vector4 Value to be set.
  103717. * @returns this effect.
  103718. */
  103719. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  103720. /**
  103721. * Sets a float4 on a uniform variable.
  103722. * @param uniformName Name of the variable.
  103723. * @param x First float in float4.
  103724. * @param y Second float in float4.
  103725. * @param z Third float in float4.
  103726. * @param w Fourth float in float4.
  103727. * @returns this effect.
  103728. */
  103729. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  103730. /**
  103731. * Sets a Color3 on a uniform variable.
  103732. * @param uniformName Name of the variable.
  103733. * @param color3 Value to be set.
  103734. * @returns this effect.
  103735. */
  103736. setColor3(uniformName: string, color3: IColor3Like): Effect;
  103737. /**
  103738. * Sets a Color4 on a uniform variable.
  103739. * @param uniformName Name of the variable.
  103740. * @param color3 Value to be set.
  103741. * @param alpha Alpha value to be set.
  103742. * @returns this effect.
  103743. */
  103744. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  103745. /**
  103746. * Sets a Color4 on a uniform variable
  103747. * @param uniformName defines the name of the variable
  103748. * @param color4 defines the value to be set
  103749. * @returns this effect.
  103750. */
  103751. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  103752. /** Release all associated resources */
  103753. dispose(): void;
  103754. /**
  103755. * This function will add a new shader to the shader store
  103756. * @param name the name of the shader
  103757. * @param pixelShader optional pixel shader content
  103758. * @param vertexShader optional vertex shader content
  103759. */
  103760. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  103761. /**
  103762. * Store of each shader (The can be looked up using effect.key)
  103763. */
  103764. static ShadersStore: {
  103765. [key: string]: string;
  103766. };
  103767. /**
  103768. * Store of each included file for a shader (The can be looked up using effect.key)
  103769. */
  103770. static IncludesShadersStore: {
  103771. [key: string]: string;
  103772. };
  103773. /**
  103774. * Resets the cache of effects.
  103775. */
  103776. static ResetCache(): void;
  103777. }
  103778. }
  103779. declare module BABYLON {
  103780. /**
  103781. * Interface used to describe the capabilities of the engine relatively to the current browser
  103782. */
  103783. export interface EngineCapabilities {
  103784. /** Maximum textures units per fragment shader */
  103785. maxTexturesImageUnits: number;
  103786. /** Maximum texture units per vertex shader */
  103787. maxVertexTextureImageUnits: number;
  103788. /** Maximum textures units in the entire pipeline */
  103789. maxCombinedTexturesImageUnits: number;
  103790. /** Maximum texture size */
  103791. maxTextureSize: number;
  103792. /** Maximum texture samples */
  103793. maxSamples?: number;
  103794. /** Maximum cube texture size */
  103795. maxCubemapTextureSize: number;
  103796. /** Maximum render texture size */
  103797. maxRenderTextureSize: number;
  103798. /** Maximum number of vertex attributes */
  103799. maxVertexAttribs: number;
  103800. /** Maximum number of varyings */
  103801. maxVaryingVectors: number;
  103802. /** Maximum number of uniforms per vertex shader */
  103803. maxVertexUniformVectors: number;
  103804. /** Maximum number of uniforms per fragment shader */
  103805. maxFragmentUniformVectors: number;
  103806. /** Defines if standard derivates (dx/dy) are supported */
  103807. standardDerivatives: boolean;
  103808. /** Defines if s3tc texture compression is supported */
  103809. s3tc?: WEBGL_compressed_texture_s3tc;
  103810. /** Defines if pvrtc texture compression is supported */
  103811. pvrtc: any;
  103812. /** Defines if etc1 texture compression is supported */
  103813. etc1: any;
  103814. /** Defines if etc2 texture compression is supported */
  103815. etc2: any;
  103816. /** Defines if astc texture compression is supported */
  103817. astc: any;
  103818. /** Defines if float textures are supported */
  103819. textureFloat: boolean;
  103820. /** Defines if vertex array objects are supported */
  103821. vertexArrayObject: boolean;
  103822. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  103823. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  103824. /** Gets the maximum level of anisotropy supported */
  103825. maxAnisotropy: number;
  103826. /** Defines if instancing is supported */
  103827. instancedArrays: boolean;
  103828. /** Defines if 32 bits indices are supported */
  103829. uintIndices: boolean;
  103830. /** Defines if high precision shaders are supported */
  103831. highPrecisionShaderSupported: boolean;
  103832. /** Defines if depth reading in the fragment shader is supported */
  103833. fragmentDepthSupported: boolean;
  103834. /** Defines if float texture linear filtering is supported*/
  103835. textureFloatLinearFiltering: boolean;
  103836. /** Defines if rendering to float textures is supported */
  103837. textureFloatRender: boolean;
  103838. /** Defines if half float textures are supported*/
  103839. textureHalfFloat: boolean;
  103840. /** Defines if half float texture linear filtering is supported*/
  103841. textureHalfFloatLinearFiltering: boolean;
  103842. /** Defines if rendering to half float textures is supported */
  103843. textureHalfFloatRender: boolean;
  103844. /** Defines if textureLOD shader command is supported */
  103845. textureLOD: boolean;
  103846. /** Defines if draw buffers extension is supported */
  103847. drawBuffersExtension: boolean;
  103848. /** Defines if depth textures are supported */
  103849. depthTextureExtension: boolean;
  103850. /** Defines if float color buffer are supported */
  103851. colorBufferFloat: boolean;
  103852. /** Gets disjoint timer query extension (null if not supported) */
  103853. timerQuery?: EXT_disjoint_timer_query;
  103854. /** Defines if timestamp can be used with timer query */
  103855. canUseTimestampForTimerQuery: boolean;
  103856. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  103857. multiview?: any;
  103858. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  103859. oculusMultiview?: any;
  103860. /** Function used to let the system compiles shaders in background */
  103861. parallelShaderCompile?: {
  103862. COMPLETION_STATUS_KHR: number;
  103863. };
  103864. /** Max number of texture samples for MSAA */
  103865. maxMSAASamples: number;
  103866. /** Defines if the blend min max extension is supported */
  103867. blendMinMax: boolean;
  103868. }
  103869. }
  103870. declare module BABYLON {
  103871. /**
  103872. * @hidden
  103873. **/
  103874. export class DepthCullingState {
  103875. private _isDepthTestDirty;
  103876. private _isDepthMaskDirty;
  103877. private _isDepthFuncDirty;
  103878. private _isCullFaceDirty;
  103879. private _isCullDirty;
  103880. private _isZOffsetDirty;
  103881. private _isFrontFaceDirty;
  103882. private _depthTest;
  103883. private _depthMask;
  103884. private _depthFunc;
  103885. private _cull;
  103886. private _cullFace;
  103887. private _zOffset;
  103888. private _frontFace;
  103889. /**
  103890. * Initializes the state.
  103891. */
  103892. constructor();
  103893. get isDirty(): boolean;
  103894. get zOffset(): number;
  103895. set zOffset(value: number);
  103896. get cullFace(): Nullable<number>;
  103897. set cullFace(value: Nullable<number>);
  103898. get cull(): Nullable<boolean>;
  103899. set cull(value: Nullable<boolean>);
  103900. get depthFunc(): Nullable<number>;
  103901. set depthFunc(value: Nullable<number>);
  103902. get depthMask(): boolean;
  103903. set depthMask(value: boolean);
  103904. get depthTest(): boolean;
  103905. set depthTest(value: boolean);
  103906. get frontFace(): Nullable<number>;
  103907. set frontFace(value: Nullable<number>);
  103908. reset(): void;
  103909. apply(gl: WebGLRenderingContext): void;
  103910. }
  103911. }
  103912. declare module BABYLON {
  103913. /**
  103914. * @hidden
  103915. **/
  103916. export class StencilState {
  103917. /** 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 */
  103918. static readonly ALWAYS: number;
  103919. /** Passed to stencilOperation to specify that stencil value must be kept */
  103920. static readonly KEEP: number;
  103921. /** Passed to stencilOperation to specify that stencil value must be replaced */
  103922. static readonly REPLACE: number;
  103923. private _isStencilTestDirty;
  103924. private _isStencilMaskDirty;
  103925. private _isStencilFuncDirty;
  103926. private _isStencilOpDirty;
  103927. private _stencilTest;
  103928. private _stencilMask;
  103929. private _stencilFunc;
  103930. private _stencilFuncRef;
  103931. private _stencilFuncMask;
  103932. private _stencilOpStencilFail;
  103933. private _stencilOpDepthFail;
  103934. private _stencilOpStencilDepthPass;
  103935. get isDirty(): boolean;
  103936. get stencilFunc(): number;
  103937. set stencilFunc(value: number);
  103938. get stencilFuncRef(): number;
  103939. set stencilFuncRef(value: number);
  103940. get stencilFuncMask(): number;
  103941. set stencilFuncMask(value: number);
  103942. get stencilOpStencilFail(): number;
  103943. set stencilOpStencilFail(value: number);
  103944. get stencilOpDepthFail(): number;
  103945. set stencilOpDepthFail(value: number);
  103946. get stencilOpStencilDepthPass(): number;
  103947. set stencilOpStencilDepthPass(value: number);
  103948. get stencilMask(): number;
  103949. set stencilMask(value: number);
  103950. get stencilTest(): boolean;
  103951. set stencilTest(value: boolean);
  103952. constructor();
  103953. reset(): void;
  103954. apply(gl: WebGLRenderingContext): void;
  103955. }
  103956. }
  103957. declare module BABYLON {
  103958. /**
  103959. * @hidden
  103960. **/
  103961. export class AlphaState {
  103962. private _isAlphaBlendDirty;
  103963. private _isBlendFunctionParametersDirty;
  103964. private _isBlendEquationParametersDirty;
  103965. private _isBlendConstantsDirty;
  103966. private _alphaBlend;
  103967. private _blendFunctionParameters;
  103968. private _blendEquationParameters;
  103969. private _blendConstants;
  103970. /**
  103971. * Initializes the state.
  103972. */
  103973. constructor();
  103974. get isDirty(): boolean;
  103975. get alphaBlend(): boolean;
  103976. set alphaBlend(value: boolean);
  103977. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  103978. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  103979. setAlphaEquationParameters(rgb: number, alpha: number): void;
  103980. reset(): void;
  103981. apply(gl: WebGLRenderingContext): void;
  103982. }
  103983. }
  103984. declare module BABYLON {
  103985. /** @hidden */
  103986. export class WebGL2ShaderProcessor implements IShaderProcessor {
  103987. attributeProcessor(attribute: string): string;
  103988. varyingProcessor(varying: string, isFragment: boolean): string;
  103989. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  103990. }
  103991. }
  103992. declare module BABYLON {
  103993. /**
  103994. * Interface for attribute information associated with buffer instanciation
  103995. */
  103996. export interface InstancingAttributeInfo {
  103997. /**
  103998. * Name of the GLSL attribute
  103999. * if attribute index is not specified, this is used to retrieve the index from the effect
  104000. */
  104001. attributeName: string;
  104002. /**
  104003. * Index/offset of the attribute in the vertex shader
  104004. * if not specified, this will be computes from the name.
  104005. */
  104006. index?: number;
  104007. /**
  104008. * size of the attribute, 1, 2, 3 or 4
  104009. */
  104010. attributeSize: number;
  104011. /**
  104012. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  104013. */
  104014. offset: number;
  104015. /**
  104016. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  104017. * default to 1
  104018. */
  104019. divisor?: number;
  104020. /**
  104021. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  104022. * default is FLOAT
  104023. */
  104024. attributeType?: number;
  104025. /**
  104026. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  104027. */
  104028. normalized?: boolean;
  104029. }
  104030. }
  104031. declare module BABYLON {
  104032. interface ThinEngine {
  104033. /**
  104034. * Update a video texture
  104035. * @param texture defines the texture to update
  104036. * @param video defines the video element to use
  104037. * @param invertY defines if data must be stored with Y axis inverted
  104038. */
  104039. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  104040. }
  104041. }
  104042. declare module BABYLON {
  104043. /**
  104044. * Settings for finer control over video usage
  104045. */
  104046. export interface VideoTextureSettings {
  104047. /**
  104048. * Applies `autoplay` to video, if specified
  104049. */
  104050. autoPlay?: boolean;
  104051. /**
  104052. * Applies `loop` to video, if specified
  104053. */
  104054. loop?: boolean;
  104055. /**
  104056. * Automatically updates internal texture from video at every frame in the render loop
  104057. */
  104058. autoUpdateTexture: boolean;
  104059. /**
  104060. * Image src displayed during the video loading or until the user interacts with the video.
  104061. */
  104062. poster?: string;
  104063. }
  104064. /**
  104065. * If you want to display a video in your scene, this is the special texture for that.
  104066. * This special texture works similar to other textures, with the exception of a few parameters.
  104067. * @see https://doc.babylonjs.com/how_to/video_texture
  104068. */
  104069. export class VideoTexture extends Texture {
  104070. /**
  104071. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  104072. */
  104073. readonly autoUpdateTexture: boolean;
  104074. /**
  104075. * The video instance used by the texture internally
  104076. */
  104077. readonly video: HTMLVideoElement;
  104078. private _onUserActionRequestedObservable;
  104079. /**
  104080. * Event triggerd when a dom action is required by the user to play the video.
  104081. * This happens due to recent changes in browser policies preventing video to auto start.
  104082. */
  104083. get onUserActionRequestedObservable(): Observable<Texture>;
  104084. private _generateMipMaps;
  104085. private _engine;
  104086. private _stillImageCaptured;
  104087. private _displayingPosterTexture;
  104088. private _settings;
  104089. private _createInternalTextureOnEvent;
  104090. private _frameId;
  104091. private _currentSrc;
  104092. /**
  104093. * Creates a video texture.
  104094. * If you want to display a video in your scene, this is the special texture for that.
  104095. * This special texture works similar to other textures, with the exception of a few parameters.
  104096. * @see https://doc.babylonjs.com/how_to/video_texture
  104097. * @param name optional name, will detect from video source, if not defined
  104098. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  104099. * @param scene is obviously the current scene.
  104100. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  104101. * @param invertY is false by default but can be used to invert video on Y axis
  104102. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  104103. * @param settings allows finer control over video usage
  104104. */
  104105. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  104106. private _getName;
  104107. private _getVideo;
  104108. private _createInternalTexture;
  104109. private reset;
  104110. /**
  104111. * @hidden Internal method to initiate `update`.
  104112. */
  104113. _rebuild(): void;
  104114. /**
  104115. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  104116. */
  104117. update(): void;
  104118. /**
  104119. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  104120. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  104121. */
  104122. updateTexture(isVisible: boolean): void;
  104123. protected _updateInternalTexture: () => void;
  104124. /**
  104125. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  104126. * @param url New url.
  104127. */
  104128. updateURL(url: string): void;
  104129. /**
  104130. * Clones the texture.
  104131. * @returns the cloned texture
  104132. */
  104133. clone(): VideoTexture;
  104134. /**
  104135. * Dispose the texture and release its associated resources.
  104136. */
  104137. dispose(): void;
  104138. /**
  104139. * Creates a video texture straight from a stream.
  104140. * @param scene Define the scene the texture should be created in
  104141. * @param stream Define the stream the texture should be created from
  104142. * @returns The created video texture as a promise
  104143. */
  104144. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  104145. /**
  104146. * Creates a video texture straight from your WebCam video feed.
  104147. * @param scene Define the scene the texture should be created in
  104148. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104149. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104150. * @returns The created video texture as a promise
  104151. */
  104152. static CreateFromWebCamAsync(scene: Scene, constraints: {
  104153. minWidth: number;
  104154. maxWidth: number;
  104155. minHeight: number;
  104156. maxHeight: number;
  104157. deviceId: string;
  104158. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  104159. /**
  104160. * Creates a video texture straight from your WebCam video feed.
  104161. * @param scene Define the scene the texture should be created in
  104162. * @param onReady Define a callback to triggered once the texture will be ready
  104163. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  104164. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  104165. */
  104166. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  104167. minWidth: number;
  104168. maxWidth: number;
  104169. minHeight: number;
  104170. maxHeight: number;
  104171. deviceId: string;
  104172. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  104173. }
  104174. }
  104175. declare module BABYLON {
  104176. /**
  104177. * Defines the interface used by objects working like Scene
  104178. * @hidden
  104179. */
  104180. interface ISceneLike {
  104181. _addPendingData(data: any): void;
  104182. _removePendingData(data: any): void;
  104183. offlineProvider: IOfflineProvider;
  104184. }
  104185. /** Interface defining initialization parameters for Engine class */
  104186. export interface EngineOptions extends WebGLContextAttributes {
  104187. /**
  104188. * Defines if the engine should no exceed a specified device ratio
  104189. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  104190. */
  104191. limitDeviceRatio?: number;
  104192. /**
  104193. * Defines if webvr should be enabled automatically
  104194. * @see http://doc.babylonjs.com/how_to/webvr_camera
  104195. */
  104196. autoEnableWebVR?: boolean;
  104197. /**
  104198. * Defines if webgl2 should be turned off even if supported
  104199. * @see http://doc.babylonjs.com/features/webgl2
  104200. */
  104201. disableWebGL2Support?: boolean;
  104202. /**
  104203. * Defines if webaudio should be initialized as well
  104204. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  104205. */
  104206. audioEngine?: boolean;
  104207. /**
  104208. * Defines if animations should run using a deterministic lock step
  104209. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  104210. */
  104211. deterministicLockstep?: boolean;
  104212. /** Defines the maximum steps to use with deterministic lock step mode */
  104213. lockstepMaxSteps?: number;
  104214. /** Defines the seconds between each deterministic lock step */
  104215. timeStep?: number;
  104216. /**
  104217. * Defines that engine should ignore context lost events
  104218. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  104219. */
  104220. doNotHandleContextLost?: boolean;
  104221. /**
  104222. * Defines that engine should ignore modifying touch action attribute and style
  104223. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  104224. */
  104225. doNotHandleTouchAction?: boolean;
  104226. /**
  104227. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  104228. */
  104229. useHighPrecisionFloats?: boolean;
  104230. }
  104231. /**
  104232. * The base engine class (root of all engines)
  104233. */
  104234. export class ThinEngine {
  104235. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  104236. static ExceptionList: ({
  104237. key: string;
  104238. capture: string;
  104239. captureConstraint: number;
  104240. targets: string[];
  104241. } | {
  104242. key: string;
  104243. capture: null;
  104244. captureConstraint: null;
  104245. targets: string[];
  104246. })[];
  104247. /** @hidden */
  104248. static _TextureLoaders: IInternalTextureLoader[];
  104249. /**
  104250. * Returns the current npm package of the sdk
  104251. */
  104252. static get NpmPackage(): string;
  104253. /**
  104254. * Returns the current version of the framework
  104255. */
  104256. static get Version(): string;
  104257. /**
  104258. * Returns a string describing the current engine
  104259. */
  104260. get description(): string;
  104261. /**
  104262. * Gets or sets the epsilon value used by collision engine
  104263. */
  104264. static CollisionsEpsilon: number;
  104265. /**
  104266. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104267. */
  104268. static get ShadersRepository(): string;
  104269. static set ShadersRepository(value: string);
  104270. /**
  104271. * Gets or sets the textures that the engine should not attempt to load as compressed
  104272. */
  104273. protected _excludedCompressedTextures: string[];
  104274. /**
  104275. * Filters the compressed texture formats to only include
  104276. * files that are not included in the skippable list
  104277. *
  104278. * @param url the current extension
  104279. * @param textureFormatInUse the current compressed texture format
  104280. * @returns "format" string
  104281. */
  104282. excludedCompressedTextureFormats(url: Nullable<string>, textureFormatInUse: Nullable<string>): Nullable<string>;
  104283. /** @hidden */
  104284. _shaderProcessor: IShaderProcessor;
  104285. /**
  104286. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  104287. */
  104288. forcePOTTextures: boolean;
  104289. /**
  104290. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  104291. */
  104292. isFullscreen: boolean;
  104293. /**
  104294. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  104295. */
  104296. cullBackFaces: boolean;
  104297. /**
  104298. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  104299. */
  104300. renderEvenInBackground: boolean;
  104301. /**
  104302. * Gets or sets a boolean indicating that cache can be kept between frames
  104303. */
  104304. preventCacheWipeBetweenFrames: boolean;
  104305. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  104306. validateShaderPrograms: boolean;
  104307. /**
  104308. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  104309. * This can provide greater z depth for distant objects.
  104310. */
  104311. useReverseDepthBuffer: boolean;
  104312. /**
  104313. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  104314. */
  104315. disableUniformBuffers: boolean;
  104316. /** @hidden */
  104317. _uniformBuffers: UniformBuffer[];
  104318. /**
  104319. * Gets a boolean indicating that the engine supports uniform buffers
  104320. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  104321. */
  104322. get supportsUniformBuffers(): boolean;
  104323. /** @hidden */
  104324. _gl: WebGLRenderingContext;
  104325. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  104326. protected _windowIsBackground: boolean;
  104327. protected _webGLVersion: number;
  104328. protected _creationOptions: EngineOptions;
  104329. protected _highPrecisionShadersAllowed: boolean;
  104330. /** @hidden */
  104331. get _shouldUseHighPrecisionShader(): boolean;
  104332. /**
  104333. * Gets a boolean indicating that only power of 2 textures are supported
  104334. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  104335. */
  104336. get needPOTTextures(): boolean;
  104337. /** @hidden */
  104338. _badOS: boolean;
  104339. /** @hidden */
  104340. _badDesktopOS: boolean;
  104341. private _hardwareScalingLevel;
  104342. /** @hidden */
  104343. _caps: EngineCapabilities;
  104344. private _isStencilEnable;
  104345. private _glVersion;
  104346. private _glRenderer;
  104347. private _glVendor;
  104348. /** @hidden */
  104349. _videoTextureSupported: boolean;
  104350. protected _renderingQueueLaunched: boolean;
  104351. protected _activeRenderLoops: (() => void)[];
  104352. /**
  104353. * Observable signaled when a context lost event is raised
  104354. */
  104355. onContextLostObservable: Observable<ThinEngine>;
  104356. /**
  104357. * Observable signaled when a context restored event is raised
  104358. */
  104359. onContextRestoredObservable: Observable<ThinEngine>;
  104360. private _onContextLost;
  104361. private _onContextRestored;
  104362. protected _contextWasLost: boolean;
  104363. /** @hidden */
  104364. _doNotHandleContextLost: boolean;
  104365. /**
  104366. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  104367. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  104368. */
  104369. get doNotHandleContextLost(): boolean;
  104370. set doNotHandleContextLost(value: boolean);
  104371. /**
  104372. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  104373. */
  104374. disableVertexArrayObjects: boolean;
  104375. /** @hidden */
  104376. protected _colorWrite: boolean;
  104377. /** @hidden */
  104378. protected _colorWriteChanged: boolean;
  104379. /** @hidden */
  104380. protected _depthCullingState: DepthCullingState;
  104381. /** @hidden */
  104382. protected _stencilState: StencilState;
  104383. /** @hidden */
  104384. _alphaState: AlphaState;
  104385. /** @hidden */
  104386. _alphaMode: number;
  104387. /** @hidden */
  104388. _alphaEquation: number;
  104389. /** @hidden */
  104390. _internalTexturesCache: InternalTexture[];
  104391. /** @hidden */
  104392. protected _activeChannel: number;
  104393. private _currentTextureChannel;
  104394. /** @hidden */
  104395. protected _boundTexturesCache: {
  104396. [key: string]: Nullable<InternalTexture>;
  104397. };
  104398. /** @hidden */
  104399. protected _currentEffect: Nullable<Effect>;
  104400. /** @hidden */
  104401. protected _currentProgram: Nullable<WebGLProgram>;
  104402. private _compiledEffects;
  104403. private _vertexAttribArraysEnabled;
  104404. /** @hidden */
  104405. protected _cachedViewport: Nullable<IViewportLike>;
  104406. private _cachedVertexArrayObject;
  104407. /** @hidden */
  104408. protected _cachedVertexBuffers: any;
  104409. /** @hidden */
  104410. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  104411. /** @hidden */
  104412. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  104413. /** @hidden */
  104414. _currentRenderTarget: Nullable<InternalTexture>;
  104415. private _uintIndicesCurrentlySet;
  104416. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  104417. /** @hidden */
  104418. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  104419. private _currentBufferPointers;
  104420. private _currentInstanceLocations;
  104421. private _currentInstanceBuffers;
  104422. private _textureUnits;
  104423. /** @hidden */
  104424. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  104425. /** @hidden */
  104426. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  104427. /** @hidden */
  104428. _boundRenderFunction: any;
  104429. private _vaoRecordInProgress;
  104430. private _mustWipeVertexAttributes;
  104431. private _emptyTexture;
  104432. private _emptyCubeTexture;
  104433. private _emptyTexture3D;
  104434. private _emptyTexture2DArray;
  104435. /** @hidden */
  104436. _frameHandler: number;
  104437. private _nextFreeTextureSlots;
  104438. private _maxSimultaneousTextures;
  104439. private _activeRequests;
  104440. protected _texturesSupported: string[];
  104441. /** @hidden */
  104442. _textureFormatInUse: Nullable<string>;
  104443. protected get _supportsHardwareTextureRescaling(): boolean;
  104444. /**
  104445. * Gets the list of texture formats supported
  104446. */
  104447. get texturesSupported(): Array<string>;
  104448. /**
  104449. * Gets the list of texture formats in use
  104450. */
  104451. get textureFormatInUse(): Nullable<string>;
  104452. /**
  104453. * Gets the current viewport
  104454. */
  104455. get currentViewport(): Nullable<IViewportLike>;
  104456. /**
  104457. * Gets the default empty texture
  104458. */
  104459. get emptyTexture(): InternalTexture;
  104460. /**
  104461. * Gets the default empty 3D texture
  104462. */
  104463. get emptyTexture3D(): InternalTexture;
  104464. /**
  104465. * Gets the default empty 2D array texture
  104466. */
  104467. get emptyTexture2DArray(): InternalTexture;
  104468. /**
  104469. * Gets the default empty cube texture
  104470. */
  104471. get emptyCubeTexture(): InternalTexture;
  104472. /**
  104473. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  104474. */
  104475. readonly premultipliedAlpha: boolean;
  104476. /**
  104477. * Observable event triggered before each texture is initialized
  104478. */
  104479. onBeforeTextureInitObservable: Observable<Texture>;
  104480. /**
  104481. * Creates a new engine
  104482. * @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
  104483. * @param antialias defines enable antialiasing (default: false)
  104484. * @param options defines further options to be sent to the getContext() function
  104485. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  104486. */
  104487. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  104488. private _rebuildInternalTextures;
  104489. private _rebuildEffects;
  104490. /**
  104491. * Gets a boolean indicating if all created effects are ready
  104492. * @returns true if all effects are ready
  104493. */
  104494. areAllEffectsReady(): boolean;
  104495. protected _rebuildBuffers(): void;
  104496. private _initGLContext;
  104497. /**
  104498. * Gets version of the current webGL context
  104499. */
  104500. get webGLVersion(): number;
  104501. /**
  104502. * Gets a string idenfifying the name of the class
  104503. * @returns "Engine" string
  104504. */
  104505. getClassName(): string;
  104506. /**
  104507. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  104508. */
  104509. get isStencilEnable(): boolean;
  104510. /** @hidden */
  104511. _prepareWorkingCanvas(): void;
  104512. /**
  104513. * Reset the texture cache to empty state
  104514. */
  104515. resetTextureCache(): void;
  104516. /**
  104517. * Gets an object containing information about the current webGL context
  104518. * @returns an object containing the vender, the renderer and the version of the current webGL context
  104519. */
  104520. getGlInfo(): {
  104521. vendor: string;
  104522. renderer: string;
  104523. version: string;
  104524. };
  104525. /**
  104526. * Defines the hardware scaling level.
  104527. * By default the hardware scaling level is computed from the window device ratio.
  104528. * 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.
  104529. * @param level defines the level to use
  104530. */
  104531. setHardwareScalingLevel(level: number): void;
  104532. /**
  104533. * Gets the current hardware scaling level.
  104534. * By default the hardware scaling level is computed from the window device ratio.
  104535. * 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.
  104536. * @returns a number indicating the current hardware scaling level
  104537. */
  104538. getHardwareScalingLevel(): number;
  104539. /**
  104540. * Gets the list of loaded textures
  104541. * @returns an array containing all loaded textures
  104542. */
  104543. getLoadedTexturesCache(): InternalTexture[];
  104544. /**
  104545. * Gets the object containing all engine capabilities
  104546. * @returns the EngineCapabilities object
  104547. */
  104548. getCaps(): EngineCapabilities;
  104549. /**
  104550. * stop executing a render loop function and remove it from the execution array
  104551. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  104552. */
  104553. stopRenderLoop(renderFunction?: () => void): void;
  104554. /** @hidden */
  104555. _renderLoop(): void;
  104556. /**
  104557. * Gets the HTML canvas attached with the current webGL context
  104558. * @returns a HTML canvas
  104559. */
  104560. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  104561. /**
  104562. * Gets host window
  104563. * @returns the host window object
  104564. */
  104565. getHostWindow(): Nullable<Window>;
  104566. /**
  104567. * Gets the current render width
  104568. * @param useScreen defines if screen size must be used (or the current render target if any)
  104569. * @returns a number defining the current render width
  104570. */
  104571. getRenderWidth(useScreen?: boolean): number;
  104572. /**
  104573. * Gets the current render height
  104574. * @param useScreen defines if screen size must be used (or the current render target if any)
  104575. * @returns a number defining the current render height
  104576. */
  104577. getRenderHeight(useScreen?: boolean): number;
  104578. /**
  104579. * Can be used to override the current requestAnimationFrame requester.
  104580. * @hidden
  104581. */
  104582. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  104583. /**
  104584. * Register and execute a render loop. The engine can have more than one render function
  104585. * @param renderFunction defines the function to continuously execute
  104586. */
  104587. runRenderLoop(renderFunction: () => void): void;
  104588. /**
  104589. * Clear the current render buffer or the current render target (if any is set up)
  104590. * @param color defines the color to use
  104591. * @param backBuffer defines if the back buffer must be cleared
  104592. * @param depth defines if the depth buffer must be cleared
  104593. * @param stencil defines if the stencil buffer must be cleared
  104594. */
  104595. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  104596. private _viewportCached;
  104597. /** @hidden */
  104598. _viewport(x: number, y: number, width: number, height: number): void;
  104599. /**
  104600. * Set the WebGL's viewport
  104601. * @param viewport defines the viewport element to be used
  104602. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  104603. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  104604. */
  104605. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  104606. /**
  104607. * Begin a new frame
  104608. */
  104609. beginFrame(): void;
  104610. /**
  104611. * Enf the current frame
  104612. */
  104613. endFrame(): void;
  104614. /**
  104615. * Resize the view according to the canvas' size
  104616. */
  104617. resize(): void;
  104618. /**
  104619. * Force a specific size of the canvas
  104620. * @param width defines the new canvas' width
  104621. * @param height defines the new canvas' height
  104622. */
  104623. setSize(width: number, height: number): void;
  104624. /**
  104625. * Binds the frame buffer to the specified texture.
  104626. * @param texture The texture to render to or null for the default canvas
  104627. * @param faceIndex The face of the texture to render to in case of cube texture
  104628. * @param requiredWidth The width of the target to render to
  104629. * @param requiredHeight The height of the target to render to
  104630. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  104631. * @param lodLevel defines the lod level to bind to the frame buffer
  104632. * @param layer defines the 2d array index to bind to frame buffer to
  104633. */
  104634. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  104635. /** @hidden */
  104636. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  104637. /**
  104638. * Unbind the current render target texture from the webGL context
  104639. * @param texture defines the render target texture to unbind
  104640. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104641. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104642. */
  104643. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  104644. /**
  104645. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  104646. */
  104647. flushFramebuffer(): void;
  104648. /**
  104649. * Unbind the current render target and bind the default framebuffer
  104650. */
  104651. restoreDefaultFramebuffer(): void;
  104652. /** @hidden */
  104653. protected _resetVertexBufferBinding(): void;
  104654. /**
  104655. * Creates a vertex buffer
  104656. * @param data the data for the vertex buffer
  104657. * @returns the new WebGL static buffer
  104658. */
  104659. createVertexBuffer(data: DataArray): DataBuffer;
  104660. private _createVertexBuffer;
  104661. /**
  104662. * Creates a dynamic vertex buffer
  104663. * @param data the data for the dynamic vertex buffer
  104664. * @returns the new WebGL dynamic buffer
  104665. */
  104666. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  104667. protected _resetIndexBufferBinding(): void;
  104668. /**
  104669. * Creates a new index buffer
  104670. * @param indices defines the content of the index buffer
  104671. * @param updatable defines if the index buffer must be updatable
  104672. * @returns a new webGL buffer
  104673. */
  104674. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  104675. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  104676. /**
  104677. * Bind a webGL buffer to the webGL context
  104678. * @param buffer defines the buffer to bind
  104679. */
  104680. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  104681. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  104682. private bindBuffer;
  104683. /**
  104684. * update the bound buffer with the given data
  104685. * @param data defines the data to update
  104686. */
  104687. updateArrayBuffer(data: Float32Array): void;
  104688. private _vertexAttribPointer;
  104689. /** @hidden */
  104690. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  104691. private _bindVertexBuffersAttributes;
  104692. /**
  104693. * Records a vertex array object
  104694. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104695. * @param vertexBuffers defines the list of vertex buffers to store
  104696. * @param indexBuffer defines the index buffer to store
  104697. * @param effect defines the effect to store
  104698. * @returns the new vertex array object
  104699. */
  104700. recordVertexArrayObject(vertexBuffers: {
  104701. [key: string]: VertexBuffer;
  104702. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  104703. /**
  104704. * Bind a specific vertex array object
  104705. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  104706. * @param vertexArrayObject defines the vertex array object to bind
  104707. * @param indexBuffer defines the index buffer to bind
  104708. */
  104709. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  104710. /**
  104711. * Bind webGl buffers directly to the webGL context
  104712. * @param vertexBuffer defines the vertex buffer to bind
  104713. * @param indexBuffer defines the index buffer to bind
  104714. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  104715. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  104716. * @param effect defines the effect associated with the vertex buffer
  104717. */
  104718. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  104719. private _unbindVertexArrayObject;
  104720. /**
  104721. * Bind a list of vertex buffers to the webGL context
  104722. * @param vertexBuffers defines the list of vertex buffers to bind
  104723. * @param indexBuffer defines the index buffer to bind
  104724. * @param effect defines the effect associated with the vertex buffers
  104725. */
  104726. bindBuffers(vertexBuffers: {
  104727. [key: string]: Nullable<VertexBuffer>;
  104728. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  104729. /**
  104730. * Unbind all instance attributes
  104731. */
  104732. unbindInstanceAttributes(): void;
  104733. /**
  104734. * Release and free the memory of a vertex array object
  104735. * @param vao defines the vertex array object to delete
  104736. */
  104737. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  104738. /** @hidden */
  104739. _releaseBuffer(buffer: DataBuffer): boolean;
  104740. protected _deleteBuffer(buffer: DataBuffer): void;
  104741. /**
  104742. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  104743. * @param instancesBuffer defines the webGL buffer to update and bind
  104744. * @param data defines the data to store in the buffer
  104745. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  104746. */
  104747. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  104748. /**
  104749. * Bind the content of a webGL buffer used with instantiation
  104750. * @param instancesBuffer defines the webGL buffer to bind
  104751. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  104752. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  104753. */
  104754. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  104755. /**
  104756. * Disable the instance attribute corresponding to the name in parameter
  104757. * @param name defines the name of the attribute to disable
  104758. */
  104759. disableInstanceAttributeByName(name: string): void;
  104760. /**
  104761. * Disable the instance attribute corresponding to the location in parameter
  104762. * @param attributeLocation defines the attribute location of the attribute to disable
  104763. */
  104764. disableInstanceAttribute(attributeLocation: number): void;
  104765. /**
  104766. * Disable the attribute corresponding to the location in parameter
  104767. * @param attributeLocation defines the attribute location of the attribute to disable
  104768. */
  104769. disableAttributeByIndex(attributeLocation: number): void;
  104770. /**
  104771. * Send a draw order
  104772. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104773. * @param indexStart defines the starting index
  104774. * @param indexCount defines the number of index to draw
  104775. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104776. */
  104777. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  104778. /**
  104779. * Draw a list of points
  104780. * @param verticesStart defines the index of first vertex to draw
  104781. * @param verticesCount defines the count of vertices to draw
  104782. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104783. */
  104784. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104785. /**
  104786. * Draw a list of unindexed primitives
  104787. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  104788. * @param verticesStart defines the index of first vertex to draw
  104789. * @param verticesCount defines the count of vertices to draw
  104790. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104791. */
  104792. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104793. /**
  104794. * Draw a list of indexed primitives
  104795. * @param fillMode defines the primitive to use
  104796. * @param indexStart defines the starting index
  104797. * @param indexCount defines the number of index to draw
  104798. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104799. */
  104800. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  104801. /**
  104802. * Draw a list of unindexed primitives
  104803. * @param fillMode defines the primitive to use
  104804. * @param verticesStart defines the index of first vertex to draw
  104805. * @param verticesCount defines the count of vertices to draw
  104806. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  104807. */
  104808. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  104809. private _drawMode;
  104810. /** @hidden */
  104811. protected _reportDrawCall(): void;
  104812. /** @hidden */
  104813. _releaseEffect(effect: Effect): void;
  104814. /** @hidden */
  104815. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  104816. /**
  104817. * Create a new effect (used to store vertex/fragment shaders)
  104818. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  104819. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  104820. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  104821. * @param samplers defines an array of string used to represent textures
  104822. * @param defines defines the string containing the defines to use to compile the shaders
  104823. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  104824. * @param onCompiled defines a function to call when the effect creation is successful
  104825. * @param onError defines a function to call when the effect creation has failed
  104826. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  104827. * @returns the new Effect
  104828. */
  104829. 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;
  104830. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  104831. private _compileShader;
  104832. private _compileRawShader;
  104833. /**
  104834. * Directly creates a webGL program
  104835. * @param pipelineContext defines the pipeline context to attach to
  104836. * @param vertexCode defines the vertex shader code to use
  104837. * @param fragmentCode defines the fragment shader code to use
  104838. * @param context defines the webGL context to use (if not set, the current one will be used)
  104839. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104840. * @returns the new webGL program
  104841. */
  104842. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104843. /**
  104844. * Creates a webGL program
  104845. * @param pipelineContext defines the pipeline context to attach to
  104846. * @param vertexCode defines the vertex shader code to use
  104847. * @param fragmentCode defines the fragment shader code to use
  104848. * @param defines defines the string containing the defines to use to compile the shaders
  104849. * @param context defines the webGL context to use (if not set, the current one will be used)
  104850. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  104851. * @returns the new webGL program
  104852. */
  104853. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104854. /**
  104855. * Creates a new pipeline context
  104856. * @returns the new pipeline
  104857. */
  104858. createPipelineContext(): IPipelineContext;
  104859. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  104860. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  104861. /** @hidden */
  104862. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  104863. /** @hidden */
  104864. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  104865. /** @hidden */
  104866. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  104867. /**
  104868. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  104869. * @param pipelineContext defines the pipeline context to use
  104870. * @param uniformsNames defines the list of uniform names
  104871. * @returns an array of webGL uniform locations
  104872. */
  104873. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  104874. /**
  104875. * Gets the lsit of active attributes for a given webGL program
  104876. * @param pipelineContext defines the pipeline context to use
  104877. * @param attributesNames defines the list of attribute names to get
  104878. * @returns an array of indices indicating the offset of each attribute
  104879. */
  104880. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  104881. /**
  104882. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  104883. * @param effect defines the effect to activate
  104884. */
  104885. enableEffect(effect: Nullable<Effect>): void;
  104886. /**
  104887. * Set the value of an uniform to a number (int)
  104888. * @param uniform defines the webGL uniform location where to store the value
  104889. * @param value defines the int number to store
  104890. */
  104891. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104892. /**
  104893. * Set the value of an uniform to an array of int32
  104894. * @param uniform defines the webGL uniform location where to store the value
  104895. * @param array defines the array of int32 to store
  104896. */
  104897. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104898. /**
  104899. * Set the value of an uniform to an array of int32 (stored as vec2)
  104900. * @param uniform defines the webGL uniform location where to store the value
  104901. * @param array defines the array of int32 to store
  104902. */
  104903. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104904. /**
  104905. * Set the value of an uniform to an array of int32 (stored as vec3)
  104906. * @param uniform defines the webGL uniform location where to store the value
  104907. * @param array defines the array of int32 to store
  104908. */
  104909. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104910. /**
  104911. * Set the value of an uniform to an array of int32 (stored as vec4)
  104912. * @param uniform defines the webGL uniform location where to store the value
  104913. * @param array defines the array of int32 to store
  104914. */
  104915. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  104916. /**
  104917. * Set the value of an uniform to an array of number
  104918. * @param uniform defines the webGL uniform location where to store the value
  104919. * @param array defines the array of number to store
  104920. */
  104921. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104922. /**
  104923. * Set the value of an uniform to an array of number (stored as vec2)
  104924. * @param uniform defines the webGL uniform location where to store the value
  104925. * @param array defines the array of number to store
  104926. */
  104927. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104928. /**
  104929. * Set the value of an uniform to an array of number (stored as vec3)
  104930. * @param uniform defines the webGL uniform location where to store the value
  104931. * @param array defines the array of number to store
  104932. */
  104933. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104934. /**
  104935. * Set the value of an uniform to an array of number (stored as vec4)
  104936. * @param uniform defines the webGL uniform location where to store the value
  104937. * @param array defines the array of number to store
  104938. */
  104939. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  104940. /**
  104941. * Set the value of an uniform to an array of float32 (stored as matrices)
  104942. * @param uniform defines the webGL uniform location where to store the value
  104943. * @param matrices defines the array of float32 to store
  104944. */
  104945. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  104946. /**
  104947. * Set the value of an uniform to a matrix (3x3)
  104948. * @param uniform defines the webGL uniform location where to store the value
  104949. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  104950. */
  104951. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104952. /**
  104953. * Set the value of an uniform to a matrix (2x2)
  104954. * @param uniform defines the webGL uniform location where to store the value
  104955. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  104956. */
  104957. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  104958. /**
  104959. * Set the value of an uniform to a number (float)
  104960. * @param uniform defines the webGL uniform location where to store the value
  104961. * @param value defines the float number to store
  104962. */
  104963. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  104964. /**
  104965. * Set the value of an uniform to a vec2
  104966. * @param uniform defines the webGL uniform location where to store the value
  104967. * @param x defines the 1st component of the value
  104968. * @param y defines the 2nd component of the value
  104969. */
  104970. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  104971. /**
  104972. * Set the value of an uniform to a vec3
  104973. * @param uniform defines the webGL uniform location where to store the value
  104974. * @param x defines the 1st component of the value
  104975. * @param y defines the 2nd component of the value
  104976. * @param z defines the 3rd component of the value
  104977. */
  104978. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  104979. /**
  104980. * Set the value of an uniform to a vec4
  104981. * @param uniform defines the webGL uniform location where to store the value
  104982. * @param x defines the 1st component of the value
  104983. * @param y defines the 2nd component of the value
  104984. * @param z defines the 3rd component of the value
  104985. * @param w defines the 4th component of the value
  104986. */
  104987. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  104988. /**
  104989. * Apply all cached states (depth, culling, stencil and alpha)
  104990. */
  104991. applyStates(): void;
  104992. /**
  104993. * Enable or disable color writing
  104994. * @param enable defines the state to set
  104995. */
  104996. setColorWrite(enable: boolean): void;
  104997. /**
  104998. * Gets a boolean indicating if color writing is enabled
  104999. * @returns the current color writing state
  105000. */
  105001. getColorWrite(): boolean;
  105002. /**
  105003. * Gets the depth culling state manager
  105004. */
  105005. get depthCullingState(): DepthCullingState;
  105006. /**
  105007. * Gets the alpha state manager
  105008. */
  105009. get alphaState(): AlphaState;
  105010. /**
  105011. * Gets the stencil state manager
  105012. */
  105013. get stencilState(): StencilState;
  105014. /**
  105015. * Clears the list of texture accessible through engine.
  105016. * This can help preventing texture load conflict due to name collision.
  105017. */
  105018. clearInternalTexturesCache(): void;
  105019. /**
  105020. * Force the entire cache to be cleared
  105021. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  105022. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  105023. */
  105024. wipeCaches(bruteForce?: boolean): void;
  105025. /** @hidden */
  105026. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  105027. min: number;
  105028. mag: number;
  105029. };
  105030. /** @hidden */
  105031. _createTexture(): WebGLTexture;
  105032. /**
  105033. * Usually called from Texture.ts.
  105034. * Passed information to create a WebGLTexture
  105035. * @param urlArg defines a value which contains one of the following:
  105036. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  105037. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  105038. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  105039. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  105040. * @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)
  105041. * @param scene needed for loading to the correct scene
  105042. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  105043. * @param onLoad optional callback to be called upon successful completion
  105044. * @param onError optional callback to be called upon failure
  105045. * @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
  105046. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  105047. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  105048. * @param forcedExtension defines the extension to use to pick the right loader
  105049. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  105050. * @param mimeType defines an optional mime type
  105051. * @returns a InternalTexture for assignment back into BABYLON.Texture
  105052. */
  105053. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>, mimeType?: string): InternalTexture;
  105054. /**
  105055. * Loads an image as an HTMLImageElement.
  105056. * @param input url string, ArrayBuffer, or Blob to load
  105057. * @param onLoad callback called when the image successfully loads
  105058. * @param onError callback called when the image fails to load
  105059. * @param offlineProvider offline provider for caching
  105060. * @param mimeType optional mime type
  105061. * @returns the HTMLImageElement of the loaded image
  105062. * @hidden
  105063. */
  105064. 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>;
  105065. /**
  105066. * @hidden
  105067. */
  105068. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  105069. /**
  105070. * Creates a raw texture
  105071. * @param data defines the data to store in the texture
  105072. * @param width defines the width of the texture
  105073. * @param height defines the height of the texture
  105074. * @param format defines the format of the data
  105075. * @param generateMipMaps defines if the engine should generate the mip levels
  105076. * @param invertY defines if data must be stored with Y axis inverted
  105077. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  105078. * @param compression defines the compression used (null by default)
  105079. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  105080. * @returns the raw texture inside an InternalTexture
  105081. */
  105082. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  105083. /**
  105084. * Creates a new raw cube texture
  105085. * @param data defines the array of data to use to create each face
  105086. * @param size defines the size of the textures
  105087. * @param format defines the format of the data
  105088. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  105089. * @param generateMipMaps defines if the engine should generate the mip levels
  105090. * @param invertY defines if data must be stored with Y axis inverted
  105091. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105092. * @param compression defines the compression used (null by default)
  105093. * @returns the cube texture as an InternalTexture
  105094. */
  105095. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  105096. /**
  105097. * Creates a new raw 3D texture
  105098. * @param data defines the data used to create the texture
  105099. * @param width defines the width of the texture
  105100. * @param height defines the height of the texture
  105101. * @param depth defines the depth of the texture
  105102. * @param format defines the format of the texture
  105103. * @param generateMipMaps defines if the engine must generate mip levels
  105104. * @param invertY defines if data must be stored with Y axis inverted
  105105. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105106. * @param compression defines the compressed used (can be null)
  105107. * @param textureType defines the compressed used (can be null)
  105108. * @returns a new raw 3D texture (stored in an InternalTexture)
  105109. */
  105110. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105111. /**
  105112. * Creates a new raw 2D array texture
  105113. * @param data defines the data used to create the texture
  105114. * @param width defines the width of the texture
  105115. * @param height defines the height of the texture
  105116. * @param depth defines the number of layers of the texture
  105117. * @param format defines the format of the texture
  105118. * @param generateMipMaps defines if the engine must generate mip levels
  105119. * @param invertY defines if data must be stored with Y axis inverted
  105120. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  105121. * @param compression defines the compressed used (can be null)
  105122. * @param textureType defines the compressed used (can be null)
  105123. * @returns a new raw 2D array texture (stored in an InternalTexture)
  105124. */
  105125. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  105126. private _unpackFlipYCached;
  105127. /**
  105128. * In case you are sharing the context with other applications, it might
  105129. * be interested to not cache the unpack flip y state to ensure a consistent
  105130. * value would be set.
  105131. */
  105132. enableUnpackFlipYCached: boolean;
  105133. /** @hidden */
  105134. _unpackFlipY(value: boolean): void;
  105135. /** @hidden */
  105136. _getUnpackAlignement(): number;
  105137. private _getTextureTarget;
  105138. /**
  105139. * Update the sampling mode of a given texture
  105140. * @param samplingMode defines the required sampling mode
  105141. * @param texture defines the texture to update
  105142. * @param generateMipMaps defines whether to generate mipmaps for the texture
  105143. */
  105144. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  105145. /**
  105146. * Update the sampling mode of a given texture
  105147. * @param texture defines the texture to update
  105148. * @param wrapU defines the texture wrap mode of the u coordinates
  105149. * @param wrapV defines the texture wrap mode of the v coordinates
  105150. * @param wrapR defines the texture wrap mode of the r coordinates
  105151. */
  105152. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  105153. /** @hidden */
  105154. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  105155. width: number;
  105156. height: number;
  105157. layers?: number;
  105158. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  105159. /** @hidden */
  105160. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105161. /** @hidden */
  105162. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  105163. /**
  105164. * Update a portion of an internal texture
  105165. * @param texture defines the texture to update
  105166. * @param imageData defines the data to store into the texture
  105167. * @param xOffset defines the x coordinates of the update rectangle
  105168. * @param yOffset defines the y coordinates of the update rectangle
  105169. * @param width defines the width of the update rectangle
  105170. * @param height defines the height of the update rectangle
  105171. * @param faceIndex defines the face index if texture is a cube (0 by default)
  105172. * @param lod defines the lod level to update (0 by default)
  105173. */
  105174. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  105175. /** @hidden */
  105176. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  105177. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  105178. private _prepareWebGLTexture;
  105179. /** @hidden */
  105180. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  105181. private _getDepthStencilBuffer;
  105182. /** @hidden */
  105183. _releaseFramebufferObjects(texture: InternalTexture): void;
  105184. /** @hidden */
  105185. _releaseTexture(texture: InternalTexture): void;
  105186. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  105187. protected _setProgram(program: WebGLProgram): void;
  105188. protected _boundUniforms: {
  105189. [key: number]: WebGLUniformLocation;
  105190. };
  105191. /**
  105192. * Binds an effect to the webGL context
  105193. * @param effect defines the effect to bind
  105194. */
  105195. bindSamplers(effect: Effect): void;
  105196. private _activateCurrentTexture;
  105197. /** @hidden */
  105198. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  105199. /** @hidden */
  105200. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  105201. /**
  105202. * Unbind all textures from the webGL context
  105203. */
  105204. unbindAllTextures(): void;
  105205. /**
  105206. * Sets a texture to the according uniform.
  105207. * @param channel The texture channel
  105208. * @param uniform The uniform to set
  105209. * @param texture The texture to apply
  105210. */
  105211. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  105212. private _bindSamplerUniformToChannel;
  105213. private _getTextureWrapMode;
  105214. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  105215. /**
  105216. * Sets an array of texture to the webGL context
  105217. * @param channel defines the channel where the texture array must be set
  105218. * @param uniform defines the associated uniform location
  105219. * @param textures defines the array of textures to bind
  105220. */
  105221. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  105222. /** @hidden */
  105223. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  105224. private _setTextureParameterFloat;
  105225. private _setTextureParameterInteger;
  105226. /**
  105227. * Unbind all vertex attributes from the webGL context
  105228. */
  105229. unbindAllAttributes(): void;
  105230. /**
  105231. * 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
  105232. */
  105233. releaseEffects(): void;
  105234. /**
  105235. * Dispose and release all associated resources
  105236. */
  105237. dispose(): void;
  105238. /**
  105239. * Attach a new callback raised when context lost event is fired
  105240. * @param callback defines the callback to call
  105241. */
  105242. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105243. /**
  105244. * Attach a new callback raised when context restored event is fired
  105245. * @param callback defines the callback to call
  105246. */
  105247. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  105248. /**
  105249. * Get the current error code of the webGL context
  105250. * @returns the error code
  105251. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  105252. */
  105253. getError(): number;
  105254. private _canRenderToFloatFramebuffer;
  105255. private _canRenderToHalfFloatFramebuffer;
  105256. private _canRenderToFramebuffer;
  105257. /** @hidden */
  105258. _getWebGLTextureType(type: number): number;
  105259. /** @hidden */
  105260. _getInternalFormat(format: number): number;
  105261. /** @hidden */
  105262. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  105263. /** @hidden */
  105264. _getRGBAMultiSampleBufferFormat(type: number): number;
  105265. /** @hidden */
  105266. _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;
  105267. /**
  105268. * Loads a file from a url
  105269. * @param url url to load
  105270. * @param onSuccess callback called when the file successfully loads
  105271. * @param onProgress callback called while file is loading (if the server supports this mode)
  105272. * @param offlineProvider defines the offline provider for caching
  105273. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  105274. * @param onError callback called when the file fails to load
  105275. * @returns a file request object
  105276. * @hidden
  105277. */
  105278. 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;
  105279. /**
  105280. * Reads pixels from the current frame buffer. Please note that this function can be slow
  105281. * @param x defines the x coordinate of the rectangle where pixels must be read
  105282. * @param y defines the y coordinate of the rectangle where pixels must be read
  105283. * @param width defines the width of the rectangle where pixels must be read
  105284. * @param height defines the height of the rectangle where pixels must be read
  105285. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  105286. * @returns a Uint8Array containing RGBA colors
  105287. */
  105288. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  105289. private static _isSupported;
  105290. /**
  105291. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  105292. * @returns true if the engine can be created
  105293. * @ignorenaming
  105294. */
  105295. static isSupported(): boolean;
  105296. /**
  105297. * Find the next highest power of two.
  105298. * @param x Number to start search from.
  105299. * @return Next highest power of two.
  105300. */
  105301. static CeilingPOT(x: number): number;
  105302. /**
  105303. * Find the next lowest power of two.
  105304. * @param x Number to start search from.
  105305. * @return Next lowest power of two.
  105306. */
  105307. static FloorPOT(x: number): number;
  105308. /**
  105309. * Find the nearest power of two.
  105310. * @param x Number to start search from.
  105311. * @return Next nearest power of two.
  105312. */
  105313. static NearestPOT(x: number): number;
  105314. /**
  105315. * Get the closest exponent of two
  105316. * @param value defines the value to approximate
  105317. * @param max defines the maximum value to return
  105318. * @param mode defines how to define the closest value
  105319. * @returns closest exponent of two of the given value
  105320. */
  105321. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  105322. /**
  105323. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  105324. * @param func - the function to be called
  105325. * @param requester - the object that will request the next frame. Falls back to window.
  105326. * @returns frame number
  105327. */
  105328. static QueueNewFrame(func: () => void, requester?: any): number;
  105329. /**
  105330. * Gets host document
  105331. * @returns the host document object
  105332. */
  105333. getHostDocument(): Nullable<Document>;
  105334. }
  105335. }
  105336. declare module BABYLON {
  105337. /**
  105338. * Class representing spherical harmonics coefficients to the 3rd degree
  105339. */
  105340. export class SphericalHarmonics {
  105341. /**
  105342. * Defines whether or not the harmonics have been prescaled for rendering.
  105343. */
  105344. preScaled: boolean;
  105345. /**
  105346. * The l0,0 coefficients of the spherical harmonics
  105347. */
  105348. l00: Vector3;
  105349. /**
  105350. * The l1,-1 coefficients of the spherical harmonics
  105351. */
  105352. l1_1: Vector3;
  105353. /**
  105354. * The l1,0 coefficients of the spherical harmonics
  105355. */
  105356. l10: Vector3;
  105357. /**
  105358. * The l1,1 coefficients of the spherical harmonics
  105359. */
  105360. l11: Vector3;
  105361. /**
  105362. * The l2,-2 coefficients of the spherical harmonics
  105363. */
  105364. l2_2: Vector3;
  105365. /**
  105366. * The l2,-1 coefficients of the spherical harmonics
  105367. */
  105368. l2_1: Vector3;
  105369. /**
  105370. * The l2,0 coefficients of the spherical harmonics
  105371. */
  105372. l20: Vector3;
  105373. /**
  105374. * The l2,1 coefficients of the spherical harmonics
  105375. */
  105376. l21: Vector3;
  105377. /**
  105378. * The l2,2 coefficients of the spherical harmonics
  105379. */
  105380. l22: Vector3;
  105381. /**
  105382. * Adds a light to the spherical harmonics
  105383. * @param direction the direction of the light
  105384. * @param color the color of the light
  105385. * @param deltaSolidAngle the delta solid angle of the light
  105386. */
  105387. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  105388. /**
  105389. * Scales the spherical harmonics by the given amount
  105390. * @param scale the amount to scale
  105391. */
  105392. scaleInPlace(scale: number): void;
  105393. /**
  105394. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  105395. *
  105396. * ```
  105397. * E_lm = A_l * L_lm
  105398. * ```
  105399. *
  105400. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  105401. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  105402. * the scaling factors are given in equation 9.
  105403. */
  105404. convertIncidentRadianceToIrradiance(): void;
  105405. /**
  105406. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  105407. *
  105408. * ```
  105409. * L = (1/pi) * E * rho
  105410. * ```
  105411. *
  105412. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  105413. */
  105414. convertIrradianceToLambertianRadiance(): void;
  105415. /**
  105416. * Integrates the reconstruction coefficients directly in to the SH preventing further
  105417. * required operations at run time.
  105418. *
  105419. * This is simply done by scaling back the SH with Ylm constants parameter.
  105420. * The trigonometric part being applied by the shader at run time.
  105421. */
  105422. preScaleForRendering(): void;
  105423. /**
  105424. * Constructs a spherical harmonics from an array.
  105425. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  105426. * @returns the spherical harmonics
  105427. */
  105428. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  105429. /**
  105430. * Gets the spherical harmonics from polynomial
  105431. * @param polynomial the spherical polynomial
  105432. * @returns the spherical harmonics
  105433. */
  105434. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  105435. }
  105436. /**
  105437. * Class representing spherical polynomial coefficients to the 3rd degree
  105438. */
  105439. export class SphericalPolynomial {
  105440. private _harmonics;
  105441. /**
  105442. * The spherical harmonics used to create the polynomials.
  105443. */
  105444. get preScaledHarmonics(): SphericalHarmonics;
  105445. /**
  105446. * The x coefficients of the spherical polynomial
  105447. */
  105448. x: Vector3;
  105449. /**
  105450. * The y coefficients of the spherical polynomial
  105451. */
  105452. y: Vector3;
  105453. /**
  105454. * The z coefficients of the spherical polynomial
  105455. */
  105456. z: Vector3;
  105457. /**
  105458. * The xx coefficients of the spherical polynomial
  105459. */
  105460. xx: Vector3;
  105461. /**
  105462. * The yy coefficients of the spherical polynomial
  105463. */
  105464. yy: Vector3;
  105465. /**
  105466. * The zz coefficients of the spherical polynomial
  105467. */
  105468. zz: Vector3;
  105469. /**
  105470. * The xy coefficients of the spherical polynomial
  105471. */
  105472. xy: Vector3;
  105473. /**
  105474. * The yz coefficients of the spherical polynomial
  105475. */
  105476. yz: Vector3;
  105477. /**
  105478. * The zx coefficients of the spherical polynomial
  105479. */
  105480. zx: Vector3;
  105481. /**
  105482. * Adds an ambient color to the spherical polynomial
  105483. * @param color the color to add
  105484. */
  105485. addAmbient(color: Color3): void;
  105486. /**
  105487. * Scales the spherical polynomial by the given amount
  105488. * @param scale the amount to scale
  105489. */
  105490. scaleInPlace(scale: number): void;
  105491. /**
  105492. * Gets the spherical polynomial from harmonics
  105493. * @param harmonics the spherical harmonics
  105494. * @returns the spherical polynomial
  105495. */
  105496. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  105497. /**
  105498. * Constructs a spherical polynomial from an array.
  105499. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  105500. * @returns the spherical polynomial
  105501. */
  105502. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  105503. }
  105504. }
  105505. declare module BABYLON {
  105506. /**
  105507. * Defines the source of the internal texture
  105508. */
  105509. export enum InternalTextureSource {
  105510. /**
  105511. * The source of the texture data is unknown
  105512. */
  105513. Unknown = 0,
  105514. /**
  105515. * Texture data comes from an URL
  105516. */
  105517. Url = 1,
  105518. /**
  105519. * Texture data is only used for temporary storage
  105520. */
  105521. Temp = 2,
  105522. /**
  105523. * Texture data comes from raw data (ArrayBuffer)
  105524. */
  105525. Raw = 3,
  105526. /**
  105527. * Texture content is dynamic (video or dynamic texture)
  105528. */
  105529. Dynamic = 4,
  105530. /**
  105531. * Texture content is generated by rendering to it
  105532. */
  105533. RenderTarget = 5,
  105534. /**
  105535. * Texture content is part of a multi render target process
  105536. */
  105537. MultiRenderTarget = 6,
  105538. /**
  105539. * Texture data comes from a cube data file
  105540. */
  105541. Cube = 7,
  105542. /**
  105543. * Texture data comes from a raw cube data
  105544. */
  105545. CubeRaw = 8,
  105546. /**
  105547. * Texture data come from a prefiltered cube data file
  105548. */
  105549. CubePrefiltered = 9,
  105550. /**
  105551. * Texture content is raw 3D data
  105552. */
  105553. Raw3D = 10,
  105554. /**
  105555. * Texture content is raw 2D array data
  105556. */
  105557. Raw2DArray = 11,
  105558. /**
  105559. * Texture content is a depth texture
  105560. */
  105561. Depth = 12,
  105562. /**
  105563. * Texture data comes from a raw cube data encoded with RGBD
  105564. */
  105565. CubeRawRGBD = 13
  105566. }
  105567. /**
  105568. * Class used to store data associated with WebGL texture data for the engine
  105569. * This class should not be used directly
  105570. */
  105571. export class InternalTexture {
  105572. /** @hidden */
  105573. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  105574. /**
  105575. * Defines if the texture is ready
  105576. */
  105577. isReady: boolean;
  105578. /**
  105579. * Defines if the texture is a cube texture
  105580. */
  105581. isCube: boolean;
  105582. /**
  105583. * Defines if the texture contains 3D data
  105584. */
  105585. is3D: boolean;
  105586. /**
  105587. * Defines if the texture contains 2D array data
  105588. */
  105589. is2DArray: boolean;
  105590. /**
  105591. * Defines if the texture contains multiview data
  105592. */
  105593. isMultiview: boolean;
  105594. /**
  105595. * Gets the URL used to load this texture
  105596. */
  105597. url: string;
  105598. /**
  105599. * Gets the sampling mode of the texture
  105600. */
  105601. samplingMode: number;
  105602. /**
  105603. * Gets a boolean indicating if the texture needs mipmaps generation
  105604. */
  105605. generateMipMaps: boolean;
  105606. /**
  105607. * Gets the number of samples used by the texture (WebGL2+ only)
  105608. */
  105609. samples: number;
  105610. /**
  105611. * Gets the type of the texture (int, float...)
  105612. */
  105613. type: number;
  105614. /**
  105615. * Gets the format of the texture (RGB, RGBA...)
  105616. */
  105617. format: number;
  105618. /**
  105619. * Observable called when the texture is loaded
  105620. */
  105621. onLoadedObservable: Observable<InternalTexture>;
  105622. /**
  105623. * Gets the width of the texture
  105624. */
  105625. width: number;
  105626. /**
  105627. * Gets the height of the texture
  105628. */
  105629. height: number;
  105630. /**
  105631. * Gets the depth of the texture
  105632. */
  105633. depth: number;
  105634. /**
  105635. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  105636. */
  105637. baseWidth: number;
  105638. /**
  105639. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  105640. */
  105641. baseHeight: number;
  105642. /**
  105643. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  105644. */
  105645. baseDepth: number;
  105646. /**
  105647. * Gets a boolean indicating if the texture is inverted on Y axis
  105648. */
  105649. invertY: boolean;
  105650. /** @hidden */
  105651. _invertVScale: boolean;
  105652. /** @hidden */
  105653. _associatedChannel: number;
  105654. /** @hidden */
  105655. _source: InternalTextureSource;
  105656. /** @hidden */
  105657. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  105658. /** @hidden */
  105659. _bufferView: Nullable<ArrayBufferView>;
  105660. /** @hidden */
  105661. _bufferViewArray: Nullable<ArrayBufferView[]>;
  105662. /** @hidden */
  105663. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  105664. /** @hidden */
  105665. _size: number;
  105666. /** @hidden */
  105667. _extension: string;
  105668. /** @hidden */
  105669. _files: Nullable<string[]>;
  105670. /** @hidden */
  105671. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105672. /** @hidden */
  105673. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105674. /** @hidden */
  105675. _framebuffer: Nullable<WebGLFramebuffer>;
  105676. /** @hidden */
  105677. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  105678. /** @hidden */
  105679. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  105680. /** @hidden */
  105681. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  105682. /** @hidden */
  105683. _attachments: Nullable<number[]>;
  105684. /** @hidden */
  105685. _cachedCoordinatesMode: Nullable<number>;
  105686. /** @hidden */
  105687. _cachedWrapU: Nullable<number>;
  105688. /** @hidden */
  105689. _cachedWrapV: Nullable<number>;
  105690. /** @hidden */
  105691. _cachedWrapR: Nullable<number>;
  105692. /** @hidden */
  105693. _cachedAnisotropicFilteringLevel: Nullable<number>;
  105694. /** @hidden */
  105695. _isDisabled: boolean;
  105696. /** @hidden */
  105697. _compression: Nullable<string>;
  105698. /** @hidden */
  105699. _generateStencilBuffer: boolean;
  105700. /** @hidden */
  105701. _generateDepthBuffer: boolean;
  105702. /** @hidden */
  105703. _comparisonFunction: number;
  105704. /** @hidden */
  105705. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  105706. /** @hidden */
  105707. _lodGenerationScale: number;
  105708. /** @hidden */
  105709. _lodGenerationOffset: number;
  105710. /** @hidden */
  105711. _depthStencilTexture: Nullable<InternalTexture>;
  105712. /** @hidden */
  105713. _colorTextureArray: Nullable<WebGLTexture>;
  105714. /** @hidden */
  105715. _depthStencilTextureArray: Nullable<WebGLTexture>;
  105716. /** @hidden */
  105717. _lodTextureHigh: Nullable<BaseTexture>;
  105718. /** @hidden */
  105719. _lodTextureMid: Nullable<BaseTexture>;
  105720. /** @hidden */
  105721. _lodTextureLow: Nullable<BaseTexture>;
  105722. /** @hidden */
  105723. _isRGBD: boolean;
  105724. /** @hidden */
  105725. _linearSpecularLOD: boolean;
  105726. /** @hidden */
  105727. _irradianceTexture: Nullable<BaseTexture>;
  105728. /** @hidden */
  105729. _webGLTexture: Nullable<WebGLTexture>;
  105730. /** @hidden */
  105731. _references: number;
  105732. private _engine;
  105733. /**
  105734. * Gets the Engine the texture belongs to.
  105735. * @returns The babylon engine
  105736. */
  105737. getEngine(): ThinEngine;
  105738. /**
  105739. * Gets the data source type of the texture
  105740. */
  105741. get source(): InternalTextureSource;
  105742. /**
  105743. * Creates a new InternalTexture
  105744. * @param engine defines the engine to use
  105745. * @param source defines the type of data that will be used
  105746. * @param delayAllocation if the texture allocation should be delayed (default: false)
  105747. */
  105748. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  105749. /**
  105750. * Increments the number of references (ie. the number of Texture that point to it)
  105751. */
  105752. incrementReferences(): void;
  105753. /**
  105754. * Change the size of the texture (not the size of the content)
  105755. * @param width defines the new width
  105756. * @param height defines the new height
  105757. * @param depth defines the new depth (1 by default)
  105758. */
  105759. updateSize(width: int, height: int, depth?: int): void;
  105760. /** @hidden */
  105761. _rebuild(): void;
  105762. /** @hidden */
  105763. _swapAndDie(target: InternalTexture): void;
  105764. /**
  105765. * Dispose the current allocated resources
  105766. */
  105767. dispose(): void;
  105768. }
  105769. }
  105770. declare module BABYLON {
  105771. /**
  105772. * Class used to work with sound analyzer using fast fourier transform (FFT)
  105773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105774. */
  105775. export class Analyser {
  105776. /**
  105777. * Gets or sets the smoothing
  105778. * @ignorenaming
  105779. */
  105780. SMOOTHING: number;
  105781. /**
  105782. * Gets or sets the FFT table size
  105783. * @ignorenaming
  105784. */
  105785. FFT_SIZE: number;
  105786. /**
  105787. * Gets or sets the bar graph amplitude
  105788. * @ignorenaming
  105789. */
  105790. BARGRAPHAMPLITUDE: number;
  105791. /**
  105792. * Gets or sets the position of the debug canvas
  105793. * @ignorenaming
  105794. */
  105795. DEBUGCANVASPOS: {
  105796. x: number;
  105797. y: number;
  105798. };
  105799. /**
  105800. * Gets or sets the debug canvas size
  105801. * @ignorenaming
  105802. */
  105803. DEBUGCANVASSIZE: {
  105804. width: number;
  105805. height: number;
  105806. };
  105807. private _byteFreqs;
  105808. private _byteTime;
  105809. private _floatFreqs;
  105810. private _webAudioAnalyser;
  105811. private _debugCanvas;
  105812. private _debugCanvasContext;
  105813. private _scene;
  105814. private _registerFunc;
  105815. private _audioEngine;
  105816. /**
  105817. * Creates a new analyser
  105818. * @param scene defines hosting scene
  105819. */
  105820. constructor(scene: Scene);
  105821. /**
  105822. * Get the number of data values you will have to play with for the visualization
  105823. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  105824. * @returns a number
  105825. */
  105826. getFrequencyBinCount(): number;
  105827. /**
  105828. * Gets the current frequency data as a byte array
  105829. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105830. * @returns a Uint8Array
  105831. */
  105832. getByteFrequencyData(): Uint8Array;
  105833. /**
  105834. * Gets the current waveform as a byte array
  105835. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  105836. * @returns a Uint8Array
  105837. */
  105838. getByteTimeDomainData(): Uint8Array;
  105839. /**
  105840. * Gets the current frequency data as a float array
  105841. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  105842. * @returns a Float32Array
  105843. */
  105844. getFloatFrequencyData(): Float32Array;
  105845. /**
  105846. * Renders the debug canvas
  105847. */
  105848. drawDebugCanvas(): void;
  105849. /**
  105850. * Stops rendering the debug canvas and removes it
  105851. */
  105852. stopDebugCanvas(): void;
  105853. /**
  105854. * Connects two audio nodes
  105855. * @param inputAudioNode defines first node to connect
  105856. * @param outputAudioNode defines second node to connect
  105857. */
  105858. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  105859. /**
  105860. * Releases all associated resources
  105861. */
  105862. dispose(): void;
  105863. }
  105864. }
  105865. declare module BABYLON {
  105866. /**
  105867. * This represents an audio engine and it is responsible
  105868. * to play, synchronize and analyse sounds throughout the application.
  105869. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105870. */
  105871. export interface IAudioEngine extends IDisposable {
  105872. /**
  105873. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105874. */
  105875. readonly canUseWebAudio: boolean;
  105876. /**
  105877. * Gets the current AudioContext if available.
  105878. */
  105879. readonly audioContext: Nullable<AudioContext>;
  105880. /**
  105881. * The master gain node defines the global audio volume of your audio engine.
  105882. */
  105883. readonly masterGain: GainNode;
  105884. /**
  105885. * Gets whether or not mp3 are supported by your browser.
  105886. */
  105887. readonly isMP3supported: boolean;
  105888. /**
  105889. * Gets whether or not ogg are supported by your browser.
  105890. */
  105891. readonly isOGGsupported: boolean;
  105892. /**
  105893. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105894. * @ignoreNaming
  105895. */
  105896. WarnedWebAudioUnsupported: boolean;
  105897. /**
  105898. * Defines if the audio engine relies on a custom unlocked button.
  105899. * In this case, the embedded button will not be displayed.
  105900. */
  105901. useCustomUnlockedButton: boolean;
  105902. /**
  105903. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  105904. */
  105905. readonly unlocked: boolean;
  105906. /**
  105907. * Event raised when audio has been unlocked on the browser.
  105908. */
  105909. onAudioUnlockedObservable: Observable<AudioEngine>;
  105910. /**
  105911. * Event raised when audio has been locked on the browser.
  105912. */
  105913. onAudioLockedObservable: Observable<AudioEngine>;
  105914. /**
  105915. * Flags the audio engine in Locked state.
  105916. * This happens due to new browser policies preventing audio to autoplay.
  105917. */
  105918. lock(): void;
  105919. /**
  105920. * Unlocks the audio engine once a user action has been done on the dom.
  105921. * This is helpful to resume play once browser policies have been satisfied.
  105922. */
  105923. unlock(): void;
  105924. }
  105925. /**
  105926. * This represents the default audio engine used in babylon.
  105927. * It is responsible to play, synchronize and analyse sounds throughout the application.
  105928. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105929. */
  105930. export class AudioEngine implements IAudioEngine {
  105931. private _audioContext;
  105932. private _audioContextInitialized;
  105933. private _muteButton;
  105934. private _hostElement;
  105935. /**
  105936. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  105937. */
  105938. canUseWebAudio: boolean;
  105939. /**
  105940. * The master gain node defines the global audio volume of your audio engine.
  105941. */
  105942. masterGain: GainNode;
  105943. /**
  105944. * Defines if Babylon should emit a warning if WebAudio is not supported.
  105945. * @ignoreNaming
  105946. */
  105947. WarnedWebAudioUnsupported: boolean;
  105948. /**
  105949. * Gets whether or not mp3 are supported by your browser.
  105950. */
  105951. isMP3supported: boolean;
  105952. /**
  105953. * Gets whether or not ogg are supported by your browser.
  105954. */
  105955. isOGGsupported: boolean;
  105956. /**
  105957. * Gets whether audio has been unlocked on the device.
  105958. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  105959. * a user interaction has happened.
  105960. */
  105961. unlocked: boolean;
  105962. /**
  105963. * Defines if the audio engine relies on a custom unlocked button.
  105964. * In this case, the embedded button will not be displayed.
  105965. */
  105966. useCustomUnlockedButton: boolean;
  105967. /**
  105968. * Event raised when audio has been unlocked on the browser.
  105969. */
  105970. onAudioUnlockedObservable: Observable<AudioEngine>;
  105971. /**
  105972. * Event raised when audio has been locked on the browser.
  105973. */
  105974. onAudioLockedObservable: Observable<AudioEngine>;
  105975. /**
  105976. * Gets the current AudioContext if available.
  105977. */
  105978. get audioContext(): Nullable<AudioContext>;
  105979. private _connectedAnalyser;
  105980. /**
  105981. * Instantiates a new audio engine.
  105982. *
  105983. * There should be only one per page as some browsers restrict the number
  105984. * of audio contexts you can create.
  105985. * @param hostElement defines the host element where to display the mute icon if necessary
  105986. */
  105987. constructor(hostElement?: Nullable<HTMLElement>);
  105988. /**
  105989. * Flags the audio engine in Locked state.
  105990. * This happens due to new browser policies preventing audio to autoplay.
  105991. */
  105992. lock(): void;
  105993. /**
  105994. * Unlocks the audio engine once a user action has been done on the dom.
  105995. * This is helpful to resume play once browser policies have been satisfied.
  105996. */
  105997. unlock(): void;
  105998. private _resumeAudioContext;
  105999. private _initializeAudioContext;
  106000. private _tryToRun;
  106001. private _triggerRunningState;
  106002. private _triggerSuspendedState;
  106003. private _displayMuteButton;
  106004. private _moveButtonToTopLeft;
  106005. private _onResize;
  106006. private _hideMuteButton;
  106007. /**
  106008. * Destroy and release the resources associated with the audio ccontext.
  106009. */
  106010. dispose(): void;
  106011. /**
  106012. * Gets the global volume sets on the master gain.
  106013. * @returns the global volume if set or -1 otherwise
  106014. */
  106015. getGlobalVolume(): number;
  106016. /**
  106017. * Sets the global volume of your experience (sets on the master gain).
  106018. * @param newVolume Defines the new global volume of the application
  106019. */
  106020. setGlobalVolume(newVolume: number): void;
  106021. /**
  106022. * Connect the audio engine to an audio analyser allowing some amazing
  106023. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  106024. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  106025. * @param analyser The analyser to connect to the engine
  106026. */
  106027. connectToAnalyser(analyser: Analyser): void;
  106028. }
  106029. }
  106030. declare module BABYLON {
  106031. /**
  106032. * Interface used to present a loading screen while loading a scene
  106033. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106034. */
  106035. export interface ILoadingScreen {
  106036. /**
  106037. * Function called to display the loading screen
  106038. */
  106039. displayLoadingUI: () => void;
  106040. /**
  106041. * Function called to hide the loading screen
  106042. */
  106043. hideLoadingUI: () => void;
  106044. /**
  106045. * Gets or sets the color to use for the background
  106046. */
  106047. loadingUIBackgroundColor: string;
  106048. /**
  106049. * Gets or sets the text to display while loading
  106050. */
  106051. loadingUIText: string;
  106052. }
  106053. /**
  106054. * Class used for the default loading screen
  106055. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  106056. */
  106057. export class DefaultLoadingScreen implements ILoadingScreen {
  106058. private _renderingCanvas;
  106059. private _loadingText;
  106060. private _loadingDivBackgroundColor;
  106061. private _loadingDiv;
  106062. private _loadingTextDiv;
  106063. /** Gets or sets the logo url to use for the default loading screen */
  106064. static DefaultLogoUrl: string;
  106065. /** Gets or sets the spinner url to use for the default loading screen */
  106066. static DefaultSpinnerUrl: string;
  106067. /**
  106068. * Creates a new default loading screen
  106069. * @param _renderingCanvas defines the canvas used to render the scene
  106070. * @param _loadingText defines the default text to display
  106071. * @param _loadingDivBackgroundColor defines the default background color
  106072. */
  106073. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  106074. /**
  106075. * Function called to display the loading screen
  106076. */
  106077. displayLoadingUI(): void;
  106078. /**
  106079. * Function called to hide the loading screen
  106080. */
  106081. hideLoadingUI(): void;
  106082. /**
  106083. * Gets or sets the text to display while loading
  106084. */
  106085. set loadingUIText(text: string);
  106086. get loadingUIText(): string;
  106087. /**
  106088. * Gets or sets the color to use for the background
  106089. */
  106090. get loadingUIBackgroundColor(): string;
  106091. set loadingUIBackgroundColor(color: string);
  106092. private _resizeLoadingUI;
  106093. }
  106094. }
  106095. declare module BABYLON {
  106096. /**
  106097. * Interface for any object that can request an animation frame
  106098. */
  106099. export interface ICustomAnimationFrameRequester {
  106100. /**
  106101. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  106102. */
  106103. renderFunction?: Function;
  106104. /**
  106105. * Called to request the next frame to render to
  106106. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  106107. */
  106108. requestAnimationFrame: Function;
  106109. /**
  106110. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  106111. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  106112. */
  106113. requestID?: number;
  106114. }
  106115. }
  106116. declare module BABYLON {
  106117. /**
  106118. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  106119. */
  106120. export class PerformanceMonitor {
  106121. private _enabled;
  106122. private _rollingFrameTime;
  106123. private _lastFrameTimeMs;
  106124. /**
  106125. * constructor
  106126. * @param frameSampleSize The number of samples required to saturate the sliding window
  106127. */
  106128. constructor(frameSampleSize?: number);
  106129. /**
  106130. * Samples current frame
  106131. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  106132. */
  106133. sampleFrame(timeMs?: number): void;
  106134. /**
  106135. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106136. */
  106137. get averageFrameTime(): number;
  106138. /**
  106139. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  106140. */
  106141. get averageFrameTimeVariance(): number;
  106142. /**
  106143. * Returns the frame time of the most recent frame
  106144. */
  106145. get instantaneousFrameTime(): number;
  106146. /**
  106147. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  106148. */
  106149. get averageFPS(): number;
  106150. /**
  106151. * Returns the average framerate in frames per second using the most recent frame time
  106152. */
  106153. get instantaneousFPS(): number;
  106154. /**
  106155. * Returns true if enough samples have been taken to completely fill the sliding window
  106156. */
  106157. get isSaturated(): boolean;
  106158. /**
  106159. * Enables contributions to the sliding window sample set
  106160. */
  106161. enable(): void;
  106162. /**
  106163. * Disables contributions to the sliding window sample set
  106164. * Samples will not be interpolated over the disabled period
  106165. */
  106166. disable(): void;
  106167. /**
  106168. * Returns true if sampling is enabled
  106169. */
  106170. get isEnabled(): boolean;
  106171. /**
  106172. * Resets performance monitor
  106173. */
  106174. reset(): void;
  106175. }
  106176. /**
  106177. * RollingAverage
  106178. *
  106179. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  106180. */
  106181. export class RollingAverage {
  106182. /**
  106183. * Current average
  106184. */
  106185. average: number;
  106186. /**
  106187. * Current variance
  106188. */
  106189. variance: number;
  106190. protected _samples: Array<number>;
  106191. protected _sampleCount: number;
  106192. protected _pos: number;
  106193. protected _m2: number;
  106194. /**
  106195. * constructor
  106196. * @param length The number of samples required to saturate the sliding window
  106197. */
  106198. constructor(length: number);
  106199. /**
  106200. * Adds a sample to the sample set
  106201. * @param v The sample value
  106202. */
  106203. add(v: number): void;
  106204. /**
  106205. * Returns previously added values or null if outside of history or outside the sliding window domain
  106206. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  106207. * @return Value previously recorded with add() or null if outside of range
  106208. */
  106209. history(i: number): number;
  106210. /**
  106211. * Returns true if enough samples have been taken to completely fill the sliding window
  106212. * @return true if sample-set saturated
  106213. */
  106214. isSaturated(): boolean;
  106215. /**
  106216. * Resets the rolling average (equivalent to 0 samples taken so far)
  106217. */
  106218. reset(): void;
  106219. /**
  106220. * Wraps a value around the sample range boundaries
  106221. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  106222. * @return Wrapped position in sample range
  106223. */
  106224. protected _wrapPosition(i: number): number;
  106225. }
  106226. }
  106227. declare module BABYLON {
  106228. /**
  106229. * This class is used to track a performance counter which is number based.
  106230. * The user has access to many properties which give statistics of different nature.
  106231. *
  106232. * The implementer can track two kinds of Performance Counter: time and count.
  106233. * 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.
  106234. * 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.
  106235. */
  106236. export class PerfCounter {
  106237. /**
  106238. * Gets or sets a global boolean to turn on and off all the counters
  106239. */
  106240. static Enabled: boolean;
  106241. /**
  106242. * Returns the smallest value ever
  106243. */
  106244. get min(): number;
  106245. /**
  106246. * Returns the biggest value ever
  106247. */
  106248. get max(): number;
  106249. /**
  106250. * Returns the average value since the performance counter is running
  106251. */
  106252. get average(): number;
  106253. /**
  106254. * Returns the average value of the last second the counter was monitored
  106255. */
  106256. get lastSecAverage(): number;
  106257. /**
  106258. * Returns the current value
  106259. */
  106260. get current(): number;
  106261. /**
  106262. * Gets the accumulated total
  106263. */
  106264. get total(): number;
  106265. /**
  106266. * Gets the total value count
  106267. */
  106268. get count(): number;
  106269. /**
  106270. * Creates a new counter
  106271. */
  106272. constructor();
  106273. /**
  106274. * Call this method to start monitoring a new frame.
  106275. * 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.
  106276. */
  106277. fetchNewFrame(): void;
  106278. /**
  106279. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  106280. * @param newCount the count value to add to the monitored count
  106281. * @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.
  106282. */
  106283. addCount(newCount: number, fetchResult: boolean): void;
  106284. /**
  106285. * Start monitoring this performance counter
  106286. */
  106287. beginMonitoring(): void;
  106288. /**
  106289. * Compute the time lapsed since the previous beginMonitoring() call.
  106290. * @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
  106291. */
  106292. endMonitoring(newFrame?: boolean): void;
  106293. private _fetchResult;
  106294. private _startMonitoringTime;
  106295. private _min;
  106296. private _max;
  106297. private _average;
  106298. private _current;
  106299. private _totalValueCount;
  106300. private _totalAccumulated;
  106301. private _lastSecAverage;
  106302. private _lastSecAccumulated;
  106303. private _lastSecTime;
  106304. private _lastSecValueCount;
  106305. }
  106306. }
  106307. declare module BABYLON {
  106308. interface ThinEngine {
  106309. /**
  106310. * Sets alpha constants used by some alpha blending modes
  106311. * @param r defines the red component
  106312. * @param g defines the green component
  106313. * @param b defines the blue component
  106314. * @param a defines the alpha component
  106315. */
  106316. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  106317. /**
  106318. * Sets the current alpha mode
  106319. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  106320. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  106321. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106322. */
  106323. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  106324. /**
  106325. * Gets the current alpha mode
  106326. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  106327. * @returns the current alpha mode
  106328. */
  106329. getAlphaMode(): number;
  106330. /**
  106331. * Sets the current alpha equation
  106332. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  106333. */
  106334. setAlphaEquation(equation: number): void;
  106335. /**
  106336. * Gets the current alpha equation.
  106337. * @returns the current alpha equation
  106338. */
  106339. getAlphaEquation(): number;
  106340. }
  106341. }
  106342. declare module BABYLON {
  106343. /**
  106344. * Defines the interface used by display changed events
  106345. */
  106346. export interface IDisplayChangedEventArgs {
  106347. /** Gets the vrDisplay object (if any) */
  106348. vrDisplay: Nullable<any>;
  106349. /** Gets a boolean indicating if webVR is supported */
  106350. vrSupported: boolean;
  106351. }
  106352. /**
  106353. * Defines the interface used by objects containing a viewport (like a camera)
  106354. */
  106355. interface IViewportOwnerLike {
  106356. /**
  106357. * Gets or sets the viewport
  106358. */
  106359. viewport: IViewportLike;
  106360. }
  106361. /**
  106362. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  106363. */
  106364. export class Engine extends ThinEngine {
  106365. /** Defines that alpha blending is disabled */
  106366. static readonly ALPHA_DISABLE: number;
  106367. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  106368. static readonly ALPHA_ADD: number;
  106369. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  106370. static readonly ALPHA_COMBINE: number;
  106371. /** Defines that alpha blending to DEST - SRC * DEST */
  106372. static readonly ALPHA_SUBTRACT: number;
  106373. /** Defines that alpha blending to SRC * DEST */
  106374. static readonly ALPHA_MULTIPLY: number;
  106375. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  106376. static readonly ALPHA_MAXIMIZED: number;
  106377. /** Defines that alpha blending to SRC + DEST */
  106378. static readonly ALPHA_ONEONE: number;
  106379. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  106380. static readonly ALPHA_PREMULTIPLIED: number;
  106381. /**
  106382. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  106383. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  106384. */
  106385. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  106386. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  106387. static readonly ALPHA_INTERPOLATE: number;
  106388. /**
  106389. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  106390. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  106391. */
  106392. static readonly ALPHA_SCREENMODE: number;
  106393. /** Defines that the ressource is not delayed*/
  106394. static readonly DELAYLOADSTATE_NONE: number;
  106395. /** Defines that the ressource was successfully delay loaded */
  106396. static readonly DELAYLOADSTATE_LOADED: number;
  106397. /** Defines that the ressource is currently delay loading */
  106398. static readonly DELAYLOADSTATE_LOADING: number;
  106399. /** Defines that the ressource is delayed and has not started loading */
  106400. static readonly DELAYLOADSTATE_NOTLOADED: number;
  106401. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  106402. static readonly NEVER: number;
  106403. /** 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 */
  106404. static readonly ALWAYS: number;
  106405. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  106406. static readonly LESS: number;
  106407. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  106408. static readonly EQUAL: number;
  106409. /** 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 */
  106410. static readonly LEQUAL: number;
  106411. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  106412. static readonly GREATER: number;
  106413. /** 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 */
  106414. static readonly GEQUAL: number;
  106415. /** 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 */
  106416. static readonly NOTEQUAL: number;
  106417. /** Passed to stencilOperation to specify that stencil value must be kept */
  106418. static readonly KEEP: number;
  106419. /** Passed to stencilOperation to specify that stencil value must be replaced */
  106420. static readonly REPLACE: number;
  106421. /** Passed to stencilOperation to specify that stencil value must be incremented */
  106422. static readonly INCR: number;
  106423. /** Passed to stencilOperation to specify that stencil value must be decremented */
  106424. static readonly DECR: number;
  106425. /** Passed to stencilOperation to specify that stencil value must be inverted */
  106426. static readonly INVERT: number;
  106427. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  106428. static readonly INCR_WRAP: number;
  106429. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  106430. static readonly DECR_WRAP: number;
  106431. /** Texture is not repeating outside of 0..1 UVs */
  106432. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  106433. /** Texture is repeating outside of 0..1 UVs */
  106434. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  106435. /** Texture is repeating and mirrored */
  106436. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  106437. /** ALPHA */
  106438. static readonly TEXTUREFORMAT_ALPHA: number;
  106439. /** LUMINANCE */
  106440. static readonly TEXTUREFORMAT_LUMINANCE: number;
  106441. /** LUMINANCE_ALPHA */
  106442. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  106443. /** RGB */
  106444. static readonly TEXTUREFORMAT_RGB: number;
  106445. /** RGBA */
  106446. static readonly TEXTUREFORMAT_RGBA: number;
  106447. /** RED */
  106448. static readonly TEXTUREFORMAT_RED: number;
  106449. /** RED (2nd reference) */
  106450. static readonly TEXTUREFORMAT_R: number;
  106451. /** RG */
  106452. static readonly TEXTUREFORMAT_RG: number;
  106453. /** RED_INTEGER */
  106454. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  106455. /** RED_INTEGER (2nd reference) */
  106456. static readonly TEXTUREFORMAT_R_INTEGER: number;
  106457. /** RG_INTEGER */
  106458. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  106459. /** RGB_INTEGER */
  106460. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  106461. /** RGBA_INTEGER */
  106462. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  106463. /** UNSIGNED_BYTE */
  106464. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  106465. /** UNSIGNED_BYTE (2nd reference) */
  106466. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  106467. /** FLOAT */
  106468. static readonly TEXTURETYPE_FLOAT: number;
  106469. /** HALF_FLOAT */
  106470. static readonly TEXTURETYPE_HALF_FLOAT: number;
  106471. /** BYTE */
  106472. static readonly TEXTURETYPE_BYTE: number;
  106473. /** SHORT */
  106474. static readonly TEXTURETYPE_SHORT: number;
  106475. /** UNSIGNED_SHORT */
  106476. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  106477. /** INT */
  106478. static readonly TEXTURETYPE_INT: number;
  106479. /** UNSIGNED_INT */
  106480. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  106481. /** UNSIGNED_SHORT_4_4_4_4 */
  106482. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  106483. /** UNSIGNED_SHORT_5_5_5_1 */
  106484. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  106485. /** UNSIGNED_SHORT_5_6_5 */
  106486. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  106487. /** UNSIGNED_INT_2_10_10_10_REV */
  106488. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  106489. /** UNSIGNED_INT_24_8 */
  106490. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  106491. /** UNSIGNED_INT_10F_11F_11F_REV */
  106492. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  106493. /** UNSIGNED_INT_5_9_9_9_REV */
  106494. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  106495. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  106496. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  106497. /** nearest is mag = nearest and min = nearest and mip = linear */
  106498. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  106499. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106500. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  106501. /** Trilinear is mag = linear and min = linear and mip = linear */
  106502. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  106503. /** nearest is mag = nearest and min = nearest and mip = linear */
  106504. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  106505. /** Bilinear is mag = linear and min = linear and mip = nearest */
  106506. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  106507. /** Trilinear is mag = linear and min = linear and mip = linear */
  106508. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  106509. /** mag = nearest and min = nearest and mip = nearest */
  106510. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  106511. /** mag = nearest and min = linear and mip = nearest */
  106512. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  106513. /** mag = nearest and min = linear and mip = linear */
  106514. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  106515. /** mag = nearest and min = linear and mip = none */
  106516. static readonly TEXTURE_NEAREST_LINEAR: number;
  106517. /** mag = nearest and min = nearest and mip = none */
  106518. static readonly TEXTURE_NEAREST_NEAREST: number;
  106519. /** mag = linear and min = nearest and mip = nearest */
  106520. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  106521. /** mag = linear and min = nearest and mip = linear */
  106522. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  106523. /** mag = linear and min = linear and mip = none */
  106524. static readonly TEXTURE_LINEAR_LINEAR: number;
  106525. /** mag = linear and min = nearest and mip = none */
  106526. static readonly TEXTURE_LINEAR_NEAREST: number;
  106527. /** Explicit coordinates mode */
  106528. static readonly TEXTURE_EXPLICIT_MODE: number;
  106529. /** Spherical coordinates mode */
  106530. static readonly TEXTURE_SPHERICAL_MODE: number;
  106531. /** Planar coordinates mode */
  106532. static readonly TEXTURE_PLANAR_MODE: number;
  106533. /** Cubic coordinates mode */
  106534. static readonly TEXTURE_CUBIC_MODE: number;
  106535. /** Projection coordinates mode */
  106536. static readonly TEXTURE_PROJECTION_MODE: number;
  106537. /** Skybox coordinates mode */
  106538. static readonly TEXTURE_SKYBOX_MODE: number;
  106539. /** Inverse Cubic coordinates mode */
  106540. static readonly TEXTURE_INVCUBIC_MODE: number;
  106541. /** Equirectangular coordinates mode */
  106542. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  106543. /** Equirectangular Fixed coordinates mode */
  106544. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  106545. /** Equirectangular Fixed Mirrored coordinates mode */
  106546. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  106547. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  106548. static readonly SCALEMODE_FLOOR: number;
  106549. /** Defines that texture rescaling will look for the nearest power of 2 size */
  106550. static readonly SCALEMODE_NEAREST: number;
  106551. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  106552. static readonly SCALEMODE_CEILING: number;
  106553. /**
  106554. * Returns the current npm package of the sdk
  106555. */
  106556. static get NpmPackage(): string;
  106557. /**
  106558. * Returns the current version of the framework
  106559. */
  106560. static get Version(): string;
  106561. /** Gets the list of created engines */
  106562. static get Instances(): Engine[];
  106563. /**
  106564. * Gets the latest created engine
  106565. */
  106566. static get LastCreatedEngine(): Nullable<Engine>;
  106567. /**
  106568. * Gets the latest created scene
  106569. */
  106570. static get LastCreatedScene(): Nullable<Scene>;
  106571. /**
  106572. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  106573. * @param flag defines which part of the materials must be marked as dirty
  106574. * @param predicate defines a predicate used to filter which materials should be affected
  106575. */
  106576. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  106577. /**
  106578. * Method called to create the default loading screen.
  106579. * This can be overriden in your own app.
  106580. * @param canvas The rendering canvas element
  106581. * @returns The loading screen
  106582. */
  106583. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  106584. /**
  106585. * Method called to create the default rescale post process on each engine.
  106586. */
  106587. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  106588. /**
  106589. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  106590. **/
  106591. enableOfflineSupport: boolean;
  106592. /**
  106593. * 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)
  106594. **/
  106595. disableManifestCheck: boolean;
  106596. /**
  106597. * Gets the list of created scenes
  106598. */
  106599. scenes: Scene[];
  106600. /**
  106601. * Event raised when a new scene is created
  106602. */
  106603. onNewSceneAddedObservable: Observable<Scene>;
  106604. /**
  106605. * Gets the list of created postprocesses
  106606. */
  106607. postProcesses: PostProcess[];
  106608. /**
  106609. * Gets a boolean indicating if the pointer is currently locked
  106610. */
  106611. isPointerLock: boolean;
  106612. /**
  106613. * Observable event triggered each time the rendering canvas is resized
  106614. */
  106615. onResizeObservable: Observable<Engine>;
  106616. /**
  106617. * Observable event triggered each time the canvas loses focus
  106618. */
  106619. onCanvasBlurObservable: Observable<Engine>;
  106620. /**
  106621. * Observable event triggered each time the canvas gains focus
  106622. */
  106623. onCanvasFocusObservable: Observable<Engine>;
  106624. /**
  106625. * Observable event triggered each time the canvas receives pointerout event
  106626. */
  106627. onCanvasPointerOutObservable: Observable<PointerEvent>;
  106628. /**
  106629. * Observable raised when the engine begins a new frame
  106630. */
  106631. onBeginFrameObservable: Observable<Engine>;
  106632. /**
  106633. * If set, will be used to request the next animation frame for the render loop
  106634. */
  106635. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  106636. /**
  106637. * Observable raised when the engine ends the current frame
  106638. */
  106639. onEndFrameObservable: Observable<Engine>;
  106640. /**
  106641. * Observable raised when the engine is about to compile a shader
  106642. */
  106643. onBeforeShaderCompilationObservable: Observable<Engine>;
  106644. /**
  106645. * Observable raised when the engine has jsut compiled a shader
  106646. */
  106647. onAfterShaderCompilationObservable: Observable<Engine>;
  106648. /**
  106649. * Gets the audio engine
  106650. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  106651. * @ignorenaming
  106652. */
  106653. static audioEngine: IAudioEngine;
  106654. /**
  106655. * Default AudioEngine factory responsible of creating the Audio Engine.
  106656. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  106657. */
  106658. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  106659. /**
  106660. * Default offline support factory responsible of creating a tool used to store data locally.
  106661. * By default, this will create a Database object if the workload has been embedded.
  106662. */
  106663. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  106664. private _loadingScreen;
  106665. private _pointerLockRequested;
  106666. private _dummyFramebuffer;
  106667. private _rescalePostProcess;
  106668. private _deterministicLockstep;
  106669. private _lockstepMaxSteps;
  106670. private _timeStep;
  106671. protected get _supportsHardwareTextureRescaling(): boolean;
  106672. private _fps;
  106673. private _deltaTime;
  106674. /** @hidden */
  106675. _drawCalls: PerfCounter;
  106676. /** 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 */
  106677. canvasTabIndex: number;
  106678. /**
  106679. * Turn this value on if you want to pause FPS computation when in background
  106680. */
  106681. disablePerformanceMonitorInBackground: boolean;
  106682. private _performanceMonitor;
  106683. /**
  106684. * Gets the performance monitor attached to this engine
  106685. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  106686. */
  106687. get performanceMonitor(): PerformanceMonitor;
  106688. private _onFocus;
  106689. private _onBlur;
  106690. private _onCanvasPointerOut;
  106691. private _onCanvasBlur;
  106692. private _onCanvasFocus;
  106693. private _onFullscreenChange;
  106694. private _onPointerLockChange;
  106695. /**
  106696. * Gets the HTML element used to attach event listeners
  106697. * @returns a HTML element
  106698. */
  106699. getInputElement(): Nullable<HTMLElement>;
  106700. /**
  106701. * Creates a new engine
  106702. * @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
  106703. * @param antialias defines enable antialiasing (default: false)
  106704. * @param options defines further options to be sent to the getContext() function
  106705. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  106706. */
  106707. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  106708. /**
  106709. * Gets current aspect ratio
  106710. * @param viewportOwner defines the camera to use to get the aspect ratio
  106711. * @param useScreen defines if screen size must be used (or the current render target if any)
  106712. * @returns a number defining the aspect ratio
  106713. */
  106714. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  106715. /**
  106716. * Gets current screen aspect ratio
  106717. * @returns a number defining the aspect ratio
  106718. */
  106719. getScreenAspectRatio(): number;
  106720. /**
  106721. * Gets the client rect of the HTML canvas attached with the current webGL context
  106722. * @returns a client rectanglee
  106723. */
  106724. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  106725. /**
  106726. * Gets the client rect of the HTML element used for events
  106727. * @returns a client rectanglee
  106728. */
  106729. getInputElementClientRect(): Nullable<ClientRect>;
  106730. /**
  106731. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  106732. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106733. * @returns true if engine is in deterministic lock step mode
  106734. */
  106735. isDeterministicLockStep(): boolean;
  106736. /**
  106737. * Gets the max steps when engine is running in deterministic lock step
  106738. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  106739. * @returns the max steps
  106740. */
  106741. getLockstepMaxSteps(): number;
  106742. /**
  106743. * Returns the time in ms between steps when using deterministic lock step.
  106744. * @returns time step in (ms)
  106745. */
  106746. getTimeStep(): number;
  106747. /**
  106748. * Force the mipmap generation for the given render target texture
  106749. * @param texture defines the render target texture to use
  106750. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  106751. */
  106752. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  106753. /** States */
  106754. /**
  106755. * Set various states to the webGL context
  106756. * @param culling defines backface culling state
  106757. * @param zOffset defines the value to apply to zOffset (0 by default)
  106758. * @param force defines if states must be applied even if cache is up to date
  106759. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  106760. */
  106761. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  106762. /**
  106763. * Set the z offset to apply to current rendering
  106764. * @param value defines the offset to apply
  106765. */
  106766. setZOffset(value: number): void;
  106767. /**
  106768. * Gets the current value of the zOffset
  106769. * @returns the current zOffset state
  106770. */
  106771. getZOffset(): number;
  106772. /**
  106773. * Enable or disable depth buffering
  106774. * @param enable defines the state to set
  106775. */
  106776. setDepthBuffer(enable: boolean): void;
  106777. /**
  106778. * Gets a boolean indicating if depth writing is enabled
  106779. * @returns the current depth writing state
  106780. */
  106781. getDepthWrite(): boolean;
  106782. /**
  106783. * Enable or disable depth writing
  106784. * @param enable defines the state to set
  106785. */
  106786. setDepthWrite(enable: boolean): void;
  106787. /**
  106788. * Gets a boolean indicating if stencil buffer is enabled
  106789. * @returns the current stencil buffer state
  106790. */
  106791. getStencilBuffer(): boolean;
  106792. /**
  106793. * Enable or disable the stencil buffer
  106794. * @param enable defines if the stencil buffer must be enabled or disabled
  106795. */
  106796. setStencilBuffer(enable: boolean): void;
  106797. /**
  106798. * Gets the current stencil mask
  106799. * @returns a number defining the new stencil mask to use
  106800. */
  106801. getStencilMask(): number;
  106802. /**
  106803. * Sets the current stencil mask
  106804. * @param mask defines the new stencil mask to use
  106805. */
  106806. setStencilMask(mask: number): void;
  106807. /**
  106808. * Gets the current stencil function
  106809. * @returns a number defining the stencil function to use
  106810. */
  106811. getStencilFunction(): number;
  106812. /**
  106813. * Gets the current stencil reference value
  106814. * @returns a number defining the stencil reference value to use
  106815. */
  106816. getStencilFunctionReference(): number;
  106817. /**
  106818. * Gets the current stencil mask
  106819. * @returns a number defining the stencil mask to use
  106820. */
  106821. getStencilFunctionMask(): number;
  106822. /**
  106823. * Sets the current stencil function
  106824. * @param stencilFunc defines the new stencil function to use
  106825. */
  106826. setStencilFunction(stencilFunc: number): void;
  106827. /**
  106828. * Sets the current stencil reference
  106829. * @param reference defines the new stencil reference to use
  106830. */
  106831. setStencilFunctionReference(reference: number): void;
  106832. /**
  106833. * Sets the current stencil mask
  106834. * @param mask defines the new stencil mask to use
  106835. */
  106836. setStencilFunctionMask(mask: number): void;
  106837. /**
  106838. * Gets the current stencil operation when stencil fails
  106839. * @returns a number defining stencil operation to use when stencil fails
  106840. */
  106841. getStencilOperationFail(): number;
  106842. /**
  106843. * Gets the current stencil operation when depth fails
  106844. * @returns a number defining stencil operation to use when depth fails
  106845. */
  106846. getStencilOperationDepthFail(): number;
  106847. /**
  106848. * Gets the current stencil operation when stencil passes
  106849. * @returns a number defining stencil operation to use when stencil passes
  106850. */
  106851. getStencilOperationPass(): number;
  106852. /**
  106853. * Sets the stencil operation to use when stencil fails
  106854. * @param operation defines the stencil operation to use when stencil fails
  106855. */
  106856. setStencilOperationFail(operation: number): void;
  106857. /**
  106858. * Sets the stencil operation to use when depth fails
  106859. * @param operation defines the stencil operation to use when depth fails
  106860. */
  106861. setStencilOperationDepthFail(operation: number): void;
  106862. /**
  106863. * Sets the stencil operation to use when stencil passes
  106864. * @param operation defines the stencil operation to use when stencil passes
  106865. */
  106866. setStencilOperationPass(operation: number): void;
  106867. /**
  106868. * Sets a boolean indicating if the dithering state is enabled or disabled
  106869. * @param value defines the dithering state
  106870. */
  106871. setDitheringState(value: boolean): void;
  106872. /**
  106873. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  106874. * @param value defines the rasterizer state
  106875. */
  106876. setRasterizerState(value: boolean): void;
  106877. /**
  106878. * Gets the current depth function
  106879. * @returns a number defining the depth function
  106880. */
  106881. getDepthFunction(): Nullable<number>;
  106882. /**
  106883. * Sets the current depth function
  106884. * @param depthFunc defines the function to use
  106885. */
  106886. setDepthFunction(depthFunc: number): void;
  106887. /**
  106888. * Sets the current depth function to GREATER
  106889. */
  106890. setDepthFunctionToGreater(): void;
  106891. /**
  106892. * Sets the current depth function to GEQUAL
  106893. */
  106894. setDepthFunctionToGreaterOrEqual(): void;
  106895. /**
  106896. * Sets the current depth function to LESS
  106897. */
  106898. setDepthFunctionToLess(): void;
  106899. /**
  106900. * Sets the current depth function to LEQUAL
  106901. */
  106902. setDepthFunctionToLessOrEqual(): void;
  106903. private _cachedStencilBuffer;
  106904. private _cachedStencilFunction;
  106905. private _cachedStencilMask;
  106906. private _cachedStencilOperationPass;
  106907. private _cachedStencilOperationFail;
  106908. private _cachedStencilOperationDepthFail;
  106909. private _cachedStencilReference;
  106910. /**
  106911. * Caches the the state of the stencil buffer
  106912. */
  106913. cacheStencilState(): void;
  106914. /**
  106915. * Restores the state of the stencil buffer
  106916. */
  106917. restoreStencilState(): void;
  106918. /**
  106919. * Directly set the WebGL Viewport
  106920. * @param x defines the x coordinate of the viewport (in screen space)
  106921. * @param y defines the y coordinate of the viewport (in screen space)
  106922. * @param width defines the width of the viewport (in screen space)
  106923. * @param height defines the height of the viewport (in screen space)
  106924. * @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
  106925. */
  106926. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  106927. /**
  106928. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  106929. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106930. * @param y defines the y-coordinate of the corner of the clear rectangle
  106931. * @param width defines the width of the clear rectangle
  106932. * @param height defines the height of the clear rectangle
  106933. * @param clearColor defines the clear color
  106934. */
  106935. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  106936. /**
  106937. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  106938. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  106939. * @param y defines the y-coordinate of the corner of the clear rectangle
  106940. * @param width defines the width of the clear rectangle
  106941. * @param height defines the height of the clear rectangle
  106942. */
  106943. enableScissor(x: number, y: number, width: number, height: number): void;
  106944. /**
  106945. * Disable previously set scissor test rectangle
  106946. */
  106947. disableScissor(): void;
  106948. protected _reportDrawCall(): void;
  106949. /**
  106950. * Initializes a webVR display and starts listening to display change events
  106951. * The onVRDisplayChangedObservable will be notified upon these changes
  106952. * @returns The onVRDisplayChangedObservable
  106953. */
  106954. initWebVR(): Observable<IDisplayChangedEventArgs>;
  106955. /** @hidden */
  106956. _prepareVRComponent(): void;
  106957. /** @hidden */
  106958. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  106959. /** @hidden */
  106960. _submitVRFrame(): void;
  106961. /**
  106962. * Call this function to leave webVR mode
  106963. * Will do nothing if webVR is not supported or if there is no webVR device
  106964. * @see http://doc.babylonjs.com/how_to/webvr_camera
  106965. */
  106966. disableVR(): void;
  106967. /**
  106968. * Gets a boolean indicating that the system is in VR mode and is presenting
  106969. * @returns true if VR mode is engaged
  106970. */
  106971. isVRPresenting(): boolean;
  106972. /** @hidden */
  106973. _requestVRFrame(): void;
  106974. /** @hidden */
  106975. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  106976. /**
  106977. * Gets the source code of the vertex shader associated with a specific webGL program
  106978. * @param program defines the program to use
  106979. * @returns a string containing the source code of the vertex shader associated with the program
  106980. */
  106981. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  106982. /**
  106983. * Gets the source code of the fragment shader associated with a specific webGL program
  106984. * @param program defines the program to use
  106985. * @returns a string containing the source code of the fragment shader associated with the program
  106986. */
  106987. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  106988. /**
  106989. * Sets a depth stencil texture from a render target to the according uniform.
  106990. * @param channel The texture channel
  106991. * @param uniform The uniform to set
  106992. * @param texture The render target texture containing the depth stencil texture to apply
  106993. */
  106994. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  106995. /**
  106996. * Sets a texture to the webGL context from a postprocess
  106997. * @param channel defines the channel to use
  106998. * @param postProcess defines the source postprocess
  106999. */
  107000. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  107001. /**
  107002. * Binds the output of the passed in post process to the texture channel specified
  107003. * @param channel The channel the texture should be bound to
  107004. * @param postProcess The post process which's output should be bound
  107005. */
  107006. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  107007. /** @hidden */
  107008. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  107009. protected _rebuildBuffers(): void;
  107010. /** @hidden */
  107011. _renderFrame(): void;
  107012. _renderLoop(): void;
  107013. /** @hidden */
  107014. _renderViews(): boolean;
  107015. /**
  107016. * Toggle full screen mode
  107017. * @param requestPointerLock defines if a pointer lock should be requested from the user
  107018. */
  107019. switchFullscreen(requestPointerLock: boolean): void;
  107020. /**
  107021. * Enters full screen mode
  107022. * @param requestPointerLock defines if a pointer lock should be requested from the user
  107023. */
  107024. enterFullscreen(requestPointerLock: boolean): void;
  107025. /**
  107026. * Exits full screen mode
  107027. */
  107028. exitFullscreen(): void;
  107029. /**
  107030. * Enters Pointerlock mode
  107031. */
  107032. enterPointerlock(): void;
  107033. /**
  107034. * Exits Pointerlock mode
  107035. */
  107036. exitPointerlock(): void;
  107037. /**
  107038. * Begin a new frame
  107039. */
  107040. beginFrame(): void;
  107041. /**
  107042. * Enf the current frame
  107043. */
  107044. endFrame(): void;
  107045. resize(): void;
  107046. /**
  107047. * Set the compressed texture format to use, based on the formats you have, and the formats
  107048. * supported by the hardware / browser.
  107049. *
  107050. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  107051. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  107052. * to API arguments needed to compressed textures. This puts the burden on the container
  107053. * generator to house the arcane code for determining these for current & future formats.
  107054. *
  107055. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  107056. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  107057. *
  107058. * Note: The result of this call is not taken into account when a texture is base64.
  107059. *
  107060. * @param formatsAvailable defines the list of those format families you have created
  107061. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  107062. *
  107063. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  107064. * @returns The extension selected.
  107065. */
  107066. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  107067. /**
  107068. * Set the compressed texture extensions or file names to skip.
  107069. *
  107070. * @param skippedFiles defines the list of those texture files you want to skip
  107071. * Example: [".dds", ".env", "myfile.png"]
  107072. */
  107073. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  107074. /**
  107075. * Force a specific size of the canvas
  107076. * @param width defines the new canvas' width
  107077. * @param height defines the new canvas' height
  107078. */
  107079. setSize(width: number, height: number): void;
  107080. /**
  107081. * Updates a dynamic vertex buffer.
  107082. * @param vertexBuffer the vertex buffer to update
  107083. * @param data the data used to update the vertex buffer
  107084. * @param byteOffset the byte offset of the data
  107085. * @param byteLength the byte length of the data
  107086. */
  107087. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  107088. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  107089. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107090. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  107091. _releaseTexture(texture: InternalTexture): void;
  107092. /**
  107093. * @hidden
  107094. * Rescales a texture
  107095. * @param source input texutre
  107096. * @param destination destination texture
  107097. * @param scene scene to use to render the resize
  107098. * @param internalFormat format to use when resizing
  107099. * @param onComplete callback to be called when resize has completed
  107100. */
  107101. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  107102. /**
  107103. * Gets the current framerate
  107104. * @returns a number representing the framerate
  107105. */
  107106. getFps(): number;
  107107. /**
  107108. * Gets the time spent between current and previous frame
  107109. * @returns a number representing the delta time in ms
  107110. */
  107111. getDeltaTime(): number;
  107112. private _measureFps;
  107113. /** @hidden */
  107114. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  107115. /**
  107116. * Update a dynamic index buffer
  107117. * @param indexBuffer defines the target index buffer
  107118. * @param indices defines the data to update
  107119. * @param offset defines the offset in the target index buffer where update should start
  107120. */
  107121. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  107122. /**
  107123. * Updates the sample count of a render target texture
  107124. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  107125. * @param texture defines the texture to update
  107126. * @param samples defines the sample count to set
  107127. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  107128. */
  107129. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  107130. /**
  107131. * Updates a depth texture Comparison Mode and Function.
  107132. * If the comparison Function is equal to 0, the mode will be set to none.
  107133. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  107134. * @param texture The texture to set the comparison function for
  107135. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  107136. */
  107137. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  107138. /**
  107139. * Creates a webGL buffer to use with instanciation
  107140. * @param capacity defines the size of the buffer
  107141. * @returns the webGL buffer
  107142. */
  107143. createInstancesBuffer(capacity: number): DataBuffer;
  107144. /**
  107145. * Delete a webGL buffer used with instanciation
  107146. * @param buffer defines the webGL buffer to delete
  107147. */
  107148. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  107149. /** @hidden */
  107150. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  107151. dispose(): void;
  107152. private _disableTouchAction;
  107153. /**
  107154. * Display the loading screen
  107155. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107156. */
  107157. displayLoadingUI(): void;
  107158. /**
  107159. * Hide the loading screen
  107160. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107161. */
  107162. hideLoadingUI(): void;
  107163. /**
  107164. * Gets the current loading screen object
  107165. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107166. */
  107167. get loadingScreen(): ILoadingScreen;
  107168. /**
  107169. * Sets the current loading screen object
  107170. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107171. */
  107172. set loadingScreen(loadingScreen: ILoadingScreen);
  107173. /**
  107174. * Sets the current loading screen text
  107175. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107176. */
  107177. set loadingUIText(text: string);
  107178. /**
  107179. * Sets the current loading screen background color
  107180. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107181. */
  107182. set loadingUIBackgroundColor(color: string);
  107183. /** Pointerlock and fullscreen */
  107184. /**
  107185. * Ask the browser to promote the current element to pointerlock mode
  107186. * @param element defines the DOM element to promote
  107187. */
  107188. static _RequestPointerlock(element: HTMLElement): void;
  107189. /**
  107190. * Asks the browser to exit pointerlock mode
  107191. */
  107192. static _ExitPointerlock(): void;
  107193. /**
  107194. * Ask the browser to promote the current element to fullscreen rendering mode
  107195. * @param element defines the DOM element to promote
  107196. */
  107197. static _RequestFullscreen(element: HTMLElement): void;
  107198. /**
  107199. * Asks the browser to exit fullscreen mode
  107200. */
  107201. static _ExitFullscreen(): void;
  107202. }
  107203. }
  107204. declare module BABYLON {
  107205. /**
  107206. * The engine store class is responsible to hold all the instances of Engine and Scene created
  107207. * during the life time of the application.
  107208. */
  107209. export class EngineStore {
  107210. /** Gets the list of created engines */
  107211. static Instances: Engine[];
  107212. /** @hidden */
  107213. static _LastCreatedScene: Nullable<Scene>;
  107214. /**
  107215. * Gets the latest created engine
  107216. */
  107217. static get LastCreatedEngine(): Nullable<Engine>;
  107218. /**
  107219. * Gets the latest created scene
  107220. */
  107221. static get LastCreatedScene(): Nullable<Scene>;
  107222. /**
  107223. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107224. * @ignorenaming
  107225. */
  107226. static UseFallbackTexture: boolean;
  107227. /**
  107228. * Texture content used if a texture cannot loaded
  107229. * @ignorenaming
  107230. */
  107231. static FallbackTexture: string;
  107232. }
  107233. }
  107234. declare module BABYLON {
  107235. /**
  107236. * Helper class that provides a small promise polyfill
  107237. */
  107238. export class PromisePolyfill {
  107239. /**
  107240. * Static function used to check if the polyfill is required
  107241. * If this is the case then the function will inject the polyfill to window.Promise
  107242. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  107243. */
  107244. static Apply(force?: boolean): void;
  107245. }
  107246. }
  107247. declare module BABYLON {
  107248. /**
  107249. * Interface for screenshot methods with describe argument called `size` as object with options
  107250. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  107251. */
  107252. export interface IScreenshotSize {
  107253. /**
  107254. * number in pixels for canvas height
  107255. */
  107256. height?: number;
  107257. /**
  107258. * multiplier allowing render at a higher or lower resolution
  107259. * If value is defined then height and width will be ignored and taken from camera
  107260. */
  107261. precision?: number;
  107262. /**
  107263. * number in pixels for canvas width
  107264. */
  107265. width?: number;
  107266. }
  107267. }
  107268. declare module BABYLON {
  107269. interface IColor4Like {
  107270. r: float;
  107271. g: float;
  107272. b: float;
  107273. a: float;
  107274. }
  107275. /**
  107276. * Class containing a set of static utilities functions
  107277. */
  107278. export class Tools {
  107279. /**
  107280. * Gets or sets the base URL to use to load assets
  107281. */
  107282. static get BaseUrl(): string;
  107283. static set BaseUrl(value: string);
  107284. /**
  107285. * Enable/Disable Custom HTTP Request Headers globally.
  107286. * default = false
  107287. * @see CustomRequestHeaders
  107288. */
  107289. static UseCustomRequestHeaders: boolean;
  107290. /**
  107291. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  107292. * i.e. when loading files, where the server/service expects an Authorization header
  107293. */
  107294. static CustomRequestHeaders: {
  107295. [key: string]: string;
  107296. };
  107297. /**
  107298. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  107299. */
  107300. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  107301. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  107302. /**
  107303. * Default behaviour for cors in the application.
  107304. * It can be a string if the expected behavior is identical in the entire app.
  107305. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  107306. */
  107307. static CorsBehavior: string | ((url: string | string[]) => string);
  107308. /**
  107309. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  107310. * @ignorenaming
  107311. */
  107312. static get UseFallbackTexture(): boolean;
  107313. static set UseFallbackTexture(value: boolean);
  107314. /**
  107315. * Use this object to register external classes like custom textures or material
  107316. * to allow the laoders to instantiate them
  107317. */
  107318. static get RegisteredExternalClasses(): {
  107319. [key: string]: Object;
  107320. };
  107321. static set RegisteredExternalClasses(classes: {
  107322. [key: string]: Object;
  107323. });
  107324. /**
  107325. * Texture content used if a texture cannot loaded
  107326. * @ignorenaming
  107327. */
  107328. static get fallbackTexture(): string;
  107329. static set fallbackTexture(value: string);
  107330. /**
  107331. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  107332. * @param u defines the coordinate on X axis
  107333. * @param v defines the coordinate on Y axis
  107334. * @param width defines the width of the source data
  107335. * @param height defines the height of the source data
  107336. * @param pixels defines the source byte array
  107337. * @param color defines the output color
  107338. */
  107339. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  107340. /**
  107341. * Interpolates between a and b via alpha
  107342. * @param a The lower value (returned when alpha = 0)
  107343. * @param b The upper value (returned when alpha = 1)
  107344. * @param alpha The interpolation-factor
  107345. * @return The mixed value
  107346. */
  107347. static Mix(a: number, b: number, alpha: number): number;
  107348. /**
  107349. * Tries to instantiate a new object from a given class name
  107350. * @param className defines the class name to instantiate
  107351. * @returns the new object or null if the system was not able to do the instantiation
  107352. */
  107353. static Instantiate(className: string): any;
  107354. /**
  107355. * Provides a slice function that will work even on IE
  107356. * @param data defines the array to slice
  107357. * @param start defines the start of the data (optional)
  107358. * @param end defines the end of the data (optional)
  107359. * @returns the new sliced array
  107360. */
  107361. static Slice<T>(data: T, start?: number, end?: number): T;
  107362. /**
  107363. * Polyfill for setImmediate
  107364. * @param action defines the action to execute after the current execution block
  107365. */
  107366. static SetImmediate(action: () => void): void;
  107367. /**
  107368. * Function indicating if a number is an exponent of 2
  107369. * @param value defines the value to test
  107370. * @returns true if the value is an exponent of 2
  107371. */
  107372. static IsExponentOfTwo(value: number): boolean;
  107373. private static _tmpFloatArray;
  107374. /**
  107375. * Returns the nearest 32-bit single precision float representation of a Number
  107376. * @param value A Number. If the parameter is of a different type, it will get converted
  107377. * to a number or to NaN if it cannot be converted
  107378. * @returns number
  107379. */
  107380. static FloatRound(value: number): number;
  107381. /**
  107382. * Extracts the filename from a path
  107383. * @param path defines the path to use
  107384. * @returns the filename
  107385. */
  107386. static GetFilename(path: string): string;
  107387. /**
  107388. * Extracts the "folder" part of a path (everything before the filename).
  107389. * @param uri The URI to extract the info from
  107390. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  107391. * @returns The "folder" part of the path
  107392. */
  107393. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  107394. /**
  107395. * Extracts text content from a DOM element hierarchy
  107396. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  107397. */
  107398. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  107399. /**
  107400. * Convert an angle in radians to degrees
  107401. * @param angle defines the angle to convert
  107402. * @returns the angle in degrees
  107403. */
  107404. static ToDegrees(angle: number): number;
  107405. /**
  107406. * Convert an angle in degrees to radians
  107407. * @param angle defines the angle to convert
  107408. * @returns the angle in radians
  107409. */
  107410. static ToRadians(angle: number): number;
  107411. /**
  107412. * Returns an array if obj is not an array
  107413. * @param obj defines the object to evaluate as an array
  107414. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  107415. * @returns either obj directly if obj is an array or a new array containing obj
  107416. */
  107417. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  107418. /**
  107419. * Gets the pointer prefix to use
  107420. * @returns "pointer" if touch is enabled. Else returns "mouse"
  107421. */
  107422. static GetPointerPrefix(): string;
  107423. /**
  107424. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  107425. * @param url define the url we are trying
  107426. * @param element define the dom element where to configure the cors policy
  107427. */
  107428. static SetCorsBehavior(url: string | string[], element: {
  107429. crossOrigin: string | null;
  107430. }): void;
  107431. /**
  107432. * Removes unwanted characters from an url
  107433. * @param url defines the url to clean
  107434. * @returns the cleaned url
  107435. */
  107436. static CleanUrl(url: string): string;
  107437. /**
  107438. * Gets or sets a function used to pre-process url before using them to load assets
  107439. */
  107440. static get PreprocessUrl(): (url: string) => string;
  107441. static set PreprocessUrl(processor: (url: string) => string);
  107442. /**
  107443. * Loads an image as an HTMLImageElement.
  107444. * @param input url string, ArrayBuffer, or Blob to load
  107445. * @param onLoad callback called when the image successfully loads
  107446. * @param onError callback called when the image fails to load
  107447. * @param offlineProvider offline provider for caching
  107448. * @param mimeType optional mime type
  107449. * @returns the HTMLImageElement of the loaded image
  107450. */
  107451. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  107452. /**
  107453. * Loads a file from a url
  107454. * @param url url string, ArrayBuffer, or Blob to load
  107455. * @param onSuccess callback called when the file successfully loads
  107456. * @param onProgress callback called while file is loading (if the server supports this mode)
  107457. * @param offlineProvider defines the offline provider for caching
  107458. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107459. * @param onError callback called when the file fails to load
  107460. * @returns a file request object
  107461. */
  107462. 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;
  107463. /**
  107464. * Loads a file from a url
  107465. * @param url the file url to load
  107466. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  107467. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  107468. */
  107469. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  107470. /**
  107471. * Load a script (identified by an url). When the url returns, the
  107472. * content of this file is added into a new script element, attached to the DOM (body element)
  107473. * @param scriptUrl defines the url of the script to laod
  107474. * @param onSuccess defines the callback called when the script is loaded
  107475. * @param onError defines the callback to call if an error occurs
  107476. * @param scriptId defines the id of the script element
  107477. */
  107478. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  107479. /**
  107480. * Load an asynchronous script (identified by an url). When the url returns, the
  107481. * content of this file is added into a new script element, attached to the DOM (body element)
  107482. * @param scriptUrl defines the url of the script to laod
  107483. * @param scriptId defines the id of the script element
  107484. * @returns a promise request object
  107485. */
  107486. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  107487. /**
  107488. * Loads a file from a blob
  107489. * @param fileToLoad defines the blob to use
  107490. * @param callback defines the callback to call when data is loaded
  107491. * @param progressCallback defines the callback to call during loading process
  107492. * @returns a file request object
  107493. */
  107494. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  107495. /**
  107496. * Reads a file from a File object
  107497. * @param file defines the file to load
  107498. * @param onSuccess defines the callback to call when data is loaded
  107499. * @param onProgress defines the callback to call during loading process
  107500. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  107501. * @param onError defines the callback to call when an error occurs
  107502. * @returns a file request object
  107503. */
  107504. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  107505. /**
  107506. * Creates a data url from a given string content
  107507. * @param content defines the content to convert
  107508. * @returns the new data url link
  107509. */
  107510. static FileAsURL(content: string): string;
  107511. /**
  107512. * Format the given number to a specific decimal format
  107513. * @param value defines the number to format
  107514. * @param decimals defines the number of decimals to use
  107515. * @returns the formatted string
  107516. */
  107517. static Format(value: number, decimals?: number): string;
  107518. /**
  107519. * Tries to copy an object by duplicating every property
  107520. * @param source defines the source object
  107521. * @param destination defines the target object
  107522. * @param doNotCopyList defines a list of properties to avoid
  107523. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  107524. */
  107525. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  107526. /**
  107527. * Gets a boolean indicating if the given object has no own property
  107528. * @param obj defines the object to test
  107529. * @returns true if object has no own property
  107530. */
  107531. static IsEmpty(obj: any): boolean;
  107532. /**
  107533. * Function used to register events at window level
  107534. * @param windowElement defines the Window object to use
  107535. * @param events defines the events to register
  107536. */
  107537. static RegisterTopRootEvents(windowElement: Window, events: {
  107538. name: string;
  107539. handler: Nullable<(e: FocusEvent) => any>;
  107540. }[]): void;
  107541. /**
  107542. * Function used to unregister events from window level
  107543. * @param windowElement defines the Window object to use
  107544. * @param events defines the events to unregister
  107545. */
  107546. static UnregisterTopRootEvents(windowElement: Window, events: {
  107547. name: string;
  107548. handler: Nullable<(e: FocusEvent) => any>;
  107549. }[]): void;
  107550. /**
  107551. * @ignore
  107552. */
  107553. static _ScreenshotCanvas: HTMLCanvasElement;
  107554. /**
  107555. * Dumps the current bound framebuffer
  107556. * @param width defines the rendering width
  107557. * @param height defines the rendering height
  107558. * @param engine defines the hosting engine
  107559. * @param successCallback defines the callback triggered once the data are available
  107560. * @param mimeType defines the mime type of the result
  107561. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  107562. */
  107563. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107564. /**
  107565. * Converts the canvas data to blob.
  107566. * This acts as a polyfill for browsers not supporting the to blob function.
  107567. * @param canvas Defines the canvas to extract the data from
  107568. * @param successCallback Defines the callback triggered once the data are available
  107569. * @param mimeType Defines the mime type of the result
  107570. */
  107571. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  107572. /**
  107573. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  107574. * @param successCallback defines the callback triggered once the data are available
  107575. * @param mimeType defines the mime type of the result
  107576. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  107577. */
  107578. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  107579. /**
  107580. * Downloads a blob in the browser
  107581. * @param blob defines the blob to download
  107582. * @param fileName defines the name of the downloaded file
  107583. */
  107584. static Download(blob: Blob, fileName: string): void;
  107585. /**
  107586. * Captures a screenshot of the current rendering
  107587. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107588. * @param engine defines the rendering engine
  107589. * @param camera defines the source camera
  107590. * @param size This parameter can be set to a single number or to an object with the
  107591. * following (optional) properties: precision, width, height. If a single number is passed,
  107592. * it will be used for both width and height. If an object is passed, the screenshot size
  107593. * will be derived from the parameters. The precision property is a multiplier allowing
  107594. * rendering at a higher or lower resolution
  107595. * @param successCallback defines the callback receives a single parameter which contains the
  107596. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107597. * src parameter of an <img> to display it
  107598. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107599. * Check your browser for supported MIME types
  107600. */
  107601. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  107602. /**
  107603. * Captures a screenshot of the current rendering
  107604. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107605. * @param engine defines the rendering engine
  107606. * @param camera defines the source camera
  107607. * @param size This parameter can be set to a single number or to an object with the
  107608. * following (optional) properties: precision, width, height. If a single number is passed,
  107609. * it will be used for both width and height. If an object is passed, the screenshot size
  107610. * will be derived from the parameters. The precision property is a multiplier allowing
  107611. * rendering at a higher or lower resolution
  107612. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  107613. * Check your browser for supported MIME types
  107614. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107615. * to the src parameter of an <img> to display it
  107616. */
  107617. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  107618. /**
  107619. * Generates an image screenshot from the specified camera.
  107620. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107621. * @param engine The engine to use for rendering
  107622. * @param camera The camera to use for rendering
  107623. * @param size This parameter can be set to a single number or to an object with the
  107624. * following (optional) properties: precision, width, height. If a single number is passed,
  107625. * it will be used for both width and height. If an object is passed, the screenshot size
  107626. * will be derived from the parameters. The precision property is a multiplier allowing
  107627. * rendering at a higher or lower resolution
  107628. * @param successCallback The callback receives a single parameter which contains the
  107629. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  107630. * src parameter of an <img> to display it
  107631. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107632. * Check your browser for supported MIME types
  107633. * @param samples Texture samples (default: 1)
  107634. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107635. * @param fileName A name for for the downloaded file.
  107636. */
  107637. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  107638. /**
  107639. * Generates an image screenshot from the specified camera.
  107640. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  107641. * @param engine The engine to use for rendering
  107642. * @param camera The camera to use for rendering
  107643. * @param size This parameter can be set to a single number or to an object with the
  107644. * following (optional) properties: precision, width, height. If a single number is passed,
  107645. * it will be used for both width and height. If an object is passed, the screenshot size
  107646. * will be derived from the parameters. The precision property is a multiplier allowing
  107647. * rendering at a higher or lower resolution
  107648. * @param mimeType The MIME type of the screenshot image (default: image/png).
  107649. * Check your browser for supported MIME types
  107650. * @param samples Texture samples (default: 1)
  107651. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  107652. * @param fileName A name for for the downloaded file.
  107653. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  107654. * to the src parameter of an <img> to display it
  107655. */
  107656. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  107657. /**
  107658. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  107659. * Be aware Math.random() could cause collisions, but:
  107660. * "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"
  107661. * @returns a pseudo random id
  107662. */
  107663. static RandomId(): string;
  107664. /**
  107665. * Test if the given uri is a base64 string
  107666. * @param uri The uri to test
  107667. * @return True if the uri is a base64 string or false otherwise
  107668. */
  107669. static IsBase64(uri: string): boolean;
  107670. /**
  107671. * Decode the given base64 uri.
  107672. * @param uri The uri to decode
  107673. * @return The decoded base64 data.
  107674. */
  107675. static DecodeBase64(uri: string): ArrayBuffer;
  107676. /**
  107677. * Gets the absolute url.
  107678. * @param url the input url
  107679. * @return the absolute url
  107680. */
  107681. static GetAbsoluteUrl(url: string): string;
  107682. /**
  107683. * No log
  107684. */
  107685. static readonly NoneLogLevel: number;
  107686. /**
  107687. * Only message logs
  107688. */
  107689. static readonly MessageLogLevel: number;
  107690. /**
  107691. * Only warning logs
  107692. */
  107693. static readonly WarningLogLevel: number;
  107694. /**
  107695. * Only error logs
  107696. */
  107697. static readonly ErrorLogLevel: number;
  107698. /**
  107699. * All logs
  107700. */
  107701. static readonly AllLogLevel: number;
  107702. /**
  107703. * Gets a value indicating the number of loading errors
  107704. * @ignorenaming
  107705. */
  107706. static get errorsCount(): number;
  107707. /**
  107708. * Callback called when a new log is added
  107709. */
  107710. static OnNewCacheEntry: (entry: string) => void;
  107711. /**
  107712. * Log a message to the console
  107713. * @param message defines the message to log
  107714. */
  107715. static Log(message: string): void;
  107716. /**
  107717. * Write a warning message to the console
  107718. * @param message defines the message to log
  107719. */
  107720. static Warn(message: string): void;
  107721. /**
  107722. * Write an error message to the console
  107723. * @param message defines the message to log
  107724. */
  107725. static Error(message: string): void;
  107726. /**
  107727. * Gets current log cache (list of logs)
  107728. */
  107729. static get LogCache(): string;
  107730. /**
  107731. * Clears the log cache
  107732. */
  107733. static ClearLogCache(): void;
  107734. /**
  107735. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  107736. */
  107737. static set LogLevels(level: number);
  107738. /**
  107739. * Checks if the window object exists
  107740. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  107741. */
  107742. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  107743. /**
  107744. * No performance log
  107745. */
  107746. static readonly PerformanceNoneLogLevel: number;
  107747. /**
  107748. * Use user marks to log performance
  107749. */
  107750. static readonly PerformanceUserMarkLogLevel: number;
  107751. /**
  107752. * Log performance to the console
  107753. */
  107754. static readonly PerformanceConsoleLogLevel: number;
  107755. private static _performance;
  107756. /**
  107757. * Sets the current performance log level
  107758. */
  107759. static set PerformanceLogLevel(level: number);
  107760. private static _StartPerformanceCounterDisabled;
  107761. private static _EndPerformanceCounterDisabled;
  107762. private static _StartUserMark;
  107763. private static _EndUserMark;
  107764. private static _StartPerformanceConsole;
  107765. private static _EndPerformanceConsole;
  107766. /**
  107767. * Starts a performance counter
  107768. */
  107769. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107770. /**
  107771. * Ends a specific performance coutner
  107772. */
  107773. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  107774. /**
  107775. * Gets either window.performance.now() if supported or Date.now() else
  107776. */
  107777. static get Now(): number;
  107778. /**
  107779. * This method will return the name of the class used to create the instance of the given object.
  107780. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  107781. * @param object the object to get the class name from
  107782. * @param isType defines if the object is actually a type
  107783. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  107784. */
  107785. static GetClassName(object: any, isType?: boolean): string;
  107786. /**
  107787. * Gets the first element of an array satisfying a given predicate
  107788. * @param array defines the array to browse
  107789. * @param predicate defines the predicate to use
  107790. * @returns null if not found or the element
  107791. */
  107792. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  107793. /**
  107794. * This method will return the name of the full name of the class, including its owning module (if any).
  107795. * 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).
  107796. * @param object the object to get the class name from
  107797. * @param isType defines if the object is actually a type
  107798. * @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.
  107799. * @ignorenaming
  107800. */
  107801. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  107802. /**
  107803. * Returns a promise that resolves after the given amount of time.
  107804. * @param delay Number of milliseconds to delay
  107805. * @returns Promise that resolves after the given amount of time
  107806. */
  107807. static DelayAsync(delay: number): Promise<void>;
  107808. /**
  107809. * Utility function to detect if the current user agent is Safari
  107810. * @returns whether or not the current user agent is safari
  107811. */
  107812. static IsSafari(): boolean;
  107813. }
  107814. /**
  107815. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  107816. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  107817. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  107818. * @param name The name of the class, case should be preserved
  107819. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  107820. */
  107821. export function className(name: string, module?: string): (target: Object) => void;
  107822. /**
  107823. * An implementation of a loop for asynchronous functions.
  107824. */
  107825. export class AsyncLoop {
  107826. /**
  107827. * Defines the number of iterations for the loop
  107828. */
  107829. iterations: number;
  107830. /**
  107831. * Defines the current index of the loop.
  107832. */
  107833. index: number;
  107834. private _done;
  107835. private _fn;
  107836. private _successCallback;
  107837. /**
  107838. * Constructor.
  107839. * @param iterations the number of iterations.
  107840. * @param func the function to run each iteration
  107841. * @param successCallback the callback that will be called upon succesful execution
  107842. * @param offset starting offset.
  107843. */
  107844. constructor(
  107845. /**
  107846. * Defines the number of iterations for the loop
  107847. */
  107848. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  107849. /**
  107850. * Execute the next iteration. Must be called after the last iteration was finished.
  107851. */
  107852. executeNext(): void;
  107853. /**
  107854. * Break the loop and run the success callback.
  107855. */
  107856. breakLoop(): void;
  107857. /**
  107858. * Create and run an async loop.
  107859. * @param iterations the number of iterations.
  107860. * @param fn the function to run each iteration
  107861. * @param successCallback the callback that will be called upon succesful execution
  107862. * @param offset starting offset.
  107863. * @returns the created async loop object
  107864. */
  107865. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  107866. /**
  107867. * A for-loop that will run a given number of iterations synchronous and the rest async.
  107868. * @param iterations total number of iterations
  107869. * @param syncedIterations number of synchronous iterations in each async iteration.
  107870. * @param fn the function to call each iteration.
  107871. * @param callback a success call back that will be called when iterating stops.
  107872. * @param breakFunction a break condition (optional)
  107873. * @param timeout timeout settings for the setTimeout function. default - 0.
  107874. * @returns the created async loop object
  107875. */
  107876. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  107877. }
  107878. }
  107879. declare module BABYLON {
  107880. /**
  107881. * This class implement a typical dictionary using a string as key and the generic type T as value.
  107882. * The underlying implementation relies on an associative array to ensure the best performances.
  107883. * The value can be anything including 'null' but except 'undefined'
  107884. */
  107885. export class StringDictionary<T> {
  107886. /**
  107887. * This will clear this dictionary and copy the content from the 'source' one.
  107888. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  107889. * @param source the dictionary to take the content from and copy to this dictionary
  107890. */
  107891. copyFrom(source: StringDictionary<T>): void;
  107892. /**
  107893. * Get a value based from its key
  107894. * @param key the given key to get the matching value from
  107895. * @return the value if found, otherwise undefined is returned
  107896. */
  107897. get(key: string): T | undefined;
  107898. /**
  107899. * Get a value from its key or add it if it doesn't exist.
  107900. * This method will ensure you that a given key/data will be present in the dictionary.
  107901. * @param key the given key to get the matching value from
  107902. * @param factory the factory that will create the value if the key is not present in the dictionary.
  107903. * The factory will only be invoked if there's no data for the given key.
  107904. * @return the value corresponding to the key.
  107905. */
  107906. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  107907. /**
  107908. * Get a value from its key if present in the dictionary otherwise add it
  107909. * @param key the key to get the value from
  107910. * @param val if there's no such key/value pair in the dictionary add it with this value
  107911. * @return the value corresponding to the key
  107912. */
  107913. getOrAdd(key: string, val: T): T;
  107914. /**
  107915. * Check if there's a given key in the dictionary
  107916. * @param key the key to check for
  107917. * @return true if the key is present, false otherwise
  107918. */
  107919. contains(key: string): boolean;
  107920. /**
  107921. * Add a new key and its corresponding value
  107922. * @param key the key to add
  107923. * @param value the value corresponding to the key
  107924. * @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
  107925. */
  107926. add(key: string, value: T): boolean;
  107927. /**
  107928. * Update a specific value associated to a key
  107929. * @param key defines the key to use
  107930. * @param value defines the value to store
  107931. * @returns true if the value was updated (or false if the key was not found)
  107932. */
  107933. set(key: string, value: T): boolean;
  107934. /**
  107935. * Get the element of the given key and remove it from the dictionary
  107936. * @param key defines the key to search
  107937. * @returns the value associated with the key or null if not found
  107938. */
  107939. getAndRemove(key: string): Nullable<T>;
  107940. /**
  107941. * Remove a key/value from the dictionary.
  107942. * @param key the key to remove
  107943. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  107944. */
  107945. remove(key: string): boolean;
  107946. /**
  107947. * Clear the whole content of the dictionary
  107948. */
  107949. clear(): void;
  107950. /**
  107951. * Gets the current count
  107952. */
  107953. get count(): number;
  107954. /**
  107955. * Execute a callback on each key/val of the dictionary.
  107956. * Note that you can remove any element in this dictionary in the callback implementation
  107957. * @param callback the callback to execute on a given key/value pair
  107958. */
  107959. forEach(callback: (key: string, val: T) => void): void;
  107960. /**
  107961. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  107962. * If the callback returns null or undefined the method will iterate to the next key/value pair
  107963. * Note that you can remove any element in this dictionary in the callback implementation
  107964. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  107965. * @returns the first item
  107966. */
  107967. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  107968. private _count;
  107969. private _data;
  107970. }
  107971. }
  107972. declare module BABYLON {
  107973. /** @hidden */
  107974. export interface ICollisionCoordinator {
  107975. createCollider(): Collider;
  107976. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107977. init(scene: Scene): void;
  107978. }
  107979. /** @hidden */
  107980. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  107981. private _scene;
  107982. private _scaledPosition;
  107983. private _scaledVelocity;
  107984. private _finalPosition;
  107985. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  107986. createCollider(): Collider;
  107987. init(scene: Scene): void;
  107988. private _collideWithWorld;
  107989. }
  107990. }
  107991. declare module BABYLON {
  107992. /**
  107993. * Class used to manage all inputs for the scene.
  107994. */
  107995. export class InputManager {
  107996. /** The distance in pixel that you have to move to prevent some events */
  107997. static DragMovementThreshold: number;
  107998. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  107999. static LongPressDelay: number;
  108000. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  108001. static DoubleClickDelay: number;
  108002. /** If you need to check double click without raising a single click at first click, enable this flag */
  108003. static ExclusiveDoubleClickMode: boolean;
  108004. private _wheelEventName;
  108005. private _onPointerMove;
  108006. private _onPointerDown;
  108007. private _onPointerUp;
  108008. private _initClickEvent;
  108009. private _initActionManager;
  108010. private _delayedSimpleClick;
  108011. private _delayedSimpleClickTimeout;
  108012. private _previousDelayedSimpleClickTimeout;
  108013. private _meshPickProceed;
  108014. private _previousButtonPressed;
  108015. private _currentPickResult;
  108016. private _previousPickResult;
  108017. private _totalPointersPressed;
  108018. private _doubleClickOccured;
  108019. private _pointerOverMesh;
  108020. private _pickedDownMesh;
  108021. private _pickedUpMesh;
  108022. private _pointerX;
  108023. private _pointerY;
  108024. private _unTranslatedPointerX;
  108025. private _unTranslatedPointerY;
  108026. private _startingPointerPosition;
  108027. private _previousStartingPointerPosition;
  108028. private _startingPointerTime;
  108029. private _previousStartingPointerTime;
  108030. private _pointerCaptures;
  108031. private _onKeyDown;
  108032. private _onKeyUp;
  108033. private _onCanvasFocusObserver;
  108034. private _onCanvasBlurObserver;
  108035. private _scene;
  108036. /**
  108037. * Creates a new InputManager
  108038. * @param scene defines the hosting scene
  108039. */
  108040. constructor(scene: Scene);
  108041. /**
  108042. * Gets the mesh that is currently under the pointer
  108043. */
  108044. get meshUnderPointer(): Nullable<AbstractMesh>;
  108045. /**
  108046. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  108047. */
  108048. get unTranslatedPointer(): Vector2;
  108049. /**
  108050. * Gets or sets the current on-screen X position of the pointer
  108051. */
  108052. get pointerX(): number;
  108053. set pointerX(value: number);
  108054. /**
  108055. * Gets or sets the current on-screen Y position of the pointer
  108056. */
  108057. get pointerY(): number;
  108058. set pointerY(value: number);
  108059. private _updatePointerPosition;
  108060. private _processPointerMove;
  108061. private _setRayOnPointerInfo;
  108062. private _checkPrePointerObservable;
  108063. /**
  108064. * Use this method to simulate a pointer move on a mesh
  108065. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108066. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108067. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108068. */
  108069. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108070. /**
  108071. * Use this method to simulate a pointer down on a mesh
  108072. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108073. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108074. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108075. */
  108076. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  108077. private _processPointerDown;
  108078. /** @hidden */
  108079. _isPointerSwiping(): boolean;
  108080. /**
  108081. * Use this method to simulate a pointer up on a mesh
  108082. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  108083. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  108084. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  108085. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  108086. */
  108087. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  108088. private _processPointerUp;
  108089. /**
  108090. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  108091. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  108092. * @returns true if the pointer was captured
  108093. */
  108094. isPointerCaptured(pointerId?: number): boolean;
  108095. /**
  108096. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  108097. * @param attachUp defines if you want to attach events to pointerup
  108098. * @param attachDown defines if you want to attach events to pointerdown
  108099. * @param attachMove defines if you want to attach events to pointermove
  108100. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  108101. */
  108102. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  108103. /**
  108104. * Detaches all event handlers
  108105. */
  108106. detachControl(): void;
  108107. /**
  108108. * Force the value of meshUnderPointer
  108109. * @param mesh defines the mesh to use
  108110. */
  108111. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  108112. /**
  108113. * Gets the mesh under the pointer
  108114. * @returns a Mesh or null if no mesh is under the pointer
  108115. */
  108116. getPointerOverMesh(): Nullable<AbstractMesh>;
  108117. }
  108118. }
  108119. declare module BABYLON {
  108120. /**
  108121. * Helper class used to generate session unique ID
  108122. */
  108123. export class UniqueIdGenerator {
  108124. private static _UniqueIdCounter;
  108125. /**
  108126. * Gets an unique (relatively to the current scene) Id
  108127. */
  108128. static get UniqueId(): number;
  108129. }
  108130. }
  108131. declare module BABYLON {
  108132. /**
  108133. * This class defines the direct association between an animation and a target
  108134. */
  108135. export class TargetedAnimation {
  108136. /**
  108137. * Animation to perform
  108138. */
  108139. animation: Animation;
  108140. /**
  108141. * Target to animate
  108142. */
  108143. target: any;
  108144. /**
  108145. * Serialize the object
  108146. * @returns the JSON object representing the current entity
  108147. */
  108148. serialize(): any;
  108149. }
  108150. /**
  108151. * Use this class to create coordinated animations on multiple targets
  108152. */
  108153. export class AnimationGroup implements IDisposable {
  108154. /** The name of the animation group */
  108155. name: string;
  108156. private _scene;
  108157. private _targetedAnimations;
  108158. private _animatables;
  108159. private _from;
  108160. private _to;
  108161. private _isStarted;
  108162. private _isPaused;
  108163. private _speedRatio;
  108164. private _loopAnimation;
  108165. /**
  108166. * Gets or sets the unique id of the node
  108167. */
  108168. uniqueId: number;
  108169. /**
  108170. * This observable will notify when one animation have ended
  108171. */
  108172. onAnimationEndObservable: Observable<TargetedAnimation>;
  108173. /**
  108174. * Observer raised when one animation loops
  108175. */
  108176. onAnimationLoopObservable: Observable<TargetedAnimation>;
  108177. /**
  108178. * Observer raised when all animations have looped
  108179. */
  108180. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  108181. /**
  108182. * This observable will notify when all animations have ended.
  108183. */
  108184. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  108185. /**
  108186. * This observable will notify when all animations have paused.
  108187. */
  108188. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  108189. /**
  108190. * This observable will notify when all animations are playing.
  108191. */
  108192. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  108193. /**
  108194. * Gets the first frame
  108195. */
  108196. get from(): number;
  108197. /**
  108198. * Gets the last frame
  108199. */
  108200. get to(): number;
  108201. /**
  108202. * Define if the animations are started
  108203. */
  108204. get isStarted(): boolean;
  108205. /**
  108206. * Gets a value indicating that the current group is playing
  108207. */
  108208. get isPlaying(): boolean;
  108209. /**
  108210. * Gets or sets the speed ratio to use for all animations
  108211. */
  108212. get speedRatio(): number;
  108213. /**
  108214. * Gets or sets the speed ratio to use for all animations
  108215. */
  108216. set speedRatio(value: number);
  108217. /**
  108218. * Gets or sets if all animations should loop or not
  108219. */
  108220. get loopAnimation(): boolean;
  108221. set loopAnimation(value: boolean);
  108222. /**
  108223. * Gets the targeted animations for this animation group
  108224. */
  108225. get targetedAnimations(): Array<TargetedAnimation>;
  108226. /**
  108227. * returning the list of animatables controlled by this animation group.
  108228. */
  108229. get animatables(): Array<Animatable>;
  108230. /**
  108231. * Instantiates a new Animation Group.
  108232. * This helps managing several animations at once.
  108233. * @see http://doc.babylonjs.com/how_to/group
  108234. * @param name Defines the name of the group
  108235. * @param scene Defines the scene the group belongs to
  108236. */
  108237. constructor(
  108238. /** The name of the animation group */
  108239. name: string, scene?: Nullable<Scene>);
  108240. /**
  108241. * Add an animation (with its target) in the group
  108242. * @param animation defines the animation we want to add
  108243. * @param target defines the target of the animation
  108244. * @returns the TargetedAnimation object
  108245. */
  108246. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  108247. /**
  108248. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  108249. * It can add constant keys at begin or end
  108250. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  108251. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  108252. * @returns the animation group
  108253. */
  108254. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  108255. private _animationLoopCount;
  108256. private _animationLoopFlags;
  108257. private _processLoop;
  108258. /**
  108259. * Start all animations on given targets
  108260. * @param loop defines if animations must loop
  108261. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  108262. * @param from defines the from key (optional)
  108263. * @param to defines the to key (optional)
  108264. * @returns the current animation group
  108265. */
  108266. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  108267. /**
  108268. * Pause all animations
  108269. * @returns the animation group
  108270. */
  108271. pause(): AnimationGroup;
  108272. /**
  108273. * Play all animations to initial state
  108274. * This function will start() the animations if they were not started or will restart() them if they were paused
  108275. * @param loop defines if animations must loop
  108276. * @returns the animation group
  108277. */
  108278. play(loop?: boolean): AnimationGroup;
  108279. /**
  108280. * Reset all animations to initial state
  108281. * @returns the animation group
  108282. */
  108283. reset(): AnimationGroup;
  108284. /**
  108285. * Restart animations from key 0
  108286. * @returns the animation group
  108287. */
  108288. restart(): AnimationGroup;
  108289. /**
  108290. * Stop all animations
  108291. * @returns the animation group
  108292. */
  108293. stop(): AnimationGroup;
  108294. /**
  108295. * Set animation weight for all animatables
  108296. * @param weight defines the weight to use
  108297. * @return the animationGroup
  108298. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108299. */
  108300. setWeightForAllAnimatables(weight: number): AnimationGroup;
  108301. /**
  108302. * Synchronize and normalize all animatables with a source animatable
  108303. * @param root defines the root animatable to synchronize with
  108304. * @return the animationGroup
  108305. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  108306. */
  108307. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  108308. /**
  108309. * Goes to a specific frame in this animation group
  108310. * @param frame the frame number to go to
  108311. * @return the animationGroup
  108312. */
  108313. goToFrame(frame: number): AnimationGroup;
  108314. /**
  108315. * Dispose all associated resources
  108316. */
  108317. dispose(): void;
  108318. private _checkAnimationGroupEnded;
  108319. /**
  108320. * Clone the current animation group and returns a copy
  108321. * @param newName defines the name of the new group
  108322. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  108323. * @returns the new aniamtion group
  108324. */
  108325. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  108326. /**
  108327. * Serializes the animationGroup to an object
  108328. * @returns Serialized object
  108329. */
  108330. serialize(): any;
  108331. /**
  108332. * Returns a new AnimationGroup object parsed from the source provided.
  108333. * @param parsedAnimationGroup defines the source
  108334. * @param scene defines the scene that will receive the animationGroup
  108335. * @returns a new AnimationGroup
  108336. */
  108337. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  108338. /**
  108339. * Returns the string "AnimationGroup"
  108340. * @returns "AnimationGroup"
  108341. */
  108342. getClassName(): string;
  108343. /**
  108344. * Creates a detailled string about the object
  108345. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  108346. * @returns a string representing the object
  108347. */
  108348. toString(fullDetails?: boolean): string;
  108349. }
  108350. }
  108351. declare module BABYLON {
  108352. /**
  108353. * Define an interface for all classes that will hold resources
  108354. */
  108355. export interface IDisposable {
  108356. /**
  108357. * Releases all held resources
  108358. */
  108359. dispose(): void;
  108360. }
  108361. /** Interface defining initialization parameters for Scene class */
  108362. export interface SceneOptions {
  108363. /**
  108364. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  108365. * It will improve performance when the number of geometries becomes important.
  108366. */
  108367. useGeometryUniqueIdsMap?: boolean;
  108368. /**
  108369. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  108370. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108371. */
  108372. useMaterialMeshMap?: boolean;
  108373. /**
  108374. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  108375. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  108376. */
  108377. useClonedMeshMap?: boolean;
  108378. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  108379. virtual?: boolean;
  108380. }
  108381. /**
  108382. * Represents a scene to be rendered by the engine.
  108383. * @see http://doc.babylonjs.com/features/scene
  108384. */
  108385. export class Scene extends AbstractScene implements IAnimatable {
  108386. /** The fog is deactivated */
  108387. static readonly FOGMODE_NONE: number;
  108388. /** The fog density is following an exponential function */
  108389. static readonly FOGMODE_EXP: number;
  108390. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  108391. static readonly FOGMODE_EXP2: number;
  108392. /** The fog density is following a linear function. */
  108393. static readonly FOGMODE_LINEAR: number;
  108394. /**
  108395. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  108396. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108397. */
  108398. static MinDeltaTime: number;
  108399. /**
  108400. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  108401. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108402. */
  108403. static MaxDeltaTime: number;
  108404. /**
  108405. * Factory used to create the default material.
  108406. * @param name The name of the material to create
  108407. * @param scene The scene to create the material for
  108408. * @returns The default material
  108409. */
  108410. static DefaultMaterialFactory(scene: Scene): Material;
  108411. /**
  108412. * Factory used to create the a collision coordinator.
  108413. * @returns The collision coordinator
  108414. */
  108415. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  108416. /** @hidden */
  108417. _inputManager: InputManager;
  108418. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  108419. cameraToUseForPointers: Nullable<Camera>;
  108420. /** @hidden */
  108421. readonly _isScene: boolean;
  108422. /** @hidden */
  108423. _blockEntityCollection: boolean;
  108424. /**
  108425. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  108426. */
  108427. autoClear: boolean;
  108428. /**
  108429. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  108430. */
  108431. autoClearDepthAndStencil: boolean;
  108432. /**
  108433. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  108434. */
  108435. clearColor: Color4;
  108436. /**
  108437. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  108438. */
  108439. ambientColor: Color3;
  108440. /**
  108441. * This is use to store the default BRDF lookup for PBR materials in your scene.
  108442. * It should only be one of the following (if not the default embedded one):
  108443. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108444. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  108445. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108446. * The material properties need to be setup according to the type of texture in use.
  108447. */
  108448. environmentBRDFTexture: BaseTexture;
  108449. /** @hidden */
  108450. protected _environmentTexture: Nullable<BaseTexture>;
  108451. /**
  108452. * Texture used in all pbr material as the reflection texture.
  108453. * As in the majority of the scene they are the same (exception for multi room and so on),
  108454. * this is easier to reference from here than from all the materials.
  108455. */
  108456. get environmentTexture(): Nullable<BaseTexture>;
  108457. /**
  108458. * Texture used in all pbr material as the reflection texture.
  108459. * As in the majority of the scene they are the same (exception for multi room and so on),
  108460. * this is easier to set here than in all the materials.
  108461. */
  108462. set environmentTexture(value: Nullable<BaseTexture>);
  108463. /** @hidden */
  108464. protected _environmentIntensity: number;
  108465. /**
  108466. * Intensity of the environment in all pbr material.
  108467. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108468. * As in the majority of the scene they are the same (exception for multi room and so on),
  108469. * this is easier to reference from here than from all the materials.
  108470. */
  108471. get environmentIntensity(): number;
  108472. /**
  108473. * Intensity of the environment in all pbr material.
  108474. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  108475. * As in the majority of the scene they are the same (exception for multi room and so on),
  108476. * this is easier to set here than in all the materials.
  108477. */
  108478. set environmentIntensity(value: number);
  108479. /** @hidden */
  108480. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  108481. /**
  108482. * Default image processing configuration used either in the rendering
  108483. * Forward main pass or through the imageProcessingPostProcess if present.
  108484. * As in the majority of the scene they are the same (exception for multi camera),
  108485. * this is easier to reference from here than from all the materials and post process.
  108486. *
  108487. * No setter as we it is a shared configuration, you can set the values instead.
  108488. */
  108489. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  108490. private _forceWireframe;
  108491. /**
  108492. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  108493. */
  108494. set forceWireframe(value: boolean);
  108495. get forceWireframe(): boolean;
  108496. private _skipFrustumClipping;
  108497. /**
  108498. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  108499. */
  108500. set skipFrustumClipping(value: boolean);
  108501. get skipFrustumClipping(): boolean;
  108502. private _forcePointsCloud;
  108503. /**
  108504. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  108505. */
  108506. set forcePointsCloud(value: boolean);
  108507. get forcePointsCloud(): boolean;
  108508. /**
  108509. * Gets or sets the active clipplane 1
  108510. */
  108511. clipPlane: Nullable<Plane>;
  108512. /**
  108513. * Gets or sets the active clipplane 2
  108514. */
  108515. clipPlane2: Nullable<Plane>;
  108516. /**
  108517. * Gets or sets the active clipplane 3
  108518. */
  108519. clipPlane3: Nullable<Plane>;
  108520. /**
  108521. * Gets or sets the active clipplane 4
  108522. */
  108523. clipPlane4: Nullable<Plane>;
  108524. /**
  108525. * Gets or sets the active clipplane 5
  108526. */
  108527. clipPlane5: Nullable<Plane>;
  108528. /**
  108529. * Gets or sets the active clipplane 6
  108530. */
  108531. clipPlane6: Nullable<Plane>;
  108532. /**
  108533. * Gets or sets a boolean indicating if animations are enabled
  108534. */
  108535. animationsEnabled: boolean;
  108536. private _animationPropertiesOverride;
  108537. /**
  108538. * Gets or sets the animation properties override
  108539. */
  108540. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  108541. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  108542. /**
  108543. * Gets or sets a boolean indicating if a constant deltatime has to be used
  108544. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  108545. */
  108546. useConstantAnimationDeltaTime: boolean;
  108547. /**
  108548. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  108549. * Please note that it requires to run a ray cast through the scene on every frame
  108550. */
  108551. constantlyUpdateMeshUnderPointer: boolean;
  108552. /**
  108553. * Defines the HTML cursor to use when hovering over interactive elements
  108554. */
  108555. hoverCursor: string;
  108556. /**
  108557. * Defines the HTML default cursor to use (empty by default)
  108558. */
  108559. defaultCursor: string;
  108560. /**
  108561. * Defines whether cursors are handled by the scene.
  108562. */
  108563. doNotHandleCursors: boolean;
  108564. /**
  108565. * This is used to call preventDefault() on pointer down
  108566. * in order to block unwanted artifacts like system double clicks
  108567. */
  108568. preventDefaultOnPointerDown: boolean;
  108569. /**
  108570. * This is used to call preventDefault() on pointer up
  108571. * in order to block unwanted artifacts like system double clicks
  108572. */
  108573. preventDefaultOnPointerUp: boolean;
  108574. /**
  108575. * Gets or sets user defined metadata
  108576. */
  108577. metadata: any;
  108578. /**
  108579. * For internal use only. Please do not use.
  108580. */
  108581. reservedDataStore: any;
  108582. /**
  108583. * Gets the name of the plugin used to load this scene (null by default)
  108584. */
  108585. loadingPluginName: string;
  108586. /**
  108587. * Use this array to add regular expressions used to disable offline support for specific urls
  108588. */
  108589. disableOfflineSupportExceptionRules: RegExp[];
  108590. /**
  108591. * An event triggered when the scene is disposed.
  108592. */
  108593. onDisposeObservable: Observable<Scene>;
  108594. private _onDisposeObserver;
  108595. /** Sets a function to be executed when this scene is disposed. */
  108596. set onDispose(callback: () => void);
  108597. /**
  108598. * An event triggered before rendering the scene (right after animations and physics)
  108599. */
  108600. onBeforeRenderObservable: Observable<Scene>;
  108601. private _onBeforeRenderObserver;
  108602. /** Sets a function to be executed before rendering this scene */
  108603. set beforeRender(callback: Nullable<() => void>);
  108604. /**
  108605. * An event triggered after rendering the scene
  108606. */
  108607. onAfterRenderObservable: Observable<Scene>;
  108608. /**
  108609. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  108610. */
  108611. onAfterRenderCameraObservable: Observable<Camera>;
  108612. private _onAfterRenderObserver;
  108613. /** Sets a function to be executed after rendering this scene */
  108614. set afterRender(callback: Nullable<() => void>);
  108615. /**
  108616. * An event triggered before animating the scene
  108617. */
  108618. onBeforeAnimationsObservable: Observable<Scene>;
  108619. /**
  108620. * An event triggered after animations processing
  108621. */
  108622. onAfterAnimationsObservable: Observable<Scene>;
  108623. /**
  108624. * An event triggered before draw calls are ready to be sent
  108625. */
  108626. onBeforeDrawPhaseObservable: Observable<Scene>;
  108627. /**
  108628. * An event triggered after draw calls have been sent
  108629. */
  108630. onAfterDrawPhaseObservable: Observable<Scene>;
  108631. /**
  108632. * An event triggered when the scene is ready
  108633. */
  108634. onReadyObservable: Observable<Scene>;
  108635. /**
  108636. * An event triggered before rendering a camera
  108637. */
  108638. onBeforeCameraRenderObservable: Observable<Camera>;
  108639. private _onBeforeCameraRenderObserver;
  108640. /** Sets a function to be executed before rendering a camera*/
  108641. set beforeCameraRender(callback: () => void);
  108642. /**
  108643. * An event triggered after rendering a camera
  108644. */
  108645. onAfterCameraRenderObservable: Observable<Camera>;
  108646. private _onAfterCameraRenderObserver;
  108647. /** Sets a function to be executed after rendering a camera*/
  108648. set afterCameraRender(callback: () => void);
  108649. /**
  108650. * An event triggered when active meshes evaluation is about to start
  108651. */
  108652. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  108653. /**
  108654. * An event triggered when active meshes evaluation is done
  108655. */
  108656. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  108657. /**
  108658. * An event triggered when particles rendering is about to start
  108659. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108660. */
  108661. onBeforeParticlesRenderingObservable: Observable<Scene>;
  108662. /**
  108663. * An event triggered when particles rendering is done
  108664. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  108665. */
  108666. onAfterParticlesRenderingObservable: Observable<Scene>;
  108667. /**
  108668. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  108669. */
  108670. onDataLoadedObservable: Observable<Scene>;
  108671. /**
  108672. * An event triggered when a camera is created
  108673. */
  108674. onNewCameraAddedObservable: Observable<Camera>;
  108675. /**
  108676. * An event triggered when a camera is removed
  108677. */
  108678. onCameraRemovedObservable: Observable<Camera>;
  108679. /**
  108680. * An event triggered when a light is created
  108681. */
  108682. onNewLightAddedObservable: Observable<Light>;
  108683. /**
  108684. * An event triggered when a light is removed
  108685. */
  108686. onLightRemovedObservable: Observable<Light>;
  108687. /**
  108688. * An event triggered when a geometry is created
  108689. */
  108690. onNewGeometryAddedObservable: Observable<Geometry>;
  108691. /**
  108692. * An event triggered when a geometry is removed
  108693. */
  108694. onGeometryRemovedObservable: Observable<Geometry>;
  108695. /**
  108696. * An event triggered when a transform node is created
  108697. */
  108698. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  108699. /**
  108700. * An event triggered when a transform node is removed
  108701. */
  108702. onTransformNodeRemovedObservable: Observable<TransformNode>;
  108703. /**
  108704. * An event triggered when a mesh is created
  108705. */
  108706. onNewMeshAddedObservable: Observable<AbstractMesh>;
  108707. /**
  108708. * An event triggered when a mesh is removed
  108709. */
  108710. onMeshRemovedObservable: Observable<AbstractMesh>;
  108711. /**
  108712. * An event triggered when a skeleton is created
  108713. */
  108714. onNewSkeletonAddedObservable: Observable<Skeleton>;
  108715. /**
  108716. * An event triggered when a skeleton is removed
  108717. */
  108718. onSkeletonRemovedObservable: Observable<Skeleton>;
  108719. /**
  108720. * An event triggered when a material is created
  108721. */
  108722. onNewMaterialAddedObservable: Observable<Material>;
  108723. /**
  108724. * An event triggered when a material is removed
  108725. */
  108726. onMaterialRemovedObservable: Observable<Material>;
  108727. /**
  108728. * An event triggered when a texture is created
  108729. */
  108730. onNewTextureAddedObservable: Observable<BaseTexture>;
  108731. /**
  108732. * An event triggered when a texture is removed
  108733. */
  108734. onTextureRemovedObservable: Observable<BaseTexture>;
  108735. /**
  108736. * An event triggered when render targets are about to be rendered
  108737. * Can happen multiple times per frame.
  108738. */
  108739. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  108740. /**
  108741. * An event triggered when render targets were rendered.
  108742. * Can happen multiple times per frame.
  108743. */
  108744. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  108745. /**
  108746. * An event triggered before calculating deterministic simulation step
  108747. */
  108748. onBeforeStepObservable: Observable<Scene>;
  108749. /**
  108750. * An event triggered after calculating deterministic simulation step
  108751. */
  108752. onAfterStepObservable: Observable<Scene>;
  108753. /**
  108754. * An event triggered when the activeCamera property is updated
  108755. */
  108756. onActiveCameraChanged: Observable<Scene>;
  108757. /**
  108758. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  108759. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108760. * 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)
  108761. */
  108762. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108763. /**
  108764. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  108765. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  108766. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  108767. */
  108768. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  108769. /**
  108770. * This Observable will when a mesh has been imported into the scene.
  108771. */
  108772. onMeshImportedObservable: Observable<AbstractMesh>;
  108773. /**
  108774. * This Observable will when an animation file has been imported into the scene.
  108775. */
  108776. onAnimationFileImportedObservable: Observable<Scene>;
  108777. /**
  108778. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  108779. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  108780. */
  108781. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  108782. /** @hidden */
  108783. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  108784. /**
  108785. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  108786. */
  108787. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  108788. /**
  108789. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  108790. */
  108791. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  108792. /**
  108793. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  108794. */
  108795. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  108796. /** Callback called when a pointer move is detected */
  108797. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108798. /** Callback called when a pointer down is detected */
  108799. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  108800. /** Callback called when a pointer up is detected */
  108801. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  108802. /** Callback called when a pointer pick is detected */
  108803. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  108804. /**
  108805. * 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).
  108806. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  108807. */
  108808. onPrePointerObservable: Observable<PointerInfoPre>;
  108809. /**
  108810. * Observable event triggered each time an input event is received from the rendering canvas
  108811. */
  108812. onPointerObservable: Observable<PointerInfo>;
  108813. /**
  108814. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  108815. */
  108816. get unTranslatedPointer(): Vector2;
  108817. /**
  108818. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  108819. */
  108820. static get DragMovementThreshold(): number;
  108821. static set DragMovementThreshold(value: number);
  108822. /**
  108823. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  108824. */
  108825. static get LongPressDelay(): number;
  108826. static set LongPressDelay(value: number);
  108827. /**
  108828. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  108829. */
  108830. static get DoubleClickDelay(): number;
  108831. static set DoubleClickDelay(value: number);
  108832. /** If you need to check double click without raising a single click at first click, enable this flag */
  108833. static get ExclusiveDoubleClickMode(): boolean;
  108834. static set ExclusiveDoubleClickMode(value: boolean);
  108835. /** @hidden */
  108836. _mirroredCameraPosition: Nullable<Vector3>;
  108837. /**
  108838. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  108839. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  108840. */
  108841. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  108842. /**
  108843. * Observable event triggered each time an keyboard event is received from the hosting window
  108844. */
  108845. onKeyboardObservable: Observable<KeyboardInfo>;
  108846. private _useRightHandedSystem;
  108847. /**
  108848. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  108849. */
  108850. set useRightHandedSystem(value: boolean);
  108851. get useRightHandedSystem(): boolean;
  108852. private _timeAccumulator;
  108853. private _currentStepId;
  108854. private _currentInternalStep;
  108855. /**
  108856. * Sets the step Id used by deterministic lock step
  108857. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108858. * @param newStepId defines the step Id
  108859. */
  108860. setStepId(newStepId: number): void;
  108861. /**
  108862. * Gets the step Id used by deterministic lock step
  108863. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108864. * @returns the step Id
  108865. */
  108866. getStepId(): number;
  108867. /**
  108868. * Gets the internal step used by deterministic lock step
  108869. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108870. * @returns the internal step
  108871. */
  108872. getInternalStep(): number;
  108873. private _fogEnabled;
  108874. /**
  108875. * Gets or sets a boolean indicating if fog is enabled on this scene
  108876. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108877. * (Default is true)
  108878. */
  108879. set fogEnabled(value: boolean);
  108880. get fogEnabled(): boolean;
  108881. private _fogMode;
  108882. /**
  108883. * Gets or sets the fog mode to use
  108884. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108885. * | mode | value |
  108886. * | --- | --- |
  108887. * | FOGMODE_NONE | 0 |
  108888. * | FOGMODE_EXP | 1 |
  108889. * | FOGMODE_EXP2 | 2 |
  108890. * | FOGMODE_LINEAR | 3 |
  108891. */
  108892. set fogMode(value: number);
  108893. get fogMode(): number;
  108894. /**
  108895. * Gets or sets the fog color to use
  108896. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108897. * (Default is Color3(0.2, 0.2, 0.3))
  108898. */
  108899. fogColor: Color3;
  108900. /**
  108901. * Gets or sets the fog density to use
  108902. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108903. * (Default is 0.1)
  108904. */
  108905. fogDensity: number;
  108906. /**
  108907. * Gets or sets the fog start distance to use
  108908. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108909. * (Default is 0)
  108910. */
  108911. fogStart: number;
  108912. /**
  108913. * Gets or sets the fog end distance to use
  108914. * @see http://doc.babylonjs.com/babylon101/environment#fog
  108915. * (Default is 1000)
  108916. */
  108917. fogEnd: number;
  108918. private _shadowsEnabled;
  108919. /**
  108920. * Gets or sets a boolean indicating if shadows are enabled on this scene
  108921. */
  108922. set shadowsEnabled(value: boolean);
  108923. get shadowsEnabled(): boolean;
  108924. private _lightsEnabled;
  108925. /**
  108926. * Gets or sets a boolean indicating if lights are enabled on this scene
  108927. */
  108928. set lightsEnabled(value: boolean);
  108929. get lightsEnabled(): boolean;
  108930. /** All of the active cameras added to this scene. */
  108931. activeCameras: Camera[];
  108932. /** @hidden */
  108933. _activeCamera: Nullable<Camera>;
  108934. /** Gets or sets the current active camera */
  108935. get activeCamera(): Nullable<Camera>;
  108936. set activeCamera(value: Nullable<Camera>);
  108937. private _defaultMaterial;
  108938. /** The default material used on meshes when no material is affected */
  108939. get defaultMaterial(): Material;
  108940. /** The default material used on meshes when no material is affected */
  108941. set defaultMaterial(value: Material);
  108942. private _texturesEnabled;
  108943. /**
  108944. * Gets or sets a boolean indicating if textures are enabled on this scene
  108945. */
  108946. set texturesEnabled(value: boolean);
  108947. get texturesEnabled(): boolean;
  108948. /**
  108949. * Gets or sets a boolean indicating if particles are enabled on this scene
  108950. */
  108951. particlesEnabled: boolean;
  108952. /**
  108953. * Gets or sets a boolean indicating if sprites are enabled on this scene
  108954. */
  108955. spritesEnabled: boolean;
  108956. private _skeletonsEnabled;
  108957. /**
  108958. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  108959. */
  108960. set skeletonsEnabled(value: boolean);
  108961. get skeletonsEnabled(): boolean;
  108962. /**
  108963. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  108964. */
  108965. lensFlaresEnabled: boolean;
  108966. /**
  108967. * Gets or sets a boolean indicating if collisions are enabled on this scene
  108968. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108969. */
  108970. collisionsEnabled: boolean;
  108971. private _collisionCoordinator;
  108972. /** @hidden */
  108973. get collisionCoordinator(): ICollisionCoordinator;
  108974. /**
  108975. * Defines the gravity applied to this scene (used only for collisions)
  108976. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  108977. */
  108978. gravity: Vector3;
  108979. /**
  108980. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  108981. */
  108982. postProcessesEnabled: boolean;
  108983. /**
  108984. * The list of postprocesses added to the scene
  108985. */
  108986. postProcesses: PostProcess[];
  108987. /**
  108988. * Gets the current postprocess manager
  108989. */
  108990. postProcessManager: PostProcessManager;
  108991. /**
  108992. * Gets or sets a boolean indicating if render targets are enabled on this scene
  108993. */
  108994. renderTargetsEnabled: boolean;
  108995. /**
  108996. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  108997. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  108998. */
  108999. dumpNextRenderTargets: boolean;
  109000. /**
  109001. * The list of user defined render targets added to the scene
  109002. */
  109003. customRenderTargets: RenderTargetTexture[];
  109004. /**
  109005. * Defines if texture loading must be delayed
  109006. * If true, textures will only be loaded when they need to be rendered
  109007. */
  109008. useDelayedTextureLoading: boolean;
  109009. /**
  109010. * Gets the list of meshes imported to the scene through SceneLoader
  109011. */
  109012. importedMeshesFiles: String[];
  109013. /**
  109014. * Gets or sets a boolean indicating if probes are enabled on this scene
  109015. */
  109016. probesEnabled: boolean;
  109017. /**
  109018. * Gets or sets the current offline provider to use to store scene data
  109019. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  109020. */
  109021. offlineProvider: IOfflineProvider;
  109022. /**
  109023. * Gets or sets the action manager associated with the scene
  109024. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  109025. */
  109026. actionManager: AbstractActionManager;
  109027. private _meshesForIntersections;
  109028. /**
  109029. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  109030. */
  109031. proceduralTexturesEnabled: boolean;
  109032. private _engine;
  109033. private _totalVertices;
  109034. /** @hidden */
  109035. _activeIndices: PerfCounter;
  109036. /** @hidden */
  109037. _activeParticles: PerfCounter;
  109038. /** @hidden */
  109039. _activeBones: PerfCounter;
  109040. private _animationRatio;
  109041. /** @hidden */
  109042. _animationTimeLast: number;
  109043. /** @hidden */
  109044. _animationTime: number;
  109045. /**
  109046. * Gets or sets a general scale for animation speed
  109047. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  109048. */
  109049. animationTimeScale: number;
  109050. /** @hidden */
  109051. _cachedMaterial: Nullable<Material>;
  109052. /** @hidden */
  109053. _cachedEffect: Nullable<Effect>;
  109054. /** @hidden */
  109055. _cachedVisibility: Nullable<number>;
  109056. private _renderId;
  109057. private _frameId;
  109058. private _executeWhenReadyTimeoutId;
  109059. private _intermediateRendering;
  109060. private _viewUpdateFlag;
  109061. private _projectionUpdateFlag;
  109062. /** @hidden */
  109063. _toBeDisposed: Nullable<IDisposable>[];
  109064. private _activeRequests;
  109065. /** @hidden */
  109066. _pendingData: any[];
  109067. private _isDisposed;
  109068. /**
  109069. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  109070. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  109071. */
  109072. dispatchAllSubMeshesOfActiveMeshes: boolean;
  109073. private _activeMeshes;
  109074. private _processedMaterials;
  109075. private _renderTargets;
  109076. /** @hidden */
  109077. _activeParticleSystems: SmartArray<IParticleSystem>;
  109078. private _activeSkeletons;
  109079. private _softwareSkinnedMeshes;
  109080. private _renderingManager;
  109081. /** @hidden */
  109082. _activeAnimatables: Animatable[];
  109083. private _transformMatrix;
  109084. private _sceneUbo;
  109085. /** @hidden */
  109086. _viewMatrix: Matrix;
  109087. private _projectionMatrix;
  109088. /** @hidden */
  109089. _forcedViewPosition: Nullable<Vector3>;
  109090. /** @hidden */
  109091. _frustumPlanes: Plane[];
  109092. /**
  109093. * Gets the list of frustum planes (built from the active camera)
  109094. */
  109095. get frustumPlanes(): Plane[];
  109096. /**
  109097. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  109098. * This is useful if there are more lights that the maximum simulteanous authorized
  109099. */
  109100. requireLightSorting: boolean;
  109101. /** @hidden */
  109102. readonly useMaterialMeshMap: boolean;
  109103. /** @hidden */
  109104. readonly useClonedMeshMap: boolean;
  109105. private _externalData;
  109106. private _uid;
  109107. /**
  109108. * @hidden
  109109. * Backing store of defined scene components.
  109110. */
  109111. _components: ISceneComponent[];
  109112. /**
  109113. * @hidden
  109114. * Backing store of defined scene components.
  109115. */
  109116. _serializableComponents: ISceneSerializableComponent[];
  109117. /**
  109118. * List of components to register on the next registration step.
  109119. */
  109120. private _transientComponents;
  109121. /**
  109122. * Registers the transient components if needed.
  109123. */
  109124. private _registerTransientComponents;
  109125. /**
  109126. * @hidden
  109127. * Add a component to the scene.
  109128. * Note that the ccomponent could be registered on th next frame if this is called after
  109129. * the register component stage.
  109130. * @param component Defines the component to add to the scene
  109131. */
  109132. _addComponent(component: ISceneComponent): void;
  109133. /**
  109134. * @hidden
  109135. * Gets a component from the scene.
  109136. * @param name defines the name of the component to retrieve
  109137. * @returns the component or null if not present
  109138. */
  109139. _getComponent(name: string): Nullable<ISceneComponent>;
  109140. /**
  109141. * @hidden
  109142. * Defines the actions happening before camera updates.
  109143. */
  109144. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  109145. /**
  109146. * @hidden
  109147. * Defines the actions happening before clear the canvas.
  109148. */
  109149. _beforeClearStage: Stage<SimpleStageAction>;
  109150. /**
  109151. * @hidden
  109152. * Defines the actions when collecting render targets for the frame.
  109153. */
  109154. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109155. /**
  109156. * @hidden
  109157. * Defines the actions happening for one camera in the frame.
  109158. */
  109159. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  109160. /**
  109161. * @hidden
  109162. * Defines the actions happening during the per mesh ready checks.
  109163. */
  109164. _isReadyForMeshStage: Stage<MeshStageAction>;
  109165. /**
  109166. * @hidden
  109167. * Defines the actions happening before evaluate active mesh checks.
  109168. */
  109169. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  109170. /**
  109171. * @hidden
  109172. * Defines the actions happening during the evaluate sub mesh checks.
  109173. */
  109174. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  109175. /**
  109176. * @hidden
  109177. * Defines the actions happening during the active mesh stage.
  109178. */
  109179. _activeMeshStage: Stage<ActiveMeshStageAction>;
  109180. /**
  109181. * @hidden
  109182. * Defines the actions happening during the per camera render target step.
  109183. */
  109184. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  109185. /**
  109186. * @hidden
  109187. * Defines the actions happening just before the active camera is drawing.
  109188. */
  109189. _beforeCameraDrawStage: Stage<CameraStageAction>;
  109190. /**
  109191. * @hidden
  109192. * Defines the actions happening just before a render target is drawing.
  109193. */
  109194. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109195. /**
  109196. * @hidden
  109197. * Defines the actions happening just before a rendering group is drawing.
  109198. */
  109199. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109200. /**
  109201. * @hidden
  109202. * Defines the actions happening just before a mesh is drawing.
  109203. */
  109204. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109205. /**
  109206. * @hidden
  109207. * Defines the actions happening just after a mesh has been drawn.
  109208. */
  109209. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  109210. /**
  109211. * @hidden
  109212. * Defines the actions happening just after a rendering group has been drawn.
  109213. */
  109214. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  109215. /**
  109216. * @hidden
  109217. * Defines the actions happening just after the active camera has been drawn.
  109218. */
  109219. _afterCameraDrawStage: Stage<CameraStageAction>;
  109220. /**
  109221. * @hidden
  109222. * Defines the actions happening just after a render target has been drawn.
  109223. */
  109224. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  109225. /**
  109226. * @hidden
  109227. * Defines the actions happening just after rendering all cameras and computing intersections.
  109228. */
  109229. _afterRenderStage: Stage<SimpleStageAction>;
  109230. /**
  109231. * @hidden
  109232. * Defines the actions happening when a pointer move event happens.
  109233. */
  109234. _pointerMoveStage: Stage<PointerMoveStageAction>;
  109235. /**
  109236. * @hidden
  109237. * Defines the actions happening when a pointer down event happens.
  109238. */
  109239. _pointerDownStage: Stage<PointerUpDownStageAction>;
  109240. /**
  109241. * @hidden
  109242. * Defines the actions happening when a pointer up event happens.
  109243. */
  109244. _pointerUpStage: Stage<PointerUpDownStageAction>;
  109245. /**
  109246. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  109247. */
  109248. private geometriesByUniqueId;
  109249. /**
  109250. * Creates a new Scene
  109251. * @param engine defines the engine to use to render this scene
  109252. * @param options defines the scene options
  109253. */
  109254. constructor(engine: Engine, options?: SceneOptions);
  109255. /**
  109256. * Gets a string idenfifying the name of the class
  109257. * @returns "Scene" string
  109258. */
  109259. getClassName(): string;
  109260. private _defaultMeshCandidates;
  109261. /**
  109262. * @hidden
  109263. */
  109264. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109265. private _defaultSubMeshCandidates;
  109266. /**
  109267. * @hidden
  109268. */
  109269. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109270. /**
  109271. * Sets the default candidate providers for the scene.
  109272. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  109273. * and getCollidingSubMeshCandidates to their default function
  109274. */
  109275. setDefaultCandidateProviders(): void;
  109276. /**
  109277. * Gets the mesh that is currently under the pointer
  109278. */
  109279. get meshUnderPointer(): Nullable<AbstractMesh>;
  109280. /**
  109281. * Gets or sets the current on-screen X position of the pointer
  109282. */
  109283. get pointerX(): number;
  109284. set pointerX(value: number);
  109285. /**
  109286. * Gets or sets the current on-screen Y position of the pointer
  109287. */
  109288. get pointerY(): number;
  109289. set pointerY(value: number);
  109290. /**
  109291. * Gets the cached material (ie. the latest rendered one)
  109292. * @returns the cached material
  109293. */
  109294. getCachedMaterial(): Nullable<Material>;
  109295. /**
  109296. * Gets the cached effect (ie. the latest rendered one)
  109297. * @returns the cached effect
  109298. */
  109299. getCachedEffect(): Nullable<Effect>;
  109300. /**
  109301. * Gets the cached visibility state (ie. the latest rendered one)
  109302. * @returns the cached visibility state
  109303. */
  109304. getCachedVisibility(): Nullable<number>;
  109305. /**
  109306. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  109307. * @param material defines the current material
  109308. * @param effect defines the current effect
  109309. * @param visibility defines the current visibility state
  109310. * @returns true if one parameter is not cached
  109311. */
  109312. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  109313. /**
  109314. * Gets the engine associated with the scene
  109315. * @returns an Engine
  109316. */
  109317. getEngine(): Engine;
  109318. /**
  109319. * Gets the total number of vertices rendered per frame
  109320. * @returns the total number of vertices rendered per frame
  109321. */
  109322. getTotalVertices(): number;
  109323. /**
  109324. * Gets the performance counter for total vertices
  109325. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109326. */
  109327. get totalVerticesPerfCounter(): PerfCounter;
  109328. /**
  109329. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  109330. * @returns the total number of active indices rendered per frame
  109331. */
  109332. getActiveIndices(): number;
  109333. /**
  109334. * Gets the performance counter for active indices
  109335. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109336. */
  109337. get totalActiveIndicesPerfCounter(): PerfCounter;
  109338. /**
  109339. * Gets the total number of active particles rendered per frame
  109340. * @returns the total number of active particles rendered per frame
  109341. */
  109342. getActiveParticles(): number;
  109343. /**
  109344. * Gets the performance counter for active particles
  109345. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109346. */
  109347. get activeParticlesPerfCounter(): PerfCounter;
  109348. /**
  109349. * Gets the total number of active bones rendered per frame
  109350. * @returns the total number of active bones rendered per frame
  109351. */
  109352. getActiveBones(): number;
  109353. /**
  109354. * Gets the performance counter for active bones
  109355. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  109356. */
  109357. get activeBonesPerfCounter(): PerfCounter;
  109358. /**
  109359. * Gets the array of active meshes
  109360. * @returns an array of AbstractMesh
  109361. */
  109362. getActiveMeshes(): SmartArray<AbstractMesh>;
  109363. /**
  109364. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  109365. * @returns a number
  109366. */
  109367. getAnimationRatio(): number;
  109368. /**
  109369. * Gets an unique Id for the current render phase
  109370. * @returns a number
  109371. */
  109372. getRenderId(): number;
  109373. /**
  109374. * Gets an unique Id for the current frame
  109375. * @returns a number
  109376. */
  109377. getFrameId(): number;
  109378. /** Call this function if you want to manually increment the render Id*/
  109379. incrementRenderId(): void;
  109380. private _createUbo;
  109381. /**
  109382. * Use this method to simulate a pointer move on a mesh
  109383. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109384. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109385. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109386. * @returns the current scene
  109387. */
  109388. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109389. /**
  109390. * Use this method to simulate a pointer down on a mesh
  109391. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109392. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109393. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109394. * @returns the current scene
  109395. */
  109396. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  109397. /**
  109398. * Use this method to simulate a pointer up on a mesh
  109399. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109400. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109401. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109402. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109403. * @returns the current scene
  109404. */
  109405. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  109406. /**
  109407. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109408. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109409. * @returns true if the pointer was captured
  109410. */
  109411. isPointerCaptured(pointerId?: number): boolean;
  109412. /**
  109413. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109414. * @param attachUp defines if you want to attach events to pointerup
  109415. * @param attachDown defines if you want to attach events to pointerdown
  109416. * @param attachMove defines if you want to attach events to pointermove
  109417. */
  109418. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  109419. /** Detaches all event handlers*/
  109420. detachControl(): void;
  109421. /**
  109422. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  109423. * Delay loaded resources are not taking in account
  109424. * @return true if all required resources are ready
  109425. */
  109426. isReady(): boolean;
  109427. /** Resets all cached information relative to material (including effect and visibility) */
  109428. resetCachedMaterial(): void;
  109429. /**
  109430. * Registers a function to be called before every frame render
  109431. * @param func defines the function to register
  109432. */
  109433. registerBeforeRender(func: () => void): void;
  109434. /**
  109435. * Unregisters a function called before every frame render
  109436. * @param func defines the function to unregister
  109437. */
  109438. unregisterBeforeRender(func: () => void): void;
  109439. /**
  109440. * Registers a function to be called after every frame render
  109441. * @param func defines the function to register
  109442. */
  109443. registerAfterRender(func: () => void): void;
  109444. /**
  109445. * Unregisters a function called after every frame render
  109446. * @param func defines the function to unregister
  109447. */
  109448. unregisterAfterRender(func: () => void): void;
  109449. private _executeOnceBeforeRender;
  109450. /**
  109451. * The provided function will run before render once and will be disposed afterwards.
  109452. * A timeout delay can be provided so that the function will be executed in N ms.
  109453. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  109454. * @param func The function to be executed.
  109455. * @param timeout optional delay in ms
  109456. */
  109457. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  109458. /** @hidden */
  109459. _addPendingData(data: any): void;
  109460. /** @hidden */
  109461. _removePendingData(data: any): void;
  109462. /**
  109463. * Returns the number of items waiting to be loaded
  109464. * @returns the number of items waiting to be loaded
  109465. */
  109466. getWaitingItemsCount(): number;
  109467. /**
  109468. * Returns a boolean indicating if the scene is still loading data
  109469. */
  109470. get isLoading(): boolean;
  109471. /**
  109472. * Registers a function to be executed when the scene is ready
  109473. * @param {Function} func - the function to be executed
  109474. */
  109475. executeWhenReady(func: () => void): void;
  109476. /**
  109477. * Returns a promise that resolves when the scene is ready
  109478. * @returns A promise that resolves when the scene is ready
  109479. */
  109480. whenReadyAsync(): Promise<void>;
  109481. /** @hidden */
  109482. _checkIsReady(): void;
  109483. /**
  109484. * Gets all animatable attached to the scene
  109485. */
  109486. get animatables(): Animatable[];
  109487. /**
  109488. * Resets the last animation time frame.
  109489. * Useful to override when animations start running when loading a scene for the first time.
  109490. */
  109491. resetLastAnimationTimeFrame(): void;
  109492. /**
  109493. * Gets the current view matrix
  109494. * @returns a Matrix
  109495. */
  109496. getViewMatrix(): Matrix;
  109497. /**
  109498. * Gets the current projection matrix
  109499. * @returns a Matrix
  109500. */
  109501. getProjectionMatrix(): Matrix;
  109502. /**
  109503. * Gets the current transform matrix
  109504. * @returns a Matrix made of View * Projection
  109505. */
  109506. getTransformMatrix(): Matrix;
  109507. /**
  109508. * Sets the current transform matrix
  109509. * @param viewL defines the View matrix to use
  109510. * @param projectionL defines the Projection matrix to use
  109511. * @param viewR defines the right View matrix to use (if provided)
  109512. * @param projectionR defines the right Projection matrix to use (if provided)
  109513. */
  109514. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  109515. /**
  109516. * Gets the uniform buffer used to store scene data
  109517. * @returns a UniformBuffer
  109518. */
  109519. getSceneUniformBuffer(): UniformBuffer;
  109520. /**
  109521. * Gets an unique (relatively to the current scene) Id
  109522. * @returns an unique number for the scene
  109523. */
  109524. getUniqueId(): number;
  109525. /**
  109526. * Add a mesh to the list of scene's meshes
  109527. * @param newMesh defines the mesh to add
  109528. * @param recursive if all child meshes should also be added to the scene
  109529. */
  109530. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  109531. /**
  109532. * Remove a mesh for the list of scene's meshes
  109533. * @param toRemove defines the mesh to remove
  109534. * @param recursive if all child meshes should also be removed from the scene
  109535. * @returns the index where the mesh was in the mesh list
  109536. */
  109537. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  109538. /**
  109539. * Add a transform node to the list of scene's transform nodes
  109540. * @param newTransformNode defines the transform node to add
  109541. */
  109542. addTransformNode(newTransformNode: TransformNode): void;
  109543. /**
  109544. * Remove a transform node for the list of scene's transform nodes
  109545. * @param toRemove defines the transform node to remove
  109546. * @returns the index where the transform node was in the transform node list
  109547. */
  109548. removeTransformNode(toRemove: TransformNode): number;
  109549. /**
  109550. * Remove a skeleton for the list of scene's skeletons
  109551. * @param toRemove defines the skeleton to remove
  109552. * @returns the index where the skeleton was in the skeleton list
  109553. */
  109554. removeSkeleton(toRemove: Skeleton): number;
  109555. /**
  109556. * Remove a morph target for the list of scene's morph targets
  109557. * @param toRemove defines the morph target to remove
  109558. * @returns the index where the morph target was in the morph target list
  109559. */
  109560. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  109561. /**
  109562. * Remove a light for the list of scene's lights
  109563. * @param toRemove defines the light to remove
  109564. * @returns the index where the light was in the light list
  109565. */
  109566. removeLight(toRemove: Light): number;
  109567. /**
  109568. * Remove a camera for the list of scene's cameras
  109569. * @param toRemove defines the camera to remove
  109570. * @returns the index where the camera was in the camera list
  109571. */
  109572. removeCamera(toRemove: Camera): number;
  109573. /**
  109574. * Remove a particle system for the list of scene's particle systems
  109575. * @param toRemove defines the particle system to remove
  109576. * @returns the index where the particle system was in the particle system list
  109577. */
  109578. removeParticleSystem(toRemove: IParticleSystem): number;
  109579. /**
  109580. * Remove a animation for the list of scene's animations
  109581. * @param toRemove defines the animation to remove
  109582. * @returns the index where the animation was in the animation list
  109583. */
  109584. removeAnimation(toRemove: Animation): number;
  109585. /**
  109586. * Will stop the animation of the given target
  109587. * @param target - the target
  109588. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  109589. * @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)
  109590. */
  109591. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  109592. /**
  109593. * Removes the given animation group from this scene.
  109594. * @param toRemove The animation group to remove
  109595. * @returns The index of the removed animation group
  109596. */
  109597. removeAnimationGroup(toRemove: AnimationGroup): number;
  109598. /**
  109599. * Removes the given multi-material from this scene.
  109600. * @param toRemove The multi-material to remove
  109601. * @returns The index of the removed multi-material
  109602. */
  109603. removeMultiMaterial(toRemove: MultiMaterial): number;
  109604. /**
  109605. * Removes the given material from this scene.
  109606. * @param toRemove The material to remove
  109607. * @returns The index of the removed material
  109608. */
  109609. removeMaterial(toRemove: Material): number;
  109610. /**
  109611. * Removes the given action manager from this scene.
  109612. * @param toRemove The action manager to remove
  109613. * @returns The index of the removed action manager
  109614. */
  109615. removeActionManager(toRemove: AbstractActionManager): number;
  109616. /**
  109617. * Removes the given texture from this scene.
  109618. * @param toRemove The texture to remove
  109619. * @returns The index of the removed texture
  109620. */
  109621. removeTexture(toRemove: BaseTexture): number;
  109622. /**
  109623. * Adds the given light to this scene
  109624. * @param newLight The light to add
  109625. */
  109626. addLight(newLight: Light): void;
  109627. /**
  109628. * Sorts the list list based on light priorities
  109629. */
  109630. sortLightsByPriority(): void;
  109631. /**
  109632. * Adds the given camera to this scene
  109633. * @param newCamera The camera to add
  109634. */
  109635. addCamera(newCamera: Camera): void;
  109636. /**
  109637. * Adds the given skeleton to this scene
  109638. * @param newSkeleton The skeleton to add
  109639. */
  109640. addSkeleton(newSkeleton: Skeleton): void;
  109641. /**
  109642. * Adds the given particle system to this scene
  109643. * @param newParticleSystem The particle system to add
  109644. */
  109645. addParticleSystem(newParticleSystem: IParticleSystem): void;
  109646. /**
  109647. * Adds the given animation to this scene
  109648. * @param newAnimation The animation to add
  109649. */
  109650. addAnimation(newAnimation: Animation): void;
  109651. /**
  109652. * Adds the given animation group to this scene.
  109653. * @param newAnimationGroup The animation group to add
  109654. */
  109655. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  109656. /**
  109657. * Adds the given multi-material to this scene
  109658. * @param newMultiMaterial The multi-material to add
  109659. */
  109660. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  109661. /**
  109662. * Adds the given material to this scene
  109663. * @param newMaterial The material to add
  109664. */
  109665. addMaterial(newMaterial: Material): void;
  109666. /**
  109667. * Adds the given morph target to this scene
  109668. * @param newMorphTargetManager The morph target to add
  109669. */
  109670. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  109671. /**
  109672. * Adds the given geometry to this scene
  109673. * @param newGeometry The geometry to add
  109674. */
  109675. addGeometry(newGeometry: Geometry): void;
  109676. /**
  109677. * Adds the given action manager to this scene
  109678. * @param newActionManager The action manager to add
  109679. */
  109680. addActionManager(newActionManager: AbstractActionManager): void;
  109681. /**
  109682. * Adds the given texture to this scene.
  109683. * @param newTexture The texture to add
  109684. */
  109685. addTexture(newTexture: BaseTexture): void;
  109686. /**
  109687. * Switch active camera
  109688. * @param newCamera defines the new active camera
  109689. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  109690. */
  109691. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  109692. /**
  109693. * sets the active camera of the scene using its ID
  109694. * @param id defines the camera's ID
  109695. * @return the new active camera or null if none found.
  109696. */
  109697. setActiveCameraByID(id: string): Nullable<Camera>;
  109698. /**
  109699. * sets the active camera of the scene using its name
  109700. * @param name defines the camera's name
  109701. * @returns the new active camera or null if none found.
  109702. */
  109703. setActiveCameraByName(name: string): Nullable<Camera>;
  109704. /**
  109705. * get an animation group using its name
  109706. * @param name defines the material's name
  109707. * @return the animation group or null if none found.
  109708. */
  109709. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  109710. /**
  109711. * Get a material using its unique id
  109712. * @param uniqueId defines the material's unique id
  109713. * @return the material or null if none found.
  109714. */
  109715. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  109716. /**
  109717. * get a material using its id
  109718. * @param id defines the material's ID
  109719. * @return the material or null if none found.
  109720. */
  109721. getMaterialByID(id: string): Nullable<Material>;
  109722. /**
  109723. * Gets a the last added material using a given id
  109724. * @param id defines the material's ID
  109725. * @return the last material with the given id or null if none found.
  109726. */
  109727. getLastMaterialByID(id: string): Nullable<Material>;
  109728. /**
  109729. * Gets a material using its name
  109730. * @param name defines the material's name
  109731. * @return the material or null if none found.
  109732. */
  109733. getMaterialByName(name: string): Nullable<Material>;
  109734. /**
  109735. * Get a texture using its unique id
  109736. * @param uniqueId defines the texture's unique id
  109737. * @return the texture or null if none found.
  109738. */
  109739. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  109740. /**
  109741. * Gets a camera using its id
  109742. * @param id defines the id to look for
  109743. * @returns the camera or null if not found
  109744. */
  109745. getCameraByID(id: string): Nullable<Camera>;
  109746. /**
  109747. * Gets a camera using its unique id
  109748. * @param uniqueId defines the unique id to look for
  109749. * @returns the camera or null if not found
  109750. */
  109751. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  109752. /**
  109753. * Gets a camera using its name
  109754. * @param name defines the camera's name
  109755. * @return the camera or null if none found.
  109756. */
  109757. getCameraByName(name: string): Nullable<Camera>;
  109758. /**
  109759. * Gets a bone using its id
  109760. * @param id defines the bone's id
  109761. * @return the bone or null if not found
  109762. */
  109763. getBoneByID(id: string): Nullable<Bone>;
  109764. /**
  109765. * Gets a bone using its id
  109766. * @param name defines the bone's name
  109767. * @return the bone or null if not found
  109768. */
  109769. getBoneByName(name: string): Nullable<Bone>;
  109770. /**
  109771. * Gets a light node using its name
  109772. * @param name defines the the light's name
  109773. * @return the light or null if none found.
  109774. */
  109775. getLightByName(name: string): Nullable<Light>;
  109776. /**
  109777. * Gets a light node using its id
  109778. * @param id defines the light's id
  109779. * @return the light or null if none found.
  109780. */
  109781. getLightByID(id: string): Nullable<Light>;
  109782. /**
  109783. * Gets a light node using its scene-generated unique ID
  109784. * @param uniqueId defines the light's unique id
  109785. * @return the light or null if none found.
  109786. */
  109787. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  109788. /**
  109789. * Gets a particle system by id
  109790. * @param id defines the particle system id
  109791. * @return the corresponding system or null if none found
  109792. */
  109793. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  109794. /**
  109795. * Gets a geometry using its ID
  109796. * @param id defines the geometry's id
  109797. * @return the geometry or null if none found.
  109798. */
  109799. getGeometryByID(id: string): Nullable<Geometry>;
  109800. private _getGeometryByUniqueID;
  109801. /**
  109802. * Add a new geometry to this scene
  109803. * @param geometry defines the geometry to be added to the scene.
  109804. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  109805. * @return a boolean defining if the geometry was added or not
  109806. */
  109807. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  109808. /**
  109809. * Removes an existing geometry
  109810. * @param geometry defines the geometry to be removed from the scene
  109811. * @return a boolean defining if the geometry was removed or not
  109812. */
  109813. removeGeometry(geometry: Geometry): boolean;
  109814. /**
  109815. * Gets the list of geometries attached to the scene
  109816. * @returns an array of Geometry
  109817. */
  109818. getGeometries(): Geometry[];
  109819. /**
  109820. * Gets the first added mesh found of a given ID
  109821. * @param id defines the id to search for
  109822. * @return the mesh found or null if not found at all
  109823. */
  109824. getMeshByID(id: string): Nullable<AbstractMesh>;
  109825. /**
  109826. * Gets a list of meshes using their id
  109827. * @param id defines the id to search for
  109828. * @returns a list of meshes
  109829. */
  109830. getMeshesByID(id: string): Array<AbstractMesh>;
  109831. /**
  109832. * Gets the first added transform node found of a given ID
  109833. * @param id defines the id to search for
  109834. * @return the found transform node or null if not found at all.
  109835. */
  109836. getTransformNodeByID(id: string): Nullable<TransformNode>;
  109837. /**
  109838. * Gets a transform node with its auto-generated unique id
  109839. * @param uniqueId efines the unique id to search for
  109840. * @return the found transform node or null if not found at all.
  109841. */
  109842. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  109843. /**
  109844. * Gets a list of transform nodes using their id
  109845. * @param id defines the id to search for
  109846. * @returns a list of transform nodes
  109847. */
  109848. getTransformNodesByID(id: string): Array<TransformNode>;
  109849. /**
  109850. * Gets a mesh with its auto-generated unique id
  109851. * @param uniqueId defines the unique id to search for
  109852. * @return the found mesh or null if not found at all.
  109853. */
  109854. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  109855. /**
  109856. * Gets a the last added mesh using a given id
  109857. * @param id defines the id to search for
  109858. * @return the found mesh or null if not found at all.
  109859. */
  109860. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  109861. /**
  109862. * Gets a the last added node (Mesh, Camera, Light) using a given id
  109863. * @param id defines the id to search for
  109864. * @return the found node or null if not found at all
  109865. */
  109866. getLastEntryByID(id: string): Nullable<Node>;
  109867. /**
  109868. * Gets a node (Mesh, Camera, Light) using a given id
  109869. * @param id defines the id to search for
  109870. * @return the found node or null if not found at all
  109871. */
  109872. getNodeByID(id: string): Nullable<Node>;
  109873. /**
  109874. * Gets a node (Mesh, Camera, Light) using a given name
  109875. * @param name defines the name to search for
  109876. * @return the found node or null if not found at all.
  109877. */
  109878. getNodeByName(name: string): Nullable<Node>;
  109879. /**
  109880. * Gets a mesh using a given name
  109881. * @param name defines the name to search for
  109882. * @return the found mesh or null if not found at all.
  109883. */
  109884. getMeshByName(name: string): Nullable<AbstractMesh>;
  109885. /**
  109886. * Gets a transform node using a given name
  109887. * @param name defines the name to search for
  109888. * @return the found transform node or null if not found at all.
  109889. */
  109890. getTransformNodeByName(name: string): Nullable<TransformNode>;
  109891. /**
  109892. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  109893. * @param id defines the id to search for
  109894. * @return the found skeleton or null if not found at all.
  109895. */
  109896. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  109897. /**
  109898. * Gets a skeleton using a given auto generated unique id
  109899. * @param uniqueId defines the unique id to search for
  109900. * @return the found skeleton or null if not found at all.
  109901. */
  109902. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  109903. /**
  109904. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  109905. * @param id defines the id to search for
  109906. * @return the found skeleton or null if not found at all.
  109907. */
  109908. getSkeletonById(id: string): Nullable<Skeleton>;
  109909. /**
  109910. * Gets a skeleton using a given name
  109911. * @param name defines the name to search for
  109912. * @return the found skeleton or null if not found at all.
  109913. */
  109914. getSkeletonByName(name: string): Nullable<Skeleton>;
  109915. /**
  109916. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  109917. * @param id defines the id to search for
  109918. * @return the found morph target manager or null if not found at all.
  109919. */
  109920. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  109921. /**
  109922. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  109923. * @param id defines the id to search for
  109924. * @return the found morph target or null if not found at all.
  109925. */
  109926. getMorphTargetById(id: string): Nullable<MorphTarget>;
  109927. /**
  109928. * Gets a boolean indicating if the given mesh is active
  109929. * @param mesh defines the mesh to look for
  109930. * @returns true if the mesh is in the active list
  109931. */
  109932. isActiveMesh(mesh: AbstractMesh): boolean;
  109933. /**
  109934. * Return a unique id as a string which can serve as an identifier for the scene
  109935. */
  109936. get uid(): string;
  109937. /**
  109938. * Add an externaly attached data from its key.
  109939. * This method call will fail and return false, if such key already exists.
  109940. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  109941. * @param key the unique key that identifies the data
  109942. * @param data the data object to associate to the key for this Engine instance
  109943. * @return true if no such key were already present and the data was added successfully, false otherwise
  109944. */
  109945. addExternalData<T>(key: string, data: T): boolean;
  109946. /**
  109947. * Get an externaly attached data from its key
  109948. * @param key the unique key that identifies the data
  109949. * @return the associated data, if present (can be null), or undefined if not present
  109950. */
  109951. getExternalData<T>(key: string): Nullable<T>;
  109952. /**
  109953. * Get an externaly attached data from its key, create it using a factory if it's not already present
  109954. * @param key the unique key that identifies the data
  109955. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  109956. * @return the associated data, can be null if the factory returned null.
  109957. */
  109958. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  109959. /**
  109960. * Remove an externaly attached data from the Engine instance
  109961. * @param key the unique key that identifies the data
  109962. * @return true if the data was successfully removed, false if it doesn't exist
  109963. */
  109964. removeExternalData(key: string): boolean;
  109965. private _evaluateSubMesh;
  109966. /**
  109967. * Clear the processed materials smart array preventing retention point in material dispose.
  109968. */
  109969. freeProcessedMaterials(): void;
  109970. private _preventFreeActiveMeshesAndRenderingGroups;
  109971. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  109972. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  109973. * when disposing several meshes in a row or a hierarchy of meshes.
  109974. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  109975. */
  109976. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  109977. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  109978. /**
  109979. * Clear the active meshes smart array preventing retention point in mesh dispose.
  109980. */
  109981. freeActiveMeshes(): void;
  109982. /**
  109983. * Clear the info related to rendering groups preventing retention points during dispose.
  109984. */
  109985. freeRenderingGroups(): void;
  109986. /** @hidden */
  109987. _isInIntermediateRendering(): boolean;
  109988. /**
  109989. * Lambda returning the list of potentially active meshes.
  109990. */
  109991. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  109992. /**
  109993. * Lambda returning the list of potentially active sub meshes.
  109994. */
  109995. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  109996. /**
  109997. * Lambda returning the list of potentially intersecting sub meshes.
  109998. */
  109999. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  110000. /**
  110001. * Lambda returning the list of potentially colliding sub meshes.
  110002. */
  110003. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  110004. private _activeMeshesFrozen;
  110005. private _skipEvaluateActiveMeshesCompletely;
  110006. /**
  110007. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  110008. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  110009. * @returns the current scene
  110010. */
  110011. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  110012. /**
  110013. * Use this function to restart evaluating active meshes on every frame
  110014. * @returns the current scene
  110015. */
  110016. unfreezeActiveMeshes(): Scene;
  110017. private _evaluateActiveMeshes;
  110018. private _activeMesh;
  110019. /**
  110020. * Update the transform matrix to update from the current active camera
  110021. * @param force defines a boolean used to force the update even if cache is up to date
  110022. */
  110023. updateTransformMatrix(force?: boolean): void;
  110024. private _bindFrameBuffer;
  110025. /** @hidden */
  110026. _allowPostProcessClearColor: boolean;
  110027. /** @hidden */
  110028. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  110029. private _processSubCameras;
  110030. private _checkIntersections;
  110031. /** @hidden */
  110032. _advancePhysicsEngineStep(step: number): void;
  110033. /**
  110034. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  110035. */
  110036. getDeterministicFrameTime: () => number;
  110037. /** @hidden */
  110038. _animate(): void;
  110039. /** Execute all animations (for a frame) */
  110040. animate(): void;
  110041. /**
  110042. * Render the scene
  110043. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  110044. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  110045. */
  110046. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  110047. /**
  110048. * Freeze all materials
  110049. * A frozen material will not be updatable but should be faster to render
  110050. */
  110051. freezeMaterials(): void;
  110052. /**
  110053. * Unfreeze all materials
  110054. * A frozen material will not be updatable but should be faster to render
  110055. */
  110056. unfreezeMaterials(): void;
  110057. /**
  110058. * Releases all held ressources
  110059. */
  110060. dispose(): void;
  110061. /**
  110062. * Gets if the scene is already disposed
  110063. */
  110064. get isDisposed(): boolean;
  110065. /**
  110066. * Call this function to reduce memory footprint of the scene.
  110067. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  110068. */
  110069. clearCachedVertexData(): void;
  110070. /**
  110071. * This function will remove the local cached buffer data from texture.
  110072. * It will save memory but will prevent the texture from being rebuilt
  110073. */
  110074. cleanCachedTextureBuffer(): void;
  110075. /**
  110076. * Get the world extend vectors with an optional filter
  110077. *
  110078. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  110079. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  110080. */
  110081. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  110082. min: Vector3;
  110083. max: Vector3;
  110084. };
  110085. /**
  110086. * Creates a ray that can be used to pick in the scene
  110087. * @param x defines the x coordinate of the origin (on-screen)
  110088. * @param y defines the y coordinate of the origin (on-screen)
  110089. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110090. * @param camera defines the camera to use for the picking
  110091. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110092. * @returns a Ray
  110093. */
  110094. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  110095. /**
  110096. * Creates a ray that can be used to pick in the scene
  110097. * @param x defines the x coordinate of the origin (on-screen)
  110098. * @param y defines the y coordinate of the origin (on-screen)
  110099. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  110100. * @param result defines the ray where to store the picking ray
  110101. * @param camera defines the camera to use for the picking
  110102. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  110103. * @returns the current scene
  110104. */
  110105. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  110106. /**
  110107. * Creates a ray that can be used to pick in the scene
  110108. * @param x defines the x coordinate of the origin (on-screen)
  110109. * @param y defines the y coordinate of the origin (on-screen)
  110110. * @param camera defines the camera to use for the picking
  110111. * @returns a Ray
  110112. */
  110113. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  110114. /**
  110115. * Creates a ray that can be used to pick in the scene
  110116. * @param x defines the x coordinate of the origin (on-screen)
  110117. * @param y defines the y coordinate of the origin (on-screen)
  110118. * @param result defines the ray where to store the picking ray
  110119. * @param camera defines the camera to use for the picking
  110120. * @returns the current scene
  110121. */
  110122. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  110123. /** Launch a ray to try to pick a mesh in the scene
  110124. * @param x position on screen
  110125. * @param y position on screen
  110126. * @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
  110127. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  110128. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110129. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110130. * @returns a PickingInfo
  110131. */
  110132. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110133. /** Use the given ray to pick a mesh in the scene
  110134. * @param ray The ray to use to pick meshes
  110135. * @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
  110136. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  110137. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110138. * @returns a PickingInfo
  110139. */
  110140. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  110141. /**
  110142. * Launch a ray to try to pick a mesh in the scene
  110143. * @param x X position on screen
  110144. * @param y Y position on screen
  110145. * @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
  110146. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  110147. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110148. * @returns an array of PickingInfo
  110149. */
  110150. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110151. /**
  110152. * Launch a ray to try to pick a mesh in the scene
  110153. * @param ray Ray to use
  110154. * @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
  110155. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  110156. * @returns an array of PickingInfo
  110157. */
  110158. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  110159. /**
  110160. * Force the value of meshUnderPointer
  110161. * @param mesh defines the mesh to use
  110162. */
  110163. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  110164. /**
  110165. * Gets the mesh under the pointer
  110166. * @returns a Mesh or null if no mesh is under the pointer
  110167. */
  110168. getPointerOverMesh(): Nullable<AbstractMesh>;
  110169. /** @hidden */
  110170. _rebuildGeometries(): void;
  110171. /** @hidden */
  110172. _rebuildTextures(): void;
  110173. private _getByTags;
  110174. /**
  110175. * Get a list of meshes by tags
  110176. * @param tagsQuery defines the tags query to use
  110177. * @param forEach defines a predicate used to filter results
  110178. * @returns an array of Mesh
  110179. */
  110180. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  110181. /**
  110182. * Get a list of cameras by tags
  110183. * @param tagsQuery defines the tags query to use
  110184. * @param forEach defines a predicate used to filter results
  110185. * @returns an array of Camera
  110186. */
  110187. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  110188. /**
  110189. * Get a list of lights by tags
  110190. * @param tagsQuery defines the tags query to use
  110191. * @param forEach defines a predicate used to filter results
  110192. * @returns an array of Light
  110193. */
  110194. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  110195. /**
  110196. * Get a list of materials by tags
  110197. * @param tagsQuery defines the tags query to use
  110198. * @param forEach defines a predicate used to filter results
  110199. * @returns an array of Material
  110200. */
  110201. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  110202. /**
  110203. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  110204. * This allowed control for front to back rendering or reversly depending of the special needs.
  110205. *
  110206. * @param renderingGroupId The rendering group id corresponding to its index
  110207. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  110208. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  110209. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  110210. */
  110211. 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;
  110212. /**
  110213. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  110214. *
  110215. * @param renderingGroupId The rendering group id corresponding to its index
  110216. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  110217. * @param depth Automatically clears depth between groups if true and autoClear is true.
  110218. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  110219. */
  110220. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  110221. /**
  110222. * Gets the current auto clear configuration for one rendering group of the rendering
  110223. * manager.
  110224. * @param index the rendering group index to get the information for
  110225. * @returns The auto clear setup for the requested rendering group
  110226. */
  110227. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  110228. private _blockMaterialDirtyMechanism;
  110229. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  110230. get blockMaterialDirtyMechanism(): boolean;
  110231. set blockMaterialDirtyMechanism(value: boolean);
  110232. /**
  110233. * Will flag all materials as dirty to trigger new shader compilation
  110234. * @param flag defines the flag used to specify which material part must be marked as dirty
  110235. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  110236. */
  110237. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  110238. /** @hidden */
  110239. _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;
  110240. /** @hidden */
  110241. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110242. /** @hidden */
  110243. _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;
  110244. /** @hidden */
  110245. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  110246. /** @hidden */
  110247. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  110248. /** @hidden */
  110249. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  110250. }
  110251. }
  110252. declare module BABYLON {
  110253. /**
  110254. * Set of assets to keep when moving a scene into an asset container.
  110255. */
  110256. export class KeepAssets extends AbstractScene {
  110257. }
  110258. /**
  110259. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  110260. */
  110261. export class InstantiatedEntries {
  110262. /**
  110263. * List of new root nodes (eg. nodes with no parent)
  110264. */
  110265. rootNodes: TransformNode[];
  110266. /**
  110267. * List of new skeletons
  110268. */
  110269. skeletons: Skeleton[];
  110270. /**
  110271. * List of new animation groups
  110272. */
  110273. animationGroups: AnimationGroup[];
  110274. }
  110275. /**
  110276. * Container with a set of assets that can be added or removed from a scene.
  110277. */
  110278. export class AssetContainer extends AbstractScene {
  110279. private _wasAddedToScene;
  110280. /**
  110281. * The scene the AssetContainer belongs to.
  110282. */
  110283. scene: Scene;
  110284. /**
  110285. * Instantiates an AssetContainer.
  110286. * @param scene The scene the AssetContainer belongs to.
  110287. */
  110288. constructor(scene: Scene);
  110289. /**
  110290. * Instantiate or clone all meshes and add the new ones to the scene.
  110291. * Skeletons and animation groups will all be cloned
  110292. * @param nameFunction defines an optional function used to get new names for clones
  110293. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  110294. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  110295. */
  110296. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  110297. /**
  110298. * Adds all the assets from the container to the scene.
  110299. */
  110300. addAllToScene(): void;
  110301. /**
  110302. * Removes all the assets in the container from the scene
  110303. */
  110304. removeAllFromScene(): void;
  110305. /**
  110306. * Disposes all the assets in the container
  110307. */
  110308. dispose(): void;
  110309. private _moveAssets;
  110310. /**
  110311. * Removes all the assets contained in the scene and adds them to the container.
  110312. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  110313. */
  110314. moveAllFromScene(keepAssets?: KeepAssets): void;
  110315. /**
  110316. * 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.
  110317. * @returns the root mesh
  110318. */
  110319. createRootMesh(): Mesh;
  110320. /**
  110321. * Merge animations from this asset container into a scene
  110322. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  110323. * @param animatables set of animatables to retarget to a node from the scene
  110324. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  110325. */
  110326. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  110327. }
  110328. }
  110329. declare module BABYLON {
  110330. /**
  110331. * Defines how the parser contract is defined.
  110332. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  110333. */
  110334. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  110335. /**
  110336. * Defines how the individual parser contract is defined.
  110337. * These parser can parse an individual asset
  110338. */
  110339. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  110340. /**
  110341. * Base class of the scene acting as a container for the different elements composing a scene.
  110342. * This class is dynamically extended by the different components of the scene increasing
  110343. * flexibility and reducing coupling
  110344. */
  110345. export abstract class AbstractScene {
  110346. /**
  110347. * Stores the list of available parsers in the application.
  110348. */
  110349. private static _BabylonFileParsers;
  110350. /**
  110351. * Stores the list of available individual parsers in the application.
  110352. */
  110353. private static _IndividualBabylonFileParsers;
  110354. /**
  110355. * Adds a parser in the list of available ones
  110356. * @param name Defines the name of the parser
  110357. * @param parser Defines the parser to add
  110358. */
  110359. static AddParser(name: string, parser: BabylonFileParser): void;
  110360. /**
  110361. * Gets a general parser from the list of avaialble ones
  110362. * @param name Defines the name of the parser
  110363. * @returns the requested parser or null
  110364. */
  110365. static GetParser(name: string): Nullable<BabylonFileParser>;
  110366. /**
  110367. * Adds n individual parser in the list of available ones
  110368. * @param name Defines the name of the parser
  110369. * @param parser Defines the parser to add
  110370. */
  110371. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  110372. /**
  110373. * Gets an individual parser from the list of avaialble ones
  110374. * @param name Defines the name of the parser
  110375. * @returns the requested parser or null
  110376. */
  110377. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  110378. /**
  110379. * Parser json data and populate both a scene and its associated container object
  110380. * @param jsonData Defines the data to parse
  110381. * @param scene Defines the scene to parse the data for
  110382. * @param container Defines the container attached to the parsing sequence
  110383. * @param rootUrl Defines the root url of the data
  110384. */
  110385. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  110386. /**
  110387. * Gets the list of root nodes (ie. nodes with no parent)
  110388. */
  110389. rootNodes: Node[];
  110390. /** All of the cameras added to this scene
  110391. * @see http://doc.babylonjs.com/babylon101/cameras
  110392. */
  110393. cameras: Camera[];
  110394. /**
  110395. * All of the lights added to this scene
  110396. * @see http://doc.babylonjs.com/babylon101/lights
  110397. */
  110398. lights: Light[];
  110399. /**
  110400. * All of the (abstract) meshes added to this scene
  110401. */
  110402. meshes: AbstractMesh[];
  110403. /**
  110404. * The list of skeletons added to the scene
  110405. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  110406. */
  110407. skeletons: Skeleton[];
  110408. /**
  110409. * All of the particle systems added to this scene
  110410. * @see http://doc.babylonjs.com/babylon101/particles
  110411. */
  110412. particleSystems: IParticleSystem[];
  110413. /**
  110414. * Gets a list of Animations associated with the scene
  110415. */
  110416. animations: Animation[];
  110417. /**
  110418. * All of the animation groups added to this scene
  110419. * @see http://doc.babylonjs.com/how_to/group
  110420. */
  110421. animationGroups: AnimationGroup[];
  110422. /**
  110423. * All of the multi-materials added to this scene
  110424. * @see http://doc.babylonjs.com/how_to/multi_materials
  110425. */
  110426. multiMaterials: MultiMaterial[];
  110427. /**
  110428. * All of the materials added to this scene
  110429. * In the context of a Scene, it is not supposed to be modified manually.
  110430. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  110431. * Note also that the order of the Material within the array is not significant and might change.
  110432. * @see http://doc.babylonjs.com/babylon101/materials
  110433. */
  110434. materials: Material[];
  110435. /**
  110436. * The list of morph target managers added to the scene
  110437. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  110438. */
  110439. morphTargetManagers: MorphTargetManager[];
  110440. /**
  110441. * The list of geometries used in the scene.
  110442. */
  110443. geometries: Geometry[];
  110444. /**
  110445. * All of the tranform nodes added to this scene
  110446. * In the context of a Scene, it is not supposed to be modified manually.
  110447. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  110448. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  110449. * @see http://doc.babylonjs.com/how_to/transformnode
  110450. */
  110451. transformNodes: TransformNode[];
  110452. /**
  110453. * ActionManagers available on the scene.
  110454. */
  110455. actionManagers: AbstractActionManager[];
  110456. /**
  110457. * Textures to keep.
  110458. */
  110459. textures: BaseTexture[];
  110460. /**
  110461. * Environment texture for the scene
  110462. */
  110463. environmentTexture: Nullable<BaseTexture>;
  110464. /**
  110465. * @returns all meshes, lights, cameras, transformNodes and bones
  110466. */
  110467. getNodes(): Array<Node>;
  110468. }
  110469. }
  110470. declare module BABYLON {
  110471. /**
  110472. * Interface used to define options for Sound class
  110473. */
  110474. export interface ISoundOptions {
  110475. /**
  110476. * Does the sound autoplay once loaded.
  110477. */
  110478. autoplay?: boolean;
  110479. /**
  110480. * Does the sound loop after it finishes playing once.
  110481. */
  110482. loop?: boolean;
  110483. /**
  110484. * Sound's volume
  110485. */
  110486. volume?: number;
  110487. /**
  110488. * Is it a spatial sound?
  110489. */
  110490. spatialSound?: boolean;
  110491. /**
  110492. * Maximum distance to hear that sound
  110493. */
  110494. maxDistance?: number;
  110495. /**
  110496. * Uses user defined attenuation function
  110497. */
  110498. useCustomAttenuation?: boolean;
  110499. /**
  110500. * Define the roll off factor of spatial sounds.
  110501. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110502. */
  110503. rolloffFactor?: number;
  110504. /**
  110505. * Define the reference distance the sound should be heard perfectly.
  110506. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110507. */
  110508. refDistance?: number;
  110509. /**
  110510. * Define the distance attenuation model the sound will follow.
  110511. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110512. */
  110513. distanceModel?: string;
  110514. /**
  110515. * Defines the playback speed (1 by default)
  110516. */
  110517. playbackRate?: number;
  110518. /**
  110519. * Defines if the sound is from a streaming source
  110520. */
  110521. streaming?: boolean;
  110522. /**
  110523. * Defines an optional length (in seconds) inside the sound file
  110524. */
  110525. length?: number;
  110526. /**
  110527. * Defines an optional offset (in seconds) inside the sound file
  110528. */
  110529. offset?: number;
  110530. /**
  110531. * If true, URLs will not be required to state the audio file codec to use.
  110532. */
  110533. skipCodecCheck?: boolean;
  110534. }
  110535. /**
  110536. * Defines a sound that can be played in the application.
  110537. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  110538. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  110539. */
  110540. export class Sound {
  110541. /**
  110542. * The name of the sound in the scene.
  110543. */
  110544. name: string;
  110545. /**
  110546. * Does the sound autoplay once loaded.
  110547. */
  110548. autoplay: boolean;
  110549. /**
  110550. * Does the sound loop after it finishes playing once.
  110551. */
  110552. loop: boolean;
  110553. /**
  110554. * Does the sound use a custom attenuation curve to simulate the falloff
  110555. * happening when the source gets further away from the camera.
  110556. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110557. */
  110558. useCustomAttenuation: boolean;
  110559. /**
  110560. * The sound track id this sound belongs to.
  110561. */
  110562. soundTrackId: number;
  110563. /**
  110564. * Is this sound currently played.
  110565. */
  110566. isPlaying: boolean;
  110567. /**
  110568. * Is this sound currently paused.
  110569. */
  110570. isPaused: boolean;
  110571. /**
  110572. * Does this sound enables spatial sound.
  110573. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110574. */
  110575. spatialSound: boolean;
  110576. /**
  110577. * Define the reference distance the sound should be heard perfectly.
  110578. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110579. */
  110580. refDistance: number;
  110581. /**
  110582. * Define the roll off factor of spatial sounds.
  110583. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110584. */
  110585. rolloffFactor: number;
  110586. /**
  110587. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  110588. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110589. */
  110590. maxDistance: number;
  110591. /**
  110592. * Define the distance attenuation model the sound will follow.
  110593. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110594. */
  110595. distanceModel: string;
  110596. /**
  110597. * @hidden
  110598. * Back Compat
  110599. **/
  110600. onended: () => any;
  110601. /**
  110602. * Observable event when the current playing sound finishes.
  110603. */
  110604. onEndedObservable: Observable<Sound>;
  110605. private _panningModel;
  110606. private _playbackRate;
  110607. private _streaming;
  110608. private _startTime;
  110609. private _startOffset;
  110610. private _position;
  110611. /** @hidden */
  110612. _positionInEmitterSpace: boolean;
  110613. private _localDirection;
  110614. private _volume;
  110615. private _isReadyToPlay;
  110616. private _isDirectional;
  110617. private _readyToPlayCallback;
  110618. private _audioBuffer;
  110619. private _soundSource;
  110620. private _streamingSource;
  110621. private _soundPanner;
  110622. private _soundGain;
  110623. private _inputAudioNode;
  110624. private _outputAudioNode;
  110625. private _coneInnerAngle;
  110626. private _coneOuterAngle;
  110627. private _coneOuterGain;
  110628. private _scene;
  110629. private _connectedTransformNode;
  110630. private _customAttenuationFunction;
  110631. private _registerFunc;
  110632. private _isOutputConnected;
  110633. private _htmlAudioElement;
  110634. private _urlType;
  110635. private _length?;
  110636. private _offset?;
  110637. /** @hidden */
  110638. static _SceneComponentInitialization: (scene: Scene) => void;
  110639. /**
  110640. * Create a sound and attach it to a scene
  110641. * @param name Name of your sound
  110642. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  110643. * @param scene defines the scene the sound belongs to
  110644. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  110645. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  110646. */
  110647. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  110648. /**
  110649. * Release the sound and its associated resources
  110650. */
  110651. dispose(): void;
  110652. /**
  110653. * Gets if the sounds is ready to be played or not.
  110654. * @returns true if ready, otherwise false
  110655. */
  110656. isReady(): boolean;
  110657. private _soundLoaded;
  110658. /**
  110659. * Sets the data of the sound from an audiobuffer
  110660. * @param audioBuffer The audioBuffer containing the data
  110661. */
  110662. setAudioBuffer(audioBuffer: AudioBuffer): void;
  110663. /**
  110664. * Updates the current sounds options such as maxdistance, loop...
  110665. * @param options A JSON object containing values named as the object properties
  110666. */
  110667. updateOptions(options: ISoundOptions): void;
  110668. private _createSpatialParameters;
  110669. private _updateSpatialParameters;
  110670. /**
  110671. * Switch the panning model to HRTF:
  110672. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110673. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110674. */
  110675. switchPanningModelToHRTF(): void;
  110676. /**
  110677. * Switch the panning model to Equal Power:
  110678. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110679. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110680. */
  110681. switchPanningModelToEqualPower(): void;
  110682. private _switchPanningModel;
  110683. /**
  110684. * Connect this sound to a sound track audio node like gain...
  110685. * @param soundTrackAudioNode the sound track audio node to connect to
  110686. */
  110687. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  110688. /**
  110689. * Transform this sound into a directional source
  110690. * @param coneInnerAngle Size of the inner cone in degree
  110691. * @param coneOuterAngle Size of the outer cone in degree
  110692. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  110693. */
  110694. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  110695. /**
  110696. * Gets or sets the inner angle for the directional cone.
  110697. */
  110698. get directionalConeInnerAngle(): number;
  110699. /**
  110700. * Gets or sets the inner angle for the directional cone.
  110701. */
  110702. set directionalConeInnerAngle(value: number);
  110703. /**
  110704. * Gets or sets the outer angle for the directional cone.
  110705. */
  110706. get directionalConeOuterAngle(): number;
  110707. /**
  110708. * Gets or sets the outer angle for the directional cone.
  110709. */
  110710. set directionalConeOuterAngle(value: number);
  110711. /**
  110712. * Sets the position of the emitter if spatial sound is enabled
  110713. * @param newPosition Defines the new posisiton
  110714. */
  110715. setPosition(newPosition: Vector3): void;
  110716. /**
  110717. * Sets the local direction of the emitter if spatial sound is enabled
  110718. * @param newLocalDirection Defines the new local direction
  110719. */
  110720. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  110721. private _updateDirection;
  110722. /** @hidden */
  110723. updateDistanceFromListener(): void;
  110724. /**
  110725. * Sets a new custom attenuation function for the sound.
  110726. * @param callback Defines the function used for the attenuation
  110727. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  110728. */
  110729. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  110730. /**
  110731. * Play the sound
  110732. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  110733. * @param offset (optional) Start the sound at a specific time in seconds
  110734. * @param length (optional) Sound duration (in seconds)
  110735. */
  110736. play(time?: number, offset?: number, length?: number): void;
  110737. private _onended;
  110738. /**
  110739. * Stop the sound
  110740. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  110741. */
  110742. stop(time?: number): void;
  110743. /**
  110744. * Put the sound in pause
  110745. */
  110746. pause(): void;
  110747. /**
  110748. * Sets a dedicated volume for this sounds
  110749. * @param newVolume Define the new volume of the sound
  110750. * @param time Define time for gradual change to new volume
  110751. */
  110752. setVolume(newVolume: number, time?: number): void;
  110753. /**
  110754. * Set the sound play back rate
  110755. * @param newPlaybackRate Define the playback rate the sound should be played at
  110756. */
  110757. setPlaybackRate(newPlaybackRate: number): void;
  110758. /**
  110759. * Gets the volume of the sound.
  110760. * @returns the volume of the sound
  110761. */
  110762. getVolume(): number;
  110763. /**
  110764. * Attach the sound to a dedicated mesh
  110765. * @param transformNode The transform node to connect the sound with
  110766. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110767. */
  110768. attachToMesh(transformNode: TransformNode): void;
  110769. /**
  110770. * Detach the sound from the previously attached mesh
  110771. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  110772. */
  110773. detachFromMesh(): void;
  110774. private _onRegisterAfterWorldMatrixUpdate;
  110775. /**
  110776. * Clone the current sound in the scene.
  110777. * @returns the new sound clone
  110778. */
  110779. clone(): Nullable<Sound>;
  110780. /**
  110781. * Gets the current underlying audio buffer containing the data
  110782. * @returns the audio buffer
  110783. */
  110784. getAudioBuffer(): Nullable<AudioBuffer>;
  110785. /**
  110786. * Serializes the Sound in a JSON representation
  110787. * @returns the JSON representation of the sound
  110788. */
  110789. serialize(): any;
  110790. /**
  110791. * Parse a JSON representation of a sound to innstantiate in a given scene
  110792. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  110793. * @param scene Define the scene the new parsed sound should be created in
  110794. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  110795. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  110796. * @returns the newly parsed sound
  110797. */
  110798. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  110799. }
  110800. }
  110801. declare module BABYLON {
  110802. /**
  110803. * This defines an action helpful to play a defined sound on a triggered action.
  110804. */
  110805. export class PlaySoundAction extends Action {
  110806. private _sound;
  110807. /**
  110808. * Instantiate the action
  110809. * @param triggerOptions defines the trigger options
  110810. * @param sound defines the sound to play
  110811. * @param condition defines the trigger related conditions
  110812. */
  110813. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110814. /** @hidden */
  110815. _prepare(): void;
  110816. /**
  110817. * Execute the action and play the sound.
  110818. */
  110819. execute(): void;
  110820. /**
  110821. * Serializes the actions and its related information.
  110822. * @param parent defines the object to serialize in
  110823. * @returns the serialized object
  110824. */
  110825. serialize(parent: any): any;
  110826. }
  110827. /**
  110828. * This defines an action helpful to stop a defined sound on a triggered action.
  110829. */
  110830. export class StopSoundAction extends Action {
  110831. private _sound;
  110832. /**
  110833. * Instantiate the action
  110834. * @param triggerOptions defines the trigger options
  110835. * @param sound defines the sound to stop
  110836. * @param condition defines the trigger related conditions
  110837. */
  110838. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  110839. /** @hidden */
  110840. _prepare(): void;
  110841. /**
  110842. * Execute the action and stop the sound.
  110843. */
  110844. execute(): void;
  110845. /**
  110846. * Serializes the actions and its related information.
  110847. * @param parent defines the object to serialize in
  110848. * @returns the serialized object
  110849. */
  110850. serialize(parent: any): any;
  110851. }
  110852. }
  110853. declare module BABYLON {
  110854. /**
  110855. * This defines an action responsible to change the value of a property
  110856. * by interpolating between its current value and the newly set one once triggered.
  110857. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110858. */
  110859. export class InterpolateValueAction extends Action {
  110860. /**
  110861. * Defines the path of the property where the value should be interpolated
  110862. */
  110863. propertyPath: string;
  110864. /**
  110865. * Defines the target value at the end of the interpolation.
  110866. */
  110867. value: any;
  110868. /**
  110869. * Defines the time it will take for the property to interpolate to the value.
  110870. */
  110871. duration: number;
  110872. /**
  110873. * Defines if the other scene animations should be stopped when the action has been triggered
  110874. */
  110875. stopOtherAnimations?: boolean;
  110876. /**
  110877. * Defines a callback raised once the interpolation animation has been done.
  110878. */
  110879. onInterpolationDone?: () => void;
  110880. /**
  110881. * Observable triggered once the interpolation animation has been done.
  110882. */
  110883. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  110884. private _target;
  110885. private _effectiveTarget;
  110886. private _property;
  110887. /**
  110888. * Instantiate the action
  110889. * @param triggerOptions defines the trigger options
  110890. * @param target defines the object containing the value to interpolate
  110891. * @param propertyPath defines the path to the property in the target object
  110892. * @param value defines the target value at the end of the interpolation
  110893. * @param duration deines the time it will take for the property to interpolate to the value.
  110894. * @param condition defines the trigger related conditions
  110895. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  110896. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  110897. */
  110898. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  110899. /** @hidden */
  110900. _prepare(): void;
  110901. /**
  110902. * Execute the action starts the value interpolation.
  110903. */
  110904. execute(): void;
  110905. /**
  110906. * Serializes the actions and its related information.
  110907. * @param parent defines the object to serialize in
  110908. * @returns the serialized object
  110909. */
  110910. serialize(parent: any): any;
  110911. }
  110912. }
  110913. declare module BABYLON {
  110914. /**
  110915. * Options allowed during the creation of a sound track.
  110916. */
  110917. export interface ISoundTrackOptions {
  110918. /**
  110919. * The volume the sound track should take during creation
  110920. */
  110921. volume?: number;
  110922. /**
  110923. * Define if the sound track is the main sound track of the scene
  110924. */
  110925. mainTrack?: boolean;
  110926. }
  110927. /**
  110928. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  110929. * It will be also used in a future release to apply effects on a specific track.
  110930. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110931. */
  110932. export class SoundTrack {
  110933. /**
  110934. * The unique identifier of the sound track in the scene.
  110935. */
  110936. id: number;
  110937. /**
  110938. * The list of sounds included in the sound track.
  110939. */
  110940. soundCollection: Array<Sound>;
  110941. private _outputAudioNode;
  110942. private _scene;
  110943. private _connectedAnalyser;
  110944. private _options;
  110945. private _isInitialized;
  110946. /**
  110947. * Creates a new sound track.
  110948. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  110949. * @param scene Define the scene the sound track belongs to
  110950. * @param options
  110951. */
  110952. constructor(scene: Scene, options?: ISoundTrackOptions);
  110953. private _initializeSoundTrackAudioGraph;
  110954. /**
  110955. * Release the sound track and its associated resources
  110956. */
  110957. dispose(): void;
  110958. /**
  110959. * Adds a sound to this sound track
  110960. * @param sound define the cound to add
  110961. * @ignoreNaming
  110962. */
  110963. AddSound(sound: Sound): void;
  110964. /**
  110965. * Removes a sound to this sound track
  110966. * @param sound define the cound to remove
  110967. * @ignoreNaming
  110968. */
  110969. RemoveSound(sound: Sound): void;
  110970. /**
  110971. * Set a global volume for the full sound track.
  110972. * @param newVolume Define the new volume of the sound track
  110973. */
  110974. setVolume(newVolume: number): void;
  110975. /**
  110976. * Switch the panning model to HRTF:
  110977. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  110978. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110979. */
  110980. switchPanningModelToHRTF(): void;
  110981. /**
  110982. * Switch the panning model to Equal Power:
  110983. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  110984. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  110985. */
  110986. switchPanningModelToEqualPower(): void;
  110987. /**
  110988. * Connect the sound track to an audio analyser allowing some amazing
  110989. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  110990. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  110991. * @param analyser The analyser to connect to the engine
  110992. */
  110993. connectToAnalyser(analyser: Analyser): void;
  110994. }
  110995. }
  110996. declare module BABYLON {
  110997. interface AbstractScene {
  110998. /**
  110999. * The list of sounds used in the scene.
  111000. */
  111001. sounds: Nullable<Array<Sound>>;
  111002. }
  111003. interface Scene {
  111004. /**
  111005. * @hidden
  111006. * Backing field
  111007. */
  111008. _mainSoundTrack: SoundTrack;
  111009. /**
  111010. * The main sound track played by the scene.
  111011. * It cotains your primary collection of sounds.
  111012. */
  111013. mainSoundTrack: SoundTrack;
  111014. /**
  111015. * The list of sound tracks added to the scene
  111016. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111017. */
  111018. soundTracks: Nullable<Array<SoundTrack>>;
  111019. /**
  111020. * Gets a sound using a given name
  111021. * @param name defines the name to search for
  111022. * @return the found sound or null if not found at all.
  111023. */
  111024. getSoundByName(name: string): Nullable<Sound>;
  111025. /**
  111026. * Gets or sets if audio support is enabled
  111027. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111028. */
  111029. audioEnabled: boolean;
  111030. /**
  111031. * Gets or sets if audio will be output to headphones
  111032. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111033. */
  111034. headphone: boolean;
  111035. /**
  111036. * Gets or sets custom audio listener position provider
  111037. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111038. */
  111039. audioListenerPositionProvider: Nullable<() => Vector3>;
  111040. /**
  111041. * Gets or sets a refresh rate when using 3D audio positioning
  111042. */
  111043. audioPositioningRefreshRate: number;
  111044. }
  111045. /**
  111046. * Defines the sound scene component responsible to manage any sounds
  111047. * in a given scene.
  111048. */
  111049. export class AudioSceneComponent implements ISceneSerializableComponent {
  111050. /**
  111051. * The component name helpfull to identify the component in the list of scene components.
  111052. */
  111053. readonly name: string;
  111054. /**
  111055. * The scene the component belongs to.
  111056. */
  111057. scene: Scene;
  111058. private _audioEnabled;
  111059. /**
  111060. * Gets whether audio is enabled or not.
  111061. * Please use related enable/disable method to switch state.
  111062. */
  111063. get audioEnabled(): boolean;
  111064. private _headphone;
  111065. /**
  111066. * Gets whether audio is outputing to headphone or not.
  111067. * Please use the according Switch methods to change output.
  111068. */
  111069. get headphone(): boolean;
  111070. /**
  111071. * Gets or sets a refresh rate when using 3D audio positioning
  111072. */
  111073. audioPositioningRefreshRate: number;
  111074. private _audioListenerPositionProvider;
  111075. /**
  111076. * Gets the current audio listener position provider
  111077. */
  111078. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  111079. /**
  111080. * Sets a custom listener position for all sounds in the scene
  111081. * By default, this is the position of the first active camera
  111082. */
  111083. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  111084. /**
  111085. * Creates a new instance of the component for the given scene
  111086. * @param scene Defines the scene to register the component in
  111087. */
  111088. constructor(scene: Scene);
  111089. /**
  111090. * Registers the component in a given scene
  111091. */
  111092. register(): void;
  111093. /**
  111094. * Rebuilds the elements related to this component in case of
  111095. * context lost for instance.
  111096. */
  111097. rebuild(): void;
  111098. /**
  111099. * Serializes the component data to the specified json object
  111100. * @param serializationObject The object to serialize to
  111101. */
  111102. serialize(serializationObject: any): void;
  111103. /**
  111104. * Adds all the elements from the container to the scene
  111105. * @param container the container holding the elements
  111106. */
  111107. addFromContainer(container: AbstractScene): void;
  111108. /**
  111109. * Removes all the elements in the container from the scene
  111110. * @param container contains the elements to remove
  111111. * @param dispose if the removed element should be disposed (default: false)
  111112. */
  111113. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  111114. /**
  111115. * Disposes the component and the associated ressources.
  111116. */
  111117. dispose(): void;
  111118. /**
  111119. * Disables audio in the associated scene.
  111120. */
  111121. disableAudio(): void;
  111122. /**
  111123. * Enables audio in the associated scene.
  111124. */
  111125. enableAudio(): void;
  111126. /**
  111127. * Switch audio to headphone output.
  111128. */
  111129. switchAudioModeForHeadphones(): void;
  111130. /**
  111131. * Switch audio to normal speakers.
  111132. */
  111133. switchAudioModeForNormalSpeakers(): void;
  111134. private _cachedCameraDirection;
  111135. private _cachedCameraPosition;
  111136. private _lastCheck;
  111137. private _afterRender;
  111138. }
  111139. }
  111140. declare module BABYLON {
  111141. /**
  111142. * Wraps one or more Sound objects and selects one with random weight for playback.
  111143. */
  111144. export class WeightedSound {
  111145. /** When true a Sound will be selected and played when the current playing Sound completes. */
  111146. loop: boolean;
  111147. private _coneInnerAngle;
  111148. private _coneOuterAngle;
  111149. private _volume;
  111150. /** A Sound is currently playing. */
  111151. isPlaying: boolean;
  111152. /** A Sound is currently paused. */
  111153. isPaused: boolean;
  111154. private _sounds;
  111155. private _weights;
  111156. private _currentIndex?;
  111157. /**
  111158. * Creates a new WeightedSound from the list of sounds given.
  111159. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  111160. * @param sounds Array of Sounds that will be selected from.
  111161. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  111162. */
  111163. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  111164. /**
  111165. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  111166. */
  111167. get directionalConeInnerAngle(): number;
  111168. /**
  111169. * The size of cone in degress for a directional sound in which there will be no attenuation.
  111170. */
  111171. set directionalConeInnerAngle(value: number);
  111172. /**
  111173. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111174. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111175. */
  111176. get directionalConeOuterAngle(): number;
  111177. /**
  111178. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  111179. * Listener angles between innerAngle and outerAngle will falloff linearly.
  111180. */
  111181. set directionalConeOuterAngle(value: number);
  111182. /**
  111183. * Playback volume.
  111184. */
  111185. get volume(): number;
  111186. /**
  111187. * Playback volume.
  111188. */
  111189. set volume(value: number);
  111190. private _onended;
  111191. /**
  111192. * Suspend playback
  111193. */
  111194. pause(): void;
  111195. /**
  111196. * Stop playback
  111197. */
  111198. stop(): void;
  111199. /**
  111200. * Start playback.
  111201. * @param startOffset Position the clip head at a specific time in seconds.
  111202. */
  111203. play(startOffset?: number): void;
  111204. }
  111205. }
  111206. declare module BABYLON {
  111207. /**
  111208. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  111209. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  111210. */
  111211. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  111212. /**
  111213. * Gets the name of the behavior.
  111214. */
  111215. get name(): string;
  111216. /**
  111217. * The easing function used by animations
  111218. */
  111219. static EasingFunction: BackEase;
  111220. /**
  111221. * The easing mode used by animations
  111222. */
  111223. static EasingMode: number;
  111224. /**
  111225. * The duration of the animation, in milliseconds
  111226. */
  111227. transitionDuration: number;
  111228. /**
  111229. * Length of the distance animated by the transition when lower radius is reached
  111230. */
  111231. lowerRadiusTransitionRange: number;
  111232. /**
  111233. * Length of the distance animated by the transition when upper radius is reached
  111234. */
  111235. upperRadiusTransitionRange: number;
  111236. private _autoTransitionRange;
  111237. /**
  111238. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111239. */
  111240. get autoTransitionRange(): boolean;
  111241. /**
  111242. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  111243. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  111244. */
  111245. set autoTransitionRange(value: boolean);
  111246. private _attachedCamera;
  111247. private _onAfterCheckInputsObserver;
  111248. private _onMeshTargetChangedObserver;
  111249. /**
  111250. * Initializes the behavior.
  111251. */
  111252. init(): void;
  111253. /**
  111254. * Attaches the behavior to its arc rotate camera.
  111255. * @param camera Defines the camera to attach the behavior to
  111256. */
  111257. attach(camera: ArcRotateCamera): void;
  111258. /**
  111259. * Detaches the behavior from its current arc rotate camera.
  111260. */
  111261. detach(): void;
  111262. private _radiusIsAnimating;
  111263. private _radiusBounceTransition;
  111264. private _animatables;
  111265. private _cachedWheelPrecision;
  111266. /**
  111267. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  111268. * @param radiusLimit The limit to check against.
  111269. * @return Bool to indicate if at limit.
  111270. */
  111271. private _isRadiusAtLimit;
  111272. /**
  111273. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  111274. * @param radiusDelta The delta by which to animate to. Can be negative.
  111275. */
  111276. private _applyBoundRadiusAnimation;
  111277. /**
  111278. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  111279. */
  111280. protected _clearAnimationLocks(): void;
  111281. /**
  111282. * Stops and removes all animations that have been applied to the camera
  111283. */
  111284. stopAllAnimations(): void;
  111285. }
  111286. }
  111287. declare module BABYLON {
  111288. /**
  111289. * 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.
  111290. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  111291. */
  111292. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  111293. /**
  111294. * Gets the name of the behavior.
  111295. */
  111296. get name(): string;
  111297. private _mode;
  111298. private _radiusScale;
  111299. private _positionScale;
  111300. private _defaultElevation;
  111301. private _elevationReturnTime;
  111302. private _elevationReturnWaitTime;
  111303. private _zoomStopsAnimation;
  111304. private _framingTime;
  111305. /**
  111306. * The easing function used by animations
  111307. */
  111308. static EasingFunction: ExponentialEase;
  111309. /**
  111310. * The easing mode used by animations
  111311. */
  111312. static EasingMode: number;
  111313. /**
  111314. * Sets the current mode used by the behavior
  111315. */
  111316. set mode(mode: number);
  111317. /**
  111318. * Gets current mode used by the behavior.
  111319. */
  111320. get mode(): number;
  111321. /**
  111322. * Sets the scale applied to the radius (1 by default)
  111323. */
  111324. set radiusScale(radius: number);
  111325. /**
  111326. * Gets the scale applied to the radius
  111327. */
  111328. get radiusScale(): number;
  111329. /**
  111330. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111331. */
  111332. set positionScale(scale: number);
  111333. /**
  111334. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  111335. */
  111336. get positionScale(): number;
  111337. /**
  111338. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111339. * behaviour is triggered, in radians.
  111340. */
  111341. set defaultElevation(elevation: number);
  111342. /**
  111343. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  111344. * behaviour is triggered, in radians.
  111345. */
  111346. get defaultElevation(): number;
  111347. /**
  111348. * Sets the time (in milliseconds) taken to return to the default beta position.
  111349. * Negative value indicates camera should not return to default.
  111350. */
  111351. set elevationReturnTime(speed: number);
  111352. /**
  111353. * Gets the time (in milliseconds) taken to return to the default beta position.
  111354. * Negative value indicates camera should not return to default.
  111355. */
  111356. get elevationReturnTime(): number;
  111357. /**
  111358. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111359. */
  111360. set elevationReturnWaitTime(time: number);
  111361. /**
  111362. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  111363. */
  111364. get elevationReturnWaitTime(): number;
  111365. /**
  111366. * Sets the flag that indicates if user zooming should stop animation.
  111367. */
  111368. set zoomStopsAnimation(flag: boolean);
  111369. /**
  111370. * Gets the flag that indicates if user zooming should stop animation.
  111371. */
  111372. get zoomStopsAnimation(): boolean;
  111373. /**
  111374. * Sets the transition time when framing the mesh, in milliseconds
  111375. */
  111376. set framingTime(time: number);
  111377. /**
  111378. * Gets the transition time when framing the mesh, in milliseconds
  111379. */
  111380. get framingTime(): number;
  111381. /**
  111382. * Define if the behavior should automatically change the configured
  111383. * camera limits and sensibilities.
  111384. */
  111385. autoCorrectCameraLimitsAndSensibility: boolean;
  111386. private _onPrePointerObservableObserver;
  111387. private _onAfterCheckInputsObserver;
  111388. private _onMeshTargetChangedObserver;
  111389. private _attachedCamera;
  111390. private _isPointerDown;
  111391. private _lastInteractionTime;
  111392. /**
  111393. * Initializes the behavior.
  111394. */
  111395. init(): void;
  111396. /**
  111397. * Attaches the behavior to its arc rotate camera.
  111398. * @param camera Defines the camera to attach the behavior to
  111399. */
  111400. attach(camera: ArcRotateCamera): void;
  111401. /**
  111402. * Detaches the behavior from its current arc rotate camera.
  111403. */
  111404. detach(): void;
  111405. private _animatables;
  111406. private _betaIsAnimating;
  111407. private _betaTransition;
  111408. private _radiusTransition;
  111409. private _vectorTransition;
  111410. /**
  111411. * Targets the given mesh and updates zoom level accordingly.
  111412. * @param mesh The mesh to target.
  111413. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111414. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111415. */
  111416. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111417. /**
  111418. * Targets the given mesh with its children and updates zoom level accordingly.
  111419. * @param mesh The mesh to target.
  111420. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111421. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111422. */
  111423. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111424. /**
  111425. * Targets the given meshes with their children and updates zoom level accordingly.
  111426. * @param meshes The mesh to target.
  111427. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111428. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111429. */
  111430. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111431. /**
  111432. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  111433. * @param minimumWorld Determines the smaller position of the bounding box extend
  111434. * @param maximumWorld Determines the bigger position of the bounding box extend
  111435. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  111436. * @param onAnimationEnd Callback triggered at the end of the framing animation
  111437. */
  111438. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  111439. /**
  111440. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  111441. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  111442. * frustum width.
  111443. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  111444. * to fully enclose the mesh in the viewing frustum.
  111445. */
  111446. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  111447. /**
  111448. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  111449. * is automatically returned to its default position (expected to be above ground plane).
  111450. */
  111451. private _maintainCameraAboveGround;
  111452. /**
  111453. * Returns the frustum slope based on the canvas ratio and camera FOV
  111454. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  111455. */
  111456. private _getFrustumSlope;
  111457. /**
  111458. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  111459. */
  111460. private _clearAnimationLocks;
  111461. /**
  111462. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  111463. */
  111464. private _applyUserInteraction;
  111465. /**
  111466. * Stops and removes all animations that have been applied to the camera
  111467. */
  111468. stopAllAnimations(): void;
  111469. /**
  111470. * Gets a value indicating if the user is moving the camera
  111471. */
  111472. get isUserIsMoving(): boolean;
  111473. /**
  111474. * The camera can move all the way towards the mesh.
  111475. */
  111476. static IgnoreBoundsSizeMode: number;
  111477. /**
  111478. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  111479. */
  111480. static FitFrustumSidesMode: number;
  111481. }
  111482. }
  111483. declare module BABYLON {
  111484. /**
  111485. * Base class for Camera Pointer Inputs.
  111486. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  111487. * for example usage.
  111488. */
  111489. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  111490. /**
  111491. * Defines the camera the input is attached to.
  111492. */
  111493. abstract camera: Camera;
  111494. /**
  111495. * Whether keyboard modifier keys are pressed at time of last mouse event.
  111496. */
  111497. protected _altKey: boolean;
  111498. protected _ctrlKey: boolean;
  111499. protected _metaKey: boolean;
  111500. protected _shiftKey: boolean;
  111501. /**
  111502. * Which mouse buttons were pressed at time of last mouse event.
  111503. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  111504. */
  111505. protected _buttonsPressed: number;
  111506. /**
  111507. * Defines the buttons associated with the input to handle camera move.
  111508. */
  111509. buttons: number[];
  111510. /**
  111511. * Attach the input controls to a specific dom element to get the input from.
  111512. * @param element Defines the element the controls should be listened from
  111513. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111514. */
  111515. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111516. /**
  111517. * Detach the current controls from the specified dom element.
  111518. * @param element Defines the element to stop listening the inputs from
  111519. */
  111520. detachControl(element: Nullable<HTMLElement>): void;
  111521. /**
  111522. * Gets the class name of the current input.
  111523. * @returns the class name
  111524. */
  111525. getClassName(): string;
  111526. /**
  111527. * Get the friendly name associated with the input class.
  111528. * @returns the input friendly name
  111529. */
  111530. getSimpleName(): string;
  111531. /**
  111532. * Called on pointer POINTERDOUBLETAP event.
  111533. * Override this method to provide functionality on POINTERDOUBLETAP event.
  111534. */
  111535. protected onDoubleTap(type: string): void;
  111536. /**
  111537. * Called on pointer POINTERMOVE event if only a single touch is active.
  111538. * Override this method to provide functionality.
  111539. */
  111540. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111541. /**
  111542. * Called on pointer POINTERMOVE event if multiple touches are active.
  111543. * Override this method to provide functionality.
  111544. */
  111545. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111546. /**
  111547. * Called on JS contextmenu event.
  111548. * Override this method to provide functionality.
  111549. */
  111550. protected onContextMenu(evt: PointerEvent): void;
  111551. /**
  111552. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111553. * press.
  111554. * Override this method to provide functionality.
  111555. */
  111556. protected onButtonDown(evt: PointerEvent): void;
  111557. /**
  111558. * Called each time a new POINTERUP event occurs. Ie, for each button
  111559. * release.
  111560. * Override this method to provide functionality.
  111561. */
  111562. protected onButtonUp(evt: PointerEvent): void;
  111563. /**
  111564. * Called when window becomes inactive.
  111565. * Override this method to provide functionality.
  111566. */
  111567. protected onLostFocus(): void;
  111568. private _pointerInput;
  111569. private _observer;
  111570. private _onLostFocus;
  111571. private pointA;
  111572. private pointB;
  111573. }
  111574. }
  111575. declare module BABYLON {
  111576. /**
  111577. * Manage the pointers inputs to control an arc rotate camera.
  111578. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111579. */
  111580. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  111581. /**
  111582. * Defines the camera the input is attached to.
  111583. */
  111584. camera: ArcRotateCamera;
  111585. /**
  111586. * Gets the class name of the current input.
  111587. * @returns the class name
  111588. */
  111589. getClassName(): string;
  111590. /**
  111591. * Defines the buttons associated with the input to handle camera move.
  111592. */
  111593. buttons: number[];
  111594. /**
  111595. * Defines the pointer angular sensibility along the X axis or how fast is
  111596. * the camera rotating.
  111597. */
  111598. angularSensibilityX: number;
  111599. /**
  111600. * Defines the pointer angular sensibility along the Y axis or how fast is
  111601. * the camera rotating.
  111602. */
  111603. angularSensibilityY: number;
  111604. /**
  111605. * Defines the pointer pinch precision or how fast is the camera zooming.
  111606. */
  111607. pinchPrecision: number;
  111608. /**
  111609. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  111610. * from 0.
  111611. * It defines the percentage of current camera.radius to use as delta when
  111612. * pinch zoom is used.
  111613. */
  111614. pinchDeltaPercentage: number;
  111615. /**
  111616. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111617. * that any object in the plane at the camera's target point will scale
  111618. * perfectly with finger motion.
  111619. * Overrides pinchDeltaPercentage and pinchPrecision.
  111620. */
  111621. useNaturalPinchZoom: boolean;
  111622. /**
  111623. * Defines the pointer panning sensibility or how fast is the camera moving.
  111624. */
  111625. panningSensibility: number;
  111626. /**
  111627. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  111628. */
  111629. multiTouchPanning: boolean;
  111630. /**
  111631. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  111632. * zoom (pinch) through multitouch.
  111633. */
  111634. multiTouchPanAndZoom: boolean;
  111635. /**
  111636. * Revers pinch action direction.
  111637. */
  111638. pinchInwards: boolean;
  111639. private _isPanClick;
  111640. private _twoFingerActivityCount;
  111641. private _isPinching;
  111642. /**
  111643. * Called on pointer POINTERMOVE event if only a single touch is active.
  111644. */
  111645. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  111646. /**
  111647. * Called on pointer POINTERDOUBLETAP event.
  111648. */
  111649. protected onDoubleTap(type: string): void;
  111650. /**
  111651. * Called on pointer POINTERMOVE event if multiple touches are active.
  111652. */
  111653. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  111654. /**
  111655. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  111656. * press.
  111657. */
  111658. protected onButtonDown(evt: PointerEvent): void;
  111659. /**
  111660. * Called each time a new POINTERUP event occurs. Ie, for each button
  111661. * release.
  111662. */
  111663. protected onButtonUp(evt: PointerEvent): void;
  111664. /**
  111665. * Called when window becomes inactive.
  111666. */
  111667. protected onLostFocus(): void;
  111668. }
  111669. }
  111670. declare module BABYLON {
  111671. /**
  111672. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  111673. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111674. */
  111675. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  111676. /**
  111677. * Defines the camera the input is attached to.
  111678. */
  111679. camera: ArcRotateCamera;
  111680. /**
  111681. * Defines the list of key codes associated with the up action (increase alpha)
  111682. */
  111683. keysUp: number[];
  111684. /**
  111685. * Defines the list of key codes associated with the down action (decrease alpha)
  111686. */
  111687. keysDown: number[];
  111688. /**
  111689. * Defines the list of key codes associated with the left action (increase beta)
  111690. */
  111691. keysLeft: number[];
  111692. /**
  111693. * Defines the list of key codes associated with the right action (decrease beta)
  111694. */
  111695. keysRight: number[];
  111696. /**
  111697. * Defines the list of key codes associated with the reset action.
  111698. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  111699. */
  111700. keysReset: number[];
  111701. /**
  111702. * Defines the panning sensibility of the inputs.
  111703. * (How fast is the camera panning)
  111704. */
  111705. panningSensibility: number;
  111706. /**
  111707. * Defines the zooming sensibility of the inputs.
  111708. * (How fast is the camera zooming)
  111709. */
  111710. zoomingSensibility: number;
  111711. /**
  111712. * Defines whether maintaining the alt key down switch the movement mode from
  111713. * orientation to zoom.
  111714. */
  111715. useAltToZoom: boolean;
  111716. /**
  111717. * Rotation speed of the camera
  111718. */
  111719. angularSpeed: number;
  111720. private _keys;
  111721. private _ctrlPressed;
  111722. private _altPressed;
  111723. private _onCanvasBlurObserver;
  111724. private _onKeyboardObserver;
  111725. private _engine;
  111726. private _scene;
  111727. /**
  111728. * Attach the input controls to a specific dom element to get the input from.
  111729. * @param element Defines the element the controls should be listened from
  111730. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111731. */
  111732. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111733. /**
  111734. * Detach the current controls from the specified dom element.
  111735. * @param element Defines the element to stop listening the inputs from
  111736. */
  111737. detachControl(element: Nullable<HTMLElement>): void;
  111738. /**
  111739. * Update the current camera state depending on the inputs that have been used this frame.
  111740. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  111741. */
  111742. checkInputs(): void;
  111743. /**
  111744. * Gets the class name of the current intput.
  111745. * @returns the class name
  111746. */
  111747. getClassName(): string;
  111748. /**
  111749. * Get the friendly name associated with the input class.
  111750. * @returns the input friendly name
  111751. */
  111752. getSimpleName(): string;
  111753. }
  111754. }
  111755. declare module BABYLON {
  111756. /**
  111757. * Manage the mouse wheel inputs to control an arc rotate camera.
  111758. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111759. */
  111760. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  111761. /**
  111762. * Defines the camera the input is attached to.
  111763. */
  111764. camera: ArcRotateCamera;
  111765. /**
  111766. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  111767. */
  111768. wheelPrecision: number;
  111769. /**
  111770. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  111771. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  111772. */
  111773. wheelDeltaPercentage: number;
  111774. private _wheel;
  111775. private _observer;
  111776. private computeDeltaFromMouseWheelLegacyEvent;
  111777. /**
  111778. * Attach the input controls to a specific dom element to get the input from.
  111779. * @param element Defines the element the controls should be listened from
  111780. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  111781. */
  111782. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  111783. /**
  111784. * Detach the current controls from the specified dom element.
  111785. * @param element Defines the element to stop listening the inputs from
  111786. */
  111787. detachControl(element: Nullable<HTMLElement>): void;
  111788. /**
  111789. * Gets the class name of the current intput.
  111790. * @returns the class name
  111791. */
  111792. getClassName(): string;
  111793. /**
  111794. * Get the friendly name associated with the input class.
  111795. * @returns the input friendly name
  111796. */
  111797. getSimpleName(): string;
  111798. }
  111799. }
  111800. declare module BABYLON {
  111801. /**
  111802. * Default Inputs manager for the ArcRotateCamera.
  111803. * It groups all the default supported inputs for ease of use.
  111804. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  111805. */
  111806. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  111807. /**
  111808. * Instantiates a new ArcRotateCameraInputsManager.
  111809. * @param camera Defines the camera the inputs belong to
  111810. */
  111811. constructor(camera: ArcRotateCamera);
  111812. /**
  111813. * Add mouse wheel input support to the input manager.
  111814. * @returns the current input manager
  111815. */
  111816. addMouseWheel(): ArcRotateCameraInputsManager;
  111817. /**
  111818. * Add pointers input support to the input manager.
  111819. * @returns the current input manager
  111820. */
  111821. addPointers(): ArcRotateCameraInputsManager;
  111822. /**
  111823. * Add keyboard input support to the input manager.
  111824. * @returns the current input manager
  111825. */
  111826. addKeyboard(): ArcRotateCameraInputsManager;
  111827. }
  111828. }
  111829. declare module BABYLON {
  111830. /**
  111831. * This represents an orbital type of camera.
  111832. *
  111833. * 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.
  111834. * 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.
  111835. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  111836. */
  111837. export class ArcRotateCamera extends TargetCamera {
  111838. /**
  111839. * Defines the rotation angle of the camera along the longitudinal axis.
  111840. */
  111841. alpha: number;
  111842. /**
  111843. * Defines the rotation angle of the camera along the latitudinal axis.
  111844. */
  111845. beta: number;
  111846. /**
  111847. * Defines the radius of the camera from it s target point.
  111848. */
  111849. radius: number;
  111850. protected _target: Vector3;
  111851. protected _targetHost: Nullable<AbstractMesh>;
  111852. /**
  111853. * Defines the target point of the camera.
  111854. * The camera looks towards it form the radius distance.
  111855. */
  111856. get target(): Vector3;
  111857. set target(value: Vector3);
  111858. /**
  111859. * Define the current local position of the camera in the scene
  111860. */
  111861. get position(): Vector3;
  111862. set position(newPosition: Vector3);
  111863. protected _upVector: Vector3;
  111864. protected _upToYMatrix: Matrix;
  111865. protected _YToUpMatrix: Matrix;
  111866. /**
  111867. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  111868. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  111869. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  111870. */
  111871. set upVector(vec: Vector3);
  111872. get upVector(): Vector3;
  111873. /**
  111874. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  111875. */
  111876. setMatUp(): void;
  111877. /**
  111878. * Current inertia value on the longitudinal axis.
  111879. * The bigger this number the longer it will take for the camera to stop.
  111880. */
  111881. inertialAlphaOffset: number;
  111882. /**
  111883. * Current inertia value on the latitudinal axis.
  111884. * The bigger this number the longer it will take for the camera to stop.
  111885. */
  111886. inertialBetaOffset: number;
  111887. /**
  111888. * Current inertia value on the radius axis.
  111889. * The bigger this number the longer it will take for the camera to stop.
  111890. */
  111891. inertialRadiusOffset: number;
  111892. /**
  111893. * Minimum allowed angle on the longitudinal axis.
  111894. * This can help limiting how the Camera is able to move in the scene.
  111895. */
  111896. lowerAlphaLimit: Nullable<number>;
  111897. /**
  111898. * Maximum allowed angle on the longitudinal axis.
  111899. * This can help limiting how the Camera is able to move in the scene.
  111900. */
  111901. upperAlphaLimit: Nullable<number>;
  111902. /**
  111903. * Minimum allowed angle on the latitudinal axis.
  111904. * This can help limiting how the Camera is able to move in the scene.
  111905. */
  111906. lowerBetaLimit: number;
  111907. /**
  111908. * Maximum allowed angle on the latitudinal axis.
  111909. * This can help limiting how the Camera is able to move in the scene.
  111910. */
  111911. upperBetaLimit: number;
  111912. /**
  111913. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  111914. * This can help limiting how the Camera is able to move in the scene.
  111915. */
  111916. lowerRadiusLimit: Nullable<number>;
  111917. /**
  111918. * Maximum allowed distance of the camera to the target (The camera can not get further).
  111919. * This can help limiting how the Camera is able to move in the scene.
  111920. */
  111921. upperRadiusLimit: Nullable<number>;
  111922. /**
  111923. * Defines the current inertia value used during panning of the camera along the X axis.
  111924. */
  111925. inertialPanningX: number;
  111926. /**
  111927. * Defines the current inertia value used during panning of the camera along the Y axis.
  111928. */
  111929. inertialPanningY: number;
  111930. /**
  111931. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  111932. * Basically if your fingers moves away from more than this distance you will be considered
  111933. * in pinch mode.
  111934. */
  111935. pinchToPanMaxDistance: number;
  111936. /**
  111937. * Defines the maximum distance the camera can pan.
  111938. * This could help keeping the cammera always in your scene.
  111939. */
  111940. panningDistanceLimit: Nullable<number>;
  111941. /**
  111942. * Defines the target of the camera before paning.
  111943. */
  111944. panningOriginTarget: Vector3;
  111945. /**
  111946. * Defines the value of the inertia used during panning.
  111947. * 0 would mean stop inertia and one would mean no decelleration at all.
  111948. */
  111949. panningInertia: number;
  111950. /**
  111951. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  111952. */
  111953. get angularSensibilityX(): number;
  111954. set angularSensibilityX(value: number);
  111955. /**
  111956. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  111957. */
  111958. get angularSensibilityY(): number;
  111959. set angularSensibilityY(value: number);
  111960. /**
  111961. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  111962. */
  111963. get pinchPrecision(): number;
  111964. set pinchPrecision(value: number);
  111965. /**
  111966. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  111967. * It will be used instead of pinchDeltaPrecision if different from 0.
  111968. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  111969. */
  111970. get pinchDeltaPercentage(): number;
  111971. set pinchDeltaPercentage(value: number);
  111972. /**
  111973. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  111974. * and pinch delta percentage.
  111975. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  111976. * that any object in the plane at the camera's target point will scale
  111977. * perfectly with finger motion.
  111978. */
  111979. get useNaturalPinchZoom(): boolean;
  111980. set useNaturalPinchZoom(value: boolean);
  111981. /**
  111982. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  111983. */
  111984. get panningSensibility(): number;
  111985. set panningSensibility(value: number);
  111986. /**
  111987. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  111988. */
  111989. get keysUp(): number[];
  111990. set keysUp(value: number[]);
  111991. /**
  111992. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  111993. */
  111994. get keysDown(): number[];
  111995. set keysDown(value: number[]);
  111996. /**
  111997. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  111998. */
  111999. get keysLeft(): number[];
  112000. set keysLeft(value: number[]);
  112001. /**
  112002. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  112003. */
  112004. get keysRight(): number[];
  112005. set keysRight(value: number[]);
  112006. /**
  112007. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  112008. */
  112009. get wheelPrecision(): number;
  112010. set wheelPrecision(value: number);
  112011. /**
  112012. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  112013. * It will be used instead of pinchDeltaPrecision if different from 0.
  112014. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  112015. */
  112016. get wheelDeltaPercentage(): number;
  112017. set wheelDeltaPercentage(value: number);
  112018. /**
  112019. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  112020. */
  112021. zoomOnFactor: number;
  112022. /**
  112023. * Defines a screen offset for the camera position.
  112024. */
  112025. targetScreenOffset: Vector2;
  112026. /**
  112027. * Allows the camera to be completely reversed.
  112028. * If false the camera can not arrive upside down.
  112029. */
  112030. allowUpsideDown: boolean;
  112031. /**
  112032. * Define if double tap/click is used to restore the previously saved state of the camera.
  112033. */
  112034. useInputToRestoreState: boolean;
  112035. /** @hidden */
  112036. _viewMatrix: Matrix;
  112037. /** @hidden */
  112038. _useCtrlForPanning: boolean;
  112039. /** @hidden */
  112040. _panningMouseButton: number;
  112041. /**
  112042. * Defines the input associated to the camera.
  112043. */
  112044. inputs: ArcRotateCameraInputsManager;
  112045. /** @hidden */
  112046. _reset: () => void;
  112047. /**
  112048. * Defines the allowed panning axis.
  112049. */
  112050. panningAxis: Vector3;
  112051. protected _localDirection: Vector3;
  112052. protected _transformedDirection: Vector3;
  112053. private _bouncingBehavior;
  112054. /**
  112055. * Gets the bouncing behavior of the camera if it has been enabled.
  112056. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112057. */
  112058. get bouncingBehavior(): Nullable<BouncingBehavior>;
  112059. /**
  112060. * Defines if the bouncing behavior of the camera is enabled on the camera.
  112061. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112062. */
  112063. get useBouncingBehavior(): boolean;
  112064. set useBouncingBehavior(value: boolean);
  112065. private _framingBehavior;
  112066. /**
  112067. * Gets the framing behavior of the camera if it has been enabled.
  112068. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112069. */
  112070. get framingBehavior(): Nullable<FramingBehavior>;
  112071. /**
  112072. * Defines if the framing behavior of the camera is enabled on the camera.
  112073. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112074. */
  112075. get useFramingBehavior(): boolean;
  112076. set useFramingBehavior(value: boolean);
  112077. private _autoRotationBehavior;
  112078. /**
  112079. * Gets the auto rotation behavior of the camera if it has been enabled.
  112080. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112081. */
  112082. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  112083. /**
  112084. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  112085. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112086. */
  112087. get useAutoRotationBehavior(): boolean;
  112088. set useAutoRotationBehavior(value: boolean);
  112089. /**
  112090. * Observable triggered when the mesh target has been changed on the camera.
  112091. */
  112092. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  112093. /**
  112094. * Event raised when the camera is colliding with a mesh.
  112095. */
  112096. onCollide: (collidedMesh: AbstractMesh) => void;
  112097. /**
  112098. * Defines whether the camera should check collision with the objects oh the scene.
  112099. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  112100. */
  112101. checkCollisions: boolean;
  112102. /**
  112103. * Defines the collision radius of the camera.
  112104. * This simulates a sphere around the camera.
  112105. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  112106. */
  112107. collisionRadius: Vector3;
  112108. protected _collider: Collider;
  112109. protected _previousPosition: Vector3;
  112110. protected _collisionVelocity: Vector3;
  112111. protected _newPosition: Vector3;
  112112. protected _previousAlpha: number;
  112113. protected _previousBeta: number;
  112114. protected _previousRadius: number;
  112115. protected _collisionTriggered: boolean;
  112116. protected _targetBoundingCenter: Nullable<Vector3>;
  112117. private _computationVector;
  112118. /**
  112119. * Instantiates a new ArcRotateCamera in a given scene
  112120. * @param name Defines the name of the camera
  112121. * @param alpha Defines the camera rotation along the logitudinal axis
  112122. * @param beta Defines the camera rotation along the latitudinal axis
  112123. * @param radius Defines the camera distance from its target
  112124. * @param target Defines the camera target
  112125. * @param scene Defines the scene the camera belongs to
  112126. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  112127. */
  112128. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  112129. /** @hidden */
  112130. _initCache(): void;
  112131. /** @hidden */
  112132. _updateCache(ignoreParentClass?: boolean): void;
  112133. protected _getTargetPosition(): Vector3;
  112134. private _storedAlpha;
  112135. private _storedBeta;
  112136. private _storedRadius;
  112137. private _storedTarget;
  112138. private _storedTargetScreenOffset;
  112139. /**
  112140. * Stores the current state of the camera (alpha, beta, radius and target)
  112141. * @returns the camera itself
  112142. */
  112143. storeState(): Camera;
  112144. /**
  112145. * @hidden
  112146. * Restored camera state. You must call storeState() first
  112147. */
  112148. _restoreStateValues(): boolean;
  112149. /** @hidden */
  112150. _isSynchronizedViewMatrix(): boolean;
  112151. /**
  112152. * Attached controls to the current camera.
  112153. * @param element Defines the element the controls should be listened from
  112154. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112155. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  112156. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  112157. */
  112158. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  112159. /**
  112160. * Detach the current controls from the camera.
  112161. * The camera will stop reacting to inputs.
  112162. * @param element Defines the element to stop listening the inputs from
  112163. */
  112164. detachControl(element: HTMLElement): void;
  112165. /** @hidden */
  112166. _checkInputs(): void;
  112167. protected _checkLimits(): void;
  112168. /**
  112169. * Rebuilds angles (alpha, beta) and radius from the give position and target
  112170. */
  112171. rebuildAnglesAndRadius(): void;
  112172. /**
  112173. * Use a position to define the current camera related information like alpha, beta and radius
  112174. * @param position Defines the position to set the camera at
  112175. */
  112176. setPosition(position: Vector3): void;
  112177. /**
  112178. * Defines the target the camera should look at.
  112179. * This will automatically adapt alpha beta and radius to fit within the new target.
  112180. * @param target Defines the new target as a Vector or a mesh
  112181. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  112182. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  112183. */
  112184. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  112185. /** @hidden */
  112186. _getViewMatrix(): Matrix;
  112187. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  112188. /**
  112189. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  112190. * @param meshes Defines the mesh to zoom on
  112191. * @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)
  112192. */
  112193. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  112194. /**
  112195. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  112196. * The target will be changed but the radius
  112197. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  112198. * @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)
  112199. */
  112200. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  112201. min: Vector3;
  112202. max: Vector3;
  112203. distance: number;
  112204. }, doNotUpdateMaxZ?: boolean): void;
  112205. /**
  112206. * @override
  112207. * Override Camera.createRigCamera
  112208. */
  112209. createRigCamera(name: string, cameraIndex: number): Camera;
  112210. /**
  112211. * @hidden
  112212. * @override
  112213. * Override Camera._updateRigCameras
  112214. */
  112215. _updateRigCameras(): void;
  112216. /**
  112217. * Destroy the camera and release the current resources hold by it.
  112218. */
  112219. dispose(): void;
  112220. /**
  112221. * Gets the current object class name.
  112222. * @return the class name
  112223. */
  112224. getClassName(): string;
  112225. }
  112226. }
  112227. declare module BABYLON {
  112228. /**
  112229. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  112230. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  112231. */
  112232. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  112233. /**
  112234. * Gets the name of the behavior.
  112235. */
  112236. get name(): string;
  112237. private _zoomStopsAnimation;
  112238. private _idleRotationSpeed;
  112239. private _idleRotationWaitTime;
  112240. private _idleRotationSpinupTime;
  112241. /**
  112242. * Sets the flag that indicates if user zooming should stop animation.
  112243. */
  112244. set zoomStopsAnimation(flag: boolean);
  112245. /**
  112246. * Gets the flag that indicates if user zooming should stop animation.
  112247. */
  112248. get zoomStopsAnimation(): boolean;
  112249. /**
  112250. * Sets the default speed at which the camera rotates around the model.
  112251. */
  112252. set idleRotationSpeed(speed: number);
  112253. /**
  112254. * Gets the default speed at which the camera rotates around the model.
  112255. */
  112256. get idleRotationSpeed(): number;
  112257. /**
  112258. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  112259. */
  112260. set idleRotationWaitTime(time: number);
  112261. /**
  112262. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  112263. */
  112264. get idleRotationWaitTime(): number;
  112265. /**
  112266. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112267. */
  112268. set idleRotationSpinupTime(time: number);
  112269. /**
  112270. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  112271. */
  112272. get idleRotationSpinupTime(): number;
  112273. /**
  112274. * Gets a value indicating if the camera is currently rotating because of this behavior
  112275. */
  112276. get rotationInProgress(): boolean;
  112277. private _onPrePointerObservableObserver;
  112278. private _onAfterCheckInputsObserver;
  112279. private _attachedCamera;
  112280. private _isPointerDown;
  112281. private _lastFrameTime;
  112282. private _lastInteractionTime;
  112283. private _cameraRotationSpeed;
  112284. /**
  112285. * Initializes the behavior.
  112286. */
  112287. init(): void;
  112288. /**
  112289. * Attaches the behavior to its arc rotate camera.
  112290. * @param camera Defines the camera to attach the behavior to
  112291. */
  112292. attach(camera: ArcRotateCamera): void;
  112293. /**
  112294. * Detaches the behavior from its current arc rotate camera.
  112295. */
  112296. detach(): void;
  112297. /**
  112298. * Returns true if user is scrolling.
  112299. * @return true if user is scrolling.
  112300. */
  112301. private _userIsZooming;
  112302. private _lastFrameRadius;
  112303. private _shouldAnimationStopForInteraction;
  112304. /**
  112305. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112306. */
  112307. private _applyUserInteraction;
  112308. private _userIsMoving;
  112309. }
  112310. }
  112311. declare module BABYLON {
  112312. /**
  112313. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  112314. */
  112315. export class AttachToBoxBehavior implements Behavior<Mesh> {
  112316. private ui;
  112317. /**
  112318. * The name of the behavior
  112319. */
  112320. name: string;
  112321. /**
  112322. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  112323. */
  112324. distanceAwayFromFace: number;
  112325. /**
  112326. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  112327. */
  112328. distanceAwayFromBottomOfFace: number;
  112329. private _faceVectors;
  112330. private _target;
  112331. private _scene;
  112332. private _onRenderObserver;
  112333. private _tmpMatrix;
  112334. private _tmpVector;
  112335. /**
  112336. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  112337. * @param ui The transform node that should be attched to the mesh
  112338. */
  112339. constructor(ui: TransformNode);
  112340. /**
  112341. * Initializes the behavior
  112342. */
  112343. init(): void;
  112344. private _closestFace;
  112345. private _zeroVector;
  112346. private _lookAtTmpMatrix;
  112347. private _lookAtToRef;
  112348. /**
  112349. * Attaches the AttachToBoxBehavior to the passed in mesh
  112350. * @param target The mesh that the specified node will be attached to
  112351. */
  112352. attach(target: Mesh): void;
  112353. /**
  112354. * Detaches the behavior from the mesh
  112355. */
  112356. detach(): void;
  112357. }
  112358. }
  112359. declare module BABYLON {
  112360. /**
  112361. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  112362. */
  112363. export class FadeInOutBehavior implements Behavior<Mesh> {
  112364. /**
  112365. * Time in milliseconds to delay before fading in (Default: 0)
  112366. */
  112367. delay: number;
  112368. /**
  112369. * Time in milliseconds for the mesh to fade in (Default: 300)
  112370. */
  112371. fadeInTime: number;
  112372. private _millisecondsPerFrame;
  112373. private _hovered;
  112374. private _hoverValue;
  112375. private _ownerNode;
  112376. /**
  112377. * Instatiates the FadeInOutBehavior
  112378. */
  112379. constructor();
  112380. /**
  112381. * The name of the behavior
  112382. */
  112383. get name(): string;
  112384. /**
  112385. * Initializes the behavior
  112386. */
  112387. init(): void;
  112388. /**
  112389. * Attaches the fade behavior on the passed in mesh
  112390. * @param ownerNode The mesh that will be faded in/out once attached
  112391. */
  112392. attach(ownerNode: Mesh): void;
  112393. /**
  112394. * Detaches the behavior from the mesh
  112395. */
  112396. detach(): void;
  112397. /**
  112398. * Triggers the mesh to begin fading in or out
  112399. * @param value if the object should fade in or out (true to fade in)
  112400. */
  112401. fadeIn(value: boolean): void;
  112402. private _update;
  112403. private _setAllVisibility;
  112404. }
  112405. }
  112406. declare module BABYLON {
  112407. /**
  112408. * Class containing a set of static utilities functions for managing Pivots
  112409. * @hidden
  112410. */
  112411. export class PivotTools {
  112412. private static _PivotCached;
  112413. private static _OldPivotPoint;
  112414. private static _PivotTranslation;
  112415. private static _PivotTmpVector;
  112416. /** @hidden */
  112417. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  112418. /** @hidden */
  112419. static _RestorePivotPoint(mesh: AbstractMesh): void;
  112420. }
  112421. }
  112422. declare module BABYLON {
  112423. /**
  112424. * Class containing static functions to help procedurally build meshes
  112425. */
  112426. export class PlaneBuilder {
  112427. /**
  112428. * Creates a plane mesh
  112429. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  112430. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  112431. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  112432. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  112433. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  112434. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  112435. * @param name defines the name of the mesh
  112436. * @param options defines the options used to create the mesh
  112437. * @param scene defines the hosting scene
  112438. * @returns the plane mesh
  112439. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  112440. */
  112441. static CreatePlane(name: string, options: {
  112442. size?: number;
  112443. width?: number;
  112444. height?: number;
  112445. sideOrientation?: number;
  112446. frontUVs?: Vector4;
  112447. backUVs?: Vector4;
  112448. updatable?: boolean;
  112449. sourcePlane?: Plane;
  112450. }, scene?: Nullable<Scene>): Mesh;
  112451. }
  112452. }
  112453. declare module BABYLON {
  112454. /**
  112455. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  112456. */
  112457. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  112458. private static _AnyMouseID;
  112459. /**
  112460. * Abstract mesh the behavior is set on
  112461. */
  112462. attachedNode: AbstractMesh;
  112463. private _dragPlane;
  112464. private _scene;
  112465. private _pointerObserver;
  112466. private _beforeRenderObserver;
  112467. private static _planeScene;
  112468. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  112469. /**
  112470. * 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)
  112471. */
  112472. maxDragAngle: number;
  112473. /**
  112474. * @hidden
  112475. */
  112476. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  112477. /**
  112478. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112479. */
  112480. currentDraggingPointerID: number;
  112481. /**
  112482. * The last position where the pointer hit the drag plane in world space
  112483. */
  112484. lastDragPosition: Vector3;
  112485. /**
  112486. * If the behavior is currently in a dragging state
  112487. */
  112488. dragging: boolean;
  112489. /**
  112490. * 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)
  112491. */
  112492. dragDeltaRatio: number;
  112493. /**
  112494. * If the drag plane orientation should be updated during the dragging (Default: true)
  112495. */
  112496. updateDragPlane: boolean;
  112497. private _debugMode;
  112498. private _moving;
  112499. /**
  112500. * Fires each time the attached mesh is dragged with the pointer
  112501. * * delta between last drag position and current drag position in world space
  112502. * * dragDistance along the drag axis
  112503. * * dragPlaneNormal normal of the current drag plane used during the drag
  112504. * * dragPlanePoint in world space where the drag intersects the drag plane
  112505. */
  112506. onDragObservable: Observable<{
  112507. delta: Vector3;
  112508. dragPlanePoint: Vector3;
  112509. dragPlaneNormal: Vector3;
  112510. dragDistance: number;
  112511. pointerId: number;
  112512. }>;
  112513. /**
  112514. * Fires each time a drag begins (eg. mouse down on mesh)
  112515. */
  112516. onDragStartObservable: Observable<{
  112517. dragPlanePoint: Vector3;
  112518. pointerId: number;
  112519. }>;
  112520. /**
  112521. * Fires each time a drag ends (eg. mouse release after drag)
  112522. */
  112523. onDragEndObservable: Observable<{
  112524. dragPlanePoint: Vector3;
  112525. pointerId: number;
  112526. }>;
  112527. /**
  112528. * If the attached mesh should be moved when dragged
  112529. */
  112530. moveAttached: boolean;
  112531. /**
  112532. * If the drag behavior will react to drag events (Default: true)
  112533. */
  112534. enabled: boolean;
  112535. /**
  112536. * If pointer events should start and release the drag (Default: true)
  112537. */
  112538. startAndReleaseDragOnPointerEvents: boolean;
  112539. /**
  112540. * If camera controls should be detached during the drag
  112541. */
  112542. detachCameraControls: boolean;
  112543. /**
  112544. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  112545. */
  112546. useObjectOrientationForDragging: boolean;
  112547. private _options;
  112548. /**
  112549. * Gets the options used by the behavior
  112550. */
  112551. get options(): {
  112552. dragAxis?: Vector3;
  112553. dragPlaneNormal?: Vector3;
  112554. };
  112555. /**
  112556. * Sets the options used by the behavior
  112557. */
  112558. set options(options: {
  112559. dragAxis?: Vector3;
  112560. dragPlaneNormal?: Vector3;
  112561. });
  112562. /**
  112563. * Creates a pointer drag behavior that can be attached to a mesh
  112564. * @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)
  112565. */
  112566. constructor(options?: {
  112567. dragAxis?: Vector3;
  112568. dragPlaneNormal?: Vector3;
  112569. });
  112570. /**
  112571. * Predicate to determine if it is valid to move the object to a new position when it is moved
  112572. */
  112573. validateDrag: (targetPosition: Vector3) => boolean;
  112574. /**
  112575. * The name of the behavior
  112576. */
  112577. get name(): string;
  112578. /**
  112579. * Initializes the behavior
  112580. */
  112581. init(): void;
  112582. private _tmpVector;
  112583. private _alternatePickedPoint;
  112584. private _worldDragAxis;
  112585. private _targetPosition;
  112586. private _attachedElement;
  112587. /**
  112588. * Attaches the drag behavior the passed in mesh
  112589. * @param ownerNode The mesh that will be dragged around once attached
  112590. * @param predicate Predicate to use for pick filtering
  112591. */
  112592. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  112593. /**
  112594. * Force relase the drag action by code.
  112595. */
  112596. releaseDrag(): void;
  112597. private _startDragRay;
  112598. private _lastPointerRay;
  112599. /**
  112600. * Simulates the start of a pointer drag event on the behavior
  112601. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  112602. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  112603. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  112604. */
  112605. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  112606. private _startDrag;
  112607. private _dragDelta;
  112608. private _moveDrag;
  112609. private _pickWithRayOnDragPlane;
  112610. private _pointA;
  112611. private _pointB;
  112612. private _pointC;
  112613. private _lineA;
  112614. private _lineB;
  112615. private _localAxis;
  112616. private _lookAt;
  112617. private _updateDragPlanePosition;
  112618. /**
  112619. * Detaches the behavior from the mesh
  112620. */
  112621. detach(): void;
  112622. }
  112623. }
  112624. declare module BABYLON {
  112625. /**
  112626. * A behavior that when attached to a mesh will allow the mesh to be scaled
  112627. */
  112628. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  112629. private _dragBehaviorA;
  112630. private _dragBehaviorB;
  112631. private _startDistance;
  112632. private _initialScale;
  112633. private _targetScale;
  112634. private _ownerNode;
  112635. private _sceneRenderObserver;
  112636. /**
  112637. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  112638. */
  112639. constructor();
  112640. /**
  112641. * The name of the behavior
  112642. */
  112643. get name(): string;
  112644. /**
  112645. * Initializes the behavior
  112646. */
  112647. init(): void;
  112648. private _getCurrentDistance;
  112649. /**
  112650. * Attaches the scale behavior the passed in mesh
  112651. * @param ownerNode The mesh that will be scaled around once attached
  112652. */
  112653. attach(ownerNode: Mesh): void;
  112654. /**
  112655. * Detaches the behavior from the mesh
  112656. */
  112657. detach(): void;
  112658. }
  112659. }
  112660. declare module BABYLON {
  112661. /**
  112662. * 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
  112663. */
  112664. export class SixDofDragBehavior implements Behavior<Mesh> {
  112665. private static _virtualScene;
  112666. private _ownerNode;
  112667. private _sceneRenderObserver;
  112668. private _scene;
  112669. private _targetPosition;
  112670. private _virtualOriginMesh;
  112671. private _virtualDragMesh;
  112672. private _pointerObserver;
  112673. private _moving;
  112674. private _startingOrientation;
  112675. /**
  112676. * 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)
  112677. */
  112678. private zDragFactor;
  112679. /**
  112680. * If the object should rotate to face the drag origin
  112681. */
  112682. rotateDraggedObject: boolean;
  112683. /**
  112684. * If the behavior is currently in a dragging state
  112685. */
  112686. dragging: boolean;
  112687. /**
  112688. * 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)
  112689. */
  112690. dragDeltaRatio: number;
  112691. /**
  112692. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  112693. */
  112694. currentDraggingPointerID: number;
  112695. /**
  112696. * If camera controls should be detached during the drag
  112697. */
  112698. detachCameraControls: boolean;
  112699. /**
  112700. * Fires each time a drag starts
  112701. */
  112702. onDragStartObservable: Observable<{}>;
  112703. /**
  112704. * Fires each time a drag ends (eg. mouse release after drag)
  112705. */
  112706. onDragEndObservable: Observable<{}>;
  112707. /**
  112708. * 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
  112709. */
  112710. constructor();
  112711. /**
  112712. * The name of the behavior
  112713. */
  112714. get name(): string;
  112715. /**
  112716. * Initializes the behavior
  112717. */
  112718. init(): void;
  112719. /**
  112720. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  112721. */
  112722. private get _pointerCamera();
  112723. /**
  112724. * Attaches the scale behavior the passed in mesh
  112725. * @param ownerNode The mesh that will be scaled around once attached
  112726. */
  112727. attach(ownerNode: Mesh): void;
  112728. /**
  112729. * Detaches the behavior from the mesh
  112730. */
  112731. detach(): void;
  112732. }
  112733. }
  112734. declare module BABYLON {
  112735. /**
  112736. * Class used to apply inverse kinematics to bones
  112737. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  112738. */
  112739. export class BoneIKController {
  112740. private static _tmpVecs;
  112741. private static _tmpQuat;
  112742. private static _tmpMats;
  112743. /**
  112744. * Gets or sets the target mesh
  112745. */
  112746. targetMesh: AbstractMesh;
  112747. /** Gets or sets the mesh used as pole */
  112748. poleTargetMesh: AbstractMesh;
  112749. /**
  112750. * Gets or sets the bone used as pole
  112751. */
  112752. poleTargetBone: Nullable<Bone>;
  112753. /**
  112754. * Gets or sets the target position
  112755. */
  112756. targetPosition: Vector3;
  112757. /**
  112758. * Gets or sets the pole target position
  112759. */
  112760. poleTargetPosition: Vector3;
  112761. /**
  112762. * Gets or sets the pole target local offset
  112763. */
  112764. poleTargetLocalOffset: Vector3;
  112765. /**
  112766. * Gets or sets the pole angle
  112767. */
  112768. poleAngle: number;
  112769. /**
  112770. * Gets or sets the mesh associated with the controller
  112771. */
  112772. mesh: AbstractMesh;
  112773. /**
  112774. * 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)
  112775. */
  112776. slerpAmount: number;
  112777. private _bone1Quat;
  112778. private _bone1Mat;
  112779. private _bone2Ang;
  112780. private _bone1;
  112781. private _bone2;
  112782. private _bone1Length;
  112783. private _bone2Length;
  112784. private _maxAngle;
  112785. private _maxReach;
  112786. private _rightHandedSystem;
  112787. private _bendAxis;
  112788. private _slerping;
  112789. private _adjustRoll;
  112790. /**
  112791. * Gets or sets maximum allowed angle
  112792. */
  112793. get maxAngle(): number;
  112794. set maxAngle(value: number);
  112795. /**
  112796. * Creates a new BoneIKController
  112797. * @param mesh defines the mesh to control
  112798. * @param bone defines the bone to control
  112799. * @param options defines options to set up the controller
  112800. */
  112801. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  112802. targetMesh?: AbstractMesh;
  112803. poleTargetMesh?: AbstractMesh;
  112804. poleTargetBone?: Bone;
  112805. poleTargetLocalOffset?: Vector3;
  112806. poleAngle?: number;
  112807. bendAxis?: Vector3;
  112808. maxAngle?: number;
  112809. slerpAmount?: number;
  112810. });
  112811. private _setMaxAngle;
  112812. /**
  112813. * Force the controller to update the bones
  112814. */
  112815. update(): void;
  112816. }
  112817. }
  112818. declare module BABYLON {
  112819. /**
  112820. * Class used to make a bone look toward a point in space
  112821. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  112822. */
  112823. export class BoneLookController {
  112824. private static _tmpVecs;
  112825. private static _tmpQuat;
  112826. private static _tmpMats;
  112827. /**
  112828. * The target Vector3 that the bone will look at
  112829. */
  112830. target: Vector3;
  112831. /**
  112832. * The mesh that the bone is attached to
  112833. */
  112834. mesh: AbstractMesh;
  112835. /**
  112836. * The bone that will be looking to the target
  112837. */
  112838. bone: Bone;
  112839. /**
  112840. * The up axis of the coordinate system that is used when the bone is rotated
  112841. */
  112842. upAxis: Vector3;
  112843. /**
  112844. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  112845. */
  112846. upAxisSpace: Space;
  112847. /**
  112848. * Used to make an adjustment to the yaw of the bone
  112849. */
  112850. adjustYaw: number;
  112851. /**
  112852. * Used to make an adjustment to the pitch of the bone
  112853. */
  112854. adjustPitch: number;
  112855. /**
  112856. * Used to make an adjustment to the roll of the bone
  112857. */
  112858. adjustRoll: number;
  112859. /**
  112860. * 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)
  112861. */
  112862. slerpAmount: number;
  112863. private _minYaw;
  112864. private _maxYaw;
  112865. private _minPitch;
  112866. private _maxPitch;
  112867. private _minYawSin;
  112868. private _minYawCos;
  112869. private _maxYawSin;
  112870. private _maxYawCos;
  112871. private _midYawConstraint;
  112872. private _minPitchTan;
  112873. private _maxPitchTan;
  112874. private _boneQuat;
  112875. private _slerping;
  112876. private _transformYawPitch;
  112877. private _transformYawPitchInv;
  112878. private _firstFrameSkipped;
  112879. private _yawRange;
  112880. private _fowardAxis;
  112881. /**
  112882. * Gets or sets the minimum yaw angle that the bone can look to
  112883. */
  112884. get minYaw(): number;
  112885. set minYaw(value: number);
  112886. /**
  112887. * Gets or sets the maximum yaw angle that the bone can look to
  112888. */
  112889. get maxYaw(): number;
  112890. set maxYaw(value: number);
  112891. /**
  112892. * Gets or sets the minimum pitch angle that the bone can look to
  112893. */
  112894. get minPitch(): number;
  112895. set minPitch(value: number);
  112896. /**
  112897. * Gets or sets the maximum pitch angle that the bone can look to
  112898. */
  112899. get maxPitch(): number;
  112900. set maxPitch(value: number);
  112901. /**
  112902. * Create a BoneLookController
  112903. * @param mesh the mesh that the bone belongs to
  112904. * @param bone the bone that will be looking to the target
  112905. * @param target the target Vector3 to look at
  112906. * @param options optional settings:
  112907. * * maxYaw: the maximum angle the bone will yaw to
  112908. * * minYaw: the minimum angle the bone will yaw to
  112909. * * maxPitch: the maximum angle the bone will pitch to
  112910. * * minPitch: the minimum angle the bone will yaw to
  112911. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  112912. * * upAxis: the up axis of the coordinate system
  112913. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  112914. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  112915. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  112916. * * adjustYaw: used to make an adjustment to the yaw of the bone
  112917. * * adjustPitch: used to make an adjustment to the pitch of the bone
  112918. * * adjustRoll: used to make an adjustment to the roll of the bone
  112919. **/
  112920. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  112921. maxYaw?: number;
  112922. minYaw?: number;
  112923. maxPitch?: number;
  112924. minPitch?: number;
  112925. slerpAmount?: number;
  112926. upAxis?: Vector3;
  112927. upAxisSpace?: Space;
  112928. yawAxis?: Vector3;
  112929. pitchAxis?: Vector3;
  112930. adjustYaw?: number;
  112931. adjustPitch?: number;
  112932. adjustRoll?: number;
  112933. });
  112934. /**
  112935. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  112936. */
  112937. update(): void;
  112938. private _getAngleDiff;
  112939. private _getAngleBetween;
  112940. private _isAngleBetween;
  112941. }
  112942. }
  112943. declare module BABYLON {
  112944. /**
  112945. * Manage the gamepad inputs to control an arc rotate camera.
  112946. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112947. */
  112948. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  112949. /**
  112950. * Defines the camera the input is attached to.
  112951. */
  112952. camera: ArcRotateCamera;
  112953. /**
  112954. * Defines the gamepad the input is gathering event from.
  112955. */
  112956. gamepad: Nullable<Gamepad>;
  112957. /**
  112958. * Defines the gamepad rotation sensiblity.
  112959. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  112960. */
  112961. gamepadRotationSensibility: number;
  112962. /**
  112963. * Defines the gamepad move sensiblity.
  112964. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  112965. */
  112966. gamepadMoveSensibility: number;
  112967. private _yAxisScale;
  112968. /**
  112969. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  112970. */
  112971. get invertYAxis(): boolean;
  112972. set invertYAxis(value: boolean);
  112973. private _onGamepadConnectedObserver;
  112974. private _onGamepadDisconnectedObserver;
  112975. /**
  112976. * Attach the input controls to a specific dom element to get the input from.
  112977. * @param element Defines the element the controls should be listened from
  112978. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112979. */
  112980. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112981. /**
  112982. * Detach the current controls from the specified dom element.
  112983. * @param element Defines the element to stop listening the inputs from
  112984. */
  112985. detachControl(element: Nullable<HTMLElement>): void;
  112986. /**
  112987. * Update the current camera state depending on the inputs that have been used this frame.
  112988. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  112989. */
  112990. checkInputs(): void;
  112991. /**
  112992. * Gets the class name of the current intput.
  112993. * @returns the class name
  112994. */
  112995. getClassName(): string;
  112996. /**
  112997. * Get the friendly name associated with the input class.
  112998. * @returns the input friendly name
  112999. */
  113000. getSimpleName(): string;
  113001. }
  113002. }
  113003. declare module BABYLON {
  113004. interface ArcRotateCameraInputsManager {
  113005. /**
  113006. * Add orientation input support to the input manager.
  113007. * @returns the current input manager
  113008. */
  113009. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  113010. }
  113011. /**
  113012. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  113013. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113014. */
  113015. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  113016. /**
  113017. * Defines the camera the input is attached to.
  113018. */
  113019. camera: ArcRotateCamera;
  113020. /**
  113021. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  113022. */
  113023. alphaCorrection: number;
  113024. /**
  113025. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  113026. */
  113027. gammaCorrection: number;
  113028. private _alpha;
  113029. private _gamma;
  113030. private _dirty;
  113031. private _deviceOrientationHandler;
  113032. /**
  113033. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  113034. */
  113035. constructor();
  113036. /**
  113037. * Attach the input controls to a specific dom element to get the input from.
  113038. * @param element Defines the element the controls should be listened from
  113039. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113040. */
  113041. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113042. /** @hidden */
  113043. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  113044. /**
  113045. * Update the current camera state depending on the inputs that have been used this frame.
  113046. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113047. */
  113048. checkInputs(): void;
  113049. /**
  113050. * Detach the current controls from the specified dom element.
  113051. * @param element Defines the element to stop listening the inputs from
  113052. */
  113053. detachControl(element: Nullable<HTMLElement>): void;
  113054. /**
  113055. * Gets the class name of the current intput.
  113056. * @returns the class name
  113057. */
  113058. getClassName(): string;
  113059. /**
  113060. * Get the friendly name associated with the input class.
  113061. * @returns the input friendly name
  113062. */
  113063. getSimpleName(): string;
  113064. }
  113065. }
  113066. declare module BABYLON {
  113067. /**
  113068. * Listen to mouse events to control the camera.
  113069. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113070. */
  113071. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  113072. /**
  113073. * Defines the camera the input is attached to.
  113074. */
  113075. camera: FlyCamera;
  113076. /**
  113077. * Defines if touch is enabled. (Default is true.)
  113078. */
  113079. touchEnabled: boolean;
  113080. /**
  113081. * Defines the buttons associated with the input to handle camera rotation.
  113082. */
  113083. buttons: number[];
  113084. /**
  113085. * Assign buttons for Yaw control.
  113086. */
  113087. buttonsYaw: number[];
  113088. /**
  113089. * Assign buttons for Pitch control.
  113090. */
  113091. buttonsPitch: number[];
  113092. /**
  113093. * Assign buttons for Roll control.
  113094. */
  113095. buttonsRoll: number[];
  113096. /**
  113097. * Detect if any button is being pressed while mouse is moved.
  113098. * -1 = Mouse locked.
  113099. * 0 = Left button.
  113100. * 1 = Middle Button.
  113101. * 2 = Right Button.
  113102. */
  113103. activeButton: number;
  113104. /**
  113105. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  113106. * Higher values reduce its sensitivity.
  113107. */
  113108. angularSensibility: number;
  113109. private _mousemoveCallback;
  113110. private _observer;
  113111. private _rollObserver;
  113112. private previousPosition;
  113113. private noPreventDefault;
  113114. private element;
  113115. /**
  113116. * Listen to mouse events to control the camera.
  113117. * @param touchEnabled Define if touch is enabled. (Default is true.)
  113118. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113119. */
  113120. constructor(touchEnabled?: boolean);
  113121. /**
  113122. * Attach the mouse control to the HTML DOM element.
  113123. * @param element Defines the element that listens to the input events.
  113124. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  113125. */
  113126. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113127. /**
  113128. * Detach the current controls from the specified dom element.
  113129. * @param element Defines the element to stop listening the inputs from
  113130. */
  113131. detachControl(element: Nullable<HTMLElement>): void;
  113132. /**
  113133. * Gets the class name of the current input.
  113134. * @returns the class name.
  113135. */
  113136. getClassName(): string;
  113137. /**
  113138. * Get the friendly name associated with the input class.
  113139. * @returns the input's friendly name.
  113140. */
  113141. getSimpleName(): string;
  113142. private _pointerInput;
  113143. private _onMouseMove;
  113144. /**
  113145. * Rotate camera by mouse offset.
  113146. */
  113147. private rotateCamera;
  113148. }
  113149. }
  113150. declare module BABYLON {
  113151. /**
  113152. * Default Inputs manager for the FlyCamera.
  113153. * It groups all the default supported inputs for ease of use.
  113154. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113155. */
  113156. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  113157. /**
  113158. * Instantiates a new FlyCameraInputsManager.
  113159. * @param camera Defines the camera the inputs belong to.
  113160. */
  113161. constructor(camera: FlyCamera);
  113162. /**
  113163. * Add keyboard input support to the input manager.
  113164. * @returns the new FlyCameraKeyboardMoveInput().
  113165. */
  113166. addKeyboard(): FlyCameraInputsManager;
  113167. /**
  113168. * Add mouse input support to the input manager.
  113169. * @param touchEnabled Enable touch screen support.
  113170. * @returns the new FlyCameraMouseInput().
  113171. */
  113172. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  113173. }
  113174. }
  113175. declare module BABYLON {
  113176. /**
  113177. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113178. * such as in a 3D Space Shooter or a Flight Simulator.
  113179. */
  113180. export class FlyCamera extends TargetCamera {
  113181. /**
  113182. * Define the collision ellipsoid of the camera.
  113183. * This is helpful for simulating a camera body, like a player's body.
  113184. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113185. */
  113186. ellipsoid: Vector3;
  113187. /**
  113188. * Define an offset for the position of the ellipsoid around the camera.
  113189. * This can be helpful if the camera is attached away from the player's body center,
  113190. * such as at its head.
  113191. */
  113192. ellipsoidOffset: Vector3;
  113193. /**
  113194. * Enable or disable collisions of the camera with the rest of the scene objects.
  113195. */
  113196. checkCollisions: boolean;
  113197. /**
  113198. * Enable or disable gravity on the camera.
  113199. */
  113200. applyGravity: boolean;
  113201. /**
  113202. * Define the current direction the camera is moving to.
  113203. */
  113204. cameraDirection: Vector3;
  113205. /**
  113206. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  113207. * This overrides and empties cameraRotation.
  113208. */
  113209. rotationQuaternion: Quaternion;
  113210. /**
  113211. * Track Roll to maintain the wanted Rolling when looking around.
  113212. */
  113213. _trackRoll: number;
  113214. /**
  113215. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  113216. */
  113217. rollCorrect: number;
  113218. /**
  113219. * Mimic a banked turn, Rolling the camera when Yawing.
  113220. * It's recommended to use rollCorrect = 10 for faster banking correction.
  113221. */
  113222. bankedTurn: boolean;
  113223. /**
  113224. * Limit in radians for how much Roll banking will add. (Default: 90°)
  113225. */
  113226. bankedTurnLimit: number;
  113227. /**
  113228. * Value of 0 disables the banked Roll.
  113229. * Value of 1 is equal to the Yaw angle in radians.
  113230. */
  113231. bankedTurnMultiplier: number;
  113232. /**
  113233. * The inputs manager loads all the input sources, such as keyboard and mouse.
  113234. */
  113235. inputs: FlyCameraInputsManager;
  113236. /**
  113237. * Gets the input sensibility for mouse input.
  113238. * Higher values reduce sensitivity.
  113239. */
  113240. get angularSensibility(): number;
  113241. /**
  113242. * Sets the input sensibility for a mouse input.
  113243. * Higher values reduce sensitivity.
  113244. */
  113245. set angularSensibility(value: number);
  113246. /**
  113247. * Get the keys for camera movement forward.
  113248. */
  113249. get keysForward(): number[];
  113250. /**
  113251. * Set the keys for camera movement forward.
  113252. */
  113253. set keysForward(value: number[]);
  113254. /**
  113255. * Get the keys for camera movement backward.
  113256. */
  113257. get keysBackward(): number[];
  113258. set keysBackward(value: number[]);
  113259. /**
  113260. * Get the keys for camera movement up.
  113261. */
  113262. get keysUp(): number[];
  113263. /**
  113264. * Set the keys for camera movement up.
  113265. */
  113266. set keysUp(value: number[]);
  113267. /**
  113268. * Get the keys for camera movement down.
  113269. */
  113270. get keysDown(): number[];
  113271. /**
  113272. * Set the keys for camera movement down.
  113273. */
  113274. set keysDown(value: number[]);
  113275. /**
  113276. * Get the keys for camera movement left.
  113277. */
  113278. get keysLeft(): number[];
  113279. /**
  113280. * Set the keys for camera movement left.
  113281. */
  113282. set keysLeft(value: number[]);
  113283. /**
  113284. * Set the keys for camera movement right.
  113285. */
  113286. get keysRight(): number[];
  113287. /**
  113288. * Set the keys for camera movement right.
  113289. */
  113290. set keysRight(value: number[]);
  113291. /**
  113292. * Event raised when the camera collides with a mesh in the scene.
  113293. */
  113294. onCollide: (collidedMesh: AbstractMesh) => void;
  113295. private _collider;
  113296. private _needMoveForGravity;
  113297. private _oldPosition;
  113298. private _diffPosition;
  113299. private _newPosition;
  113300. /** @hidden */
  113301. _localDirection: Vector3;
  113302. /** @hidden */
  113303. _transformedDirection: Vector3;
  113304. /**
  113305. * Instantiates a FlyCamera.
  113306. * This is a flying camera, designed for 3D movement and rotation in all directions,
  113307. * such as in a 3D Space Shooter or a Flight Simulator.
  113308. * @param name Define the name of the camera in the scene.
  113309. * @param position Define the starting position of the camera in the scene.
  113310. * @param scene Define the scene the camera belongs to.
  113311. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  113312. */
  113313. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113314. /**
  113315. * Attach a control to the HTML DOM element.
  113316. * @param element Defines the element that listens to the input events.
  113317. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  113318. */
  113319. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113320. /**
  113321. * Detach a control from the HTML DOM element.
  113322. * The camera will stop reacting to that input.
  113323. * @param element Defines the element that listens to the input events.
  113324. */
  113325. detachControl(element: HTMLElement): void;
  113326. private _collisionMask;
  113327. /**
  113328. * Get the mask that the camera ignores in collision events.
  113329. */
  113330. get collisionMask(): number;
  113331. /**
  113332. * Set the mask that the camera ignores in collision events.
  113333. */
  113334. set collisionMask(mask: number);
  113335. /** @hidden */
  113336. _collideWithWorld(displacement: Vector3): void;
  113337. /** @hidden */
  113338. private _onCollisionPositionChange;
  113339. /** @hidden */
  113340. _checkInputs(): void;
  113341. /** @hidden */
  113342. _decideIfNeedsToMove(): boolean;
  113343. /** @hidden */
  113344. _updatePosition(): void;
  113345. /**
  113346. * Restore the Roll to its target value at the rate specified.
  113347. * @param rate - Higher means slower restoring.
  113348. * @hidden
  113349. */
  113350. restoreRoll(rate: number): void;
  113351. /**
  113352. * Destroy the camera and release the current resources held by it.
  113353. */
  113354. dispose(): void;
  113355. /**
  113356. * Get the current object class name.
  113357. * @returns the class name.
  113358. */
  113359. getClassName(): string;
  113360. }
  113361. }
  113362. declare module BABYLON {
  113363. /**
  113364. * Listen to keyboard events to control the camera.
  113365. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113366. */
  113367. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  113368. /**
  113369. * Defines the camera the input is attached to.
  113370. */
  113371. camera: FlyCamera;
  113372. /**
  113373. * The list of keyboard keys used to control the forward move of the camera.
  113374. */
  113375. keysForward: number[];
  113376. /**
  113377. * The list of keyboard keys used to control the backward move of the camera.
  113378. */
  113379. keysBackward: number[];
  113380. /**
  113381. * The list of keyboard keys used to control the forward move of the camera.
  113382. */
  113383. keysUp: number[];
  113384. /**
  113385. * The list of keyboard keys used to control the backward move of the camera.
  113386. */
  113387. keysDown: number[];
  113388. /**
  113389. * The list of keyboard keys used to control the right strafe move of the camera.
  113390. */
  113391. keysRight: number[];
  113392. /**
  113393. * The list of keyboard keys used to control the left strafe move of the camera.
  113394. */
  113395. keysLeft: number[];
  113396. private _keys;
  113397. private _onCanvasBlurObserver;
  113398. private _onKeyboardObserver;
  113399. private _engine;
  113400. private _scene;
  113401. /**
  113402. * Attach the input controls to a specific dom element to get the input from.
  113403. * @param element Defines the element the controls should be listened from
  113404. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113405. */
  113406. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113407. /**
  113408. * Detach the current controls from the specified dom element.
  113409. * @param element Defines the element to stop listening the inputs from
  113410. */
  113411. detachControl(element: Nullable<HTMLElement>): void;
  113412. /**
  113413. * Gets the class name of the current intput.
  113414. * @returns the class name
  113415. */
  113416. getClassName(): string;
  113417. /** @hidden */
  113418. _onLostFocus(e: FocusEvent): void;
  113419. /**
  113420. * Get the friendly name associated with the input class.
  113421. * @returns the input friendly name
  113422. */
  113423. getSimpleName(): string;
  113424. /**
  113425. * Update the current camera state depending on the inputs that have been used this frame.
  113426. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113427. */
  113428. checkInputs(): void;
  113429. }
  113430. }
  113431. declare module BABYLON {
  113432. /**
  113433. * Manage the mouse wheel inputs to control a follow camera.
  113434. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113435. */
  113436. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  113437. /**
  113438. * Defines the camera the input is attached to.
  113439. */
  113440. camera: FollowCamera;
  113441. /**
  113442. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  113443. */
  113444. axisControlRadius: boolean;
  113445. /**
  113446. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  113447. */
  113448. axisControlHeight: boolean;
  113449. /**
  113450. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  113451. */
  113452. axisControlRotation: boolean;
  113453. /**
  113454. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  113455. * relation to mouseWheel events.
  113456. */
  113457. wheelPrecision: number;
  113458. /**
  113459. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113460. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113461. */
  113462. wheelDeltaPercentage: number;
  113463. private _wheel;
  113464. private _observer;
  113465. /**
  113466. * Attach the input controls to a specific dom element to get the input from.
  113467. * @param element Defines the element the controls should be listened from
  113468. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113469. */
  113470. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113471. /**
  113472. * Detach the current controls from the specified dom element.
  113473. * @param element Defines the element to stop listening the inputs from
  113474. */
  113475. detachControl(element: Nullable<HTMLElement>): void;
  113476. /**
  113477. * Gets the class name of the current intput.
  113478. * @returns the class name
  113479. */
  113480. getClassName(): string;
  113481. /**
  113482. * Get the friendly name associated with the input class.
  113483. * @returns the input friendly name
  113484. */
  113485. getSimpleName(): string;
  113486. }
  113487. }
  113488. declare module BABYLON {
  113489. /**
  113490. * Manage the pointers inputs to control an follow camera.
  113491. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113492. */
  113493. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  113494. /**
  113495. * Defines the camera the input is attached to.
  113496. */
  113497. camera: FollowCamera;
  113498. /**
  113499. * Gets the class name of the current input.
  113500. * @returns the class name
  113501. */
  113502. getClassName(): string;
  113503. /**
  113504. * Defines the pointer angular sensibility along the X axis or how fast is
  113505. * the camera rotating.
  113506. * A negative number will reverse the axis direction.
  113507. */
  113508. angularSensibilityX: number;
  113509. /**
  113510. * Defines the pointer angular sensibility along the Y axis or how fast is
  113511. * the camera rotating.
  113512. * A negative number will reverse the axis direction.
  113513. */
  113514. angularSensibilityY: number;
  113515. /**
  113516. * Defines the pointer pinch precision or how fast is the camera zooming.
  113517. * A negative number will reverse the axis direction.
  113518. */
  113519. pinchPrecision: number;
  113520. /**
  113521. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  113522. * from 0.
  113523. * It defines the percentage of current camera.radius to use as delta when
  113524. * pinch zoom is used.
  113525. */
  113526. pinchDeltaPercentage: number;
  113527. /**
  113528. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  113529. */
  113530. axisXControlRadius: boolean;
  113531. /**
  113532. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  113533. */
  113534. axisXControlHeight: boolean;
  113535. /**
  113536. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  113537. */
  113538. axisXControlRotation: boolean;
  113539. /**
  113540. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  113541. */
  113542. axisYControlRadius: boolean;
  113543. /**
  113544. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  113545. */
  113546. axisYControlHeight: boolean;
  113547. /**
  113548. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  113549. */
  113550. axisYControlRotation: boolean;
  113551. /**
  113552. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  113553. */
  113554. axisPinchControlRadius: boolean;
  113555. /**
  113556. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  113557. */
  113558. axisPinchControlHeight: boolean;
  113559. /**
  113560. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  113561. */
  113562. axisPinchControlRotation: boolean;
  113563. /**
  113564. * Log error messages if basic misconfiguration has occurred.
  113565. */
  113566. warningEnable: boolean;
  113567. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113568. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113569. private _warningCounter;
  113570. private _warning;
  113571. }
  113572. }
  113573. declare module BABYLON {
  113574. /**
  113575. * Default Inputs manager for the FollowCamera.
  113576. * It groups all the default supported inputs for ease of use.
  113577. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113578. */
  113579. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  113580. /**
  113581. * Instantiates a new FollowCameraInputsManager.
  113582. * @param camera Defines the camera the inputs belong to
  113583. */
  113584. constructor(camera: FollowCamera);
  113585. /**
  113586. * Add keyboard input support to the input manager.
  113587. * @returns the current input manager
  113588. */
  113589. addKeyboard(): FollowCameraInputsManager;
  113590. /**
  113591. * Add mouse wheel input support to the input manager.
  113592. * @returns the current input manager
  113593. */
  113594. addMouseWheel(): FollowCameraInputsManager;
  113595. /**
  113596. * Add pointers input support to the input manager.
  113597. * @returns the current input manager
  113598. */
  113599. addPointers(): FollowCameraInputsManager;
  113600. /**
  113601. * Add orientation input support to the input manager.
  113602. * @returns the current input manager
  113603. */
  113604. addVRDeviceOrientation(): FollowCameraInputsManager;
  113605. }
  113606. }
  113607. declare module BABYLON {
  113608. /**
  113609. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  113610. * an arc rotate version arcFollowCamera are available.
  113611. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113612. */
  113613. export class FollowCamera extends TargetCamera {
  113614. /**
  113615. * Distance the follow camera should follow an object at
  113616. */
  113617. radius: number;
  113618. /**
  113619. * Minimum allowed distance of the camera to the axis of rotation
  113620. * (The camera can not get closer).
  113621. * This can help limiting how the Camera is able to move in the scene.
  113622. */
  113623. lowerRadiusLimit: Nullable<number>;
  113624. /**
  113625. * Maximum allowed distance of the camera to the axis of rotation
  113626. * (The camera can not get further).
  113627. * This can help limiting how the Camera is able to move in the scene.
  113628. */
  113629. upperRadiusLimit: Nullable<number>;
  113630. /**
  113631. * Define a rotation offset between the camera and the object it follows
  113632. */
  113633. rotationOffset: number;
  113634. /**
  113635. * Minimum allowed angle to camera position relative to target object.
  113636. * This can help limiting how the Camera is able to move in the scene.
  113637. */
  113638. lowerRotationOffsetLimit: Nullable<number>;
  113639. /**
  113640. * Maximum allowed angle to camera position relative to target object.
  113641. * This can help limiting how the Camera is able to move in the scene.
  113642. */
  113643. upperRotationOffsetLimit: Nullable<number>;
  113644. /**
  113645. * Define a height offset between the camera and the object it follows.
  113646. * It can help following an object from the top (like a car chaing a plane)
  113647. */
  113648. heightOffset: number;
  113649. /**
  113650. * Minimum allowed height of camera position relative to target object.
  113651. * This can help limiting how the Camera is able to move in the scene.
  113652. */
  113653. lowerHeightOffsetLimit: Nullable<number>;
  113654. /**
  113655. * Maximum allowed height of camera position relative to target object.
  113656. * This can help limiting how the Camera is able to move in the scene.
  113657. */
  113658. upperHeightOffsetLimit: Nullable<number>;
  113659. /**
  113660. * Define how fast the camera can accelerate to follow it s target.
  113661. */
  113662. cameraAcceleration: number;
  113663. /**
  113664. * Define the speed limit of the camera following an object.
  113665. */
  113666. maxCameraSpeed: number;
  113667. /**
  113668. * Define the target of the camera.
  113669. */
  113670. lockedTarget: Nullable<AbstractMesh>;
  113671. /**
  113672. * Defines the input associated with the camera.
  113673. */
  113674. inputs: FollowCameraInputsManager;
  113675. /**
  113676. * Instantiates the follow camera.
  113677. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113678. * @param name Define the name of the camera in the scene
  113679. * @param position Define the position of the camera
  113680. * @param scene Define the scene the camera belong to
  113681. * @param lockedTarget Define the target of the camera
  113682. */
  113683. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  113684. private _follow;
  113685. /**
  113686. * Attached controls to the current camera.
  113687. * @param element Defines the element the controls should be listened from
  113688. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113689. */
  113690. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113691. /**
  113692. * Detach the current controls from the camera.
  113693. * The camera will stop reacting to inputs.
  113694. * @param element Defines the element to stop listening the inputs from
  113695. */
  113696. detachControl(element: HTMLElement): void;
  113697. /** @hidden */
  113698. _checkInputs(): void;
  113699. private _checkLimits;
  113700. /**
  113701. * Gets the camera class name.
  113702. * @returns the class name
  113703. */
  113704. getClassName(): string;
  113705. }
  113706. /**
  113707. * Arc Rotate version of the follow camera.
  113708. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  113709. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113710. */
  113711. export class ArcFollowCamera extends TargetCamera {
  113712. /** The longitudinal angle of the camera */
  113713. alpha: number;
  113714. /** The latitudinal angle of the camera */
  113715. beta: number;
  113716. /** The radius of the camera from its target */
  113717. radius: number;
  113718. /** Define the camera target (the messh it should follow) */
  113719. target: Nullable<AbstractMesh>;
  113720. private _cartesianCoordinates;
  113721. /**
  113722. * Instantiates a new ArcFollowCamera
  113723. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  113724. * @param name Define the name of the camera
  113725. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  113726. * @param beta Define the rotation angle of the camera around the elevation axis
  113727. * @param radius Define the radius of the camera from its target point
  113728. * @param target Define the target of the camera
  113729. * @param scene Define the scene the camera belongs to
  113730. */
  113731. constructor(name: string,
  113732. /** The longitudinal angle of the camera */
  113733. alpha: number,
  113734. /** The latitudinal angle of the camera */
  113735. beta: number,
  113736. /** The radius of the camera from its target */
  113737. radius: number,
  113738. /** Define the camera target (the messh it should follow) */
  113739. target: Nullable<AbstractMesh>, scene: Scene);
  113740. private _follow;
  113741. /** @hidden */
  113742. _checkInputs(): void;
  113743. /**
  113744. * Returns the class name of the object.
  113745. * It is mostly used internally for serialization purposes.
  113746. */
  113747. getClassName(): string;
  113748. }
  113749. }
  113750. declare module BABYLON {
  113751. /**
  113752. * Manage the keyboard inputs to control the movement of a follow camera.
  113753. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113754. */
  113755. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  113756. /**
  113757. * Defines the camera the input is attached to.
  113758. */
  113759. camera: FollowCamera;
  113760. /**
  113761. * Defines the list of key codes associated with the up action (increase heightOffset)
  113762. */
  113763. keysHeightOffsetIncr: number[];
  113764. /**
  113765. * Defines the list of key codes associated with the down action (decrease heightOffset)
  113766. */
  113767. keysHeightOffsetDecr: number[];
  113768. /**
  113769. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  113770. */
  113771. keysHeightOffsetModifierAlt: boolean;
  113772. /**
  113773. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  113774. */
  113775. keysHeightOffsetModifierCtrl: boolean;
  113776. /**
  113777. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  113778. */
  113779. keysHeightOffsetModifierShift: boolean;
  113780. /**
  113781. * Defines the list of key codes associated with the left action (increase rotationOffset)
  113782. */
  113783. keysRotationOffsetIncr: number[];
  113784. /**
  113785. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  113786. */
  113787. keysRotationOffsetDecr: number[];
  113788. /**
  113789. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  113790. */
  113791. keysRotationOffsetModifierAlt: boolean;
  113792. /**
  113793. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  113794. */
  113795. keysRotationOffsetModifierCtrl: boolean;
  113796. /**
  113797. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  113798. */
  113799. keysRotationOffsetModifierShift: boolean;
  113800. /**
  113801. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  113802. */
  113803. keysRadiusIncr: number[];
  113804. /**
  113805. * Defines the list of key codes associated with the zoom-out action (increase radius)
  113806. */
  113807. keysRadiusDecr: number[];
  113808. /**
  113809. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  113810. */
  113811. keysRadiusModifierAlt: boolean;
  113812. /**
  113813. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  113814. */
  113815. keysRadiusModifierCtrl: boolean;
  113816. /**
  113817. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  113818. */
  113819. keysRadiusModifierShift: boolean;
  113820. /**
  113821. * Defines the rate of change of heightOffset.
  113822. */
  113823. heightSensibility: number;
  113824. /**
  113825. * Defines the rate of change of rotationOffset.
  113826. */
  113827. rotationSensibility: number;
  113828. /**
  113829. * Defines the rate of change of radius.
  113830. */
  113831. radiusSensibility: number;
  113832. private _keys;
  113833. private _ctrlPressed;
  113834. private _altPressed;
  113835. private _shiftPressed;
  113836. private _onCanvasBlurObserver;
  113837. private _onKeyboardObserver;
  113838. private _engine;
  113839. private _scene;
  113840. /**
  113841. * Attach the input controls to a specific dom element to get the input from.
  113842. * @param element Defines the element the controls should be listened from
  113843. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113844. */
  113845. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113846. /**
  113847. * Detach the current controls from the specified dom element.
  113848. * @param element Defines the element to stop listening the inputs from
  113849. */
  113850. detachControl(element: Nullable<HTMLElement>): void;
  113851. /**
  113852. * Update the current camera state depending on the inputs that have been used this frame.
  113853. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113854. */
  113855. checkInputs(): void;
  113856. /**
  113857. * Gets the class name of the current input.
  113858. * @returns the class name
  113859. */
  113860. getClassName(): string;
  113861. /**
  113862. * Get the friendly name associated with the input class.
  113863. * @returns the input friendly name
  113864. */
  113865. getSimpleName(): string;
  113866. /**
  113867. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113868. * allow modification of the heightOffset value.
  113869. */
  113870. private _modifierHeightOffset;
  113871. /**
  113872. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113873. * allow modification of the rotationOffset value.
  113874. */
  113875. private _modifierRotationOffset;
  113876. /**
  113877. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  113878. * allow modification of the radius value.
  113879. */
  113880. private _modifierRadius;
  113881. }
  113882. }
  113883. declare module BABYLON {
  113884. interface FreeCameraInputsManager {
  113885. /**
  113886. * @hidden
  113887. */
  113888. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  113889. /**
  113890. * Add orientation input support to the input manager.
  113891. * @returns the current input manager
  113892. */
  113893. addDeviceOrientation(): FreeCameraInputsManager;
  113894. }
  113895. /**
  113896. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  113897. * Screen rotation is taken into account.
  113898. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113899. */
  113900. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  113901. private _camera;
  113902. private _screenOrientationAngle;
  113903. private _constantTranform;
  113904. private _screenQuaternion;
  113905. private _alpha;
  113906. private _beta;
  113907. private _gamma;
  113908. /**
  113909. * Can be used to detect if a device orientation sensor is available on a device
  113910. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  113911. * @returns a promise that will resolve on orientation change
  113912. */
  113913. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  113914. /**
  113915. * @hidden
  113916. */
  113917. _onDeviceOrientationChangedObservable: Observable<void>;
  113918. /**
  113919. * Instantiates a new input
  113920. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113921. */
  113922. constructor();
  113923. /**
  113924. * Define the camera controlled by the input.
  113925. */
  113926. get camera(): FreeCamera;
  113927. set camera(camera: FreeCamera);
  113928. /**
  113929. * Attach the input controls to a specific dom element to get the input from.
  113930. * @param element Defines the element the controls should be listened from
  113931. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113932. */
  113933. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113934. private _orientationChanged;
  113935. private _deviceOrientation;
  113936. /**
  113937. * Detach the current controls from the specified dom element.
  113938. * @param element Defines the element to stop listening the inputs from
  113939. */
  113940. detachControl(element: Nullable<HTMLElement>): void;
  113941. /**
  113942. * Update the current camera state depending on the inputs that have been used this frame.
  113943. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113944. */
  113945. checkInputs(): void;
  113946. /**
  113947. * Gets the class name of the current intput.
  113948. * @returns the class name
  113949. */
  113950. getClassName(): string;
  113951. /**
  113952. * Get the friendly name associated with the input class.
  113953. * @returns the input friendly name
  113954. */
  113955. getSimpleName(): string;
  113956. }
  113957. }
  113958. declare module BABYLON {
  113959. /**
  113960. * Manage the gamepad inputs to control a free camera.
  113961. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113962. */
  113963. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  113964. /**
  113965. * Define the camera the input is attached to.
  113966. */
  113967. camera: FreeCamera;
  113968. /**
  113969. * Define the Gamepad controlling the input
  113970. */
  113971. gamepad: Nullable<Gamepad>;
  113972. /**
  113973. * Defines the gamepad rotation sensiblity.
  113974. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  113975. */
  113976. gamepadAngularSensibility: number;
  113977. /**
  113978. * Defines the gamepad move sensiblity.
  113979. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  113980. */
  113981. gamepadMoveSensibility: number;
  113982. private _yAxisScale;
  113983. /**
  113984. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  113985. */
  113986. get invertYAxis(): boolean;
  113987. set invertYAxis(value: boolean);
  113988. private _onGamepadConnectedObserver;
  113989. private _onGamepadDisconnectedObserver;
  113990. private _cameraTransform;
  113991. private _deltaTransform;
  113992. private _vector3;
  113993. private _vector2;
  113994. /**
  113995. * Attach the input controls to a specific dom element to get the input from.
  113996. * @param element Defines the element the controls should be listened from
  113997. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113998. */
  113999. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114000. /**
  114001. * Detach the current controls from the specified dom element.
  114002. * @param element Defines the element to stop listening the inputs from
  114003. */
  114004. detachControl(element: Nullable<HTMLElement>): void;
  114005. /**
  114006. * Update the current camera state depending on the inputs that have been used this frame.
  114007. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114008. */
  114009. checkInputs(): void;
  114010. /**
  114011. * Gets the class name of the current intput.
  114012. * @returns the class name
  114013. */
  114014. getClassName(): string;
  114015. /**
  114016. * Get the friendly name associated with the input class.
  114017. * @returns the input friendly name
  114018. */
  114019. getSimpleName(): string;
  114020. }
  114021. }
  114022. declare module BABYLON {
  114023. /**
  114024. * Defines the potential axis of a Joystick
  114025. */
  114026. export enum JoystickAxis {
  114027. /** X axis */
  114028. X = 0,
  114029. /** Y axis */
  114030. Y = 1,
  114031. /** Z axis */
  114032. Z = 2
  114033. }
  114034. /**
  114035. * Class used to define virtual joystick (used in touch mode)
  114036. */
  114037. export class VirtualJoystick {
  114038. /**
  114039. * Gets or sets a boolean indicating that left and right values must be inverted
  114040. */
  114041. reverseLeftRight: boolean;
  114042. /**
  114043. * Gets or sets a boolean indicating that up and down values must be inverted
  114044. */
  114045. reverseUpDown: boolean;
  114046. /**
  114047. * Gets the offset value for the position (ie. the change of the position value)
  114048. */
  114049. deltaPosition: Vector3;
  114050. /**
  114051. * Gets a boolean indicating if the virtual joystick was pressed
  114052. */
  114053. pressed: boolean;
  114054. /**
  114055. * Canvas the virtual joystick will render onto, default z-index of this is 5
  114056. */
  114057. static Canvas: Nullable<HTMLCanvasElement>;
  114058. private static _globalJoystickIndex;
  114059. private static vjCanvasContext;
  114060. private static vjCanvasWidth;
  114061. private static vjCanvasHeight;
  114062. private static halfWidth;
  114063. private _action;
  114064. private _axisTargetedByLeftAndRight;
  114065. private _axisTargetedByUpAndDown;
  114066. private _joystickSensibility;
  114067. private _inversedSensibility;
  114068. private _joystickPointerID;
  114069. private _joystickColor;
  114070. private _joystickPointerPos;
  114071. private _joystickPreviousPointerPos;
  114072. private _joystickPointerStartPos;
  114073. private _deltaJoystickVector;
  114074. private _leftJoystick;
  114075. private _touches;
  114076. private _onPointerDownHandlerRef;
  114077. private _onPointerMoveHandlerRef;
  114078. private _onPointerUpHandlerRef;
  114079. private _onResize;
  114080. /**
  114081. * Creates a new virtual joystick
  114082. * @param leftJoystick defines that the joystick is for left hand (false by default)
  114083. */
  114084. constructor(leftJoystick?: boolean);
  114085. /**
  114086. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  114087. * @param newJoystickSensibility defines the new sensibility
  114088. */
  114089. setJoystickSensibility(newJoystickSensibility: number): void;
  114090. private _onPointerDown;
  114091. private _onPointerMove;
  114092. private _onPointerUp;
  114093. /**
  114094. * Change the color of the virtual joystick
  114095. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  114096. */
  114097. setJoystickColor(newColor: string): void;
  114098. /**
  114099. * Defines a callback to call when the joystick is touched
  114100. * @param action defines the callback
  114101. */
  114102. setActionOnTouch(action: () => any): void;
  114103. /**
  114104. * Defines which axis you'd like to control for left & right
  114105. * @param axis defines the axis to use
  114106. */
  114107. setAxisForLeftRight(axis: JoystickAxis): void;
  114108. /**
  114109. * Defines which axis you'd like to control for up & down
  114110. * @param axis defines the axis to use
  114111. */
  114112. setAxisForUpDown(axis: JoystickAxis): void;
  114113. private _drawVirtualJoystick;
  114114. /**
  114115. * Release internal HTML canvas
  114116. */
  114117. releaseCanvas(): void;
  114118. }
  114119. }
  114120. declare module BABYLON {
  114121. interface FreeCameraInputsManager {
  114122. /**
  114123. * Add virtual joystick input support to the input manager.
  114124. * @returns the current input manager
  114125. */
  114126. addVirtualJoystick(): FreeCameraInputsManager;
  114127. }
  114128. /**
  114129. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  114130. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114131. */
  114132. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  114133. /**
  114134. * Defines the camera the input is attached to.
  114135. */
  114136. camera: FreeCamera;
  114137. private _leftjoystick;
  114138. private _rightjoystick;
  114139. /**
  114140. * Gets the left stick of the virtual joystick.
  114141. * @returns The virtual Joystick
  114142. */
  114143. getLeftJoystick(): VirtualJoystick;
  114144. /**
  114145. * Gets the right stick of the virtual joystick.
  114146. * @returns The virtual Joystick
  114147. */
  114148. getRightJoystick(): VirtualJoystick;
  114149. /**
  114150. * Update the current camera state depending on the inputs that have been used this frame.
  114151. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114152. */
  114153. checkInputs(): void;
  114154. /**
  114155. * Attach the input controls to a specific dom element to get the input from.
  114156. * @param element Defines the element the controls should be listened from
  114157. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114158. */
  114159. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114160. /**
  114161. * Detach the current controls from the specified dom element.
  114162. * @param element Defines the element to stop listening the inputs from
  114163. */
  114164. detachControl(element: Nullable<HTMLElement>): void;
  114165. /**
  114166. * Gets the class name of the current intput.
  114167. * @returns the class name
  114168. */
  114169. getClassName(): string;
  114170. /**
  114171. * Get the friendly name associated with the input class.
  114172. * @returns the input friendly name
  114173. */
  114174. getSimpleName(): string;
  114175. }
  114176. }
  114177. declare module BABYLON {
  114178. /**
  114179. * This represents a FPS type of camera controlled by touch.
  114180. * This is like a universal camera minus the Gamepad controls.
  114181. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114182. */
  114183. export class TouchCamera extends FreeCamera {
  114184. /**
  114185. * Defines the touch sensibility for rotation.
  114186. * The higher the faster.
  114187. */
  114188. get touchAngularSensibility(): number;
  114189. set touchAngularSensibility(value: number);
  114190. /**
  114191. * Defines the touch sensibility for move.
  114192. * The higher the faster.
  114193. */
  114194. get touchMoveSensibility(): number;
  114195. set touchMoveSensibility(value: number);
  114196. /**
  114197. * Instantiates a new touch camera.
  114198. * This represents a FPS type of camera controlled by touch.
  114199. * This is like a universal camera minus the Gamepad controls.
  114200. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114201. * @param name Define the name of the camera in the scene
  114202. * @param position Define the start position of the camera in the scene
  114203. * @param scene Define the scene the camera belongs to
  114204. */
  114205. constructor(name: string, position: Vector3, scene: Scene);
  114206. /**
  114207. * Gets the current object class name.
  114208. * @return the class name
  114209. */
  114210. getClassName(): string;
  114211. /** @hidden */
  114212. _setupInputs(): void;
  114213. }
  114214. }
  114215. declare module BABYLON {
  114216. /**
  114217. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  114218. * being tilted forward or back and left or right.
  114219. */
  114220. export class DeviceOrientationCamera extends FreeCamera {
  114221. private _initialQuaternion;
  114222. private _quaternionCache;
  114223. private _tmpDragQuaternion;
  114224. private _disablePointerInputWhenUsingDeviceOrientation;
  114225. /**
  114226. * Creates a new device orientation camera
  114227. * @param name The name of the camera
  114228. * @param position The start position camera
  114229. * @param scene The scene the camera belongs to
  114230. */
  114231. constructor(name: string, position: Vector3, scene: Scene);
  114232. /**
  114233. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  114234. */
  114235. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  114236. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  114237. private _dragFactor;
  114238. /**
  114239. * Enabled turning on the y axis when the orientation sensor is active
  114240. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  114241. */
  114242. enableHorizontalDragging(dragFactor?: number): void;
  114243. /**
  114244. * Gets the current instance class name ("DeviceOrientationCamera").
  114245. * This helps avoiding instanceof at run time.
  114246. * @returns the class name
  114247. */
  114248. getClassName(): string;
  114249. /**
  114250. * @hidden
  114251. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  114252. */
  114253. _checkInputs(): void;
  114254. /**
  114255. * Reset the camera to its default orientation on the specified axis only.
  114256. * @param axis The axis to reset
  114257. */
  114258. resetToCurrentRotation(axis?: Axis): void;
  114259. }
  114260. }
  114261. declare module BABYLON {
  114262. /**
  114263. * Defines supported buttons for XBox360 compatible gamepads
  114264. */
  114265. export enum Xbox360Button {
  114266. /** A */
  114267. A = 0,
  114268. /** B */
  114269. B = 1,
  114270. /** X */
  114271. X = 2,
  114272. /** Y */
  114273. Y = 3,
  114274. /** Start */
  114275. Start = 4,
  114276. /** Back */
  114277. Back = 5,
  114278. /** Left button */
  114279. LB = 6,
  114280. /** Right button */
  114281. RB = 7,
  114282. /** Left stick */
  114283. LeftStick = 8,
  114284. /** Right stick */
  114285. RightStick = 9
  114286. }
  114287. /** Defines values for XBox360 DPad */
  114288. export enum Xbox360Dpad {
  114289. /** Up */
  114290. Up = 0,
  114291. /** Down */
  114292. Down = 1,
  114293. /** Left */
  114294. Left = 2,
  114295. /** Right */
  114296. Right = 3
  114297. }
  114298. /**
  114299. * Defines a XBox360 gamepad
  114300. */
  114301. export class Xbox360Pad extends Gamepad {
  114302. private _leftTrigger;
  114303. private _rightTrigger;
  114304. private _onlefttriggerchanged;
  114305. private _onrighttriggerchanged;
  114306. private _onbuttondown;
  114307. private _onbuttonup;
  114308. private _ondpaddown;
  114309. private _ondpadup;
  114310. /** Observable raised when a button is pressed */
  114311. onButtonDownObservable: Observable<Xbox360Button>;
  114312. /** Observable raised when a button is released */
  114313. onButtonUpObservable: Observable<Xbox360Button>;
  114314. /** Observable raised when a pad is pressed */
  114315. onPadDownObservable: Observable<Xbox360Dpad>;
  114316. /** Observable raised when a pad is released */
  114317. onPadUpObservable: Observable<Xbox360Dpad>;
  114318. private _buttonA;
  114319. private _buttonB;
  114320. private _buttonX;
  114321. private _buttonY;
  114322. private _buttonBack;
  114323. private _buttonStart;
  114324. private _buttonLB;
  114325. private _buttonRB;
  114326. private _buttonLeftStick;
  114327. private _buttonRightStick;
  114328. private _dPadUp;
  114329. private _dPadDown;
  114330. private _dPadLeft;
  114331. private _dPadRight;
  114332. private _isXboxOnePad;
  114333. /**
  114334. * Creates a new XBox360 gamepad object
  114335. * @param id defines the id of this gamepad
  114336. * @param index defines its index
  114337. * @param gamepad defines the internal HTML gamepad object
  114338. * @param xboxOne defines if it is a XBox One gamepad
  114339. */
  114340. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  114341. /**
  114342. * Defines the callback to call when left trigger is pressed
  114343. * @param callback defines the callback to use
  114344. */
  114345. onlefttriggerchanged(callback: (value: number) => void): void;
  114346. /**
  114347. * Defines the callback to call when right trigger is pressed
  114348. * @param callback defines the callback to use
  114349. */
  114350. onrighttriggerchanged(callback: (value: number) => void): void;
  114351. /**
  114352. * Gets the left trigger value
  114353. */
  114354. get leftTrigger(): number;
  114355. /**
  114356. * Sets the left trigger value
  114357. */
  114358. set leftTrigger(newValue: number);
  114359. /**
  114360. * Gets the right trigger value
  114361. */
  114362. get rightTrigger(): number;
  114363. /**
  114364. * Sets the right trigger value
  114365. */
  114366. set rightTrigger(newValue: number);
  114367. /**
  114368. * Defines the callback to call when a button is pressed
  114369. * @param callback defines the callback to use
  114370. */
  114371. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  114372. /**
  114373. * Defines the callback to call when a button is released
  114374. * @param callback defines the callback to use
  114375. */
  114376. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  114377. /**
  114378. * Defines the callback to call when a pad is pressed
  114379. * @param callback defines the callback to use
  114380. */
  114381. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  114382. /**
  114383. * Defines the callback to call when a pad is released
  114384. * @param callback defines the callback to use
  114385. */
  114386. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  114387. private _setButtonValue;
  114388. private _setDPadValue;
  114389. /**
  114390. * Gets the value of the `A` button
  114391. */
  114392. get buttonA(): number;
  114393. /**
  114394. * Sets the value of the `A` button
  114395. */
  114396. set buttonA(value: number);
  114397. /**
  114398. * Gets the value of the `B` button
  114399. */
  114400. get buttonB(): number;
  114401. /**
  114402. * Sets the value of the `B` button
  114403. */
  114404. set buttonB(value: number);
  114405. /**
  114406. * Gets the value of the `X` button
  114407. */
  114408. get buttonX(): number;
  114409. /**
  114410. * Sets the value of the `X` button
  114411. */
  114412. set buttonX(value: number);
  114413. /**
  114414. * Gets the value of the `Y` button
  114415. */
  114416. get buttonY(): number;
  114417. /**
  114418. * Sets the value of the `Y` button
  114419. */
  114420. set buttonY(value: number);
  114421. /**
  114422. * Gets the value of the `Start` button
  114423. */
  114424. get buttonStart(): number;
  114425. /**
  114426. * Sets the value of the `Start` button
  114427. */
  114428. set buttonStart(value: number);
  114429. /**
  114430. * Gets the value of the `Back` button
  114431. */
  114432. get buttonBack(): number;
  114433. /**
  114434. * Sets the value of the `Back` button
  114435. */
  114436. set buttonBack(value: number);
  114437. /**
  114438. * Gets the value of the `Left` button
  114439. */
  114440. get buttonLB(): number;
  114441. /**
  114442. * Sets the value of the `Left` button
  114443. */
  114444. set buttonLB(value: number);
  114445. /**
  114446. * Gets the value of the `Right` button
  114447. */
  114448. get buttonRB(): number;
  114449. /**
  114450. * Sets the value of the `Right` button
  114451. */
  114452. set buttonRB(value: number);
  114453. /**
  114454. * Gets the value of the Left joystick
  114455. */
  114456. get buttonLeftStick(): number;
  114457. /**
  114458. * Sets the value of the Left joystick
  114459. */
  114460. set buttonLeftStick(value: number);
  114461. /**
  114462. * Gets the value of the Right joystick
  114463. */
  114464. get buttonRightStick(): number;
  114465. /**
  114466. * Sets the value of the Right joystick
  114467. */
  114468. set buttonRightStick(value: number);
  114469. /**
  114470. * Gets the value of D-pad up
  114471. */
  114472. get dPadUp(): number;
  114473. /**
  114474. * Sets the value of D-pad up
  114475. */
  114476. set dPadUp(value: number);
  114477. /**
  114478. * Gets the value of D-pad down
  114479. */
  114480. get dPadDown(): number;
  114481. /**
  114482. * Sets the value of D-pad down
  114483. */
  114484. set dPadDown(value: number);
  114485. /**
  114486. * Gets the value of D-pad left
  114487. */
  114488. get dPadLeft(): number;
  114489. /**
  114490. * Sets the value of D-pad left
  114491. */
  114492. set dPadLeft(value: number);
  114493. /**
  114494. * Gets the value of D-pad right
  114495. */
  114496. get dPadRight(): number;
  114497. /**
  114498. * Sets the value of D-pad right
  114499. */
  114500. set dPadRight(value: number);
  114501. /**
  114502. * Force the gamepad to synchronize with device values
  114503. */
  114504. update(): void;
  114505. /**
  114506. * Disposes the gamepad
  114507. */
  114508. dispose(): void;
  114509. }
  114510. }
  114511. declare module BABYLON {
  114512. /**
  114513. * Defines supported buttons for DualShock compatible gamepads
  114514. */
  114515. export enum DualShockButton {
  114516. /** Cross */
  114517. Cross = 0,
  114518. /** Circle */
  114519. Circle = 1,
  114520. /** Square */
  114521. Square = 2,
  114522. /** Triangle */
  114523. Triangle = 3,
  114524. /** Options */
  114525. Options = 4,
  114526. /** Share */
  114527. Share = 5,
  114528. /** L1 */
  114529. L1 = 6,
  114530. /** R1 */
  114531. R1 = 7,
  114532. /** Left stick */
  114533. LeftStick = 8,
  114534. /** Right stick */
  114535. RightStick = 9
  114536. }
  114537. /** Defines values for DualShock DPad */
  114538. export enum DualShockDpad {
  114539. /** Up */
  114540. Up = 0,
  114541. /** Down */
  114542. Down = 1,
  114543. /** Left */
  114544. Left = 2,
  114545. /** Right */
  114546. Right = 3
  114547. }
  114548. /**
  114549. * Defines a DualShock gamepad
  114550. */
  114551. export class DualShockPad extends Gamepad {
  114552. private _leftTrigger;
  114553. private _rightTrigger;
  114554. private _onlefttriggerchanged;
  114555. private _onrighttriggerchanged;
  114556. private _onbuttondown;
  114557. private _onbuttonup;
  114558. private _ondpaddown;
  114559. private _ondpadup;
  114560. /** Observable raised when a button is pressed */
  114561. onButtonDownObservable: Observable<DualShockButton>;
  114562. /** Observable raised when a button is released */
  114563. onButtonUpObservable: Observable<DualShockButton>;
  114564. /** Observable raised when a pad is pressed */
  114565. onPadDownObservable: Observable<DualShockDpad>;
  114566. /** Observable raised when a pad is released */
  114567. onPadUpObservable: Observable<DualShockDpad>;
  114568. private _buttonCross;
  114569. private _buttonCircle;
  114570. private _buttonSquare;
  114571. private _buttonTriangle;
  114572. private _buttonShare;
  114573. private _buttonOptions;
  114574. private _buttonL1;
  114575. private _buttonR1;
  114576. private _buttonLeftStick;
  114577. private _buttonRightStick;
  114578. private _dPadUp;
  114579. private _dPadDown;
  114580. private _dPadLeft;
  114581. private _dPadRight;
  114582. /**
  114583. * Creates a new DualShock gamepad object
  114584. * @param id defines the id of this gamepad
  114585. * @param index defines its index
  114586. * @param gamepad defines the internal HTML gamepad object
  114587. */
  114588. constructor(id: string, index: number, gamepad: any);
  114589. /**
  114590. * Defines the callback to call when left trigger is pressed
  114591. * @param callback defines the callback to use
  114592. */
  114593. onlefttriggerchanged(callback: (value: number) => void): void;
  114594. /**
  114595. * Defines the callback to call when right trigger is pressed
  114596. * @param callback defines the callback to use
  114597. */
  114598. onrighttriggerchanged(callback: (value: number) => void): void;
  114599. /**
  114600. * Gets the left trigger value
  114601. */
  114602. get leftTrigger(): number;
  114603. /**
  114604. * Sets the left trigger value
  114605. */
  114606. set leftTrigger(newValue: number);
  114607. /**
  114608. * Gets the right trigger value
  114609. */
  114610. get rightTrigger(): number;
  114611. /**
  114612. * Sets the right trigger value
  114613. */
  114614. set rightTrigger(newValue: number);
  114615. /**
  114616. * Defines the callback to call when a button is pressed
  114617. * @param callback defines the callback to use
  114618. */
  114619. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  114620. /**
  114621. * Defines the callback to call when a button is released
  114622. * @param callback defines the callback to use
  114623. */
  114624. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  114625. /**
  114626. * Defines the callback to call when a pad is pressed
  114627. * @param callback defines the callback to use
  114628. */
  114629. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  114630. /**
  114631. * Defines the callback to call when a pad is released
  114632. * @param callback defines the callback to use
  114633. */
  114634. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  114635. private _setButtonValue;
  114636. private _setDPadValue;
  114637. /**
  114638. * Gets the value of the `Cross` button
  114639. */
  114640. get buttonCross(): number;
  114641. /**
  114642. * Sets the value of the `Cross` button
  114643. */
  114644. set buttonCross(value: number);
  114645. /**
  114646. * Gets the value of the `Circle` button
  114647. */
  114648. get buttonCircle(): number;
  114649. /**
  114650. * Sets the value of the `Circle` button
  114651. */
  114652. set buttonCircle(value: number);
  114653. /**
  114654. * Gets the value of the `Square` button
  114655. */
  114656. get buttonSquare(): number;
  114657. /**
  114658. * Sets the value of the `Square` button
  114659. */
  114660. set buttonSquare(value: number);
  114661. /**
  114662. * Gets the value of the `Triangle` button
  114663. */
  114664. get buttonTriangle(): number;
  114665. /**
  114666. * Sets the value of the `Triangle` button
  114667. */
  114668. set buttonTriangle(value: number);
  114669. /**
  114670. * Gets the value of the `Options` button
  114671. */
  114672. get buttonOptions(): number;
  114673. /**
  114674. * Sets the value of the `Options` button
  114675. */
  114676. set buttonOptions(value: number);
  114677. /**
  114678. * Gets the value of the `Share` button
  114679. */
  114680. get buttonShare(): number;
  114681. /**
  114682. * Sets the value of the `Share` button
  114683. */
  114684. set buttonShare(value: number);
  114685. /**
  114686. * Gets the value of the `L1` button
  114687. */
  114688. get buttonL1(): number;
  114689. /**
  114690. * Sets the value of the `L1` button
  114691. */
  114692. set buttonL1(value: number);
  114693. /**
  114694. * Gets the value of the `R1` button
  114695. */
  114696. get buttonR1(): number;
  114697. /**
  114698. * Sets the value of the `R1` button
  114699. */
  114700. set buttonR1(value: number);
  114701. /**
  114702. * Gets the value of the Left joystick
  114703. */
  114704. get buttonLeftStick(): number;
  114705. /**
  114706. * Sets the value of the Left joystick
  114707. */
  114708. set buttonLeftStick(value: number);
  114709. /**
  114710. * Gets the value of the Right joystick
  114711. */
  114712. get buttonRightStick(): number;
  114713. /**
  114714. * Sets the value of the Right joystick
  114715. */
  114716. set buttonRightStick(value: number);
  114717. /**
  114718. * Gets the value of D-pad up
  114719. */
  114720. get dPadUp(): number;
  114721. /**
  114722. * Sets the value of D-pad up
  114723. */
  114724. set dPadUp(value: number);
  114725. /**
  114726. * Gets the value of D-pad down
  114727. */
  114728. get dPadDown(): number;
  114729. /**
  114730. * Sets the value of D-pad down
  114731. */
  114732. set dPadDown(value: number);
  114733. /**
  114734. * Gets the value of D-pad left
  114735. */
  114736. get dPadLeft(): number;
  114737. /**
  114738. * Sets the value of D-pad left
  114739. */
  114740. set dPadLeft(value: number);
  114741. /**
  114742. * Gets the value of D-pad right
  114743. */
  114744. get dPadRight(): number;
  114745. /**
  114746. * Sets the value of D-pad right
  114747. */
  114748. set dPadRight(value: number);
  114749. /**
  114750. * Force the gamepad to synchronize with device values
  114751. */
  114752. update(): void;
  114753. /**
  114754. * Disposes the gamepad
  114755. */
  114756. dispose(): void;
  114757. }
  114758. }
  114759. declare module BABYLON {
  114760. /**
  114761. * Manager for handling gamepads
  114762. */
  114763. export class GamepadManager {
  114764. private _scene?;
  114765. private _babylonGamepads;
  114766. private _oneGamepadConnected;
  114767. /** @hidden */
  114768. _isMonitoring: boolean;
  114769. private _gamepadEventSupported;
  114770. private _gamepadSupport?;
  114771. /**
  114772. * observable to be triggered when the gamepad controller has been connected
  114773. */
  114774. onGamepadConnectedObservable: Observable<Gamepad>;
  114775. /**
  114776. * observable to be triggered when the gamepad controller has been disconnected
  114777. */
  114778. onGamepadDisconnectedObservable: Observable<Gamepad>;
  114779. private _onGamepadConnectedEvent;
  114780. private _onGamepadDisconnectedEvent;
  114781. /**
  114782. * Initializes the gamepad manager
  114783. * @param _scene BabylonJS scene
  114784. */
  114785. constructor(_scene?: Scene | undefined);
  114786. /**
  114787. * The gamepads in the game pad manager
  114788. */
  114789. get gamepads(): Gamepad[];
  114790. /**
  114791. * Get the gamepad controllers based on type
  114792. * @param type The type of gamepad controller
  114793. * @returns Nullable gamepad
  114794. */
  114795. getGamepadByType(type?: number): Nullable<Gamepad>;
  114796. /**
  114797. * Disposes the gamepad manager
  114798. */
  114799. dispose(): void;
  114800. private _addNewGamepad;
  114801. private _startMonitoringGamepads;
  114802. private _stopMonitoringGamepads;
  114803. /** @hidden */
  114804. _checkGamepadsStatus(): void;
  114805. private _updateGamepadObjects;
  114806. }
  114807. }
  114808. declare module BABYLON {
  114809. interface Scene {
  114810. /** @hidden */
  114811. _gamepadManager: Nullable<GamepadManager>;
  114812. /**
  114813. * Gets the gamepad manager associated with the scene
  114814. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  114815. */
  114816. gamepadManager: GamepadManager;
  114817. }
  114818. /**
  114819. * Interface representing a free camera inputs manager
  114820. */
  114821. interface FreeCameraInputsManager {
  114822. /**
  114823. * Adds gamepad input support to the FreeCameraInputsManager.
  114824. * @returns the FreeCameraInputsManager
  114825. */
  114826. addGamepad(): FreeCameraInputsManager;
  114827. }
  114828. /**
  114829. * Interface representing an arc rotate camera inputs manager
  114830. */
  114831. interface ArcRotateCameraInputsManager {
  114832. /**
  114833. * Adds gamepad input support to the ArcRotateCamera InputManager.
  114834. * @returns the camera inputs manager
  114835. */
  114836. addGamepad(): ArcRotateCameraInputsManager;
  114837. }
  114838. /**
  114839. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  114840. */
  114841. export class GamepadSystemSceneComponent implements ISceneComponent {
  114842. /**
  114843. * The component name helpfull to identify the component in the list of scene components.
  114844. */
  114845. readonly name: string;
  114846. /**
  114847. * The scene the component belongs to.
  114848. */
  114849. scene: Scene;
  114850. /**
  114851. * Creates a new instance of the component for the given scene
  114852. * @param scene Defines the scene to register the component in
  114853. */
  114854. constructor(scene: Scene);
  114855. /**
  114856. * Registers the component in a given scene
  114857. */
  114858. register(): void;
  114859. /**
  114860. * Rebuilds the elements related to this component in case of
  114861. * context lost for instance.
  114862. */
  114863. rebuild(): void;
  114864. /**
  114865. * Disposes the component and the associated ressources
  114866. */
  114867. dispose(): void;
  114868. private _beforeCameraUpdate;
  114869. }
  114870. }
  114871. declare module BABYLON {
  114872. /**
  114873. * 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,
  114874. * which still works and will still be found in many Playgrounds.
  114875. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114876. */
  114877. export class UniversalCamera extends TouchCamera {
  114878. /**
  114879. * Defines the gamepad rotation sensiblity.
  114880. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114881. */
  114882. get gamepadAngularSensibility(): number;
  114883. set gamepadAngularSensibility(value: number);
  114884. /**
  114885. * Defines the gamepad move sensiblity.
  114886. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114887. */
  114888. get gamepadMoveSensibility(): number;
  114889. set gamepadMoveSensibility(value: number);
  114890. /**
  114891. * 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,
  114892. * which still works and will still be found in many Playgrounds.
  114893. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114894. * @param name Define the name of the camera in the scene
  114895. * @param position Define the start position of the camera in the scene
  114896. * @param scene Define the scene the camera belongs to
  114897. */
  114898. constructor(name: string, position: Vector3, scene: Scene);
  114899. /**
  114900. * Gets the current object class name.
  114901. * @return the class name
  114902. */
  114903. getClassName(): string;
  114904. }
  114905. }
  114906. declare module BABYLON {
  114907. /**
  114908. * This represents a FPS type of camera. This is only here for back compat purpose.
  114909. * Please use the UniversalCamera instead as both are identical.
  114910. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114911. */
  114912. export class GamepadCamera extends UniversalCamera {
  114913. /**
  114914. * Instantiates a new Gamepad Camera
  114915. * This represents a FPS type of camera. This is only here for back compat purpose.
  114916. * Please use the UniversalCamera instead as both are identical.
  114917. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  114918. * @param name Define the name of the camera in the scene
  114919. * @param position Define the start position of the camera in the scene
  114920. * @param scene Define the scene the camera belongs to
  114921. */
  114922. constructor(name: string, position: Vector3, scene: Scene);
  114923. /**
  114924. * Gets the current object class name.
  114925. * @return the class name
  114926. */
  114927. getClassName(): string;
  114928. }
  114929. }
  114930. declare module BABYLON {
  114931. /** @hidden */
  114932. export var passPixelShader: {
  114933. name: string;
  114934. shader: string;
  114935. };
  114936. }
  114937. declare module BABYLON {
  114938. /** @hidden */
  114939. export var passCubePixelShader: {
  114940. name: string;
  114941. shader: string;
  114942. };
  114943. }
  114944. declare module BABYLON {
  114945. /**
  114946. * PassPostProcess which produces an output the same as it's input
  114947. */
  114948. export class PassPostProcess extends PostProcess {
  114949. /**
  114950. * Creates the PassPostProcess
  114951. * @param name The name of the effect.
  114952. * @param options The required width/height ratio to downsize to before computing the render pass.
  114953. * @param camera The camera to apply the render pass to.
  114954. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114955. * @param engine The engine which the post process will be applied. (default: current engine)
  114956. * @param reusable If the post process can be reused on the same frame. (default: false)
  114957. * @param textureType The type of texture to be used when performing the post processing.
  114958. * @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)
  114959. */
  114960. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114961. }
  114962. /**
  114963. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  114964. */
  114965. export class PassCubePostProcess extends PostProcess {
  114966. private _face;
  114967. /**
  114968. * Gets or sets the cube face to display.
  114969. * * 0 is +X
  114970. * * 1 is -X
  114971. * * 2 is +Y
  114972. * * 3 is -Y
  114973. * * 4 is +Z
  114974. * * 5 is -Z
  114975. */
  114976. get face(): number;
  114977. set face(value: number);
  114978. /**
  114979. * Creates the PassCubePostProcess
  114980. * @param name The name of the effect.
  114981. * @param options The required width/height ratio to downsize to before computing the render pass.
  114982. * @param camera The camera to apply the render pass to.
  114983. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  114984. * @param engine The engine which the post process will be applied. (default: current engine)
  114985. * @param reusable If the post process can be reused on the same frame. (default: false)
  114986. * @param textureType The type of texture to be used when performing the post processing.
  114987. * @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)
  114988. */
  114989. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  114990. }
  114991. }
  114992. declare module BABYLON {
  114993. /** @hidden */
  114994. export var anaglyphPixelShader: {
  114995. name: string;
  114996. shader: string;
  114997. };
  114998. }
  114999. declare module BABYLON {
  115000. /**
  115001. * Postprocess used to generate anaglyphic rendering
  115002. */
  115003. export class AnaglyphPostProcess extends PostProcess {
  115004. private _passedProcess;
  115005. /**
  115006. * Creates a new AnaglyphPostProcess
  115007. * @param name defines postprocess name
  115008. * @param options defines creation options or target ratio scale
  115009. * @param rigCameras defines cameras using this postprocess
  115010. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  115011. * @param engine defines hosting engine
  115012. * @param reusable defines if the postprocess will be reused multiple times per frame
  115013. */
  115014. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  115015. }
  115016. }
  115017. declare module BABYLON {
  115018. /**
  115019. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  115020. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115021. */
  115022. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  115023. /**
  115024. * Creates a new AnaglyphArcRotateCamera
  115025. * @param name defines camera name
  115026. * @param alpha defines alpha angle (in radians)
  115027. * @param beta defines beta angle (in radians)
  115028. * @param radius defines radius
  115029. * @param target defines camera target
  115030. * @param interaxialDistance defines distance between each color axis
  115031. * @param scene defines the hosting scene
  115032. */
  115033. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  115034. /**
  115035. * Gets camera class name
  115036. * @returns AnaglyphArcRotateCamera
  115037. */
  115038. getClassName(): string;
  115039. }
  115040. }
  115041. declare module BABYLON {
  115042. /**
  115043. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  115044. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115045. */
  115046. export class AnaglyphFreeCamera extends FreeCamera {
  115047. /**
  115048. * Creates a new AnaglyphFreeCamera
  115049. * @param name defines camera name
  115050. * @param position defines initial position
  115051. * @param interaxialDistance defines distance between each color axis
  115052. * @param scene defines the hosting scene
  115053. */
  115054. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115055. /**
  115056. * Gets camera class name
  115057. * @returns AnaglyphFreeCamera
  115058. */
  115059. getClassName(): string;
  115060. }
  115061. }
  115062. declare module BABYLON {
  115063. /**
  115064. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  115065. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115066. */
  115067. export class AnaglyphGamepadCamera extends GamepadCamera {
  115068. /**
  115069. * Creates a new AnaglyphGamepadCamera
  115070. * @param name defines camera name
  115071. * @param position defines initial position
  115072. * @param interaxialDistance defines distance between each color axis
  115073. * @param scene defines the hosting scene
  115074. */
  115075. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115076. /**
  115077. * Gets camera class name
  115078. * @returns AnaglyphGamepadCamera
  115079. */
  115080. getClassName(): string;
  115081. }
  115082. }
  115083. declare module BABYLON {
  115084. /**
  115085. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  115086. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  115087. */
  115088. export class AnaglyphUniversalCamera extends UniversalCamera {
  115089. /**
  115090. * Creates a new AnaglyphUniversalCamera
  115091. * @param name defines camera name
  115092. * @param position defines initial position
  115093. * @param interaxialDistance defines distance between each color axis
  115094. * @param scene defines the hosting scene
  115095. */
  115096. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  115097. /**
  115098. * Gets camera class name
  115099. * @returns AnaglyphUniversalCamera
  115100. */
  115101. getClassName(): string;
  115102. }
  115103. }
  115104. declare module BABYLON {
  115105. /** @hidden */
  115106. export var stereoscopicInterlacePixelShader: {
  115107. name: string;
  115108. shader: string;
  115109. };
  115110. }
  115111. declare module BABYLON {
  115112. /**
  115113. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  115114. */
  115115. export class StereoscopicInterlacePostProcessI extends PostProcess {
  115116. private _stepSize;
  115117. private _passedProcess;
  115118. /**
  115119. * Initializes a StereoscopicInterlacePostProcessI
  115120. * @param name The name of the effect.
  115121. * @param rigCameras The rig cameras to be appled to the post process
  115122. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  115123. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  115124. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115125. * @param engine The engine which the post process will be applied. (default: current engine)
  115126. * @param reusable If the post process can be reused on the same frame. (default: false)
  115127. */
  115128. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115129. }
  115130. /**
  115131. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  115132. */
  115133. export class StereoscopicInterlacePostProcess extends PostProcess {
  115134. private _stepSize;
  115135. private _passedProcess;
  115136. /**
  115137. * Initializes a StereoscopicInterlacePostProcess
  115138. * @param name The name of the effect.
  115139. * @param rigCameras The rig cameras to be appled to the post process
  115140. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  115141. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  115142. * @param engine The engine which the post process will be applied. (default: current engine)
  115143. * @param reusable If the post process can be reused on the same frame. (default: false)
  115144. */
  115145. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  115146. }
  115147. }
  115148. declare module BABYLON {
  115149. /**
  115150. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  115151. * @see http://doc.babylonjs.com/features/cameras
  115152. */
  115153. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  115154. /**
  115155. * Creates a new StereoscopicArcRotateCamera
  115156. * @param name defines camera name
  115157. * @param alpha defines alpha angle (in radians)
  115158. * @param beta defines beta angle (in radians)
  115159. * @param radius defines radius
  115160. * @param target defines camera target
  115161. * @param interaxialDistance defines distance between each color axis
  115162. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115163. * @param scene defines the hosting scene
  115164. */
  115165. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115166. /**
  115167. * Gets camera class name
  115168. * @returns StereoscopicArcRotateCamera
  115169. */
  115170. getClassName(): string;
  115171. }
  115172. }
  115173. declare module BABYLON {
  115174. /**
  115175. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  115176. * @see http://doc.babylonjs.com/features/cameras
  115177. */
  115178. export class StereoscopicFreeCamera extends FreeCamera {
  115179. /**
  115180. * Creates a new StereoscopicFreeCamera
  115181. * @param name defines camera name
  115182. * @param position defines initial position
  115183. * @param interaxialDistance defines distance between each color axis
  115184. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115185. * @param scene defines the hosting scene
  115186. */
  115187. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115188. /**
  115189. * Gets camera class name
  115190. * @returns StereoscopicFreeCamera
  115191. */
  115192. getClassName(): string;
  115193. }
  115194. }
  115195. declare module BABYLON {
  115196. /**
  115197. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  115198. * @see http://doc.babylonjs.com/features/cameras
  115199. */
  115200. export class StereoscopicGamepadCamera extends GamepadCamera {
  115201. /**
  115202. * Creates a new StereoscopicGamepadCamera
  115203. * @param name defines camera name
  115204. * @param position defines initial position
  115205. * @param interaxialDistance defines distance between each color axis
  115206. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115207. * @param scene defines the hosting scene
  115208. */
  115209. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115210. /**
  115211. * Gets camera class name
  115212. * @returns StereoscopicGamepadCamera
  115213. */
  115214. getClassName(): string;
  115215. }
  115216. }
  115217. declare module BABYLON {
  115218. /**
  115219. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  115220. * @see http://doc.babylonjs.com/features/cameras
  115221. */
  115222. export class StereoscopicUniversalCamera extends UniversalCamera {
  115223. /**
  115224. * Creates a new StereoscopicUniversalCamera
  115225. * @param name defines camera name
  115226. * @param position defines initial position
  115227. * @param interaxialDistance defines distance between each color axis
  115228. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  115229. * @param scene defines the hosting scene
  115230. */
  115231. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  115232. /**
  115233. * Gets camera class name
  115234. * @returns StereoscopicUniversalCamera
  115235. */
  115236. getClassName(): string;
  115237. }
  115238. }
  115239. declare module BABYLON {
  115240. /**
  115241. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  115242. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115243. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115244. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115245. */
  115246. export class VirtualJoysticksCamera extends FreeCamera {
  115247. /**
  115248. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  115249. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  115250. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  115251. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  115252. * @param name Define the name of the camera in the scene
  115253. * @param position Define the start position of the camera in the scene
  115254. * @param scene Define the scene the camera belongs to
  115255. */
  115256. constructor(name: string, position: Vector3, scene: Scene);
  115257. /**
  115258. * Gets the current object class name.
  115259. * @return the class name
  115260. */
  115261. getClassName(): string;
  115262. }
  115263. }
  115264. declare module BABYLON {
  115265. /**
  115266. * This represents all the required metrics to create a VR camera.
  115267. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  115268. */
  115269. export class VRCameraMetrics {
  115270. /**
  115271. * Define the horizontal resolution off the screen.
  115272. */
  115273. hResolution: number;
  115274. /**
  115275. * Define the vertical resolution off the screen.
  115276. */
  115277. vResolution: number;
  115278. /**
  115279. * Define the horizontal screen size.
  115280. */
  115281. hScreenSize: number;
  115282. /**
  115283. * Define the vertical screen size.
  115284. */
  115285. vScreenSize: number;
  115286. /**
  115287. * Define the vertical screen center position.
  115288. */
  115289. vScreenCenter: number;
  115290. /**
  115291. * Define the distance of the eyes to the screen.
  115292. */
  115293. eyeToScreenDistance: number;
  115294. /**
  115295. * Define the distance between both lenses
  115296. */
  115297. lensSeparationDistance: number;
  115298. /**
  115299. * Define the distance between both viewer's eyes.
  115300. */
  115301. interpupillaryDistance: number;
  115302. /**
  115303. * Define the distortion factor of the VR postprocess.
  115304. * Please, touch with care.
  115305. */
  115306. distortionK: number[];
  115307. /**
  115308. * Define the chromatic aberration correction factors for the VR post process.
  115309. */
  115310. chromaAbCorrection: number[];
  115311. /**
  115312. * Define the scale factor of the post process.
  115313. * The smaller the better but the slower.
  115314. */
  115315. postProcessScaleFactor: number;
  115316. /**
  115317. * Define an offset for the lens center.
  115318. */
  115319. lensCenterOffset: number;
  115320. /**
  115321. * Define if the current vr camera should compensate the distortion of the lense or not.
  115322. */
  115323. compensateDistortion: boolean;
  115324. /**
  115325. * Defines if multiview should be enabled when rendering (Default: false)
  115326. */
  115327. multiviewEnabled: boolean;
  115328. /**
  115329. * Gets the rendering aspect ratio based on the provided resolutions.
  115330. */
  115331. get aspectRatio(): number;
  115332. /**
  115333. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  115334. */
  115335. get aspectRatioFov(): number;
  115336. /**
  115337. * @hidden
  115338. */
  115339. get leftHMatrix(): Matrix;
  115340. /**
  115341. * @hidden
  115342. */
  115343. get rightHMatrix(): Matrix;
  115344. /**
  115345. * @hidden
  115346. */
  115347. get leftPreViewMatrix(): Matrix;
  115348. /**
  115349. * @hidden
  115350. */
  115351. get rightPreViewMatrix(): Matrix;
  115352. /**
  115353. * Get the default VRMetrics based on the most generic setup.
  115354. * @returns the default vr metrics
  115355. */
  115356. static GetDefault(): VRCameraMetrics;
  115357. }
  115358. }
  115359. declare module BABYLON {
  115360. /** @hidden */
  115361. export var vrDistortionCorrectionPixelShader: {
  115362. name: string;
  115363. shader: string;
  115364. };
  115365. }
  115366. declare module BABYLON {
  115367. /**
  115368. * VRDistortionCorrectionPostProcess used for mobile VR
  115369. */
  115370. export class VRDistortionCorrectionPostProcess extends PostProcess {
  115371. private _isRightEye;
  115372. private _distortionFactors;
  115373. private _postProcessScaleFactor;
  115374. private _lensCenterOffset;
  115375. private _scaleIn;
  115376. private _scaleFactor;
  115377. private _lensCenter;
  115378. /**
  115379. * Initializes the VRDistortionCorrectionPostProcess
  115380. * @param name The name of the effect.
  115381. * @param camera The camera to apply the render pass to.
  115382. * @param isRightEye If this is for the right eye distortion
  115383. * @param vrMetrics All the required metrics for the VR camera
  115384. */
  115385. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  115386. }
  115387. }
  115388. declare module BABYLON {
  115389. /**
  115390. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  115391. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115392. */
  115393. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  115394. /**
  115395. * Creates a new VRDeviceOrientationArcRotateCamera
  115396. * @param name defines camera name
  115397. * @param alpha defines the camera rotation along the logitudinal axis
  115398. * @param beta defines the camera rotation along the latitudinal axis
  115399. * @param radius defines the camera distance from its target
  115400. * @param target defines the camera target
  115401. * @param scene defines the scene the camera belongs to
  115402. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115403. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115404. */
  115405. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115406. /**
  115407. * Gets camera class name
  115408. * @returns VRDeviceOrientationArcRotateCamera
  115409. */
  115410. getClassName(): string;
  115411. }
  115412. }
  115413. declare module BABYLON {
  115414. /**
  115415. * Camera used to simulate VR rendering (based on FreeCamera)
  115416. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115417. */
  115418. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  115419. /**
  115420. * Creates a new VRDeviceOrientationFreeCamera
  115421. * @param name defines camera name
  115422. * @param position defines the start position of the camera
  115423. * @param scene defines the scene the camera belongs to
  115424. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115425. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115426. */
  115427. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115428. /**
  115429. * Gets camera class name
  115430. * @returns VRDeviceOrientationFreeCamera
  115431. */
  115432. getClassName(): string;
  115433. }
  115434. }
  115435. declare module BABYLON {
  115436. /**
  115437. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  115438. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  115439. */
  115440. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  115441. /**
  115442. * Creates a new VRDeviceOrientationGamepadCamera
  115443. * @param name defines camera name
  115444. * @param position defines the start position of the camera
  115445. * @param scene defines the scene the camera belongs to
  115446. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  115447. * @param vrCameraMetrics defines the vr metrics associated to the camera
  115448. */
  115449. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  115450. /**
  115451. * Gets camera class name
  115452. * @returns VRDeviceOrientationGamepadCamera
  115453. */
  115454. getClassName(): string;
  115455. }
  115456. }
  115457. declare module BABYLON {
  115458. /** @hidden */
  115459. export var imageProcessingPixelShader: {
  115460. name: string;
  115461. shader: string;
  115462. };
  115463. }
  115464. declare module BABYLON {
  115465. /**
  115466. * ImageProcessingPostProcess
  115467. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  115468. */
  115469. export class ImageProcessingPostProcess extends PostProcess {
  115470. /**
  115471. * Default configuration related to image processing available in the PBR Material.
  115472. */
  115473. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  115474. /**
  115475. * Gets the image processing configuration used either in this material.
  115476. */
  115477. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  115478. /**
  115479. * Sets the Default image processing configuration used either in the this material.
  115480. *
  115481. * If sets to null, the scene one is in use.
  115482. */
  115483. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  115484. /**
  115485. * Keep track of the image processing observer to allow dispose and replace.
  115486. */
  115487. private _imageProcessingObserver;
  115488. /**
  115489. * Attaches a new image processing configuration to the PBR Material.
  115490. * @param configuration
  115491. */
  115492. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  115493. /**
  115494. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115495. */
  115496. get colorCurves(): Nullable<ColorCurves>;
  115497. /**
  115498. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  115499. */
  115500. set colorCurves(value: Nullable<ColorCurves>);
  115501. /**
  115502. * Gets wether the color curves effect is enabled.
  115503. */
  115504. get colorCurvesEnabled(): boolean;
  115505. /**
  115506. * Sets wether the color curves effect is enabled.
  115507. */
  115508. set colorCurvesEnabled(value: boolean);
  115509. /**
  115510. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115511. */
  115512. get colorGradingTexture(): Nullable<BaseTexture>;
  115513. /**
  115514. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  115515. */
  115516. set colorGradingTexture(value: Nullable<BaseTexture>);
  115517. /**
  115518. * Gets wether the color grading effect is enabled.
  115519. */
  115520. get colorGradingEnabled(): boolean;
  115521. /**
  115522. * Gets wether the color grading effect is enabled.
  115523. */
  115524. set colorGradingEnabled(value: boolean);
  115525. /**
  115526. * Gets exposure used in the effect.
  115527. */
  115528. get exposure(): number;
  115529. /**
  115530. * Sets exposure used in the effect.
  115531. */
  115532. set exposure(value: number);
  115533. /**
  115534. * Gets wether tonemapping is enabled or not.
  115535. */
  115536. get toneMappingEnabled(): boolean;
  115537. /**
  115538. * Sets wether tonemapping is enabled or not
  115539. */
  115540. set toneMappingEnabled(value: boolean);
  115541. /**
  115542. * Gets the type of tone mapping effect.
  115543. */
  115544. get toneMappingType(): number;
  115545. /**
  115546. * Sets the type of tone mapping effect.
  115547. */
  115548. set toneMappingType(value: number);
  115549. /**
  115550. * Gets contrast used in the effect.
  115551. */
  115552. get contrast(): number;
  115553. /**
  115554. * Sets contrast used in the effect.
  115555. */
  115556. set contrast(value: number);
  115557. /**
  115558. * Gets Vignette stretch size.
  115559. */
  115560. get vignetteStretch(): number;
  115561. /**
  115562. * Sets Vignette stretch size.
  115563. */
  115564. set vignetteStretch(value: number);
  115565. /**
  115566. * Gets Vignette centre X Offset.
  115567. */
  115568. get vignetteCentreX(): number;
  115569. /**
  115570. * Sets Vignette centre X Offset.
  115571. */
  115572. set vignetteCentreX(value: number);
  115573. /**
  115574. * Gets Vignette centre Y Offset.
  115575. */
  115576. get vignetteCentreY(): number;
  115577. /**
  115578. * Sets Vignette centre Y Offset.
  115579. */
  115580. set vignetteCentreY(value: number);
  115581. /**
  115582. * Gets Vignette weight or intensity of the vignette effect.
  115583. */
  115584. get vignetteWeight(): number;
  115585. /**
  115586. * Sets Vignette weight or intensity of the vignette effect.
  115587. */
  115588. set vignetteWeight(value: number);
  115589. /**
  115590. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115591. * if vignetteEnabled is set to true.
  115592. */
  115593. get vignetteColor(): Color4;
  115594. /**
  115595. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  115596. * if vignetteEnabled is set to true.
  115597. */
  115598. set vignetteColor(value: Color4);
  115599. /**
  115600. * Gets Camera field of view used by the Vignette effect.
  115601. */
  115602. get vignetteCameraFov(): number;
  115603. /**
  115604. * Sets Camera field of view used by the Vignette effect.
  115605. */
  115606. set vignetteCameraFov(value: number);
  115607. /**
  115608. * Gets the vignette blend mode allowing different kind of effect.
  115609. */
  115610. get vignetteBlendMode(): number;
  115611. /**
  115612. * Sets the vignette blend mode allowing different kind of effect.
  115613. */
  115614. set vignetteBlendMode(value: number);
  115615. /**
  115616. * Gets wether the vignette effect is enabled.
  115617. */
  115618. get vignetteEnabled(): boolean;
  115619. /**
  115620. * Sets wether the vignette effect is enabled.
  115621. */
  115622. set vignetteEnabled(value: boolean);
  115623. private _fromLinearSpace;
  115624. /**
  115625. * Gets wether the input of the processing is in Gamma or Linear Space.
  115626. */
  115627. get fromLinearSpace(): boolean;
  115628. /**
  115629. * Sets wether the input of the processing is in Gamma or Linear Space.
  115630. */
  115631. set fromLinearSpace(value: boolean);
  115632. /**
  115633. * Defines cache preventing GC.
  115634. */
  115635. private _defines;
  115636. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  115637. /**
  115638. * "ImageProcessingPostProcess"
  115639. * @returns "ImageProcessingPostProcess"
  115640. */
  115641. getClassName(): string;
  115642. protected _updateParameters(): void;
  115643. dispose(camera?: Camera): void;
  115644. }
  115645. }
  115646. declare module BABYLON {
  115647. /**
  115648. * Class containing static functions to help procedurally build meshes
  115649. */
  115650. export class GroundBuilder {
  115651. /**
  115652. * Creates a ground mesh
  115653. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  115654. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  115655. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  115656. * @param name defines the name of the mesh
  115657. * @param options defines the options used to create the mesh
  115658. * @param scene defines the hosting scene
  115659. * @returns the ground mesh
  115660. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  115661. */
  115662. static CreateGround(name: string, options: {
  115663. width?: number;
  115664. height?: number;
  115665. subdivisions?: number;
  115666. subdivisionsX?: number;
  115667. subdivisionsY?: number;
  115668. updatable?: boolean;
  115669. }, scene: any): Mesh;
  115670. /**
  115671. * Creates a tiled ground mesh
  115672. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  115673. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  115674. * * 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
  115675. * * 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
  115676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115677. * @param name defines the name of the mesh
  115678. * @param options defines the options used to create the mesh
  115679. * @param scene defines the hosting scene
  115680. * @returns the tiled ground mesh
  115681. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  115682. */
  115683. static CreateTiledGround(name: string, options: {
  115684. xmin: number;
  115685. zmin: number;
  115686. xmax: number;
  115687. zmax: number;
  115688. subdivisions?: {
  115689. w: number;
  115690. h: number;
  115691. };
  115692. precision?: {
  115693. w: number;
  115694. h: number;
  115695. };
  115696. updatable?: boolean;
  115697. }, scene?: Nullable<Scene>): Mesh;
  115698. /**
  115699. * Creates a ground mesh from a height map
  115700. * * The parameter `url` sets the URL of the height map image resource.
  115701. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  115702. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  115703. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  115704. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  115705. * * 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.
  115706. * * 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).
  115707. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  115708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115709. * @param name defines the name of the mesh
  115710. * @param url defines the url to the height map
  115711. * @param options defines the options used to create the mesh
  115712. * @param scene defines the hosting scene
  115713. * @returns the ground mesh
  115714. * @see https://doc.babylonjs.com/babylon101/height_map
  115715. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  115716. */
  115717. static CreateGroundFromHeightMap(name: string, url: string, options: {
  115718. width?: number;
  115719. height?: number;
  115720. subdivisions?: number;
  115721. minHeight?: number;
  115722. maxHeight?: number;
  115723. colorFilter?: Color3;
  115724. alphaFilter?: number;
  115725. updatable?: boolean;
  115726. onReady?: (mesh: GroundMesh) => void;
  115727. }, scene?: Nullable<Scene>): GroundMesh;
  115728. }
  115729. }
  115730. declare module BABYLON {
  115731. /**
  115732. * Class containing static functions to help procedurally build meshes
  115733. */
  115734. export class TorusBuilder {
  115735. /**
  115736. * Creates a torus mesh
  115737. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  115738. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  115739. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  115740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115741. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115743. * @param name defines the name of the mesh
  115744. * @param options defines the options used to create the mesh
  115745. * @param scene defines the hosting scene
  115746. * @returns the torus mesh
  115747. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  115748. */
  115749. static CreateTorus(name: string, options: {
  115750. diameter?: number;
  115751. thickness?: number;
  115752. tessellation?: number;
  115753. updatable?: boolean;
  115754. sideOrientation?: number;
  115755. frontUVs?: Vector4;
  115756. backUVs?: Vector4;
  115757. }, scene: any): Mesh;
  115758. }
  115759. }
  115760. declare module BABYLON {
  115761. /**
  115762. * Class containing static functions to help procedurally build meshes
  115763. */
  115764. export class CylinderBuilder {
  115765. /**
  115766. * Creates a cylinder or a cone mesh
  115767. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  115768. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  115769. * * 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.
  115770. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  115771. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  115772. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  115773. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  115774. * * 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).
  115775. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  115776. * * 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).
  115777. * * 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
  115778. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  115779. * * 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
  115780. * * 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.
  115781. * * If `enclose` is false, a ring surface is one element.
  115782. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  115783. * * 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
  115784. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  115785. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  115786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  115787. * @param name defines the name of the mesh
  115788. * @param options defines the options used to create the mesh
  115789. * @param scene defines the hosting scene
  115790. * @returns the cylinder mesh
  115791. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  115792. */
  115793. static CreateCylinder(name: string, options: {
  115794. height?: number;
  115795. diameterTop?: number;
  115796. diameterBottom?: number;
  115797. diameter?: number;
  115798. tessellation?: number;
  115799. subdivisions?: number;
  115800. arc?: number;
  115801. faceColors?: Color4[];
  115802. faceUV?: Vector4[];
  115803. updatable?: boolean;
  115804. hasRings?: boolean;
  115805. enclose?: boolean;
  115806. cap?: number;
  115807. sideOrientation?: number;
  115808. frontUVs?: Vector4;
  115809. backUVs?: Vector4;
  115810. }, scene: any): Mesh;
  115811. }
  115812. }
  115813. declare module BABYLON {
  115814. /**
  115815. * States of the webXR experience
  115816. */
  115817. export enum WebXRState {
  115818. /**
  115819. * Transitioning to being in XR mode
  115820. */
  115821. ENTERING_XR = 0,
  115822. /**
  115823. * Transitioning to non XR mode
  115824. */
  115825. EXITING_XR = 1,
  115826. /**
  115827. * In XR mode and presenting
  115828. */
  115829. IN_XR = 2,
  115830. /**
  115831. * Not entered XR mode
  115832. */
  115833. NOT_IN_XR = 3
  115834. }
  115835. /**
  115836. * Abstraction of the XR render target
  115837. */
  115838. export interface WebXRRenderTarget extends IDisposable {
  115839. /**
  115840. * xrpresent context of the canvas which can be used to display/mirror xr content
  115841. */
  115842. canvasContext: WebGLRenderingContext;
  115843. /**
  115844. * xr layer for the canvas
  115845. */
  115846. xrLayer: Nullable<XRWebGLLayer>;
  115847. /**
  115848. * Initializes the xr layer for the session
  115849. * @param xrSession xr session
  115850. * @returns a promise that will resolve once the XR Layer has been created
  115851. */
  115852. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115853. }
  115854. }
  115855. declare module BABYLON {
  115856. /**
  115857. * COnfiguration object for WebXR output canvas
  115858. */
  115859. export class WebXRManagedOutputCanvasOptions {
  115860. /**
  115861. * Options for this XR Layer output
  115862. */
  115863. canvasOptions?: XRWebGLLayerOptions;
  115864. /**
  115865. * CSS styling for a newly created canvas (if not provided)
  115866. */
  115867. newCanvasCssStyle?: string;
  115868. /**
  115869. * An optional canvas in case you wish to create it yourself and provide it here.
  115870. * If not provided, a new canvas will be created
  115871. */
  115872. canvasElement?: HTMLCanvasElement;
  115873. /**
  115874. * Get the default values of the configuration object
  115875. * @returns default values of this configuration object
  115876. */
  115877. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  115878. }
  115879. /**
  115880. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  115881. */
  115882. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  115883. private _options;
  115884. private _engine;
  115885. private _canvas;
  115886. /**
  115887. * Rendering context of the canvas which can be used to display/mirror xr content
  115888. */
  115889. canvasContext: WebGLRenderingContext;
  115890. /**
  115891. * xr layer for the canvas
  115892. */
  115893. xrLayer: Nullable<XRWebGLLayer>;
  115894. /**
  115895. * Initializes the xr layer for the session
  115896. * @param xrSession xr session
  115897. * @returns a promise that will resolve once the XR Layer has been created
  115898. */
  115899. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  115900. /**
  115901. * Initializes the canvas to be added/removed upon entering/exiting xr
  115902. * @param _xrSessionManager The XR Session manager
  115903. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  115904. */
  115905. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  115906. /**
  115907. * Disposes of the object
  115908. */
  115909. dispose(): void;
  115910. private _setManagedOutputCanvas;
  115911. private _addCanvas;
  115912. private _removeCanvas;
  115913. }
  115914. }
  115915. declare module BABYLON {
  115916. /**
  115917. * Manages an XRSession to work with Babylon's engine
  115918. * @see https://doc.babylonjs.com/how_to/webxr
  115919. */
  115920. export class WebXRSessionManager implements IDisposable {
  115921. /** The scene which the session should be created for */
  115922. scene: Scene;
  115923. /**
  115924. * Fires every time a new xrFrame arrives which can be used to update the camera
  115925. */
  115926. onXRFrameObservable: Observable<XRFrame>;
  115927. /**
  115928. * Fires when the xr session is ended either by the device or manually done
  115929. */
  115930. onXRSessionEnded: Observable<any>;
  115931. /**
  115932. * Fires when the xr session is ended either by the device or manually done
  115933. */
  115934. onXRSessionInit: Observable<XRSession>;
  115935. /**
  115936. * Fires when the reference space changed
  115937. */
  115938. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  115939. /**
  115940. * Underlying xr session
  115941. */
  115942. session: XRSession;
  115943. /**
  115944. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  115945. * or get the offset the player is currently at.
  115946. */
  115947. viewerReferenceSpace: XRReferenceSpace;
  115948. private _referenceSpace;
  115949. /**
  115950. * The current reference space used in this session. This reference space can constantly change!
  115951. * It is mainly used to offset the camera's position.
  115952. */
  115953. get referenceSpace(): XRReferenceSpace;
  115954. /**
  115955. * Set a new reference space and triggers the observable
  115956. */
  115957. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  115958. /**
  115959. * The base reference space from which the session started. good if you want to reset your
  115960. * reference space
  115961. */
  115962. baseReferenceSpace: XRReferenceSpace;
  115963. /**
  115964. * Used just in case of a failure to initialize an immersive session.
  115965. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  115966. */
  115967. defaultHeightCompensation: number;
  115968. /**
  115969. * Current XR frame
  115970. */
  115971. currentFrame: Nullable<XRFrame>;
  115972. /** WebXR timestamp updated every frame */
  115973. currentTimestamp: number;
  115974. private _xrNavigator;
  115975. private baseLayer;
  115976. private _rttProvider;
  115977. private _sessionEnded;
  115978. /**
  115979. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  115980. * @param scene The scene which the session should be created for
  115981. */
  115982. constructor(
  115983. /** The scene which the session should be created for */
  115984. scene: Scene);
  115985. /**
  115986. * Initializes the manager
  115987. * After initialization enterXR can be called to start an XR session
  115988. * @returns Promise which resolves after it is initialized
  115989. */
  115990. initializeAsync(): Promise<void>;
  115991. /**
  115992. * Initializes an xr session
  115993. * @param xrSessionMode mode to initialize
  115994. * @param xrSessionInit defines optional and required values to pass to the session builder
  115995. * @returns a promise which will resolve once the session has been initialized
  115996. */
  115997. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  115998. /**
  115999. * Sets the reference space on the xr session
  116000. * @param referenceSpaceType space to set
  116001. * @returns a promise that will resolve once the reference space has been set
  116002. */
  116003. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  116004. /**
  116005. * Resets the reference space to the one started the session
  116006. */
  116007. resetReferenceSpace(): void;
  116008. /**
  116009. * Updates the render state of the session
  116010. * @param state state to set
  116011. * @returns a promise that resolves once the render state has been updated
  116012. */
  116013. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  116014. /**
  116015. * Starts rendering to the xr layer
  116016. */
  116017. runXRRenderLoop(): void;
  116018. /**
  116019. * Gets the correct render target texture to be rendered this frame for this eye
  116020. * @param eye the eye for which to get the render target
  116021. * @returns the render target for the specified eye
  116022. */
  116023. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  116024. /**
  116025. * Stops the xrSession and restores the renderloop
  116026. * @returns Promise which resolves after it exits XR
  116027. */
  116028. exitXRAsync(): Promise<void>;
  116029. /**
  116030. * Checks if a session would be supported for the creation options specified
  116031. * @param sessionMode session mode to check if supported eg. immersive-vr
  116032. * @returns A Promise that resolves to true if supported and false if not
  116033. */
  116034. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116035. /**
  116036. * Creates a WebXRRenderTarget object for the XR session
  116037. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  116038. * @param options optional options to provide when creating a new render target
  116039. * @returns a WebXR render target to which the session can render
  116040. */
  116041. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  116042. /**
  116043. * @hidden
  116044. * Converts the render layer of xrSession to a render target
  116045. * @param session session to create render target for
  116046. * @param scene scene the new render target should be created for
  116047. * @param baseLayer the webgl layer to create the render target for
  116048. */
  116049. static _CreateRenderTargetTextureFromSession(_session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  116050. /**
  116051. * Disposes of the session manager
  116052. */
  116053. dispose(): void;
  116054. /**
  116055. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  116056. * @param sessionMode defines the session to test
  116057. * @returns a promise with boolean as final value
  116058. */
  116059. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  116060. }
  116061. }
  116062. declare module BABYLON {
  116063. /**
  116064. * WebXR Camera which holds the views for the xrSession
  116065. * @see https://doc.babylonjs.com/how_to/webxr_camera
  116066. */
  116067. export class WebXRCamera extends FreeCamera {
  116068. private _xrSessionManager;
  116069. private _firstFrame;
  116070. private _referenceQuaternion;
  116071. private _referencedPosition;
  116072. private _xrInvPositionCache;
  116073. private _xrInvQuaternionCache;
  116074. /**
  116075. * Should position compensation execute on first frame.
  116076. * This is used when copying the position from a native (non XR) camera
  116077. */
  116078. compensateOnFirstFrame: boolean;
  116079. /**
  116080. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  116081. * @param name the name of the camera
  116082. * @param scene the scene to add the camera to
  116083. * @param _xrSessionManager a constructed xr session manager
  116084. */
  116085. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  116086. /**
  116087. * Return the user's height, unrelated to the current ground.
  116088. * This will be the y position of this camera, when ground level is 0.
  116089. */
  116090. get realWorldHeight(): number;
  116091. /** @hidden */
  116092. _updateForDualEyeDebugging(): void;
  116093. /**
  116094. * Sets this camera's transformation based on a non-vr camera
  116095. * @param otherCamera the non-vr camera to copy the transformation from
  116096. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  116097. */
  116098. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  116099. private _updateFromXRSession;
  116100. private _updateNumberOfRigCameras;
  116101. private _updateReferenceSpace;
  116102. private _updateReferenceSpaceOffset;
  116103. }
  116104. }
  116105. declare module BABYLON {
  116106. /**
  116107. * Defining the interface required for a (webxr) feature
  116108. */
  116109. export interface IWebXRFeature extends IDisposable {
  116110. /**
  116111. * Is this feature attached
  116112. */
  116113. attached: boolean;
  116114. /**
  116115. * Should auto-attach be disabled?
  116116. */
  116117. disableAutoAttach: boolean;
  116118. /**
  116119. * Attach the feature to the session
  116120. * Will usually be called by the features manager
  116121. *
  116122. * @param force should attachment be forced (even when already attached)
  116123. * @returns true if successful.
  116124. */
  116125. attach(force?: boolean): boolean;
  116126. /**
  116127. * Detach the feature from the session
  116128. * Will usually be called by the features manager
  116129. *
  116130. * @returns true if successful.
  116131. */
  116132. detach(): boolean;
  116133. }
  116134. /**
  116135. * A list of the currently available features without referencing them
  116136. */
  116137. export class WebXRFeatureName {
  116138. /**
  116139. * The name of the hit test feature
  116140. */
  116141. static HIT_TEST: string;
  116142. /**
  116143. * The name of the anchor system feature
  116144. */
  116145. static ANCHOR_SYSTEM: string;
  116146. /**
  116147. * The name of the background remover feature
  116148. */
  116149. static BACKGROUND_REMOVER: string;
  116150. /**
  116151. * The name of the pointer selection feature
  116152. */
  116153. static POINTER_SELECTION: string;
  116154. /**
  116155. * The name of the teleportation feature
  116156. */
  116157. static TELEPORTATION: string;
  116158. /**
  116159. * The name of the plane detection feature
  116160. */
  116161. static PLANE_DETECTION: string;
  116162. /**
  116163. * physics impostors for xr controllers feature
  116164. */
  116165. static PHYSICS_CONTROLLERS: string;
  116166. }
  116167. /**
  116168. * Defining the constructor of a feature. Used to register the modules.
  116169. */
  116170. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  116171. /**
  116172. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  116173. * It is mainly used in AR sessions.
  116174. *
  116175. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  116176. */
  116177. export class WebXRFeaturesManager implements IDisposable {
  116178. private _xrSessionManager;
  116179. private static readonly _AvailableFeatures;
  116180. /**
  116181. * Used to register a module. After calling this function a developer can use this feature in the scene.
  116182. * Mainly used internally.
  116183. *
  116184. * @param featureName the name of the feature to register
  116185. * @param constructorFunction the function used to construct the module
  116186. * @param version the (babylon) version of the module
  116187. * @param stable is that a stable version of this module
  116188. */
  116189. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  116190. /**
  116191. * Returns a constructor of a specific feature.
  116192. *
  116193. * @param featureName the name of the feature to construct
  116194. * @param version the version of the feature to load
  116195. * @param xrSessionManager the xrSessionManager. Used to construct the module
  116196. * @param options optional options provided to the module.
  116197. * @returns a function that, when called, will return a new instance of this feature
  116198. */
  116199. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  116200. /**
  116201. * Return the latest unstable version of this feature
  116202. * @param featureName the name of the feature to search
  116203. * @returns the version number. if not found will return -1
  116204. */
  116205. static GetLatestVersionOfFeature(featureName: string): number;
  116206. /**
  116207. * Return the latest stable version of this feature
  116208. * @param featureName the name of the feature to search
  116209. * @returns the version number. if not found will return -1
  116210. */
  116211. static GetStableVersionOfFeature(featureName: string): number;
  116212. /**
  116213. * Can be used to return the list of features currently registered
  116214. *
  116215. * @returns an Array of available features
  116216. */
  116217. static GetAvailableFeatures(): string[];
  116218. /**
  116219. * Gets the versions available for a specific feature
  116220. * @param featureName the name of the feature
  116221. * @returns an array with the available versions
  116222. */
  116223. static GetAvailableVersions(featureName: string): string[];
  116224. private _features;
  116225. /**
  116226. * constructs a new features manages.
  116227. *
  116228. * @param _xrSessionManager an instance of WebXRSessionManager
  116229. */
  116230. constructor(_xrSessionManager: WebXRSessionManager);
  116231. /**
  116232. * 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.
  116233. * 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.
  116234. *
  116235. * @param featureName the name of the feature to load or the class of the feature
  116236. * @param version optional version to load. if not provided the latest version will be enabled
  116237. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  116238. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  116239. * @returns a new constructed feature or throws an error if feature not found.
  116240. */
  116241. enableFeature(featureName: string | {
  116242. Name: string;
  116243. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  116244. /**
  116245. * Used to disable an already-enabled feature
  116246. * The feature will be disposed and will be recreated once enabled.
  116247. * @param featureName the feature to disable
  116248. * @returns true if disable was successful
  116249. */
  116250. disableFeature(featureName: string | {
  116251. Name: string;
  116252. }): boolean;
  116253. /**
  116254. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  116255. * Can be used during a session to start a feature
  116256. * @param featureName the name of feature to attach
  116257. */
  116258. attachFeature(featureName: string): void;
  116259. /**
  116260. * Can be used inside a session or when the session ends to detach a specific feature
  116261. * @param featureName the name of the feature to detach
  116262. */
  116263. detachFeature(featureName: string): void;
  116264. /**
  116265. * Get the list of enabled features
  116266. * @returns an array of enabled features
  116267. */
  116268. getEnabledFeatures(): string[];
  116269. /**
  116270. * get the implementation of an enabled feature.
  116271. * @param featureName the name of the feature to load
  116272. * @returns the feature class, if found
  116273. */
  116274. getEnabledFeature(featureName: string): IWebXRFeature;
  116275. /**
  116276. * dispose this features manager
  116277. */
  116278. dispose(): void;
  116279. }
  116280. }
  116281. declare module BABYLON {
  116282. /**
  116283. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  116284. * @see https://doc.babylonjs.com/how_to/webxr
  116285. */
  116286. export class WebXRExperienceHelper implements IDisposable {
  116287. private scene;
  116288. /**
  116289. * Camera used to render xr content
  116290. */
  116291. camera: WebXRCamera;
  116292. /**
  116293. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  116294. */
  116295. state: WebXRState;
  116296. private _setState;
  116297. /**
  116298. * Fires when the state of the experience helper has changed
  116299. */
  116300. onStateChangedObservable: Observable<WebXRState>;
  116301. /**
  116302. * Observers registered here will be triggered after the camera's initial transformation is set
  116303. * This can be used to set a different ground level or an extra rotation.
  116304. *
  116305. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  116306. * to the position set after this observable is done executing.
  116307. */
  116308. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  116309. /** Session manager used to keep track of xr session */
  116310. sessionManager: WebXRSessionManager;
  116311. /** A features manager for this xr session */
  116312. featuresManager: WebXRFeaturesManager;
  116313. private _nonVRCamera;
  116314. private _originalSceneAutoClear;
  116315. private _supported;
  116316. /**
  116317. * Creates the experience helper
  116318. * @param scene the scene to attach the experience helper to
  116319. * @returns a promise for the experience helper
  116320. */
  116321. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  116322. /**
  116323. * Creates a WebXRExperienceHelper
  116324. * @param scene The scene the helper should be created in
  116325. */
  116326. private constructor();
  116327. /**
  116328. * Exits XR mode and returns the scene to its original state
  116329. * @returns promise that resolves after xr mode has exited
  116330. */
  116331. exitXRAsync(): Promise<void>;
  116332. /**
  116333. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  116334. * @param sessionMode options for the XR session
  116335. * @param referenceSpaceType frame of reference of the XR session
  116336. * @param renderTarget the output canvas that will be used to enter XR mode
  116337. * @returns promise that resolves after xr mode has entered
  116338. */
  116339. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  116340. /**
  116341. * Disposes of the experience helper
  116342. */
  116343. dispose(): void;
  116344. private _nonXRToXRCamera;
  116345. }
  116346. }
  116347. declare module BABYLON {
  116348. /**
  116349. * X-Y values for axes in WebXR
  116350. */
  116351. export interface IWebXRMotionControllerAxesValue {
  116352. /**
  116353. * The value of the x axis
  116354. */
  116355. x: number;
  116356. /**
  116357. * The value of the y-axis
  116358. */
  116359. y: number;
  116360. }
  116361. /**
  116362. * changed / previous values for the values of this component
  116363. */
  116364. export interface IWebXRMotionControllerComponentChangesValues<T> {
  116365. /**
  116366. * current (this frame) value
  116367. */
  116368. current: T;
  116369. /**
  116370. * previous (last change) value
  116371. */
  116372. previous: T;
  116373. }
  116374. /**
  116375. * Represents changes in the component between current frame and last values recorded
  116376. */
  116377. export interface IWebXRMotionControllerComponentChanges {
  116378. /**
  116379. * will be populated with previous and current values if touched changed
  116380. */
  116381. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116382. /**
  116383. * will be populated with previous and current values if pressed changed
  116384. */
  116385. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  116386. /**
  116387. * will be populated with previous and current values if value changed
  116388. */
  116389. value?: IWebXRMotionControllerComponentChangesValues<number>;
  116390. /**
  116391. * will be populated with previous and current values if axes changed
  116392. */
  116393. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  116394. }
  116395. /**
  116396. * This class represents a single component (for example button or thumbstick) of a motion controller
  116397. */
  116398. export class WebXRControllerComponent implements IDisposable {
  116399. /**
  116400. * the id of this component
  116401. */
  116402. id: string;
  116403. /**
  116404. * the type of the component
  116405. */
  116406. type: MotionControllerComponentType;
  116407. private _buttonIndex;
  116408. private _axesIndices;
  116409. /**
  116410. * Thumbstick component type
  116411. */
  116412. static THUMBSTICK_TYPE: MotionControllerComponentType;
  116413. /**
  116414. * Touchpad component type
  116415. */
  116416. static TOUCHPAD_TYPE: MotionControllerComponentType;
  116417. /**
  116418. * trigger component type
  116419. */
  116420. static TRIGGER_TYPE: MotionControllerComponentType;
  116421. /**
  116422. * squeeze component type
  116423. */
  116424. static SQUEEZE_TYPE: MotionControllerComponentType;
  116425. /**
  116426. * button component type
  116427. */
  116428. static BUTTON_TYPE: MotionControllerComponentType;
  116429. /**
  116430. * Observers registered here will be triggered when the state of a button changes
  116431. * State change is either pressed / touched / value
  116432. */
  116433. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  116434. /**
  116435. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  116436. * the axes data changes
  116437. */
  116438. onAxisValueChangedObservable: Observable<{
  116439. x: number;
  116440. y: number;
  116441. }>;
  116442. private _currentValue;
  116443. private _touched;
  116444. private _pressed;
  116445. private _axes;
  116446. private _changes;
  116447. private _hasChanges;
  116448. /**
  116449. * Return whether or not the component changed the last frame
  116450. */
  116451. get hasChanges(): boolean;
  116452. /**
  116453. * Creates a new component for a motion controller.
  116454. * It is created by the motion controller itself
  116455. *
  116456. * @param id the id of this component
  116457. * @param type the type of the component
  116458. * @param _buttonIndex index in the buttons array of the gamepad
  116459. * @param _axesIndices indices of the values in the axes array of the gamepad
  116460. */
  116461. constructor(
  116462. /**
  116463. * the id of this component
  116464. */
  116465. id: string,
  116466. /**
  116467. * the type of the component
  116468. */
  116469. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  116470. /**
  116471. * Get the current value of this component
  116472. */
  116473. get value(): number;
  116474. /**
  116475. * is the button currently pressed
  116476. */
  116477. get pressed(): boolean;
  116478. /**
  116479. * is the button currently touched
  116480. */
  116481. get touched(): boolean;
  116482. /**
  116483. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  116484. */
  116485. get axes(): IWebXRMotionControllerAxesValue;
  116486. /**
  116487. * Get the changes. Elements will be populated only if they changed with their previous and current value
  116488. */
  116489. get changes(): IWebXRMotionControllerComponentChanges;
  116490. /**
  116491. * Is this component a button (hence - pressable)
  116492. * @returns true if can be pressed
  116493. */
  116494. isButton(): boolean;
  116495. /**
  116496. * Are there axes correlating to this component
  116497. * @return true is axes data is available
  116498. */
  116499. isAxes(): boolean;
  116500. /**
  116501. * update this component using the gamepad object it is in. Called on every frame
  116502. * @param nativeController the native gamepad controller object
  116503. */
  116504. update(nativeController: IMinimalMotionControllerObject): void;
  116505. /**
  116506. * Dispose this component
  116507. */
  116508. dispose(): void;
  116509. }
  116510. }
  116511. declare module BABYLON {
  116512. /**
  116513. * Class used to represent data loading progression
  116514. */
  116515. export class SceneLoaderProgressEvent {
  116516. /** defines if data length to load can be evaluated */
  116517. readonly lengthComputable: boolean;
  116518. /** defines the loaded data length */
  116519. readonly loaded: number;
  116520. /** defines the data length to load */
  116521. readonly total: number;
  116522. /**
  116523. * Create a new progress event
  116524. * @param lengthComputable defines if data length to load can be evaluated
  116525. * @param loaded defines the loaded data length
  116526. * @param total defines the data length to load
  116527. */
  116528. constructor(
  116529. /** defines if data length to load can be evaluated */
  116530. lengthComputable: boolean,
  116531. /** defines the loaded data length */
  116532. loaded: number,
  116533. /** defines the data length to load */
  116534. total: number);
  116535. /**
  116536. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  116537. * @param event defines the source event
  116538. * @returns a new SceneLoaderProgressEvent
  116539. */
  116540. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  116541. }
  116542. /**
  116543. * Interface used by SceneLoader plugins to define supported file extensions
  116544. */
  116545. export interface ISceneLoaderPluginExtensions {
  116546. /**
  116547. * Defines the list of supported extensions
  116548. */
  116549. [extension: string]: {
  116550. isBinary: boolean;
  116551. };
  116552. }
  116553. /**
  116554. * Interface used by SceneLoader plugin factory
  116555. */
  116556. export interface ISceneLoaderPluginFactory {
  116557. /**
  116558. * Defines the name of the factory
  116559. */
  116560. name: string;
  116561. /**
  116562. * Function called to create a new plugin
  116563. * @return the new plugin
  116564. */
  116565. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  116566. /**
  116567. * The callback that returns true if the data can be directly loaded.
  116568. * @param data string containing the file data
  116569. * @returns if the data can be loaded directly
  116570. */
  116571. canDirectLoad?(data: string): boolean;
  116572. }
  116573. /**
  116574. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  116575. */
  116576. export interface ISceneLoaderPluginBase {
  116577. /**
  116578. * The friendly name of this plugin.
  116579. */
  116580. name: string;
  116581. /**
  116582. * The file extensions supported by this plugin.
  116583. */
  116584. extensions: string | ISceneLoaderPluginExtensions;
  116585. /**
  116586. * The callback called when loading from a url.
  116587. * @param scene scene loading this url
  116588. * @param url url to load
  116589. * @param onSuccess callback called when the file successfully loads
  116590. * @param onProgress callback called while file is loading (if the server supports this mode)
  116591. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116592. * @param onError callback called when the file fails to load
  116593. * @returns a file request object
  116594. */
  116595. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116596. /**
  116597. * The callback called when loading from a file object.
  116598. * @param scene scene loading this file
  116599. * @param file defines the file to load
  116600. * @param onSuccess defines the callback to call when data is loaded
  116601. * @param onProgress defines the callback to call during loading process
  116602. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  116603. * @param onError defines the callback to call when an error occurs
  116604. * @returns a file request object
  116605. */
  116606. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  116607. /**
  116608. * The callback that returns true if the data can be directly loaded.
  116609. * @param data string containing the file data
  116610. * @returns if the data can be loaded directly
  116611. */
  116612. canDirectLoad?(data: string): boolean;
  116613. /**
  116614. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  116615. * @param scene scene loading this data
  116616. * @param data string containing the data
  116617. * @returns data to pass to the plugin
  116618. */
  116619. directLoad?(scene: Scene, data: string): any;
  116620. /**
  116621. * The callback that allows custom handling of the root url based on the response url.
  116622. * @param rootUrl the original root url
  116623. * @param responseURL the response url if available
  116624. * @returns the new root url
  116625. */
  116626. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  116627. }
  116628. /**
  116629. * Interface used to define a SceneLoader plugin
  116630. */
  116631. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  116632. /**
  116633. * Import meshes into a scene.
  116634. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116635. * @param scene The scene to import into
  116636. * @param data The data to import
  116637. * @param rootUrl The root url for scene and resources
  116638. * @param meshes The meshes array to import into
  116639. * @param particleSystems The particle systems array to import into
  116640. * @param skeletons The skeletons array to import into
  116641. * @param onError The callback when import fails
  116642. * @returns True if successful or false otherwise
  116643. */
  116644. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  116645. /**
  116646. * Load into a scene.
  116647. * @param scene The scene to load into
  116648. * @param data The data to import
  116649. * @param rootUrl The root url for scene and resources
  116650. * @param onError The callback when import fails
  116651. * @returns True if successful or false otherwise
  116652. */
  116653. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  116654. /**
  116655. * Load into an asset container.
  116656. * @param scene The scene to load into
  116657. * @param data The data to import
  116658. * @param rootUrl The root url for scene and resources
  116659. * @param onError The callback when import fails
  116660. * @returns The loaded asset container
  116661. */
  116662. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  116663. }
  116664. /**
  116665. * Interface used to define an async SceneLoader plugin
  116666. */
  116667. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  116668. /**
  116669. * Import meshes into a scene.
  116670. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116671. * @param scene The scene to import into
  116672. * @param data The data to import
  116673. * @param rootUrl The root url for scene and resources
  116674. * @param onProgress The callback when the load progresses
  116675. * @param fileName Defines the name of the file to load
  116676. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  116677. */
  116678. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  116679. meshes: AbstractMesh[];
  116680. particleSystems: IParticleSystem[];
  116681. skeletons: Skeleton[];
  116682. animationGroups: AnimationGroup[];
  116683. }>;
  116684. /**
  116685. * Load into a scene.
  116686. * @param scene The scene to load into
  116687. * @param data The data to import
  116688. * @param rootUrl The root url for scene and resources
  116689. * @param onProgress The callback when the load progresses
  116690. * @param fileName Defines the name of the file to load
  116691. * @returns Nothing
  116692. */
  116693. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  116694. /**
  116695. * Load into an asset container.
  116696. * @param scene The scene to load into
  116697. * @param data The data to import
  116698. * @param rootUrl The root url for scene and resources
  116699. * @param onProgress The callback when the load progresses
  116700. * @param fileName Defines the name of the file to load
  116701. * @returns The loaded asset container
  116702. */
  116703. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  116704. }
  116705. /**
  116706. * Mode that determines how to handle old animation groups before loading new ones.
  116707. */
  116708. export enum SceneLoaderAnimationGroupLoadingMode {
  116709. /**
  116710. * Reset all old animations to initial state then dispose them.
  116711. */
  116712. Clean = 0,
  116713. /**
  116714. * Stop all old animations.
  116715. */
  116716. Stop = 1,
  116717. /**
  116718. * Restart old animations from first frame.
  116719. */
  116720. Sync = 2,
  116721. /**
  116722. * Old animations remains untouched.
  116723. */
  116724. NoSync = 3
  116725. }
  116726. /**
  116727. * Class used to load scene from various file formats using registered plugins
  116728. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  116729. */
  116730. export class SceneLoader {
  116731. /**
  116732. * No logging while loading
  116733. */
  116734. static readonly NO_LOGGING: number;
  116735. /**
  116736. * Minimal logging while loading
  116737. */
  116738. static readonly MINIMAL_LOGGING: number;
  116739. /**
  116740. * Summary logging while loading
  116741. */
  116742. static readonly SUMMARY_LOGGING: number;
  116743. /**
  116744. * Detailled logging while loading
  116745. */
  116746. static readonly DETAILED_LOGGING: number;
  116747. /**
  116748. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  116749. */
  116750. static get ForceFullSceneLoadingForIncremental(): boolean;
  116751. static set ForceFullSceneLoadingForIncremental(value: boolean);
  116752. /**
  116753. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  116754. */
  116755. static get ShowLoadingScreen(): boolean;
  116756. static set ShowLoadingScreen(value: boolean);
  116757. /**
  116758. * Defines the current logging level (while loading the scene)
  116759. * @ignorenaming
  116760. */
  116761. static get loggingLevel(): number;
  116762. static set loggingLevel(value: number);
  116763. /**
  116764. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  116765. */
  116766. static get CleanBoneMatrixWeights(): boolean;
  116767. static set CleanBoneMatrixWeights(value: boolean);
  116768. /**
  116769. * Event raised when a plugin is used to load a scene
  116770. */
  116771. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  116772. private static _registeredPlugins;
  116773. private static _getDefaultPlugin;
  116774. private static _getPluginForExtension;
  116775. private static _getPluginForDirectLoad;
  116776. private static _getPluginForFilename;
  116777. private static _getDirectLoad;
  116778. private static _loadData;
  116779. private static _getFileInfo;
  116780. /**
  116781. * Gets a plugin that can load the given extension
  116782. * @param extension defines the extension to load
  116783. * @returns a plugin or null if none works
  116784. */
  116785. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  116786. /**
  116787. * Gets a boolean indicating that the given extension can be loaded
  116788. * @param extension defines the extension to load
  116789. * @returns true if the extension is supported
  116790. */
  116791. static IsPluginForExtensionAvailable(extension: string): boolean;
  116792. /**
  116793. * Adds a new plugin to the list of registered plugins
  116794. * @param plugin defines the plugin to add
  116795. */
  116796. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  116797. /**
  116798. * Import meshes into a scene
  116799. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116800. * @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)
  116801. * @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)
  116802. * @param scene the instance of BABYLON.Scene to append to
  116803. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  116804. * @param onProgress a callback with a progress event for each file being loaded
  116805. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116806. * @param pluginExtension the extension used to determine the plugin
  116807. * @returns The loaded plugin
  116808. */
  116809. 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>;
  116810. /**
  116811. * Import meshes into a scene
  116812. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  116813. * @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)
  116814. * @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)
  116815. * @param scene the instance of BABYLON.Scene to append to
  116816. * @param onProgress a callback with a progress event for each file being loaded
  116817. * @param pluginExtension the extension used to determine the plugin
  116818. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  116819. */
  116820. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  116821. meshes: AbstractMesh[];
  116822. particleSystems: IParticleSystem[];
  116823. skeletons: Skeleton[];
  116824. animationGroups: AnimationGroup[];
  116825. }>;
  116826. /**
  116827. * Load a scene
  116828. * @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)
  116829. * @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)
  116830. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116831. * @param onSuccess a callback with the scene when import succeeds
  116832. * @param onProgress a callback with a progress event for each file being loaded
  116833. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116834. * @param pluginExtension the extension used to determine the plugin
  116835. * @returns The loaded plugin
  116836. */
  116837. 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>;
  116838. /**
  116839. * Load a scene
  116840. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  116841. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  116842. * @param engine is the instance of BABYLON.Engine to use to create the scene
  116843. * @param onProgress a callback with a progress event for each file being loaded
  116844. * @param pluginExtension the extension used to determine the plugin
  116845. * @returns The loaded scene
  116846. */
  116847. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116848. /**
  116849. * Append a scene
  116850. * @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)
  116851. * @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)
  116852. * @param scene is the instance of BABYLON.Scene to append to
  116853. * @param onSuccess a callback with the scene when import succeeds
  116854. * @param onProgress a callback with a progress event for each file being loaded
  116855. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116856. * @param pluginExtension the extension used to determine the plugin
  116857. * @returns The loaded plugin
  116858. */
  116859. 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>;
  116860. /**
  116861. * Append a scene
  116862. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  116863. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  116864. * @param scene is the instance of BABYLON.Scene to append to
  116865. * @param onProgress a callback with a progress event for each file being loaded
  116866. * @param pluginExtension the extension used to determine the plugin
  116867. * @returns The given scene
  116868. */
  116869. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  116870. /**
  116871. * Load a scene into an asset container
  116872. * @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)
  116873. * @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)
  116874. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116875. * @param onSuccess a callback with the scene when import succeeds
  116876. * @param onProgress a callback with a progress event for each file being loaded
  116877. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116878. * @param pluginExtension the extension used to determine the plugin
  116879. * @returns The loaded plugin
  116880. */
  116881. 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>;
  116882. /**
  116883. * Load a scene into an asset container
  116884. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  116885. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene (default: empty string)
  116886. * @param scene is the instance of Scene to append to
  116887. * @param onProgress a callback with a progress event for each file being loaded
  116888. * @param pluginExtension the extension used to determine the plugin
  116889. * @returns The loaded asset container
  116890. */
  116891. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  116892. /**
  116893. * Import animations from a file into a scene
  116894. * @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)
  116895. * @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)
  116896. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116897. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116898. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116899. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116900. * @param onSuccess a callback with the scene when import succeeds
  116901. * @param onProgress a callback with a progress event for each file being loaded
  116902. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116903. */
  116904. 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;
  116905. /**
  116906. * Import animations from a file into a scene
  116907. * @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)
  116908. * @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)
  116909. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  116910. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  116911. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  116912. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  116913. * @param onSuccess a callback with the scene when import succeeds
  116914. * @param onProgress a callback with a progress event for each file being loaded
  116915. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  116916. * @returns the updated scene with imported animations
  116917. */
  116918. 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>;
  116919. }
  116920. }
  116921. declare module BABYLON {
  116922. /**
  116923. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  116924. */
  116925. export type MotionControllerHandness = "none" | "left" | "right";
  116926. /**
  116927. * The type of components available in motion controllers.
  116928. * This is not the name of the component.
  116929. */
  116930. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  116931. /**
  116932. * The state of a controller component
  116933. */
  116934. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  116935. /**
  116936. * The schema of motion controller layout.
  116937. * No object will be initialized using this interface
  116938. * This is used just to define the profile.
  116939. */
  116940. export interface IMotionControllerLayout {
  116941. /**
  116942. * Defines the main button component id
  116943. */
  116944. selectComponentId: string;
  116945. /**
  116946. * Available components (unsorted)
  116947. */
  116948. components: {
  116949. /**
  116950. * A map of component Ids
  116951. */
  116952. [componentId: string]: {
  116953. /**
  116954. * The type of input the component outputs
  116955. */
  116956. type: MotionControllerComponentType;
  116957. /**
  116958. * The indices of this component in the gamepad object
  116959. */
  116960. gamepadIndices: {
  116961. /**
  116962. * Index of button
  116963. */
  116964. button?: number;
  116965. /**
  116966. * If available, index of x-axis
  116967. */
  116968. xAxis?: number;
  116969. /**
  116970. * If available, index of y-axis
  116971. */
  116972. yAxis?: number;
  116973. };
  116974. /**
  116975. * The mesh's root node name
  116976. */
  116977. rootNodeName: string;
  116978. /**
  116979. * Animation definitions for this model
  116980. */
  116981. visualResponses: {
  116982. [stateKey: string]: {
  116983. /**
  116984. * What property will be animated
  116985. */
  116986. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  116987. /**
  116988. * What states influence this visual reponse
  116989. */
  116990. states: MotionControllerComponentStateType[];
  116991. /**
  116992. * Type of animation - movement or visibility
  116993. */
  116994. valueNodeProperty: "transform" | "visibility";
  116995. /**
  116996. * Base node name to move. Its position will be calculated according to the min and max nodes
  116997. */
  116998. valueNodeName?: string;
  116999. /**
  117000. * Minimum movement node
  117001. */
  117002. minNodeName?: string;
  117003. /**
  117004. * Max movement node
  117005. */
  117006. maxNodeName?: string;
  117007. };
  117008. };
  117009. /**
  117010. * If touch enabled, what is the name of node to display user feedback
  117011. */
  117012. touchPointNodeName?: string;
  117013. };
  117014. };
  117015. /**
  117016. * Is it xr standard mapping or not
  117017. */
  117018. gamepadMapping: "" | "xr-standard";
  117019. /**
  117020. * Base root node of this entire model
  117021. */
  117022. rootNodeName: string;
  117023. /**
  117024. * Path to load the assets. Usually relative to the base path
  117025. */
  117026. assetPath: string;
  117027. }
  117028. /**
  117029. * A definition for the layout map in the input profile
  117030. */
  117031. export interface IMotionControllerLayoutMap {
  117032. /**
  117033. * Layouts with handness type as a key
  117034. */
  117035. [handness: string]: IMotionControllerLayout;
  117036. }
  117037. /**
  117038. * The XR Input profile schema
  117039. * Profiles can be found here:
  117040. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  117041. */
  117042. export interface IMotionControllerProfile {
  117043. /**
  117044. * The id of this profile
  117045. * correlates to the profile(s) in the xrInput.profiles array
  117046. */
  117047. profileId: string;
  117048. /**
  117049. * fallback profiles for this profileId
  117050. */
  117051. fallbackProfileIds: string[];
  117052. /**
  117053. * The layout map, with handness as key
  117054. */
  117055. layouts: IMotionControllerLayoutMap;
  117056. }
  117057. /**
  117058. * A helper-interface for the 3 meshes needed for controller button animation
  117059. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  117060. */
  117061. export interface IMotionControllerButtonMeshMap {
  117062. /**
  117063. * The mesh that will be changed when value changes
  117064. */
  117065. valueMesh: AbstractMesh;
  117066. /**
  117067. * the mesh that defines the pressed value mesh position.
  117068. * This is used to find the max-position of this button
  117069. */
  117070. pressedMesh: AbstractMesh;
  117071. /**
  117072. * the mesh that defines the unpressed value mesh position.
  117073. * This is used to find the min (or initial) position of this button
  117074. */
  117075. unpressedMesh: AbstractMesh;
  117076. }
  117077. /**
  117078. * A helper-interface for the 3 meshes needed for controller axis animation.
  117079. * This will be expanded when touchpad animations are fully supported
  117080. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  117081. */
  117082. export interface IMotionControllerMeshMap {
  117083. /**
  117084. * The mesh that will be changed when axis value changes
  117085. */
  117086. valueMesh: AbstractMesh;
  117087. /**
  117088. * the mesh that defines the minimum value mesh position.
  117089. */
  117090. minMesh?: AbstractMesh;
  117091. /**
  117092. * the mesh that defines the maximum value mesh position.
  117093. */
  117094. maxMesh?: AbstractMesh;
  117095. }
  117096. /**
  117097. * The elements needed for change-detection of the gamepad objects in motion controllers
  117098. */
  117099. export interface IMinimalMotionControllerObject {
  117100. /**
  117101. * An array of available buttons
  117102. */
  117103. buttons: Array<{
  117104. /**
  117105. * Value of the button/trigger
  117106. */
  117107. value: number;
  117108. /**
  117109. * If the button/trigger is currently touched
  117110. */
  117111. touched: boolean;
  117112. /**
  117113. * If the button/trigger is currently pressed
  117114. */
  117115. pressed: boolean;
  117116. }>;
  117117. /**
  117118. * Available axes of this controller
  117119. */
  117120. axes: number[];
  117121. }
  117122. /**
  117123. * An Abstract Motion controller
  117124. * This class receives an xrInput and a profile layout and uses those to initialize the components
  117125. * Each component has an observable to check for changes in value and state
  117126. */
  117127. export abstract class WebXRAbstractMotionController implements IDisposable {
  117128. protected scene: Scene;
  117129. protected layout: IMotionControllerLayout;
  117130. /**
  117131. * The gamepad object correlating to this controller
  117132. */
  117133. gamepadObject: IMinimalMotionControllerObject;
  117134. /**
  117135. * handness (left/right/none) of this controller
  117136. */
  117137. handness: MotionControllerHandness;
  117138. /**
  117139. * The profile id of this motion controller
  117140. */
  117141. abstract profileId: string;
  117142. /**
  117143. * A map of components (WebXRControllerComponent) in this motion controller
  117144. * Components have a ComponentType and can also have both button and axis definitions
  117145. */
  117146. readonly components: {
  117147. [id: string]: WebXRControllerComponent;
  117148. };
  117149. /**
  117150. * Observers registered here will be triggered when the model of this controller is done loading
  117151. */
  117152. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  117153. /**
  117154. * The root mesh of the model. It is null if the model was not yet initialized
  117155. */
  117156. rootMesh: Nullable<AbstractMesh>;
  117157. /**
  117158. * Disable the model's animation. Can be set at any time.
  117159. */
  117160. disableAnimation: boolean;
  117161. private _modelReady;
  117162. /**
  117163. * constructs a new abstract motion controller
  117164. * @param scene the scene to which the model of the controller will be added
  117165. * @param layout The profile layout to load
  117166. * @param gamepadObject The gamepad object correlating to this controller
  117167. * @param handness handness (left/right/none) of this controller
  117168. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  117169. */
  117170. constructor(scene: Scene, layout: IMotionControllerLayout,
  117171. /**
  117172. * The gamepad object correlating to this controller
  117173. */
  117174. gamepadObject: IMinimalMotionControllerObject,
  117175. /**
  117176. * handness (left/right/none) of this controller
  117177. */
  117178. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  117179. private _initComponent;
  117180. /**
  117181. * Update this model using the current XRFrame
  117182. * @param xrFrame the current xr frame to use and update the model
  117183. */
  117184. updateFromXRFrame(xrFrame: XRFrame): void;
  117185. /**
  117186. * Get the list of components available in this motion controller
  117187. * @returns an array of strings correlating to available components
  117188. */
  117189. getComponentIds(): string[];
  117190. /**
  117191. * Get the main (Select) component of this controller as defined in the layout
  117192. * @returns the main component of this controller
  117193. */
  117194. getMainComponent(): WebXRControllerComponent;
  117195. /**
  117196. * get a component based an its component id as defined in layout.components
  117197. * @param id the id of the component
  117198. * @returns the component correlates to the id or undefined if not found
  117199. */
  117200. getComponent(id: string): WebXRControllerComponent;
  117201. /**
  117202. * Get the first component of specific type
  117203. * @param type type of component to find
  117204. * @return a controller component or null if not found
  117205. */
  117206. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  117207. /**
  117208. * Returns all components of specific type
  117209. * @param type the type to search for
  117210. * @return an array of components with this type
  117211. */
  117212. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  117213. /**
  117214. * Loads the model correlating to this controller
  117215. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  117216. * @returns A promise fulfilled with the result of the model loading
  117217. */
  117218. loadModel(): Promise<boolean>;
  117219. /**
  117220. * Update the model itself with the current frame data
  117221. * @param xrFrame the frame to use for updating the model mesh
  117222. */
  117223. protected updateModel(xrFrame: XRFrame): void;
  117224. /**
  117225. * Moves the axis on the controller mesh based on its current state
  117226. * @param axis the index of the axis
  117227. * @param axisValue the value of the axis which determines the meshes new position
  117228. * @hidden
  117229. */
  117230. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  117231. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117232. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  117233. private _getGenericFilenameAndPath;
  117234. private _getGenericParentMesh;
  117235. /**
  117236. * Get the filename and path for this controller's model
  117237. * @returns a map of filename and path
  117238. */
  117239. protected abstract _getFilenameAndPath(): {
  117240. filename: string;
  117241. path: string;
  117242. };
  117243. /**
  117244. * This function will be called after the model was successfully loaded and can be used
  117245. * for mesh transformations before it is available for the user
  117246. * @param meshes the loaded meshes
  117247. */
  117248. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  117249. /**
  117250. * Set the root mesh for this controller. Important for the WebXR controller class
  117251. * @param meshes the loaded meshes
  117252. */
  117253. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  117254. /**
  117255. * A function executed each frame that updates the mesh (if needed)
  117256. * @param xrFrame the current xrFrame
  117257. */
  117258. protected abstract _updateModel(xrFrame: XRFrame): void;
  117259. /**
  117260. * This function is called before the mesh is loaded. It checks for loading constraints.
  117261. * For example, this function can check if the GLB loader is available
  117262. * If this function returns false, the generic controller will be loaded instead
  117263. * @returns Is the client ready to load the mesh
  117264. */
  117265. protected abstract _getModelLoadingConstraints(): boolean;
  117266. /**
  117267. * Dispose this controller, the model mesh and all its components
  117268. */
  117269. dispose(): void;
  117270. }
  117271. }
  117272. declare module BABYLON {
  117273. /**
  117274. * A generic trigger-only motion controller for WebXR
  117275. */
  117276. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  117277. /**
  117278. * Static version of the profile id of this controller
  117279. */
  117280. static ProfileId: string;
  117281. profileId: string;
  117282. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  117283. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  117284. protected _updateModel(): void;
  117285. protected _getFilenameAndPath(): {
  117286. filename: string;
  117287. path: string;
  117288. };
  117289. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117290. protected _getModelLoadingConstraints(): boolean;
  117291. }
  117292. }
  117293. declare module BABYLON {
  117294. /**
  117295. * Class containing static functions to help procedurally build meshes
  117296. */
  117297. export class SphereBuilder {
  117298. /**
  117299. * Creates a sphere mesh
  117300. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  117301. * * 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`)
  117302. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  117303. * * 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
  117304. * * 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)
  117305. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117306. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117308. * @param name defines the name of the mesh
  117309. * @param options defines the options used to create the mesh
  117310. * @param scene defines the hosting scene
  117311. * @returns the sphere mesh
  117312. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  117313. */
  117314. static CreateSphere(name: string, options: {
  117315. segments?: number;
  117316. diameter?: number;
  117317. diameterX?: number;
  117318. diameterY?: number;
  117319. diameterZ?: number;
  117320. arc?: number;
  117321. slice?: number;
  117322. sideOrientation?: number;
  117323. frontUVs?: Vector4;
  117324. backUVs?: Vector4;
  117325. updatable?: boolean;
  117326. }, scene?: Nullable<Scene>): Mesh;
  117327. }
  117328. }
  117329. declare module BABYLON {
  117330. /**
  117331. * A profiled motion controller has its profile loaded from an online repository.
  117332. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  117333. */
  117334. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  117335. private _repositoryUrl;
  117336. /**
  117337. * The profile ID of this controller. Will be populated when the controller initializes.
  117338. */
  117339. profileId: string;
  117340. private _buttonMeshMapping;
  117341. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  117342. protected _getFilenameAndPath(): {
  117343. filename: string;
  117344. path: string;
  117345. };
  117346. private _touchDots;
  117347. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  117348. protected _setRootMesh(meshes: AbstractMesh[]): void;
  117349. protected _updateModel(_xrFrame: XRFrame): void;
  117350. protected _getModelLoadingConstraints(): boolean;
  117351. dispose(): void;
  117352. }
  117353. }
  117354. declare module BABYLON {
  117355. /**
  117356. * A construction function type to create a new controller based on an xrInput object
  117357. */
  117358. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  117359. /**
  117360. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  117361. *
  117362. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  117363. * it should be replaced with auto-loaded controllers.
  117364. *
  117365. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  117366. */
  117367. export class WebXRMotionControllerManager {
  117368. /**
  117369. * The base URL of the online controller repository. Can be changed at any time.
  117370. */
  117371. static BaseRepositoryUrl: string;
  117372. /**
  117373. * Use the online repository, or use only locally-defined controllers
  117374. */
  117375. static UseOnlineRepository: boolean;
  117376. /**
  117377. * Which repository gets priority - local or online
  117378. */
  117379. static PrioritizeOnlineRepository: boolean;
  117380. private static _AvailableControllers;
  117381. private static _Fallbacks;
  117382. /**
  117383. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  117384. *
  117385. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  117386. *
  117387. * @param type the profile type to register
  117388. * @param constructFunction the function to be called when loading this profile
  117389. */
  117390. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  117391. /**
  117392. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  117393. * The order of search:
  117394. *
  117395. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  117396. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  117397. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  117398. * 4) return the generic trigger controller if none were found
  117399. *
  117400. * @param xrInput the xrInput to which a new controller is initialized
  117401. * @param scene the scene to which the model will be added
  117402. * @param forceProfile force a certain profile for this controller
  117403. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  117404. */
  117405. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  117406. private static _LoadProfilesFromAvailableControllers;
  117407. private static _ProfilesList;
  117408. private static _ProfileLoadingPromises;
  117409. private static _LoadProfileFromRepository;
  117410. /**
  117411. * Clear the cache used for profile loading and reload when requested again
  117412. */
  117413. static ClearProfilesCache(): void;
  117414. /**
  117415. * Will update the list of profiles available in the repository
  117416. * @return a promise that resolves to a map of profiles available online
  117417. */
  117418. static UpdateProfilesList(): Promise<{
  117419. [profile: string]: string;
  117420. }>;
  117421. /**
  117422. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  117423. * @param profileId the profile to which a fallback needs to be found
  117424. * @return an array with corresponding fallback profiles
  117425. */
  117426. static FindFallbackWithProfileId(profileId: string): string[];
  117427. /**
  117428. * Register a fallback to a specific profile.
  117429. * @param profileId the profileId that will receive the fallbacks
  117430. * @param fallbacks A list of fallback profiles
  117431. */
  117432. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  117433. /**
  117434. * Register the default fallbacks.
  117435. * This function is called automatically when this file is imported.
  117436. */
  117437. static DefaultFallbacks(): void;
  117438. }
  117439. }
  117440. declare module BABYLON {
  117441. /**
  117442. * Configuration options for the WebXR controller creation
  117443. */
  117444. export interface IWebXRControllerOptions {
  117445. /**
  117446. * Force a specific controller type for this controller.
  117447. * This can be used when creating your own profile or when testing different controllers
  117448. */
  117449. forceControllerProfile?: string;
  117450. /**
  117451. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  117452. */
  117453. doNotLoadControllerMesh?: boolean;
  117454. /**
  117455. * Should the controller mesh be animated when a user interacts with it
  117456. * The pressed buttons / thumbstick and touchpad animations will be disabled
  117457. */
  117458. disableMotionControllerAnimation?: boolean;
  117459. }
  117460. /**
  117461. * Represents an XR controller
  117462. */
  117463. export class WebXRInputSource {
  117464. private _scene;
  117465. /** The underlying input source for the controller */
  117466. inputSource: XRInputSource;
  117467. private _options;
  117468. /**
  117469. * 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
  117470. */
  117471. grip?: AbstractMesh;
  117472. /**
  117473. * Pointer which can be used to select objects or attach a visible laser to
  117474. */
  117475. pointer: AbstractMesh;
  117476. /**
  117477. * If available, this is the gamepad object related to this controller.
  117478. * Using this object it is possible to get click events and trackpad changes of the
  117479. * webxr controller that is currently being used.
  117480. */
  117481. motionController?: WebXRAbstractMotionController;
  117482. /**
  117483. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  117484. */
  117485. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  117486. /**
  117487. * Will be triggered when the mesh associated with the motion controller is done loading.
  117488. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  117489. * A shortened version of controller -> motion controller -> on mesh loaded.
  117490. */
  117491. onMeshLoadedObservable: Observable<AbstractMesh>;
  117492. /**
  117493. * Event that fires when the controller is removed/disposed.
  117494. * The object provided as event data is this controller, after associated assets were disposed.
  117495. * uniqueId is still available.
  117496. */
  117497. onDisposeObservable: Observable<WebXRInputSource>;
  117498. private _tmpQuaternion;
  117499. private _tmpVector;
  117500. private _uniqueId;
  117501. /**
  117502. * Creates the controller
  117503. * @see https://doc.babylonjs.com/how_to/webxr
  117504. * @param _scene the scene which the controller should be associated to
  117505. * @param inputSource the underlying input source for the controller
  117506. * @param _options options for this controller creation
  117507. */
  117508. constructor(_scene: Scene,
  117509. /** The underlying input source for the controller */
  117510. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  117511. /**
  117512. * Get this controllers unique id
  117513. */
  117514. get uniqueId(): string;
  117515. /**
  117516. * Updates the controller pose based on the given XRFrame
  117517. * @param xrFrame xr frame to update the pose with
  117518. * @param referenceSpace reference space to use
  117519. */
  117520. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  117521. /**
  117522. * Gets a world space ray coming from the pointer or grip
  117523. * @param result the resulting ray
  117524. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  117525. */
  117526. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  117527. /**
  117528. * Disposes of the object
  117529. */
  117530. dispose(): void;
  117531. }
  117532. }
  117533. declare module BABYLON {
  117534. /**
  117535. * The schema for initialization options of the XR Input class
  117536. */
  117537. export interface IWebXRInputOptions {
  117538. /**
  117539. * If set to true no model will be automatically loaded
  117540. */
  117541. doNotLoadControllerMeshes?: boolean;
  117542. /**
  117543. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  117544. * If not found, the xr input profile data will be used.
  117545. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  117546. */
  117547. forceInputProfile?: string;
  117548. /**
  117549. * Do not send a request to the controlle repository to load the profile.
  117550. *
  117551. * Instead, use the controllers available in babylon itself.
  117552. */
  117553. disableOnlineControllerRepository?: boolean;
  117554. /**
  117555. * A custom URL for the controllers repository
  117556. */
  117557. customControllersRepositoryURL?: string;
  117558. /**
  117559. * Should the controller model's components not move according to the user input
  117560. */
  117561. disableControllerAnimation?: boolean;
  117562. }
  117563. /**
  117564. * XR input used to track XR inputs such as controllers/rays
  117565. */
  117566. export class WebXRInput implements IDisposable {
  117567. /**
  117568. * the xr session manager for this session
  117569. */
  117570. xrSessionManager: WebXRSessionManager;
  117571. /**
  117572. * the WebXR camera for this session. Mainly used for teleportation
  117573. */
  117574. xrCamera: WebXRCamera;
  117575. private readonly options;
  117576. /**
  117577. * XR controllers being tracked
  117578. */
  117579. controllers: Array<WebXRInputSource>;
  117580. private _frameObserver;
  117581. private _sessionEndedObserver;
  117582. private _sessionInitObserver;
  117583. /**
  117584. * Event when a controller has been connected/added
  117585. */
  117586. onControllerAddedObservable: Observable<WebXRInputSource>;
  117587. /**
  117588. * Event when a controller has been removed/disconnected
  117589. */
  117590. onControllerRemovedObservable: Observable<WebXRInputSource>;
  117591. /**
  117592. * Initializes the WebXRInput
  117593. * @param xrSessionManager the xr session manager for this session
  117594. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  117595. * @param options = initialization options for this xr input
  117596. */
  117597. constructor(
  117598. /**
  117599. * the xr session manager for this session
  117600. */
  117601. xrSessionManager: WebXRSessionManager,
  117602. /**
  117603. * the WebXR camera for this session. Mainly used for teleportation
  117604. */
  117605. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  117606. private _onInputSourcesChange;
  117607. private _addAndRemoveControllers;
  117608. /**
  117609. * Disposes of the object
  117610. */
  117611. dispose(): void;
  117612. }
  117613. }
  117614. declare module BABYLON {
  117615. /**
  117616. * This is the base class for all WebXR features.
  117617. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  117618. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  117619. */
  117620. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  117621. protected _xrSessionManager: WebXRSessionManager;
  117622. /**
  117623. * Construct a new (abstract) webxr feature
  117624. * @param _xrSessionManager the xr session manager for this feature
  117625. */
  117626. constructor(_xrSessionManager: WebXRSessionManager);
  117627. private _attached;
  117628. private _removeOnDetach;
  117629. /**
  117630. * Is this feature attached
  117631. */
  117632. get attached(): boolean;
  117633. /**
  117634. * Should auto-attach be disabled?
  117635. */
  117636. disableAutoAttach: boolean;
  117637. /**
  117638. * attach this feature
  117639. *
  117640. * @param force should attachment be forced (even when already attached)
  117641. * @returns true if successful, false is failed or already attached
  117642. */
  117643. attach(force?: boolean): boolean;
  117644. /**
  117645. * detach this feature.
  117646. *
  117647. * @returns true if successful, false if failed or already detached
  117648. */
  117649. detach(): boolean;
  117650. /**
  117651. * Dispose this feature and all of the resources attached
  117652. */
  117653. dispose(): void;
  117654. /**
  117655. * Code in this function will be executed on each xrFrame received from the browser.
  117656. * This function will not execute after the feature is detached.
  117657. * @param _xrFrame the current frame
  117658. */
  117659. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  117660. /**
  117661. * This is used to register callbacks that will automatically be removed when detach is called.
  117662. * @param observable the observable to which the observer will be attached
  117663. * @param callback the callback to register
  117664. */
  117665. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  117666. }
  117667. }
  117668. declare module BABYLON {
  117669. /**
  117670. * Renders a layer on top of an existing scene
  117671. */
  117672. export class UtilityLayerRenderer implements IDisposable {
  117673. /** the original scene that will be rendered on top of */
  117674. originalScene: Scene;
  117675. private _pointerCaptures;
  117676. private _lastPointerEvents;
  117677. private static _DefaultUtilityLayer;
  117678. private static _DefaultKeepDepthUtilityLayer;
  117679. private _sharedGizmoLight;
  117680. private _renderCamera;
  117681. /**
  117682. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  117683. * @returns the camera that is used when rendering the utility layer
  117684. */
  117685. getRenderCamera(): Camera;
  117686. /**
  117687. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  117688. * @param cam the camera that should be used when rendering the utility layer
  117689. */
  117690. setRenderCamera(cam: Nullable<Camera>): void;
  117691. /**
  117692. * @hidden
  117693. * Light which used by gizmos to get light shading
  117694. */
  117695. _getSharedGizmoLight(): HemisphericLight;
  117696. /**
  117697. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  117698. */
  117699. pickUtilitySceneFirst: boolean;
  117700. /**
  117701. * 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)
  117702. */
  117703. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  117704. /**
  117705. * 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)
  117706. */
  117707. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  117708. /**
  117709. * The scene that is rendered on top of the original scene
  117710. */
  117711. utilityLayerScene: Scene;
  117712. /**
  117713. * If the utility layer should automatically be rendered on top of existing scene
  117714. */
  117715. shouldRender: boolean;
  117716. /**
  117717. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  117718. */
  117719. onlyCheckPointerDownEvents: boolean;
  117720. /**
  117721. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  117722. */
  117723. processAllEvents: boolean;
  117724. /**
  117725. * Observable raised when the pointer move from the utility layer scene to the main scene
  117726. */
  117727. onPointerOutObservable: Observable<number>;
  117728. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  117729. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  117730. private _afterRenderObserver;
  117731. private _sceneDisposeObserver;
  117732. private _originalPointerObserver;
  117733. /**
  117734. * Instantiates a UtilityLayerRenderer
  117735. * @param originalScene the original scene that will be rendered on top of
  117736. * @param handleEvents boolean indicating if the utility layer should handle events
  117737. */
  117738. constructor(
  117739. /** the original scene that will be rendered on top of */
  117740. originalScene: Scene, handleEvents?: boolean);
  117741. private _notifyObservers;
  117742. /**
  117743. * Renders the utility layers scene on top of the original scene
  117744. */
  117745. render(): void;
  117746. /**
  117747. * Disposes of the renderer
  117748. */
  117749. dispose(): void;
  117750. private _updateCamera;
  117751. }
  117752. }
  117753. declare module BABYLON {
  117754. /**
  117755. * Options interface for the pointer selection module
  117756. */
  117757. export interface IWebXRControllerPointerSelectionOptions {
  117758. /**
  117759. * the xr input to use with this pointer selection
  117760. */
  117761. xrInput: WebXRInput;
  117762. /**
  117763. * Different button type to use instead of the main component
  117764. */
  117765. overrideButtonId?: string;
  117766. /**
  117767. * The amount of time in miliseconds it takes between pick found something to a pointer down event.
  117768. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  117769. * 3000 means 3 seconds between pointing at something and selecting it
  117770. */
  117771. timeToSelect?: number;
  117772. /**
  117773. * 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)
  117774. * If not disabled, the last picked point will be used to execute a pointer up event
  117775. * If disabled, pointer up event will be triggered right after the pointer down event.
  117776. * Used in screen and gaze target ray mode only
  117777. */
  117778. disablePointerUpOnTouchOut: boolean;
  117779. /**
  117780. * For gaze mode (time to select instead of press)
  117781. */
  117782. forceGazeMode: boolean;
  117783. /**
  117784. * 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
  117785. * to start a new countdown to the pointer down event.
  117786. * Defaults to 1.
  117787. */
  117788. gazeModePointerMovedFactor?: number;
  117789. /**
  117790. * Should meshes created here be added to a utility layer or the main scene
  117791. */
  117792. useUtilityLayer?: boolean;
  117793. /**
  117794. * if provided, this scene will be used to render meshes.
  117795. */
  117796. customUtilityLayerScene?: Scene;
  117797. /**
  117798. * use this rendering group id for the meshes (optional)
  117799. */
  117800. renderingGroupId?: number;
  117801. }
  117802. /**
  117803. * A module that will enable pointer selection for motion controllers of XR Input Sources
  117804. */
  117805. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  117806. private readonly _options;
  117807. /**
  117808. * The module's name
  117809. */
  117810. static readonly Name: string;
  117811. /**
  117812. * The (Babylon) version of this module.
  117813. * This is an integer representing the implementation version.
  117814. * This number does not correspond to the webxr specs version
  117815. */
  117816. static readonly Version: number;
  117817. /**
  117818. * This color will be set to the laser pointer when selection is triggered
  117819. */
  117820. laserPointerPickedColor: Color3;
  117821. /**
  117822. * This color will be applied to the selection ring when selection is triggered
  117823. */
  117824. selectionMeshPickedColor: Color3;
  117825. /**
  117826. * default color of the selection ring
  117827. */
  117828. selectionMeshDefaultColor: Color3;
  117829. /**
  117830. * Default color of the laser pointer
  117831. */
  117832. lasterPointerDefaultColor: Color3;
  117833. /**
  117834. * Should the laser pointer be displayed
  117835. */
  117836. displayLaserPointer: boolean;
  117837. /**
  117838. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  117839. */
  117840. displaySelectionMesh: boolean;
  117841. /**
  117842. * Disable lighting on the laser pointer (so it will always be visible)
  117843. */
  117844. disablePointerLighting: boolean;
  117845. /**
  117846. * Disable lighting on the selection mesh (so it will always be visible)
  117847. */
  117848. disableSelectionMeshLighting: boolean;
  117849. private static _idCounter;
  117850. private _controllers;
  117851. private _scene;
  117852. /**
  117853. * constructs a new background remover module
  117854. * @param _xrSessionManager the session manager for this module
  117855. * @param _options read-only options to be used in this module
  117856. */
  117857. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  117858. /**
  117859. * attach this feature
  117860. * Will usually be called by the features manager
  117861. *
  117862. * @returns true if successful.
  117863. */
  117864. attach(): boolean;
  117865. /**
  117866. * detach this feature.
  117867. * Will usually be called by the features manager
  117868. *
  117869. * @returns true if successful.
  117870. */
  117871. detach(): boolean;
  117872. /**
  117873. * Get the xr controller that correlates to the pointer id in the pointer event
  117874. *
  117875. * @param id the pointer id to search for
  117876. * @returns the controller that correlates to this id or null if not found
  117877. */
  117878. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  117879. /**
  117880. * Will get the mesh under a specific pointer.
  117881. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  117882. * @param controllerId the controllerId to check
  117883. * @returns The mesh under pointer or null if no mesh is under the pointer
  117884. */
  117885. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  117886. protected _onXRFrame(_xrFrame: XRFrame): void;
  117887. private _attachController;
  117888. private _attachScreenRayMode;
  117889. private _attachGazeMode;
  117890. private _tmpVectorForPickCompare;
  117891. private _pickingMoved;
  117892. private _attachTrackedPointerRayMode;
  117893. private _detachController;
  117894. private _generateNewMeshPair;
  117895. private _convertNormalToDirectionOfRay;
  117896. private _updatePointerDistance;
  117897. }
  117898. }
  117899. declare module BABYLON {
  117900. /**
  117901. * Button which can be used to enter a different mode of XR
  117902. */
  117903. export class WebXREnterExitUIButton {
  117904. /** button element */
  117905. element: HTMLElement;
  117906. /** XR initialization options for the button */
  117907. sessionMode: XRSessionMode;
  117908. /** Reference space type */
  117909. referenceSpaceType: XRReferenceSpaceType;
  117910. /**
  117911. * Creates a WebXREnterExitUIButton
  117912. * @param element button element
  117913. * @param sessionMode XR initialization session mode
  117914. * @param referenceSpaceType the type of reference space to be used
  117915. */
  117916. constructor(
  117917. /** button element */
  117918. element: HTMLElement,
  117919. /** XR initialization options for the button */
  117920. sessionMode: XRSessionMode,
  117921. /** Reference space type */
  117922. referenceSpaceType: XRReferenceSpaceType);
  117923. /**
  117924. * Overwritable function which can be used to update the button's visuals when the state changes
  117925. * @param activeButton the current active button in the UI
  117926. */
  117927. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  117928. }
  117929. /**
  117930. * Options to create the webXR UI
  117931. */
  117932. export class WebXREnterExitUIOptions {
  117933. /**
  117934. * Context to enter xr with
  117935. */
  117936. renderTarget?: Nullable<WebXRRenderTarget>;
  117937. /**
  117938. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  117939. */
  117940. customButtons?: Array<WebXREnterExitUIButton>;
  117941. /**
  117942. * A session mode to use when creating the default button.
  117943. * Default is immersive-vr
  117944. */
  117945. sessionMode?: XRSessionMode;
  117946. /**
  117947. * A reference space type to use when creating the default button.
  117948. * Default is local-floor
  117949. */
  117950. referenceSpaceType?: XRReferenceSpaceType;
  117951. }
  117952. /**
  117953. * UI to allow the user to enter/exit XR mode
  117954. */
  117955. export class WebXREnterExitUI implements IDisposable {
  117956. private scene;
  117957. /** version of the options passed to this UI */
  117958. options: WebXREnterExitUIOptions;
  117959. private _overlay;
  117960. private _buttons;
  117961. private _activeButton;
  117962. /**
  117963. * Fired every time the active button is changed.
  117964. *
  117965. * When xr is entered via a button that launches xr that button will be the callback parameter
  117966. *
  117967. * When exiting xr the callback parameter will be null)
  117968. */
  117969. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  117970. /**
  117971. * Creates UI to allow the user to enter/exit XR mode
  117972. * @param scene the scene to add the ui to
  117973. * @param helper the xr experience helper to enter/exit xr with
  117974. * @param options options to configure the UI
  117975. * @returns the created ui
  117976. */
  117977. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  117978. /**
  117979. *
  117980. * @param scene babylon scene object to use
  117981. * @param options (read-only) version of the options passed to this UI
  117982. */
  117983. private constructor();
  117984. private _updateButtons;
  117985. /**
  117986. * Disposes of the object
  117987. */
  117988. dispose(): void;
  117989. }
  117990. }
  117991. declare module BABYLON {
  117992. /**
  117993. * Class containing static functions to help procedurally build meshes
  117994. */
  117995. export class LinesBuilder {
  117996. /**
  117997. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  117998. * * 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
  117999. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  118000. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  118001. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  118002. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  118003. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118004. * * 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
  118005. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  118006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118007. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  118008. * @param name defines the name of the new line system
  118009. * @param options defines the options used to create the line system
  118010. * @param scene defines the hosting scene
  118011. * @returns a new line system mesh
  118012. */
  118013. static CreateLineSystem(name: string, options: {
  118014. lines: Vector3[][];
  118015. updatable?: boolean;
  118016. instance?: Nullable<LinesMesh>;
  118017. colors?: Nullable<Color4[][]>;
  118018. useVertexAlpha?: boolean;
  118019. }, scene: Nullable<Scene>): LinesMesh;
  118020. /**
  118021. * Creates a line mesh
  118022. * 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
  118023. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118024. * * The parameter `points` is an array successive Vector3
  118025. * * 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
  118026. * * The optional parameter `colors` is an array of successive Color4, one per line point
  118027. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  118028. * * When updating an instance, remember that only point positions can change, not the number of points
  118029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118030. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  118031. * @param name defines the name of the new line system
  118032. * @param options defines the options used to create the line system
  118033. * @param scene defines the hosting scene
  118034. * @returns a new line mesh
  118035. */
  118036. static CreateLines(name: string, options: {
  118037. points: Vector3[];
  118038. updatable?: boolean;
  118039. instance?: Nullable<LinesMesh>;
  118040. colors?: Color4[];
  118041. useVertexAlpha?: boolean;
  118042. }, scene?: Nullable<Scene>): LinesMesh;
  118043. /**
  118044. * Creates a dashed line mesh
  118045. * * 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
  118046. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  118047. * * The parameter `points` is an array successive Vector3
  118048. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  118049. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  118050. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  118051. * * 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
  118052. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  118053. * * When updating an instance, remember that only point positions can change, not the number of points
  118054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118055. * @param name defines the name of the mesh
  118056. * @param options defines the options used to create the mesh
  118057. * @param scene defines the hosting scene
  118058. * @returns the dashed line mesh
  118059. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  118060. */
  118061. static CreateDashedLines(name: string, options: {
  118062. points: Vector3[];
  118063. dashSize?: number;
  118064. gapSize?: number;
  118065. dashNb?: number;
  118066. updatable?: boolean;
  118067. instance?: LinesMesh;
  118068. useVertexAlpha?: boolean;
  118069. }, scene?: Nullable<Scene>): LinesMesh;
  118070. }
  118071. }
  118072. declare module BABYLON {
  118073. /**
  118074. * The options container for the teleportation module
  118075. */
  118076. export interface IWebXRTeleportationOptions {
  118077. /**
  118078. * Babylon XR Input class for controller
  118079. */
  118080. xrInput: WebXRInput;
  118081. /**
  118082. * A list of meshes to use as floor meshes.
  118083. * Meshes can be added and removed after initializing the feature using the
  118084. * addFloorMesh and removeFloorMesh functions
  118085. * If empty, rotation will still work
  118086. */
  118087. floorMeshes?: AbstractMesh[];
  118088. /**
  118089. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  118090. * If you want to support rotation, make sure your mesh has a direction indicator.
  118091. *
  118092. * When left untouched, the default mesh will be initialized.
  118093. */
  118094. teleportationTargetMesh?: AbstractMesh;
  118095. /**
  118096. * An array of points to which the teleportation will snap to.
  118097. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  118098. */
  118099. snapPositions?: Vector3[];
  118100. /**
  118101. * How close should the teleportation ray be in order to snap to position.
  118102. * Default to 0.8 units (meters)
  118103. */
  118104. snapToPositionRadius?: number;
  118105. /**
  118106. * Should teleportation move only to snap points
  118107. */
  118108. snapPointsOnly?: boolean;
  118109. /**
  118110. * Values to configure the default target mesh
  118111. */
  118112. defaultTargetMeshOptions?: {
  118113. /**
  118114. * Fill color of the teleportation area
  118115. */
  118116. teleportationFillColor?: string;
  118117. /**
  118118. * Border color for the teleportation area
  118119. */
  118120. teleportationBorderColor?: string;
  118121. /**
  118122. * Disable the mesh's animation sequence
  118123. */
  118124. disableAnimation?: boolean;
  118125. /**
  118126. * Disable lighting on the material or the ring and arrow
  118127. */
  118128. disableLighting?: boolean;
  118129. /**
  118130. * Override the default material of the torus and arrow
  118131. */
  118132. torusArrowMaterial?: Material;
  118133. };
  118134. /**
  118135. * Disable using the thumbstick and use the main component (usuallly trigger) on long press.
  118136. * This will be automatically true if the controller doesnt have a thumbstick or touchpad.
  118137. */
  118138. useMainComponentOnly?: boolean;
  118139. /**
  118140. * If main component is used (no thumbstick), how long should the "long press" take before teleporting
  118141. */
  118142. timeToTeleport?: number;
  118143. /**
  118144. * Should meshes created here be added to a utility layer or the main scene
  118145. */
  118146. useUtilityLayer?: boolean;
  118147. /**
  118148. * if provided, this scene will be used to render meshes.
  118149. */
  118150. customUtilityLayerScene?: Scene;
  118151. /**
  118152. * use this rendering group id for the meshes (optional)
  118153. */
  118154. renderingGroupId?: number;
  118155. }
  118156. /**
  118157. * This is a teleportation feature to be used with webxr-enabled motion controllers.
  118158. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  118159. * the input of the attached controllers.
  118160. */
  118161. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  118162. private _options;
  118163. /**
  118164. * The module's name
  118165. */
  118166. static readonly Name: string;
  118167. /**
  118168. * The (Babylon) version of this module.
  118169. * This is an integer representing the implementation version.
  118170. * This number does not correspond to the webxr specs version
  118171. */
  118172. static readonly Version: number;
  118173. /**
  118174. * Is rotation enabled when moving forward?
  118175. * Disabling this feature will prevent the user from deciding the direction when teleporting
  118176. */
  118177. rotationEnabled: boolean;
  118178. /**
  118179. * Should the module support parabolic ray on top of direct ray
  118180. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  118181. * Very helpful when moving between floors / different heights
  118182. */
  118183. parabolicRayEnabled: boolean;
  118184. /**
  118185. * The distance from the user to the inspection point in the direction of the controller
  118186. * A higher number will allow the user to move further
  118187. * defaults to 5 (meters, in xr units)
  118188. */
  118189. parabolicCheckRadius: number;
  118190. /**
  118191. * How much rotation should be applied when rotating right and left
  118192. */
  118193. rotationAngle: number;
  118194. /**
  118195. * Is movement backwards enabled
  118196. */
  118197. backwardsMovementEnabled: boolean;
  118198. /**
  118199. * Distance to travel when moving backwards
  118200. */
  118201. backwardsTeleportationDistance: number;
  118202. /**
  118203. * Add a new mesh to the floor meshes array
  118204. * @param mesh the mesh to use as floor mesh
  118205. */
  118206. addFloorMesh(mesh: AbstractMesh): void;
  118207. /**
  118208. * Remove a mesh from the floor meshes array
  118209. * @param mesh the mesh to remove
  118210. */
  118211. removeFloorMesh(mesh: AbstractMesh): void;
  118212. /**
  118213. * Remove a mesh from the floor meshes array using its name
  118214. * @param name the mesh name to remove
  118215. */
  118216. removeFloorMeshByName(name: string): void;
  118217. private _tmpRay;
  118218. private _tmpVector;
  118219. private _floorMeshes;
  118220. private _snapToPositions;
  118221. private _controllers;
  118222. /**
  118223. * constructs a new anchor system
  118224. * @param _xrSessionManager an instance of WebXRSessionManager
  118225. * @param _options configuration object for this feature
  118226. */
  118227. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  118228. private _selectionFeature;
  118229. private _snappedToPoint;
  118230. private _teleportationRingMaterial?;
  118231. /**
  118232. * Get the snapPointsOnly flag
  118233. */
  118234. get snapPointsOnly(): boolean;
  118235. /**
  118236. * Sets the snapPointsOnly flag
  118237. * @param snapToPoints should teleportation be exclusively to snap points
  118238. */
  118239. set snapPointsOnly(snapToPoints: boolean);
  118240. /**
  118241. * Add a new snap-to point to fix teleportation to this position
  118242. * @param newSnapPoint The new Snap-To point
  118243. */
  118244. addSnapPoint(newSnapPoint: Vector3): void;
  118245. /**
  118246. * 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
  118247. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  118248. * @returns was the point found and removed or not
  118249. */
  118250. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  118251. /**
  118252. * This function sets a selection feature that will be disabled when
  118253. * the forward ray is shown and will be reattached when hidden.
  118254. * This is used to remove the selection rays when moving.
  118255. * @param selectionFeature the feature to disable when forward movement is enabled
  118256. */
  118257. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  118258. attach(): boolean;
  118259. detach(): boolean;
  118260. dispose(): void;
  118261. protected _onXRFrame(_xrFrame: XRFrame): void;
  118262. private _currentTeleportationControllerId;
  118263. private _attachController;
  118264. private _teleportForward;
  118265. private _detachController;
  118266. private _createDefaultTargetMesh;
  118267. private _setTargetMeshVisibility;
  118268. private _setTargetMeshPosition;
  118269. private _quadraticBezierCurve;
  118270. private _showParabolicPath;
  118271. private _findClosestSnapPointWithRadius;
  118272. }
  118273. }
  118274. declare module BABYLON {
  118275. /**
  118276. * Options for the default xr helper
  118277. */
  118278. export class WebXRDefaultExperienceOptions {
  118279. /**
  118280. * Floor meshes that will be used for teleporting
  118281. */
  118282. floorMeshes?: Array<AbstractMesh>;
  118283. /**
  118284. * Enable or disable default UI to enter XR
  118285. */
  118286. disableDefaultUI?: boolean;
  118287. /**
  118288. * optional configuration for the output canvas
  118289. */
  118290. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  118291. /**
  118292. * optional UI options. This can be used among other to change session mode and reference space type
  118293. */
  118294. uiOptions?: WebXREnterExitUIOptions;
  118295. /**
  118296. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  118297. */
  118298. inputOptions?: IWebXRInputOptions;
  118299. /**
  118300. * Should teleportation not initialize. defaults to false.
  118301. */
  118302. disableTeleportation?: boolean;
  118303. /**
  118304. * If set to true, the first frame will not be used to reset position
  118305. * The first frame is mainly used when copying transformation from the old camera
  118306. * Mainly used in AR
  118307. */
  118308. ignoreNativeCameraTransformation?: boolean;
  118309. /**
  118310. * When loading teleportation and pointer select, use stable versions instead of latest.
  118311. */
  118312. useStablePlugins?: boolean;
  118313. }
  118314. /**
  118315. * Default experience which provides a similar setup to the previous webVRExperience
  118316. */
  118317. export class WebXRDefaultExperience {
  118318. /**
  118319. * Base experience
  118320. */
  118321. baseExperience: WebXRExperienceHelper;
  118322. /**
  118323. * Input experience extension
  118324. */
  118325. input: WebXRInput;
  118326. /**
  118327. * Enables laser pointer and selection
  118328. */
  118329. pointerSelection: WebXRControllerPointerSelection;
  118330. /**
  118331. * Enables teleportation
  118332. */
  118333. teleportation: WebXRMotionControllerTeleportation;
  118334. /**
  118335. * Enables ui for entering/exiting xr
  118336. */
  118337. enterExitUI: WebXREnterExitUI;
  118338. /**
  118339. * Default target xr should render to
  118340. */
  118341. renderTarget: WebXRRenderTarget;
  118342. /**
  118343. * Creates the default xr experience
  118344. * @param scene scene
  118345. * @param options options for basic configuration
  118346. * @returns resulting WebXRDefaultExperience
  118347. */
  118348. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  118349. private constructor();
  118350. /**
  118351. * DIsposes of the experience helper
  118352. */
  118353. dispose(): void;
  118354. }
  118355. }
  118356. declare module BABYLON {
  118357. /**
  118358. * Options to modify the vr teleportation behavior.
  118359. */
  118360. export interface VRTeleportationOptions {
  118361. /**
  118362. * The name of the mesh which should be used as the teleportation floor. (default: null)
  118363. */
  118364. floorMeshName?: string;
  118365. /**
  118366. * A list of meshes to be used as the teleportation floor. (default: empty)
  118367. */
  118368. floorMeshes?: Mesh[];
  118369. /**
  118370. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  118371. */
  118372. teleportationMode?: number;
  118373. /**
  118374. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  118375. */
  118376. teleportationTime?: number;
  118377. /**
  118378. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  118379. */
  118380. teleportationSpeed?: number;
  118381. /**
  118382. * The easing function used in the animation or null for Linear. (default CircleEase)
  118383. */
  118384. easingFunction?: EasingFunction;
  118385. }
  118386. /**
  118387. * Options to modify the vr experience helper's behavior.
  118388. */
  118389. export interface VRExperienceHelperOptions extends WebVROptions {
  118390. /**
  118391. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  118392. */
  118393. createDeviceOrientationCamera?: boolean;
  118394. /**
  118395. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  118396. */
  118397. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  118398. /**
  118399. * Uses the main button on the controller to toggle the laser casted. (default: true)
  118400. */
  118401. laserToggle?: boolean;
  118402. /**
  118403. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  118404. */
  118405. floorMeshes?: Mesh[];
  118406. /**
  118407. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  118408. */
  118409. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  118410. /**
  118411. * Defines if WebXR should be used instead of WebVR (if available)
  118412. */
  118413. useXR?: boolean;
  118414. }
  118415. /**
  118416. * Event containing information after VR has been entered
  118417. */
  118418. export class OnAfterEnteringVRObservableEvent {
  118419. /**
  118420. * If entering vr was successful
  118421. */
  118422. success: boolean;
  118423. }
  118424. /**
  118425. * Helps to quickly add VR support to an existing scene.
  118426. * See http://doc.babylonjs.com/how_to/webvr_helper
  118427. */
  118428. export class VRExperienceHelper {
  118429. /** Options to modify the vr experience helper's behavior. */
  118430. webVROptions: VRExperienceHelperOptions;
  118431. private _scene;
  118432. private _position;
  118433. private _btnVR;
  118434. private _btnVRDisplayed;
  118435. private _webVRsupported;
  118436. private _webVRready;
  118437. private _webVRrequesting;
  118438. private _webVRpresenting;
  118439. private _hasEnteredVR;
  118440. private _fullscreenVRpresenting;
  118441. private _inputElement;
  118442. private _webVRCamera;
  118443. private _vrDeviceOrientationCamera;
  118444. private _deviceOrientationCamera;
  118445. private _existingCamera;
  118446. private _onKeyDown;
  118447. private _onVrDisplayPresentChange;
  118448. private _onVRDisplayChanged;
  118449. private _onVRRequestPresentStart;
  118450. private _onVRRequestPresentComplete;
  118451. /**
  118452. * 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)
  118453. */
  118454. enableGazeEvenWhenNoPointerLock: boolean;
  118455. /**
  118456. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  118457. */
  118458. exitVROnDoubleTap: boolean;
  118459. /**
  118460. * Observable raised right before entering VR.
  118461. */
  118462. onEnteringVRObservable: Observable<VRExperienceHelper>;
  118463. /**
  118464. * Observable raised when entering VR has completed.
  118465. */
  118466. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  118467. /**
  118468. * Observable raised when exiting VR.
  118469. */
  118470. onExitingVRObservable: Observable<VRExperienceHelper>;
  118471. /**
  118472. * Observable raised when controller mesh is loaded.
  118473. */
  118474. onControllerMeshLoadedObservable: Observable<WebVRController>;
  118475. /** Return this.onEnteringVRObservable
  118476. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  118477. */
  118478. get onEnteringVR(): Observable<VRExperienceHelper>;
  118479. /** Return this.onExitingVRObservable
  118480. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  118481. */
  118482. get onExitingVR(): Observable<VRExperienceHelper>;
  118483. /** Return this.onControllerMeshLoadedObservable
  118484. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  118485. */
  118486. get onControllerMeshLoaded(): Observable<WebVRController>;
  118487. private _rayLength;
  118488. private _useCustomVRButton;
  118489. private _teleportationRequested;
  118490. private _teleportActive;
  118491. private _floorMeshName;
  118492. private _floorMeshesCollection;
  118493. private _teleportationMode;
  118494. private _teleportationTime;
  118495. private _teleportationSpeed;
  118496. private _teleportationEasing;
  118497. private _rotationAllowed;
  118498. private _teleportBackwardsVector;
  118499. private _teleportationTarget;
  118500. private _isDefaultTeleportationTarget;
  118501. private _postProcessMove;
  118502. private _teleportationFillColor;
  118503. private _teleportationBorderColor;
  118504. private _rotationAngle;
  118505. private _haloCenter;
  118506. private _cameraGazer;
  118507. private _padSensibilityUp;
  118508. private _padSensibilityDown;
  118509. private _leftController;
  118510. private _rightController;
  118511. private _gazeColor;
  118512. private _laserColor;
  118513. private _pickedLaserColor;
  118514. private _pickedGazeColor;
  118515. /**
  118516. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  118517. */
  118518. onNewMeshSelected: Observable<AbstractMesh>;
  118519. /**
  118520. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  118521. * This observable will provide the mesh and the controller used to select the mesh
  118522. */
  118523. onMeshSelectedWithController: Observable<{
  118524. mesh: AbstractMesh;
  118525. controller: WebVRController;
  118526. }>;
  118527. /**
  118528. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  118529. */
  118530. onNewMeshPicked: Observable<PickingInfo>;
  118531. private _circleEase;
  118532. /**
  118533. * Observable raised before camera teleportation
  118534. */
  118535. onBeforeCameraTeleport: Observable<Vector3>;
  118536. /**
  118537. * Observable raised after camera teleportation
  118538. */
  118539. onAfterCameraTeleport: Observable<Vector3>;
  118540. /**
  118541. * Observable raised when current selected mesh gets unselected
  118542. */
  118543. onSelectedMeshUnselected: Observable<AbstractMesh>;
  118544. private _raySelectionPredicate;
  118545. /**
  118546. * To be optionaly changed by user to define custom ray selection
  118547. */
  118548. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  118549. /**
  118550. * To be optionaly changed by user to define custom selection logic (after ray selection)
  118551. */
  118552. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  118553. /**
  118554. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  118555. */
  118556. teleportationEnabled: boolean;
  118557. private _defaultHeight;
  118558. private _teleportationInitialized;
  118559. private _interactionsEnabled;
  118560. private _interactionsRequested;
  118561. private _displayGaze;
  118562. private _displayLaserPointer;
  118563. /**
  118564. * The mesh used to display where the user is going to teleport.
  118565. */
  118566. get teleportationTarget(): Mesh;
  118567. /**
  118568. * Sets the mesh to be used to display where the user is going to teleport.
  118569. */
  118570. set teleportationTarget(value: Mesh);
  118571. /**
  118572. * 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
  118573. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  118574. * See http://doc.babylonjs.com/resources/baking_transformations
  118575. */
  118576. get gazeTrackerMesh(): Mesh;
  118577. set gazeTrackerMesh(value: Mesh);
  118578. /**
  118579. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  118580. */
  118581. updateGazeTrackerScale: boolean;
  118582. /**
  118583. * If the gaze trackers color should be updated when selecting meshes
  118584. */
  118585. updateGazeTrackerColor: boolean;
  118586. /**
  118587. * If the controller laser color should be updated when selecting meshes
  118588. */
  118589. updateControllerLaserColor: boolean;
  118590. /**
  118591. * The gaze tracking mesh corresponding to the left controller
  118592. */
  118593. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  118594. /**
  118595. * The gaze tracking mesh corresponding to the right controller
  118596. */
  118597. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  118598. /**
  118599. * If the ray of the gaze should be displayed.
  118600. */
  118601. get displayGaze(): boolean;
  118602. /**
  118603. * Sets if the ray of the gaze should be displayed.
  118604. */
  118605. set displayGaze(value: boolean);
  118606. /**
  118607. * If the ray of the LaserPointer should be displayed.
  118608. */
  118609. get displayLaserPointer(): boolean;
  118610. /**
  118611. * Sets if the ray of the LaserPointer should be displayed.
  118612. */
  118613. set displayLaserPointer(value: boolean);
  118614. /**
  118615. * The deviceOrientationCamera used as the camera when not in VR.
  118616. */
  118617. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  118618. /**
  118619. * Based on the current WebVR support, returns the current VR camera used.
  118620. */
  118621. get currentVRCamera(): Nullable<Camera>;
  118622. /**
  118623. * The webVRCamera which is used when in VR.
  118624. */
  118625. get webVRCamera(): WebVRFreeCamera;
  118626. /**
  118627. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  118628. */
  118629. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  118630. /**
  118631. * The html button that is used to trigger entering into VR.
  118632. */
  118633. get vrButton(): Nullable<HTMLButtonElement>;
  118634. private get _teleportationRequestInitiated();
  118635. /**
  118636. * Defines whether or not Pointer lock should be requested when switching to
  118637. * full screen.
  118638. */
  118639. requestPointerLockOnFullScreen: boolean;
  118640. /**
  118641. * If asking to force XR, this will be populated with the default xr experience
  118642. */
  118643. xr: WebXRDefaultExperience;
  118644. /**
  118645. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  118646. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  118647. */
  118648. xrTestDone: boolean;
  118649. /**
  118650. * Instantiates a VRExperienceHelper.
  118651. * Helps to quickly add VR support to an existing scene.
  118652. * @param scene The scene the VRExperienceHelper belongs to.
  118653. * @param webVROptions Options to modify the vr experience helper's behavior.
  118654. */
  118655. constructor(scene: Scene,
  118656. /** Options to modify the vr experience helper's behavior. */
  118657. webVROptions?: VRExperienceHelperOptions);
  118658. private completeVRInit;
  118659. private _onDefaultMeshLoaded;
  118660. private _onResize;
  118661. private _onFullscreenChange;
  118662. /**
  118663. * Gets a value indicating if we are currently in VR mode.
  118664. */
  118665. get isInVRMode(): boolean;
  118666. private onVrDisplayPresentChange;
  118667. private onVRDisplayChanged;
  118668. private moveButtonToBottomRight;
  118669. private displayVRButton;
  118670. private updateButtonVisibility;
  118671. private _cachedAngularSensibility;
  118672. /**
  118673. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  118674. * Otherwise, will use the fullscreen API.
  118675. */
  118676. enterVR(): void;
  118677. /**
  118678. * Attempt to exit VR, or fullscreen.
  118679. */
  118680. exitVR(): void;
  118681. /**
  118682. * The position of the vr experience helper.
  118683. */
  118684. get position(): Vector3;
  118685. /**
  118686. * Sets the position of the vr experience helper.
  118687. */
  118688. set position(value: Vector3);
  118689. /**
  118690. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  118691. */
  118692. enableInteractions(): void;
  118693. private get _noControllerIsActive();
  118694. private beforeRender;
  118695. private _isTeleportationFloor;
  118696. /**
  118697. * Adds a floor mesh to be used for teleportation.
  118698. * @param floorMesh the mesh to be used for teleportation.
  118699. */
  118700. addFloorMesh(floorMesh: Mesh): void;
  118701. /**
  118702. * Removes a floor mesh from being used for teleportation.
  118703. * @param floorMesh the mesh to be removed.
  118704. */
  118705. removeFloorMesh(floorMesh: Mesh): void;
  118706. /**
  118707. * Enables interactions and teleportation using the VR controllers and gaze.
  118708. * @param vrTeleportationOptions options to modify teleportation behavior.
  118709. */
  118710. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  118711. private _onNewGamepadConnected;
  118712. private _tryEnableInteractionOnController;
  118713. private _onNewGamepadDisconnected;
  118714. private _enableInteractionOnController;
  118715. private _checkTeleportWithRay;
  118716. private _checkRotate;
  118717. private _checkTeleportBackwards;
  118718. private _enableTeleportationOnController;
  118719. private _createTeleportationCircles;
  118720. private _displayTeleportationTarget;
  118721. private _hideTeleportationTarget;
  118722. private _rotateCamera;
  118723. private _moveTeleportationSelectorTo;
  118724. private _workingVector;
  118725. private _workingQuaternion;
  118726. private _workingMatrix;
  118727. /**
  118728. * Time Constant Teleportation Mode
  118729. */
  118730. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  118731. /**
  118732. * Speed Constant Teleportation Mode
  118733. */
  118734. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  118735. /**
  118736. * Teleports the users feet to the desired location
  118737. * @param location The location where the user's feet should be placed
  118738. */
  118739. teleportCamera(location: Vector3): void;
  118740. private _convertNormalToDirectionOfRay;
  118741. private _castRayAndSelectObject;
  118742. private _notifySelectedMeshUnselected;
  118743. /**
  118744. * Permanently set new colors for the laser pointer
  118745. * @param color the new laser color
  118746. * @param pickedColor the new laser color when picked mesh detected
  118747. */
  118748. setLaserColor(color: Color3, pickedColor?: Color3): void;
  118749. /**
  118750. * Set lighting enabled / disabled on the laser pointer of both controllers
  118751. * @param enabled should the lighting be enabled on the laser pointer
  118752. */
  118753. setLaserLightingState(enabled?: boolean): void;
  118754. /**
  118755. * Permanently set new colors for the gaze pointer
  118756. * @param color the new gaze color
  118757. * @param pickedColor the new gaze color when picked mesh detected
  118758. */
  118759. setGazeColor(color: Color3, pickedColor?: Color3): void;
  118760. /**
  118761. * Sets the color of the laser ray from the vr controllers.
  118762. * @param color new color for the ray.
  118763. */
  118764. changeLaserColor(color: Color3): void;
  118765. /**
  118766. * Sets the color of the ray from the vr headsets gaze.
  118767. * @param color new color for the ray.
  118768. */
  118769. changeGazeColor(color: Color3): void;
  118770. /**
  118771. * Exits VR and disposes of the vr experience helper
  118772. */
  118773. dispose(): void;
  118774. /**
  118775. * Gets the name of the VRExperienceHelper class
  118776. * @returns "VRExperienceHelper"
  118777. */
  118778. getClassName(): string;
  118779. }
  118780. }
  118781. declare module BABYLON {
  118782. /**
  118783. * Contains an array of blocks representing the octree
  118784. */
  118785. export interface IOctreeContainer<T> {
  118786. /**
  118787. * Blocks within the octree
  118788. */
  118789. blocks: Array<OctreeBlock<T>>;
  118790. }
  118791. /**
  118792. * Class used to store a cell in an octree
  118793. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118794. */
  118795. export class OctreeBlock<T> {
  118796. /**
  118797. * Gets the content of the current block
  118798. */
  118799. entries: T[];
  118800. /**
  118801. * Gets the list of block children
  118802. */
  118803. blocks: Array<OctreeBlock<T>>;
  118804. private _depth;
  118805. private _maxDepth;
  118806. private _capacity;
  118807. private _minPoint;
  118808. private _maxPoint;
  118809. private _boundingVectors;
  118810. private _creationFunc;
  118811. /**
  118812. * Creates a new block
  118813. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  118814. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  118815. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118816. * @param depth defines the current depth of this block in the octree
  118817. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  118818. * @param creationFunc defines a callback to call when an element is added to the block
  118819. */
  118820. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  118821. /**
  118822. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  118823. */
  118824. get capacity(): number;
  118825. /**
  118826. * Gets the minimum vector (in world space) of the block's bounding box
  118827. */
  118828. get minPoint(): Vector3;
  118829. /**
  118830. * Gets the maximum vector (in world space) of the block's bounding box
  118831. */
  118832. get maxPoint(): Vector3;
  118833. /**
  118834. * Add a new element to this block
  118835. * @param entry defines the element to add
  118836. */
  118837. addEntry(entry: T): void;
  118838. /**
  118839. * Remove an element from this block
  118840. * @param entry defines the element to remove
  118841. */
  118842. removeEntry(entry: T): void;
  118843. /**
  118844. * Add an array of elements to this block
  118845. * @param entries defines the array of elements to add
  118846. */
  118847. addEntries(entries: T[]): void;
  118848. /**
  118849. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  118850. * @param frustumPlanes defines the frustum planes to test
  118851. * @param selection defines the array to store current content if selection is positive
  118852. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118853. */
  118854. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118855. /**
  118856. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  118857. * @param sphereCenter defines the bounding sphere center
  118858. * @param sphereRadius defines the bounding sphere radius
  118859. * @param selection defines the array to store current content if selection is positive
  118860. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118861. */
  118862. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  118863. /**
  118864. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  118865. * @param ray defines the ray to test with
  118866. * @param selection defines the array to store current content if selection is positive
  118867. */
  118868. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  118869. /**
  118870. * Subdivide the content into child blocks (this block will then be empty)
  118871. */
  118872. createInnerBlocks(): void;
  118873. /**
  118874. * @hidden
  118875. */
  118876. 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;
  118877. }
  118878. }
  118879. declare module BABYLON {
  118880. /**
  118881. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  118882. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118883. */
  118884. export class Octree<T> {
  118885. /** 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.) */
  118886. maxDepth: number;
  118887. /**
  118888. * Blocks within the octree containing objects
  118889. */
  118890. blocks: Array<OctreeBlock<T>>;
  118891. /**
  118892. * Content stored in the octree
  118893. */
  118894. dynamicContent: T[];
  118895. private _maxBlockCapacity;
  118896. private _selectionContent;
  118897. private _creationFunc;
  118898. /**
  118899. * Creates a octree
  118900. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118901. * @param creationFunc function to be used to instatiate the octree
  118902. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  118903. * @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.)
  118904. */
  118905. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  118906. /** 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.) */
  118907. maxDepth?: number);
  118908. /**
  118909. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  118910. * @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);
  118911. * @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);
  118912. * @param entries meshes to be added to the octree blocks
  118913. */
  118914. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  118915. /**
  118916. * Adds a mesh to the octree
  118917. * @param entry Mesh to add to the octree
  118918. */
  118919. addMesh(entry: T): void;
  118920. /**
  118921. * Remove an element from the octree
  118922. * @param entry defines the element to remove
  118923. */
  118924. removeMesh(entry: T): void;
  118925. /**
  118926. * Selects an array of meshes within the frustum
  118927. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  118928. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  118929. * @returns array of meshes within the frustum
  118930. */
  118931. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  118932. /**
  118933. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  118934. * @param sphereCenter defines the bounding sphere center
  118935. * @param sphereRadius defines the bounding sphere radius
  118936. * @param allowDuplicate defines if the selection array can contains duplicated entries
  118937. * @returns an array of objects that intersect the sphere
  118938. */
  118939. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  118940. /**
  118941. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  118942. * @param ray defines the ray to test with
  118943. * @returns array of intersected objects
  118944. */
  118945. intersectsRay(ray: Ray): SmartArray<T>;
  118946. /**
  118947. * Adds a mesh into the octree block if it intersects the block
  118948. */
  118949. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  118950. /**
  118951. * Adds a submesh into the octree block if it intersects the block
  118952. */
  118953. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  118954. }
  118955. }
  118956. declare module BABYLON {
  118957. interface Scene {
  118958. /**
  118959. * @hidden
  118960. * Backing Filed
  118961. */
  118962. _selectionOctree: Octree<AbstractMesh>;
  118963. /**
  118964. * Gets the octree used to boost mesh selection (picking)
  118965. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118966. */
  118967. selectionOctree: Octree<AbstractMesh>;
  118968. /**
  118969. * Creates or updates the octree used to boost selection (picking)
  118970. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118971. * @param maxCapacity defines the maximum capacity per leaf
  118972. * @param maxDepth defines the maximum depth of the octree
  118973. * @returns an octree of AbstractMesh
  118974. */
  118975. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  118976. }
  118977. interface AbstractMesh {
  118978. /**
  118979. * @hidden
  118980. * Backing Field
  118981. */
  118982. _submeshesOctree: Octree<SubMesh>;
  118983. /**
  118984. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  118985. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  118986. * @param maxCapacity defines the maximum size of each block (64 by default)
  118987. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  118988. * @returns the new octree
  118989. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  118990. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  118991. */
  118992. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  118993. }
  118994. /**
  118995. * Defines the octree scene component responsible to manage any octrees
  118996. * in a given scene.
  118997. */
  118998. export class OctreeSceneComponent {
  118999. /**
  119000. * The component name help to identify the component in the list of scene components.
  119001. */
  119002. readonly name: string;
  119003. /**
  119004. * The scene the component belongs to.
  119005. */
  119006. scene: Scene;
  119007. /**
  119008. * Indicates if the meshes have been checked to make sure they are isEnabled()
  119009. */
  119010. readonly checksIsEnabled: boolean;
  119011. /**
  119012. * Creates a new instance of the component for the given scene
  119013. * @param scene Defines the scene to register the component in
  119014. */
  119015. constructor(scene: Scene);
  119016. /**
  119017. * Registers the component in a given scene
  119018. */
  119019. register(): void;
  119020. /**
  119021. * Return the list of active meshes
  119022. * @returns the list of active meshes
  119023. */
  119024. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  119025. /**
  119026. * Return the list of active sub meshes
  119027. * @param mesh The mesh to get the candidates sub meshes from
  119028. * @returns the list of active sub meshes
  119029. */
  119030. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  119031. private _tempRay;
  119032. /**
  119033. * Return the list of sub meshes intersecting with a given local ray
  119034. * @param mesh defines the mesh to find the submesh for
  119035. * @param localRay defines the ray in local space
  119036. * @returns the list of intersecting sub meshes
  119037. */
  119038. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  119039. /**
  119040. * Return the list of sub meshes colliding with a collider
  119041. * @param mesh defines the mesh to find the submesh for
  119042. * @param collider defines the collider to evaluate the collision against
  119043. * @returns the list of colliding sub meshes
  119044. */
  119045. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  119046. /**
  119047. * Rebuilds the elements related to this component in case of
  119048. * context lost for instance.
  119049. */
  119050. rebuild(): void;
  119051. /**
  119052. * Disposes the component and the associated ressources.
  119053. */
  119054. dispose(): void;
  119055. }
  119056. }
  119057. declare module BABYLON {
  119058. /**
  119059. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  119060. */
  119061. export class Gizmo implements IDisposable {
  119062. /** The utility layer the gizmo will be added to */
  119063. gizmoLayer: UtilityLayerRenderer;
  119064. /**
  119065. * The root mesh of the gizmo
  119066. */
  119067. _rootMesh: Mesh;
  119068. private _attachedMesh;
  119069. /**
  119070. * Ratio for the scale of the gizmo (Default: 1)
  119071. */
  119072. scaleRatio: number;
  119073. /**
  119074. * If a custom mesh has been set (Default: false)
  119075. */
  119076. protected _customMeshSet: boolean;
  119077. /**
  119078. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  119079. * * When set, interactions will be enabled
  119080. */
  119081. get attachedMesh(): Nullable<AbstractMesh>;
  119082. set attachedMesh(value: Nullable<AbstractMesh>);
  119083. /**
  119084. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  119085. * @param mesh The mesh to replace the default mesh of the gizmo
  119086. */
  119087. setCustomMesh(mesh: Mesh): void;
  119088. /**
  119089. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  119090. */
  119091. updateGizmoRotationToMatchAttachedMesh: boolean;
  119092. /**
  119093. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  119094. */
  119095. updateGizmoPositionToMatchAttachedMesh: boolean;
  119096. /**
  119097. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  119098. */
  119099. updateScale: boolean;
  119100. protected _interactionsEnabled: boolean;
  119101. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119102. private _beforeRenderObserver;
  119103. private _tempVector;
  119104. /**
  119105. * Creates a gizmo
  119106. * @param gizmoLayer The utility layer the gizmo will be added to
  119107. */
  119108. constructor(
  119109. /** The utility layer the gizmo will be added to */
  119110. gizmoLayer?: UtilityLayerRenderer);
  119111. /**
  119112. * Updates the gizmo to match the attached mesh's position/rotation
  119113. */
  119114. protected _update(): void;
  119115. /**
  119116. * Disposes of the gizmo
  119117. */
  119118. dispose(): void;
  119119. }
  119120. }
  119121. declare module BABYLON {
  119122. /**
  119123. * Single plane drag gizmo
  119124. */
  119125. export class PlaneDragGizmo extends Gizmo {
  119126. /**
  119127. * Drag behavior responsible for the gizmos dragging interactions
  119128. */
  119129. dragBehavior: PointerDragBehavior;
  119130. private _pointerObserver;
  119131. /**
  119132. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119133. */
  119134. snapDistance: number;
  119135. /**
  119136. * Event that fires each time the gizmo snaps to a new location.
  119137. * * snapDistance is the the change in distance
  119138. */
  119139. onSnapObservable: Observable<{
  119140. snapDistance: number;
  119141. }>;
  119142. private _plane;
  119143. private _coloredMaterial;
  119144. private _hoverMaterial;
  119145. private _isEnabled;
  119146. private _parent;
  119147. /** @hidden */
  119148. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  119149. /** @hidden */
  119150. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119151. /**
  119152. * Creates a PlaneDragGizmo
  119153. * @param gizmoLayer The utility layer the gizmo will be added to
  119154. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  119155. * @param color The color of the gizmo
  119156. */
  119157. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119158. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119159. /**
  119160. * If the gizmo is enabled
  119161. */
  119162. set isEnabled(value: boolean);
  119163. get isEnabled(): boolean;
  119164. /**
  119165. * Disposes of the gizmo
  119166. */
  119167. dispose(): void;
  119168. }
  119169. }
  119170. declare module BABYLON {
  119171. /**
  119172. * Gizmo that enables dragging a mesh along 3 axis
  119173. */
  119174. export class PositionGizmo extends Gizmo {
  119175. /**
  119176. * Internal gizmo used for interactions on the x axis
  119177. */
  119178. xGizmo: AxisDragGizmo;
  119179. /**
  119180. * Internal gizmo used for interactions on the y axis
  119181. */
  119182. yGizmo: AxisDragGizmo;
  119183. /**
  119184. * Internal gizmo used for interactions on the z axis
  119185. */
  119186. zGizmo: AxisDragGizmo;
  119187. /**
  119188. * Internal gizmo used for interactions on the yz plane
  119189. */
  119190. xPlaneGizmo: PlaneDragGizmo;
  119191. /**
  119192. * Internal gizmo used for interactions on the xz plane
  119193. */
  119194. yPlaneGizmo: PlaneDragGizmo;
  119195. /**
  119196. * Internal gizmo used for interactions on the xy plane
  119197. */
  119198. zPlaneGizmo: PlaneDragGizmo;
  119199. /**
  119200. * private variables
  119201. */
  119202. private _meshAttached;
  119203. private _updateGizmoRotationToMatchAttachedMesh;
  119204. private _snapDistance;
  119205. private _scaleRatio;
  119206. /** Fires an event when any of it's sub gizmos are dragged */
  119207. onDragStartObservable: Observable<unknown>;
  119208. /** Fires an event when any of it's sub gizmos are released from dragging */
  119209. onDragEndObservable: Observable<unknown>;
  119210. /**
  119211. * If set to true, planar drag is enabled
  119212. */
  119213. private _planarGizmoEnabled;
  119214. get attachedMesh(): Nullable<AbstractMesh>;
  119215. set attachedMesh(mesh: Nullable<AbstractMesh>);
  119216. /**
  119217. * Creates a PositionGizmo
  119218. * @param gizmoLayer The utility layer the gizmo will be added to
  119219. */
  119220. constructor(gizmoLayer?: UtilityLayerRenderer);
  119221. /**
  119222. * If the planar drag gizmo is enabled
  119223. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  119224. */
  119225. set planarGizmoEnabled(value: boolean);
  119226. get planarGizmoEnabled(): boolean;
  119227. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  119228. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  119229. /**
  119230. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119231. */
  119232. set snapDistance(value: number);
  119233. get snapDistance(): number;
  119234. /**
  119235. * Ratio for the scale of the gizmo (Default: 1)
  119236. */
  119237. set scaleRatio(value: number);
  119238. get scaleRatio(): number;
  119239. /**
  119240. * Disposes of the gizmo
  119241. */
  119242. dispose(): void;
  119243. /**
  119244. * CustomMeshes are not supported by this gizmo
  119245. * @param mesh The mesh to replace the default mesh of the gizmo
  119246. */
  119247. setCustomMesh(mesh: Mesh): void;
  119248. }
  119249. }
  119250. declare module BABYLON {
  119251. /**
  119252. * Single axis drag gizmo
  119253. */
  119254. export class AxisDragGizmo extends Gizmo {
  119255. /**
  119256. * Drag behavior responsible for the gizmos dragging interactions
  119257. */
  119258. dragBehavior: PointerDragBehavior;
  119259. private _pointerObserver;
  119260. /**
  119261. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  119262. */
  119263. snapDistance: number;
  119264. /**
  119265. * Event that fires each time the gizmo snaps to a new location.
  119266. * * snapDistance is the the change in distance
  119267. */
  119268. onSnapObservable: Observable<{
  119269. snapDistance: number;
  119270. }>;
  119271. private _isEnabled;
  119272. private _parent;
  119273. private _arrow;
  119274. private _coloredMaterial;
  119275. private _hoverMaterial;
  119276. /** @hidden */
  119277. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  119278. /** @hidden */
  119279. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  119280. /**
  119281. * Creates an AxisDragGizmo
  119282. * @param gizmoLayer The utility layer the gizmo will be added to
  119283. * @param dragAxis The axis which the gizmo will be able to drag on
  119284. * @param color The color of the gizmo
  119285. */
  119286. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  119287. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  119288. /**
  119289. * If the gizmo is enabled
  119290. */
  119291. set isEnabled(value: boolean);
  119292. get isEnabled(): boolean;
  119293. /**
  119294. * Disposes of the gizmo
  119295. */
  119296. dispose(): void;
  119297. }
  119298. }
  119299. declare module BABYLON.Debug {
  119300. /**
  119301. * The Axes viewer will show 3 axes in a specific point in space
  119302. */
  119303. export class AxesViewer {
  119304. private _xAxis;
  119305. private _yAxis;
  119306. private _zAxis;
  119307. private _scaleLinesFactor;
  119308. private _instanced;
  119309. /**
  119310. * Gets the hosting scene
  119311. */
  119312. scene: Scene;
  119313. /**
  119314. * Gets or sets a number used to scale line length
  119315. */
  119316. scaleLines: number;
  119317. /** Gets the node hierarchy used to render x-axis */
  119318. get xAxis(): TransformNode;
  119319. /** Gets the node hierarchy used to render y-axis */
  119320. get yAxis(): TransformNode;
  119321. /** Gets the node hierarchy used to render z-axis */
  119322. get zAxis(): TransformNode;
  119323. /**
  119324. * Creates a new AxesViewer
  119325. * @param scene defines the hosting scene
  119326. * @param scaleLines defines a number used to scale line length (1 by default)
  119327. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  119328. * @param xAxis defines the node hierarchy used to render the x-axis
  119329. * @param yAxis defines the node hierarchy used to render the y-axis
  119330. * @param zAxis defines the node hierarchy used to render the z-axis
  119331. */
  119332. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  119333. /**
  119334. * Force the viewer to update
  119335. * @param position defines the position of the viewer
  119336. * @param xaxis defines the x axis of the viewer
  119337. * @param yaxis defines the y axis of the viewer
  119338. * @param zaxis defines the z axis of the viewer
  119339. */
  119340. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  119341. /**
  119342. * Creates an instance of this axes viewer.
  119343. * @returns a new axes viewer with instanced meshes
  119344. */
  119345. createInstance(): AxesViewer;
  119346. /** Releases resources */
  119347. dispose(): void;
  119348. private static _SetRenderingGroupId;
  119349. }
  119350. }
  119351. declare module BABYLON.Debug {
  119352. /**
  119353. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  119354. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  119355. */
  119356. export class BoneAxesViewer extends AxesViewer {
  119357. /**
  119358. * Gets or sets the target mesh where to display the axes viewer
  119359. */
  119360. mesh: Nullable<Mesh>;
  119361. /**
  119362. * Gets or sets the target bone where to display the axes viewer
  119363. */
  119364. bone: Nullable<Bone>;
  119365. /** Gets current position */
  119366. pos: Vector3;
  119367. /** Gets direction of X axis */
  119368. xaxis: Vector3;
  119369. /** Gets direction of Y axis */
  119370. yaxis: Vector3;
  119371. /** Gets direction of Z axis */
  119372. zaxis: Vector3;
  119373. /**
  119374. * Creates a new BoneAxesViewer
  119375. * @param scene defines the hosting scene
  119376. * @param bone defines the target bone
  119377. * @param mesh defines the target mesh
  119378. * @param scaleLines defines a scaling factor for line length (1 by default)
  119379. */
  119380. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  119381. /**
  119382. * Force the viewer to update
  119383. */
  119384. update(): void;
  119385. /** Releases resources */
  119386. dispose(): void;
  119387. }
  119388. }
  119389. declare module BABYLON {
  119390. /**
  119391. * Interface used to define scene explorer extensibility option
  119392. */
  119393. export interface IExplorerExtensibilityOption {
  119394. /**
  119395. * Define the option label
  119396. */
  119397. label: string;
  119398. /**
  119399. * Defines the action to execute on click
  119400. */
  119401. action: (entity: any) => void;
  119402. }
  119403. /**
  119404. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  119405. */
  119406. export interface IExplorerExtensibilityGroup {
  119407. /**
  119408. * Defines a predicate to test if a given type mut be extended
  119409. */
  119410. predicate: (entity: any) => boolean;
  119411. /**
  119412. * Gets the list of options added to a type
  119413. */
  119414. entries: IExplorerExtensibilityOption[];
  119415. }
  119416. /**
  119417. * Interface used to define the options to use to create the Inspector
  119418. */
  119419. export interface IInspectorOptions {
  119420. /**
  119421. * Display in overlay mode (default: false)
  119422. */
  119423. overlay?: boolean;
  119424. /**
  119425. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  119426. */
  119427. globalRoot?: HTMLElement;
  119428. /**
  119429. * Display the Scene explorer
  119430. */
  119431. showExplorer?: boolean;
  119432. /**
  119433. * Display the property inspector
  119434. */
  119435. showInspector?: boolean;
  119436. /**
  119437. * Display in embed mode (both panes on the right)
  119438. */
  119439. embedMode?: boolean;
  119440. /**
  119441. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  119442. */
  119443. handleResize?: boolean;
  119444. /**
  119445. * Allow the panes to popup (default: true)
  119446. */
  119447. enablePopup?: boolean;
  119448. /**
  119449. * Allow the panes to be closed by users (default: true)
  119450. */
  119451. enableClose?: boolean;
  119452. /**
  119453. * Optional list of extensibility entries
  119454. */
  119455. explorerExtensibility?: IExplorerExtensibilityGroup[];
  119456. /**
  119457. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  119458. */
  119459. inspectorURL?: string;
  119460. /**
  119461. * Optional initial tab (default to DebugLayerTab.Properties)
  119462. */
  119463. initialTab?: DebugLayerTab;
  119464. }
  119465. interface Scene {
  119466. /**
  119467. * @hidden
  119468. * Backing field
  119469. */
  119470. _debugLayer: DebugLayer;
  119471. /**
  119472. * Gets the debug layer (aka Inspector) associated with the scene
  119473. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119474. */
  119475. debugLayer: DebugLayer;
  119476. }
  119477. /**
  119478. * Enum of inspector action tab
  119479. */
  119480. export enum DebugLayerTab {
  119481. /**
  119482. * Properties tag (default)
  119483. */
  119484. Properties = 0,
  119485. /**
  119486. * Debug tab
  119487. */
  119488. Debug = 1,
  119489. /**
  119490. * Statistics tab
  119491. */
  119492. Statistics = 2,
  119493. /**
  119494. * Tools tab
  119495. */
  119496. Tools = 3,
  119497. /**
  119498. * Settings tab
  119499. */
  119500. Settings = 4
  119501. }
  119502. /**
  119503. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119504. * what is happening in your scene
  119505. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119506. */
  119507. export class DebugLayer {
  119508. /**
  119509. * Define the url to get the inspector script from.
  119510. * By default it uses the babylonjs CDN.
  119511. * @ignoreNaming
  119512. */
  119513. static InspectorURL: string;
  119514. private _scene;
  119515. private BJSINSPECTOR;
  119516. private _onPropertyChangedObservable?;
  119517. /**
  119518. * Observable triggered when a property is changed through the inspector.
  119519. */
  119520. get onPropertyChangedObservable(): any;
  119521. /**
  119522. * Instantiates a new debug layer.
  119523. * The debug layer (aka Inspector) is the go to tool in order to better understand
  119524. * what is happening in your scene
  119525. * @see http://doc.babylonjs.com/features/playground_debuglayer
  119526. * @param scene Defines the scene to inspect
  119527. */
  119528. constructor(scene: Scene);
  119529. /** Creates the inspector window. */
  119530. private _createInspector;
  119531. /**
  119532. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  119533. * @param entity defines the entity to select
  119534. * @param lineContainerTitle defines the specific block to highlight
  119535. */
  119536. select(entity: any, lineContainerTitle?: string): void;
  119537. /** Get the inspector from bundle or global */
  119538. private _getGlobalInspector;
  119539. /**
  119540. * Get if the inspector is visible or not.
  119541. * @returns true if visible otherwise, false
  119542. */
  119543. isVisible(): boolean;
  119544. /**
  119545. * Hide the inspector and close its window.
  119546. */
  119547. hide(): void;
  119548. /**
  119549. * Launch the debugLayer.
  119550. * @param config Define the configuration of the inspector
  119551. * @return a promise fulfilled when the debug layer is visible
  119552. */
  119553. show(config?: IInspectorOptions): Promise<DebugLayer>;
  119554. }
  119555. }
  119556. declare module BABYLON {
  119557. /**
  119558. * Class containing static functions to help procedurally build meshes
  119559. */
  119560. export class BoxBuilder {
  119561. /**
  119562. * Creates a box mesh
  119563. * * The parameter `size` sets the size (float) of each box side (default 1)
  119564. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  119565. * * 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)
  119566. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  119567. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  119568. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  119569. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119570. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  119571. * @param name defines the name of the mesh
  119572. * @param options defines the options used to create the mesh
  119573. * @param scene defines the hosting scene
  119574. * @returns the box mesh
  119575. */
  119576. static CreateBox(name: string, options: {
  119577. size?: number;
  119578. width?: number;
  119579. height?: number;
  119580. depth?: number;
  119581. faceUV?: Vector4[];
  119582. faceColors?: Color4[];
  119583. sideOrientation?: number;
  119584. frontUVs?: Vector4;
  119585. backUVs?: Vector4;
  119586. wrap?: boolean;
  119587. topBaseAt?: number;
  119588. bottomBaseAt?: number;
  119589. updatable?: boolean;
  119590. }, scene?: Nullable<Scene>): Mesh;
  119591. }
  119592. }
  119593. declare module BABYLON.Debug {
  119594. /**
  119595. * Used to show the physics impostor around the specific mesh
  119596. */
  119597. export class PhysicsViewer {
  119598. /** @hidden */
  119599. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  119600. /** @hidden */
  119601. protected _meshes: Array<Nullable<AbstractMesh>>;
  119602. /** @hidden */
  119603. protected _scene: Nullable<Scene>;
  119604. /** @hidden */
  119605. protected _numMeshes: number;
  119606. /** @hidden */
  119607. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  119608. private _renderFunction;
  119609. private _utilityLayer;
  119610. private _debugBoxMesh;
  119611. private _debugSphereMesh;
  119612. private _debugCylinderMesh;
  119613. private _debugMaterial;
  119614. private _debugMeshMeshes;
  119615. /**
  119616. * Creates a new PhysicsViewer
  119617. * @param scene defines the hosting scene
  119618. */
  119619. constructor(scene: Scene);
  119620. /** @hidden */
  119621. protected _updateDebugMeshes(): void;
  119622. /**
  119623. * Renders a specified physic impostor
  119624. * @param impostor defines the impostor to render
  119625. * @param targetMesh defines the mesh represented by the impostor
  119626. * @returns the new debug mesh used to render the impostor
  119627. */
  119628. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  119629. /**
  119630. * Hides a specified physic impostor
  119631. * @param impostor defines the impostor to hide
  119632. */
  119633. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  119634. private _getDebugMaterial;
  119635. private _getDebugBoxMesh;
  119636. private _getDebugSphereMesh;
  119637. private _getDebugCylinderMesh;
  119638. private _getDebugMeshMesh;
  119639. private _getDebugMesh;
  119640. /** Releases all resources */
  119641. dispose(): void;
  119642. }
  119643. }
  119644. declare module BABYLON {
  119645. /**
  119646. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119647. * in order to better appreciate the issue one might have.
  119648. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119649. */
  119650. export class RayHelper {
  119651. /**
  119652. * Defines the ray we are currently tryin to visualize.
  119653. */
  119654. ray: Nullable<Ray>;
  119655. private _renderPoints;
  119656. private _renderLine;
  119657. private _renderFunction;
  119658. private _scene;
  119659. private _updateToMeshFunction;
  119660. private _attachedToMesh;
  119661. private _meshSpaceDirection;
  119662. private _meshSpaceOrigin;
  119663. /**
  119664. * Helper function to create a colored helper in a scene in one line.
  119665. * @param ray Defines the ray we are currently tryin to visualize
  119666. * @param scene Defines the scene the ray is used in
  119667. * @param color Defines the color we want to see the ray in
  119668. * @returns The newly created ray helper.
  119669. */
  119670. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  119671. /**
  119672. * Instantiate a new ray helper.
  119673. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  119674. * in order to better appreciate the issue one might have.
  119675. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  119676. * @param ray Defines the ray we are currently tryin to visualize
  119677. */
  119678. constructor(ray: Ray);
  119679. /**
  119680. * Shows the ray we are willing to debug.
  119681. * @param scene Defines the scene the ray needs to be rendered in
  119682. * @param color Defines the color the ray needs to be rendered in
  119683. */
  119684. show(scene: Scene, color?: Color3): void;
  119685. /**
  119686. * Hides the ray we are debugging.
  119687. */
  119688. hide(): void;
  119689. private _render;
  119690. /**
  119691. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  119692. * @param mesh Defines the mesh we want the helper attached to
  119693. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  119694. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  119695. * @param length Defines the length of the ray
  119696. */
  119697. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  119698. /**
  119699. * Detach the ray helper from the mesh it has previously been attached to.
  119700. */
  119701. detachFromMesh(): void;
  119702. private _updateToMesh;
  119703. /**
  119704. * Dispose the helper and release its associated resources.
  119705. */
  119706. dispose(): void;
  119707. }
  119708. }
  119709. declare module BABYLON.Debug {
  119710. /**
  119711. * Class used to render a debug view of a given skeleton
  119712. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  119713. */
  119714. export class SkeletonViewer {
  119715. /** defines the skeleton to render */
  119716. skeleton: Skeleton;
  119717. /** defines the mesh attached to the skeleton */
  119718. mesh: AbstractMesh;
  119719. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119720. autoUpdateBonesMatrices: boolean;
  119721. /** defines the rendering group id to use with the viewer */
  119722. renderingGroupId: number;
  119723. /** Gets or sets the color used to render the skeleton */
  119724. color: Color3;
  119725. private _scene;
  119726. private _debugLines;
  119727. private _debugMesh;
  119728. private _isEnabled;
  119729. private _renderFunction;
  119730. private _utilityLayer;
  119731. /**
  119732. * Returns the mesh used to render the bones
  119733. */
  119734. get debugMesh(): Nullable<LinesMesh>;
  119735. /**
  119736. * Creates a new SkeletonViewer
  119737. * @param skeleton defines the skeleton to render
  119738. * @param mesh defines the mesh attached to the skeleton
  119739. * @param scene defines the hosting scene
  119740. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  119741. * @param renderingGroupId defines the rendering group id to use with the viewer
  119742. */
  119743. constructor(
  119744. /** defines the skeleton to render */
  119745. skeleton: Skeleton,
  119746. /** defines the mesh attached to the skeleton */
  119747. mesh: AbstractMesh, scene: Scene,
  119748. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  119749. autoUpdateBonesMatrices?: boolean,
  119750. /** defines the rendering group id to use with the viewer */
  119751. renderingGroupId?: number);
  119752. /** Gets or sets a boolean indicating if the viewer is enabled */
  119753. set isEnabled(value: boolean);
  119754. get isEnabled(): boolean;
  119755. private _getBonePosition;
  119756. private _getLinesForBonesWithLength;
  119757. private _getLinesForBonesNoLength;
  119758. /** Update the viewer to sync with current skeleton state */
  119759. update(): void;
  119760. /** Release associated resources */
  119761. dispose(): void;
  119762. }
  119763. }
  119764. declare module BABYLON {
  119765. /**
  119766. * Options to create the null engine
  119767. */
  119768. export class NullEngineOptions {
  119769. /**
  119770. * Render width (Default: 512)
  119771. */
  119772. renderWidth: number;
  119773. /**
  119774. * Render height (Default: 256)
  119775. */
  119776. renderHeight: number;
  119777. /**
  119778. * Texture size (Default: 512)
  119779. */
  119780. textureSize: number;
  119781. /**
  119782. * If delta time between frames should be constant
  119783. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119784. */
  119785. deterministicLockstep: boolean;
  119786. /**
  119787. * Maximum about of steps between frames (Default: 4)
  119788. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119789. */
  119790. lockstepMaxSteps: number;
  119791. }
  119792. /**
  119793. * The null engine class provides support for headless version of babylon.js.
  119794. * This can be used in server side scenario or for testing purposes
  119795. */
  119796. export class NullEngine extends Engine {
  119797. private _options;
  119798. /**
  119799. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  119800. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119801. * @returns true if engine is in deterministic lock step mode
  119802. */
  119803. isDeterministicLockStep(): boolean;
  119804. /**
  119805. * Gets the max steps when engine is running in deterministic lock step
  119806. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  119807. * @returns the max steps
  119808. */
  119809. getLockstepMaxSteps(): number;
  119810. /**
  119811. * Gets the current hardware scaling level.
  119812. * By default the hardware scaling level is computed from the window device ratio.
  119813. * 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.
  119814. * @returns a number indicating the current hardware scaling level
  119815. */
  119816. getHardwareScalingLevel(): number;
  119817. constructor(options?: NullEngineOptions);
  119818. /**
  119819. * Creates a vertex buffer
  119820. * @param vertices the data for the vertex buffer
  119821. * @returns the new WebGL static buffer
  119822. */
  119823. createVertexBuffer(vertices: FloatArray): DataBuffer;
  119824. /**
  119825. * Creates a new index buffer
  119826. * @param indices defines the content of the index buffer
  119827. * @param updatable defines if the index buffer must be updatable
  119828. * @returns a new webGL buffer
  119829. */
  119830. createIndexBuffer(indices: IndicesArray): DataBuffer;
  119831. /**
  119832. * Clear the current render buffer or the current render target (if any is set up)
  119833. * @param color defines the color to use
  119834. * @param backBuffer defines if the back buffer must be cleared
  119835. * @param depth defines if the depth buffer must be cleared
  119836. * @param stencil defines if the stencil buffer must be cleared
  119837. */
  119838. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  119839. /**
  119840. * Gets the current render width
  119841. * @param useScreen defines if screen size must be used (or the current render target if any)
  119842. * @returns a number defining the current render width
  119843. */
  119844. getRenderWidth(useScreen?: boolean): number;
  119845. /**
  119846. * Gets the current render height
  119847. * @param useScreen defines if screen size must be used (or the current render target if any)
  119848. * @returns a number defining the current render height
  119849. */
  119850. getRenderHeight(useScreen?: boolean): number;
  119851. /**
  119852. * Set the WebGL's viewport
  119853. * @param viewport defines the viewport element to be used
  119854. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  119855. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  119856. */
  119857. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  119858. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  119859. /**
  119860. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  119861. * @param pipelineContext defines the pipeline context to use
  119862. * @param uniformsNames defines the list of uniform names
  119863. * @returns an array of webGL uniform locations
  119864. */
  119865. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  119866. /**
  119867. * Gets the lsit of active attributes for a given webGL program
  119868. * @param pipelineContext defines the pipeline context to use
  119869. * @param attributesNames defines the list of attribute names to get
  119870. * @returns an array of indices indicating the offset of each attribute
  119871. */
  119872. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  119873. /**
  119874. * Binds an effect to the webGL context
  119875. * @param effect defines the effect to bind
  119876. */
  119877. bindSamplers(effect: Effect): void;
  119878. /**
  119879. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  119880. * @param effect defines the effect to activate
  119881. */
  119882. enableEffect(effect: Effect): void;
  119883. /**
  119884. * Set various states to the webGL context
  119885. * @param culling defines backface culling state
  119886. * @param zOffset defines the value to apply to zOffset (0 by default)
  119887. * @param force defines if states must be applied even if cache is up to date
  119888. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  119889. */
  119890. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  119891. /**
  119892. * Set the value of an uniform to an array of int32
  119893. * @param uniform defines the webGL uniform location where to store the value
  119894. * @param array defines the array of int32 to store
  119895. */
  119896. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  119897. /**
  119898. * Set the value of an uniform to an array of int32 (stored as vec2)
  119899. * @param uniform defines the webGL uniform location where to store the value
  119900. * @param array defines the array of int32 to store
  119901. */
  119902. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  119903. /**
  119904. * Set the value of an uniform to an array of int32 (stored as vec3)
  119905. * @param uniform defines the webGL uniform location where to store the value
  119906. * @param array defines the array of int32 to store
  119907. */
  119908. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  119909. /**
  119910. * Set the value of an uniform to an array of int32 (stored as vec4)
  119911. * @param uniform defines the webGL uniform location where to store the value
  119912. * @param array defines the array of int32 to store
  119913. */
  119914. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  119915. /**
  119916. * Set the value of an uniform to an array of float32
  119917. * @param uniform defines the webGL uniform location where to store the value
  119918. * @param array defines the array of float32 to store
  119919. */
  119920. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  119921. /**
  119922. * Set the value of an uniform to an array of float32 (stored as vec2)
  119923. * @param uniform defines the webGL uniform location where to store the value
  119924. * @param array defines the array of float32 to store
  119925. */
  119926. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  119927. /**
  119928. * Set the value of an uniform to an array of float32 (stored as vec3)
  119929. * @param uniform defines the webGL uniform location where to store the value
  119930. * @param array defines the array of float32 to store
  119931. */
  119932. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  119933. /**
  119934. * Set the value of an uniform to an array of float32 (stored as vec4)
  119935. * @param uniform defines the webGL uniform location where to store the value
  119936. * @param array defines the array of float32 to store
  119937. */
  119938. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  119939. /**
  119940. * Set the value of an uniform to an array of number
  119941. * @param uniform defines the webGL uniform location where to store the value
  119942. * @param array defines the array of number to store
  119943. */
  119944. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  119945. /**
  119946. * Set the value of an uniform to an array of number (stored as vec2)
  119947. * @param uniform defines the webGL uniform location where to store the value
  119948. * @param array defines the array of number to store
  119949. */
  119950. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  119951. /**
  119952. * Set the value of an uniform to an array of number (stored as vec3)
  119953. * @param uniform defines the webGL uniform location where to store the value
  119954. * @param array defines the array of number to store
  119955. */
  119956. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  119957. /**
  119958. * Set the value of an uniform to an array of number (stored as vec4)
  119959. * @param uniform defines the webGL uniform location where to store the value
  119960. * @param array defines the array of number to store
  119961. */
  119962. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  119963. /**
  119964. * Set the value of an uniform to an array of float32 (stored as matrices)
  119965. * @param uniform defines the webGL uniform location where to store the value
  119966. * @param matrices defines the array of float32 to store
  119967. */
  119968. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  119969. /**
  119970. * Set the value of an uniform to a matrix (3x3)
  119971. * @param uniform defines the webGL uniform location where to store the value
  119972. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  119973. */
  119974. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119975. /**
  119976. * Set the value of an uniform to a matrix (2x2)
  119977. * @param uniform defines the webGL uniform location where to store the value
  119978. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  119979. */
  119980. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  119981. /**
  119982. * Set the value of an uniform to a number (float)
  119983. * @param uniform defines the webGL uniform location where to store the value
  119984. * @param value defines the float number to store
  119985. */
  119986. setFloat(uniform: WebGLUniformLocation, value: number): void;
  119987. /**
  119988. * Set the value of an uniform to a vec2
  119989. * @param uniform defines the webGL uniform location where to store the value
  119990. * @param x defines the 1st component of the value
  119991. * @param y defines the 2nd component of the value
  119992. */
  119993. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  119994. /**
  119995. * Set the value of an uniform to a vec3
  119996. * @param uniform defines the webGL uniform location where to store the value
  119997. * @param x defines the 1st component of the value
  119998. * @param y defines the 2nd component of the value
  119999. * @param z defines the 3rd component of the value
  120000. */
  120001. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  120002. /**
  120003. * Set the value of an uniform to a boolean
  120004. * @param uniform defines the webGL uniform location where to store the value
  120005. * @param bool defines the boolean to store
  120006. */
  120007. setBool(uniform: WebGLUniformLocation, bool: number): void;
  120008. /**
  120009. * Set the value of an uniform to a vec4
  120010. * @param uniform defines the webGL uniform location where to store the value
  120011. * @param x defines the 1st component of the value
  120012. * @param y defines the 2nd component of the value
  120013. * @param z defines the 3rd component of the value
  120014. * @param w defines the 4th component of the value
  120015. */
  120016. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  120017. /**
  120018. * Sets the current alpha mode
  120019. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  120020. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120021. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120022. */
  120023. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  120024. /**
  120025. * Bind webGl buffers directly to the webGL context
  120026. * @param vertexBuffers defines the vertex buffer to bind
  120027. * @param indexBuffer defines the index buffer to bind
  120028. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  120029. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  120030. * @param effect defines the effect associated with the vertex buffer
  120031. */
  120032. bindBuffers(vertexBuffers: {
  120033. [key: string]: VertexBuffer;
  120034. }, indexBuffer: DataBuffer, effect: Effect): void;
  120035. /**
  120036. * Force the entire cache to be cleared
  120037. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  120038. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  120039. */
  120040. wipeCaches(bruteForce?: boolean): void;
  120041. /**
  120042. * Send a draw order
  120043. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  120044. * @param indexStart defines the starting index
  120045. * @param indexCount defines the number of index to draw
  120046. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120047. */
  120048. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  120049. /**
  120050. * Draw a list of indexed primitives
  120051. * @param fillMode defines the primitive to use
  120052. * @param indexStart defines the starting index
  120053. * @param indexCount defines the number of index to draw
  120054. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120055. */
  120056. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120057. /**
  120058. * Draw a list of unindexed primitives
  120059. * @param fillMode defines the primitive to use
  120060. * @param verticesStart defines the index of first vertex to draw
  120061. * @param verticesCount defines the count of vertices to draw
  120062. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120063. */
  120064. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120065. /** @hidden */
  120066. _createTexture(): WebGLTexture;
  120067. /** @hidden */
  120068. _releaseTexture(texture: InternalTexture): void;
  120069. /**
  120070. * Usually called from Texture.ts.
  120071. * Passed information to create a WebGLTexture
  120072. * @param urlArg defines a value which contains one of the following:
  120073. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  120074. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  120075. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  120076. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  120077. * @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)
  120078. * @param scene needed for loading to the correct scene
  120079. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  120080. * @param onLoad optional callback to be called upon successful completion
  120081. * @param onError optional callback to be called upon failure
  120082. * @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
  120083. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  120084. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  120085. * @param forcedExtension defines the extension to use to pick the right loader
  120086. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  120087. * @returns a InternalTexture for assignment back into BABYLON.Texture
  120088. */
  120089. createTexture(urlArg: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<ArrayBuffer | HTMLImageElement>, fallBack?: InternalTexture, format?: number): InternalTexture;
  120090. /**
  120091. * Creates a new render target texture
  120092. * @param size defines the size of the texture
  120093. * @param options defines the options used to create the texture
  120094. * @returns a new render target texture stored in an InternalTexture
  120095. */
  120096. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  120097. /**
  120098. * Update the sampling mode of a given texture
  120099. * @param samplingMode defines the required sampling mode
  120100. * @param texture defines the texture to update
  120101. */
  120102. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  120103. /**
  120104. * Binds the frame buffer to the specified texture.
  120105. * @param texture The texture to render to or null for the default canvas
  120106. * @param faceIndex The face of the texture to render to in case of cube texture
  120107. * @param requiredWidth The width of the target to render to
  120108. * @param requiredHeight The height of the target to render to
  120109. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  120110. * @param lodLevel defines le lod level to bind to the frame buffer
  120111. */
  120112. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  120113. /**
  120114. * Unbind the current render target texture from the webGL context
  120115. * @param texture defines the render target texture to unbind
  120116. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120117. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120118. */
  120119. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  120120. /**
  120121. * Creates a dynamic vertex buffer
  120122. * @param vertices the data for the dynamic vertex buffer
  120123. * @returns the new WebGL dynamic buffer
  120124. */
  120125. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  120126. /**
  120127. * Update the content of a dynamic texture
  120128. * @param texture defines the texture to update
  120129. * @param canvas defines the canvas containing the source
  120130. * @param invertY defines if data must be stored with Y axis inverted
  120131. * @param premulAlpha defines if alpha is stored as premultiplied
  120132. * @param format defines the format of the data
  120133. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  120134. */
  120135. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  120136. /**
  120137. * Gets a boolean indicating if all created effects are ready
  120138. * @returns true if all effects are ready
  120139. */
  120140. areAllEffectsReady(): boolean;
  120141. /**
  120142. * @hidden
  120143. * Get the current error code of the webGL context
  120144. * @returns the error code
  120145. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  120146. */
  120147. getError(): number;
  120148. /** @hidden */
  120149. _getUnpackAlignement(): number;
  120150. /** @hidden */
  120151. _unpackFlipY(value: boolean): void;
  120152. /**
  120153. * Update a dynamic index buffer
  120154. * @param indexBuffer defines the target index buffer
  120155. * @param indices defines the data to update
  120156. * @param offset defines the offset in the target index buffer where update should start
  120157. */
  120158. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  120159. /**
  120160. * Updates a dynamic vertex buffer.
  120161. * @param vertexBuffer the vertex buffer to update
  120162. * @param vertices the data used to update the vertex buffer
  120163. * @param byteOffset the byte offset of the data (optional)
  120164. * @param byteLength the byte length of the data (optional)
  120165. */
  120166. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  120167. /** @hidden */
  120168. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  120169. /** @hidden */
  120170. _bindTexture(channel: number, texture: InternalTexture): void;
  120171. protected _deleteBuffer(buffer: WebGLBuffer): void;
  120172. /**
  120173. * 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
  120174. */
  120175. releaseEffects(): void;
  120176. displayLoadingUI(): void;
  120177. hideLoadingUI(): void;
  120178. /** @hidden */
  120179. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120180. /** @hidden */
  120181. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120182. /** @hidden */
  120183. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  120184. /** @hidden */
  120185. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  120186. }
  120187. }
  120188. declare module BABYLON {
  120189. /**
  120190. * @hidden
  120191. **/
  120192. export class _TimeToken {
  120193. _startTimeQuery: Nullable<WebGLQuery>;
  120194. _endTimeQuery: Nullable<WebGLQuery>;
  120195. _timeElapsedQuery: Nullable<WebGLQuery>;
  120196. _timeElapsedQueryEnded: boolean;
  120197. }
  120198. }
  120199. declare module BABYLON {
  120200. /** @hidden */
  120201. export class _OcclusionDataStorage {
  120202. /** @hidden */
  120203. occlusionInternalRetryCounter: number;
  120204. /** @hidden */
  120205. isOcclusionQueryInProgress: boolean;
  120206. /** @hidden */
  120207. isOccluded: boolean;
  120208. /** @hidden */
  120209. occlusionRetryCount: number;
  120210. /** @hidden */
  120211. occlusionType: number;
  120212. /** @hidden */
  120213. occlusionQueryAlgorithmType: number;
  120214. }
  120215. interface Engine {
  120216. /**
  120217. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  120218. * @return the new query
  120219. */
  120220. createQuery(): WebGLQuery;
  120221. /**
  120222. * Delete and release a webGL query
  120223. * @param query defines the query to delete
  120224. * @return the current engine
  120225. */
  120226. deleteQuery(query: WebGLQuery): Engine;
  120227. /**
  120228. * Check if a given query has resolved and got its value
  120229. * @param query defines the query to check
  120230. * @returns true if the query got its value
  120231. */
  120232. isQueryResultAvailable(query: WebGLQuery): boolean;
  120233. /**
  120234. * Gets the value of a given query
  120235. * @param query defines the query to check
  120236. * @returns the value of the query
  120237. */
  120238. getQueryResult(query: WebGLQuery): number;
  120239. /**
  120240. * Initiates an occlusion query
  120241. * @param algorithmType defines the algorithm to use
  120242. * @param query defines the query to use
  120243. * @returns the current engine
  120244. * @see http://doc.babylonjs.com/features/occlusionquery
  120245. */
  120246. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  120247. /**
  120248. * Ends an occlusion query
  120249. * @see http://doc.babylonjs.com/features/occlusionquery
  120250. * @param algorithmType defines the algorithm to use
  120251. * @returns the current engine
  120252. */
  120253. endOcclusionQuery(algorithmType: number): Engine;
  120254. /**
  120255. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  120256. * Please note that only one query can be issued at a time
  120257. * @returns a time token used to track the time span
  120258. */
  120259. startTimeQuery(): Nullable<_TimeToken>;
  120260. /**
  120261. * Ends a time query
  120262. * @param token defines the token used to measure the time span
  120263. * @returns the time spent (in ns)
  120264. */
  120265. endTimeQuery(token: _TimeToken): int;
  120266. /** @hidden */
  120267. _currentNonTimestampToken: Nullable<_TimeToken>;
  120268. /** @hidden */
  120269. _createTimeQuery(): WebGLQuery;
  120270. /** @hidden */
  120271. _deleteTimeQuery(query: WebGLQuery): void;
  120272. /** @hidden */
  120273. _getGlAlgorithmType(algorithmType: number): number;
  120274. /** @hidden */
  120275. _getTimeQueryResult(query: WebGLQuery): any;
  120276. /** @hidden */
  120277. _getTimeQueryAvailability(query: WebGLQuery): any;
  120278. }
  120279. interface AbstractMesh {
  120280. /**
  120281. * Backing filed
  120282. * @hidden
  120283. */
  120284. __occlusionDataStorage: _OcclusionDataStorage;
  120285. /**
  120286. * Access property
  120287. * @hidden
  120288. */
  120289. _occlusionDataStorage: _OcclusionDataStorage;
  120290. /**
  120291. * 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.
  120292. * The default value is -1 which means don't break the query and wait till the result
  120293. * @see http://doc.babylonjs.com/features/occlusionquery
  120294. */
  120295. occlusionRetryCount: number;
  120296. /**
  120297. * 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:
  120298. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  120299. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  120300. * * 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.
  120301. * @see http://doc.babylonjs.com/features/occlusionquery
  120302. */
  120303. occlusionType: number;
  120304. /**
  120305. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  120306. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  120307. * * 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.
  120308. * @see http://doc.babylonjs.com/features/occlusionquery
  120309. */
  120310. occlusionQueryAlgorithmType: number;
  120311. /**
  120312. * 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
  120313. * @see http://doc.babylonjs.com/features/occlusionquery
  120314. */
  120315. isOccluded: boolean;
  120316. /**
  120317. * Flag to check the progress status of the query
  120318. * @see http://doc.babylonjs.com/features/occlusionquery
  120319. */
  120320. isOcclusionQueryInProgress: boolean;
  120321. }
  120322. }
  120323. declare module BABYLON {
  120324. /** @hidden */
  120325. export var _forceTransformFeedbackToBundle: boolean;
  120326. interface Engine {
  120327. /**
  120328. * Creates a webGL transform feedback object
  120329. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  120330. * @returns the webGL transform feedback object
  120331. */
  120332. createTransformFeedback(): WebGLTransformFeedback;
  120333. /**
  120334. * Delete a webGL transform feedback object
  120335. * @param value defines the webGL transform feedback object to delete
  120336. */
  120337. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  120338. /**
  120339. * Bind a webGL transform feedback object to the webgl context
  120340. * @param value defines the webGL transform feedback object to bind
  120341. */
  120342. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  120343. /**
  120344. * Begins a transform feedback operation
  120345. * @param usePoints defines if points or triangles must be used
  120346. */
  120347. beginTransformFeedback(usePoints: boolean): void;
  120348. /**
  120349. * Ends a transform feedback operation
  120350. */
  120351. endTransformFeedback(): void;
  120352. /**
  120353. * Specify the varyings to use with transform feedback
  120354. * @param program defines the associated webGL program
  120355. * @param value defines the list of strings representing the varying names
  120356. */
  120357. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  120358. /**
  120359. * Bind a webGL buffer for a transform feedback operation
  120360. * @param value defines the webGL buffer to bind
  120361. */
  120362. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  120363. }
  120364. }
  120365. declare module BABYLON {
  120366. /**
  120367. * Creation options of the multi render target texture.
  120368. */
  120369. export interface IMultiRenderTargetOptions {
  120370. /**
  120371. * Define if the texture needs to create mip maps after render.
  120372. */
  120373. generateMipMaps?: boolean;
  120374. /**
  120375. * Define the types of all the draw buffers we want to create
  120376. */
  120377. types?: number[];
  120378. /**
  120379. * Define the sampling modes of all the draw buffers we want to create
  120380. */
  120381. samplingModes?: number[];
  120382. /**
  120383. * Define if a depth buffer is required
  120384. */
  120385. generateDepthBuffer?: boolean;
  120386. /**
  120387. * Define if a stencil buffer is required
  120388. */
  120389. generateStencilBuffer?: boolean;
  120390. /**
  120391. * Define if a depth texture is required instead of a depth buffer
  120392. */
  120393. generateDepthTexture?: boolean;
  120394. /**
  120395. * Define the number of desired draw buffers
  120396. */
  120397. textureCount?: number;
  120398. /**
  120399. * Define if aspect ratio should be adapted to the texture or stay the scene one
  120400. */
  120401. doNotChangeAspectRatio?: boolean;
  120402. /**
  120403. * Define the default type of the buffers we are creating
  120404. */
  120405. defaultType?: number;
  120406. }
  120407. /**
  120408. * A multi render target, like a render target provides the ability to render to a texture.
  120409. * Unlike the render target, it can render to several draw buffers in one draw.
  120410. * This is specially interesting in deferred rendering or for any effects requiring more than
  120411. * just one color from a single pass.
  120412. */
  120413. export class MultiRenderTarget extends RenderTargetTexture {
  120414. private _internalTextures;
  120415. private _textures;
  120416. private _multiRenderTargetOptions;
  120417. /**
  120418. * Get if draw buffers are currently supported by the used hardware and browser.
  120419. */
  120420. get isSupported(): boolean;
  120421. /**
  120422. * Get the list of textures generated by the multi render target.
  120423. */
  120424. get textures(): Texture[];
  120425. /**
  120426. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  120427. */
  120428. get depthTexture(): Texture;
  120429. /**
  120430. * Set the wrapping mode on U of all the textures we are rendering to.
  120431. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120432. */
  120433. set wrapU(wrap: number);
  120434. /**
  120435. * Set the wrapping mode on V of all the textures we are rendering to.
  120436. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  120437. */
  120438. set wrapV(wrap: number);
  120439. /**
  120440. * Instantiate a new multi render target texture.
  120441. * A multi render target, like a render target provides the ability to render to a texture.
  120442. * Unlike the render target, it can render to several draw buffers in one draw.
  120443. * This is specially interesting in deferred rendering or for any effects requiring more than
  120444. * just one color from a single pass.
  120445. * @param name Define the name of the texture
  120446. * @param size Define the size of the buffers to render to
  120447. * @param count Define the number of target we are rendering into
  120448. * @param scene Define the scene the texture belongs to
  120449. * @param options Define the options used to create the multi render target
  120450. */
  120451. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  120452. /** @hidden */
  120453. _rebuild(): void;
  120454. private _createInternalTextures;
  120455. private _createTextures;
  120456. /**
  120457. * Define the number of samples used if MSAA is enabled.
  120458. */
  120459. get samples(): number;
  120460. set samples(value: number);
  120461. /**
  120462. * Resize all the textures in the multi render target.
  120463. * Be carrefull as it will recreate all the data in the new texture.
  120464. * @param size Define the new size
  120465. */
  120466. resize(size: any): void;
  120467. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  120468. /**
  120469. * Dispose the render targets and their associated resources
  120470. */
  120471. dispose(): void;
  120472. /**
  120473. * Release all the underlying texture used as draw buffers.
  120474. */
  120475. releaseInternalTextures(): void;
  120476. }
  120477. }
  120478. declare module BABYLON {
  120479. interface ThinEngine {
  120480. /**
  120481. * Unbind a list of render target textures from the webGL context
  120482. * This is used only when drawBuffer extension or webGL2 are active
  120483. * @param textures defines the render target textures to unbind
  120484. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  120485. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  120486. */
  120487. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  120488. /**
  120489. * Create a multi render target texture
  120490. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  120491. * @param size defines the size of the texture
  120492. * @param options defines the creation options
  120493. * @returns the cube texture as an InternalTexture
  120494. */
  120495. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  120496. /**
  120497. * Update the sample count for a given multiple render target texture
  120498. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  120499. * @param textures defines the textures to update
  120500. * @param samples defines the sample count to set
  120501. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  120502. */
  120503. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  120504. }
  120505. }
  120506. declare module BABYLON {
  120507. /**
  120508. * Class used to define an additional view for the engine
  120509. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120510. */
  120511. export class EngineView {
  120512. /** Defines the canvas where to render the view */
  120513. target: HTMLCanvasElement;
  120514. /** Defines an optional camera used to render the view (will use active camera else) */
  120515. camera?: Camera;
  120516. }
  120517. interface Engine {
  120518. /**
  120519. * Gets or sets the HTML element to use for attaching events
  120520. */
  120521. inputElement: Nullable<HTMLElement>;
  120522. /**
  120523. * Gets the current engine view
  120524. * @see https://doc.babylonjs.com/how_to/multi_canvases
  120525. */
  120526. activeView: Nullable<EngineView>;
  120527. /** Gets or sets the list of views */
  120528. views: EngineView[];
  120529. /**
  120530. * Register a new child canvas
  120531. * @param canvas defines the canvas to register
  120532. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  120533. * @returns the associated view
  120534. */
  120535. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  120536. /**
  120537. * Remove a registered child canvas
  120538. * @param canvas defines the canvas to remove
  120539. * @returns the current engine
  120540. */
  120541. unRegisterView(canvas: HTMLCanvasElement): Engine;
  120542. }
  120543. }
  120544. declare module BABYLON {
  120545. /**
  120546. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  120547. */
  120548. export interface CubeMapInfo {
  120549. /**
  120550. * The pixel array for the front face.
  120551. * This is stored in format, left to right, up to down format.
  120552. */
  120553. front: Nullable<ArrayBufferView>;
  120554. /**
  120555. * The pixel array for the back face.
  120556. * This is stored in format, left to right, up to down format.
  120557. */
  120558. back: Nullable<ArrayBufferView>;
  120559. /**
  120560. * The pixel array for the left face.
  120561. * This is stored in format, left to right, up to down format.
  120562. */
  120563. left: Nullable<ArrayBufferView>;
  120564. /**
  120565. * The pixel array for the right face.
  120566. * This is stored in format, left to right, up to down format.
  120567. */
  120568. right: Nullable<ArrayBufferView>;
  120569. /**
  120570. * The pixel array for the up face.
  120571. * This is stored in format, left to right, up to down format.
  120572. */
  120573. up: Nullable<ArrayBufferView>;
  120574. /**
  120575. * The pixel array for the down face.
  120576. * This is stored in format, left to right, up to down format.
  120577. */
  120578. down: Nullable<ArrayBufferView>;
  120579. /**
  120580. * The size of the cubemap stored.
  120581. *
  120582. * Each faces will be size * size pixels.
  120583. */
  120584. size: number;
  120585. /**
  120586. * The format of the texture.
  120587. *
  120588. * RGBA, RGB.
  120589. */
  120590. format: number;
  120591. /**
  120592. * The type of the texture data.
  120593. *
  120594. * UNSIGNED_INT, FLOAT.
  120595. */
  120596. type: number;
  120597. /**
  120598. * Specifies whether the texture is in gamma space.
  120599. */
  120600. gammaSpace: boolean;
  120601. }
  120602. /**
  120603. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  120604. */
  120605. export class PanoramaToCubeMapTools {
  120606. private static FACE_FRONT;
  120607. private static FACE_BACK;
  120608. private static FACE_RIGHT;
  120609. private static FACE_LEFT;
  120610. private static FACE_DOWN;
  120611. private static FACE_UP;
  120612. /**
  120613. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  120614. *
  120615. * @param float32Array The source data.
  120616. * @param inputWidth The width of the input panorama.
  120617. * @param inputHeight The height of the input panorama.
  120618. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  120619. * @return The cubemap data
  120620. */
  120621. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  120622. private static CreateCubemapTexture;
  120623. private static CalcProjectionSpherical;
  120624. }
  120625. }
  120626. declare module BABYLON {
  120627. /**
  120628. * Helper class dealing with the extraction of spherical polynomial dataArray
  120629. * from a cube map.
  120630. */
  120631. export class CubeMapToSphericalPolynomialTools {
  120632. private static FileFaces;
  120633. /**
  120634. * Converts a texture to the according Spherical Polynomial data.
  120635. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120636. *
  120637. * @param texture The texture to extract the information from.
  120638. * @return The Spherical Polynomial data.
  120639. */
  120640. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  120641. /**
  120642. * Converts a cubemap to the according Spherical Polynomial data.
  120643. * This extracts the first 3 orders only as they are the only one used in the lighting.
  120644. *
  120645. * @param cubeInfo The Cube map to extract the information from.
  120646. * @return The Spherical Polynomial data.
  120647. */
  120648. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  120649. }
  120650. }
  120651. declare module BABYLON {
  120652. interface BaseTexture {
  120653. /**
  120654. * Get the polynomial representation of the texture data.
  120655. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  120656. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  120657. */
  120658. sphericalPolynomial: Nullable<SphericalPolynomial>;
  120659. }
  120660. }
  120661. declare module BABYLON {
  120662. /** @hidden */
  120663. export var rgbdEncodePixelShader: {
  120664. name: string;
  120665. shader: string;
  120666. };
  120667. }
  120668. declare module BABYLON {
  120669. /** @hidden */
  120670. export var rgbdDecodePixelShader: {
  120671. name: string;
  120672. shader: string;
  120673. };
  120674. }
  120675. declare module BABYLON {
  120676. /**
  120677. * Raw texture data and descriptor sufficient for WebGL texture upload
  120678. */
  120679. export interface EnvironmentTextureInfo {
  120680. /**
  120681. * Version of the environment map
  120682. */
  120683. version: number;
  120684. /**
  120685. * Width of image
  120686. */
  120687. width: number;
  120688. /**
  120689. * Irradiance information stored in the file.
  120690. */
  120691. irradiance: any;
  120692. /**
  120693. * Specular information stored in the file.
  120694. */
  120695. specular: any;
  120696. }
  120697. /**
  120698. * Defines One Image in the file. It requires only the position in the file
  120699. * as well as the length.
  120700. */
  120701. interface BufferImageData {
  120702. /**
  120703. * Length of the image data.
  120704. */
  120705. length: number;
  120706. /**
  120707. * Position of the data from the null terminator delimiting the end of the JSON.
  120708. */
  120709. position: number;
  120710. }
  120711. /**
  120712. * Defines the specular data enclosed in the file.
  120713. * This corresponds to the version 1 of the data.
  120714. */
  120715. export interface EnvironmentTextureSpecularInfoV1 {
  120716. /**
  120717. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  120718. */
  120719. specularDataPosition?: number;
  120720. /**
  120721. * This contains all the images data needed to reconstruct the cubemap.
  120722. */
  120723. mipmaps: Array<BufferImageData>;
  120724. /**
  120725. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  120726. */
  120727. lodGenerationScale: number;
  120728. }
  120729. /**
  120730. * Sets of helpers addressing the serialization and deserialization of environment texture
  120731. * stored in a BabylonJS env file.
  120732. * Those files are usually stored as .env files.
  120733. */
  120734. export class EnvironmentTextureTools {
  120735. /**
  120736. * Magic number identifying the env file.
  120737. */
  120738. private static _MagicBytes;
  120739. /**
  120740. * Gets the environment info from an env file.
  120741. * @param data The array buffer containing the .env bytes.
  120742. * @returns the environment file info (the json header) if successfully parsed.
  120743. */
  120744. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  120745. /**
  120746. * Creates an environment texture from a loaded cube texture.
  120747. * @param texture defines the cube texture to convert in env file
  120748. * @return a promise containing the environment data if succesfull.
  120749. */
  120750. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  120751. /**
  120752. * Creates a JSON representation of the spherical data.
  120753. * @param texture defines the texture containing the polynomials
  120754. * @return the JSON representation of the spherical info
  120755. */
  120756. private static _CreateEnvTextureIrradiance;
  120757. /**
  120758. * Creates the ArrayBufferViews used for initializing environment texture image data.
  120759. * @param data the image data
  120760. * @param info parameters that determine what views will be created for accessing the underlying buffer
  120761. * @return the views described by info providing access to the underlying buffer
  120762. */
  120763. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  120764. /**
  120765. * Uploads the texture info contained in the env file to the GPU.
  120766. * @param texture defines the internal texture to upload to
  120767. * @param data defines the data to load
  120768. * @param info defines the texture info retrieved through the GetEnvInfo method
  120769. * @returns a promise
  120770. */
  120771. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  120772. private static _OnImageReadyAsync;
  120773. /**
  120774. * Uploads the levels of image data to the GPU.
  120775. * @param texture defines the internal texture to upload to
  120776. * @param imageData defines the array buffer views of image data [mipmap][face]
  120777. * @returns a promise
  120778. */
  120779. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  120780. /**
  120781. * Uploads spherical polynomials information to the texture.
  120782. * @param texture defines the texture we are trying to upload the information to
  120783. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  120784. */
  120785. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  120786. /** @hidden */
  120787. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  120788. }
  120789. }
  120790. declare module BABYLON {
  120791. /**
  120792. * Contains position and normal vectors for a vertex
  120793. */
  120794. export class PositionNormalVertex {
  120795. /** the position of the vertex (defaut: 0,0,0) */
  120796. position: Vector3;
  120797. /** the normal of the vertex (defaut: 0,1,0) */
  120798. normal: Vector3;
  120799. /**
  120800. * Creates a PositionNormalVertex
  120801. * @param position the position of the vertex (defaut: 0,0,0)
  120802. * @param normal the normal of the vertex (defaut: 0,1,0)
  120803. */
  120804. constructor(
  120805. /** the position of the vertex (defaut: 0,0,0) */
  120806. position?: Vector3,
  120807. /** the normal of the vertex (defaut: 0,1,0) */
  120808. normal?: Vector3);
  120809. /**
  120810. * Clones the PositionNormalVertex
  120811. * @returns the cloned PositionNormalVertex
  120812. */
  120813. clone(): PositionNormalVertex;
  120814. }
  120815. /**
  120816. * Contains position, normal and uv vectors for a vertex
  120817. */
  120818. export class PositionNormalTextureVertex {
  120819. /** the position of the vertex (defaut: 0,0,0) */
  120820. position: Vector3;
  120821. /** the normal of the vertex (defaut: 0,1,0) */
  120822. normal: Vector3;
  120823. /** the uv of the vertex (default: 0,0) */
  120824. uv: Vector2;
  120825. /**
  120826. * Creates a PositionNormalTextureVertex
  120827. * @param position the position of the vertex (defaut: 0,0,0)
  120828. * @param normal the normal of the vertex (defaut: 0,1,0)
  120829. * @param uv the uv of the vertex (default: 0,0)
  120830. */
  120831. constructor(
  120832. /** the position of the vertex (defaut: 0,0,0) */
  120833. position?: Vector3,
  120834. /** the normal of the vertex (defaut: 0,1,0) */
  120835. normal?: Vector3,
  120836. /** the uv of the vertex (default: 0,0) */
  120837. uv?: Vector2);
  120838. /**
  120839. * Clones the PositionNormalTextureVertex
  120840. * @returns the cloned PositionNormalTextureVertex
  120841. */
  120842. clone(): PositionNormalTextureVertex;
  120843. }
  120844. }
  120845. declare module BABYLON {
  120846. /** @hidden */
  120847. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  120848. private _genericAttributeLocation;
  120849. private _varyingLocationCount;
  120850. private _varyingLocationMap;
  120851. private _replacements;
  120852. private _textureCount;
  120853. private _uniforms;
  120854. lineProcessor(line: string): string;
  120855. attributeProcessor(attribute: string): string;
  120856. varyingProcessor(varying: string, isFragment: boolean): string;
  120857. uniformProcessor(uniform: string): string;
  120858. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  120859. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  120860. }
  120861. }
  120862. declare module BABYLON {
  120863. /**
  120864. * Container for accessors for natively-stored mesh data buffers.
  120865. */
  120866. class NativeDataBuffer extends DataBuffer {
  120867. /**
  120868. * Accessor value used to identify/retrieve a natively-stored index buffer.
  120869. */
  120870. nativeIndexBuffer?: any;
  120871. /**
  120872. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  120873. */
  120874. nativeVertexBuffer?: any;
  120875. }
  120876. /** @hidden */
  120877. class NativeTexture extends InternalTexture {
  120878. getInternalTexture(): InternalTexture;
  120879. getViewCount(): number;
  120880. }
  120881. /** @hidden */
  120882. export class NativeEngine extends Engine {
  120883. private readonly _native;
  120884. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  120885. private readonly INVALID_HANDLE;
  120886. getHardwareScalingLevel(): number;
  120887. constructor();
  120888. /**
  120889. * Can be used to override the current requestAnimationFrame requester.
  120890. * @hidden
  120891. */
  120892. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  120893. /**
  120894. * Override default engine behavior.
  120895. * @param color
  120896. * @param backBuffer
  120897. * @param depth
  120898. * @param stencil
  120899. */
  120900. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  120901. /**
  120902. * Gets host document
  120903. * @returns the host document object
  120904. */
  120905. getHostDocument(): Nullable<Document>;
  120906. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  120907. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  120908. createVertexBuffer(data: DataArray): NativeDataBuffer;
  120909. recordVertexArrayObject(vertexBuffers: {
  120910. [key: string]: VertexBuffer;
  120911. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  120912. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120913. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  120914. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  120915. /**
  120916. * Draw a list of indexed primitives
  120917. * @param fillMode defines the primitive to use
  120918. * @param indexStart defines the starting index
  120919. * @param indexCount defines the number of index to draw
  120920. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120921. */
  120922. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  120923. /**
  120924. * Draw a list of unindexed primitives
  120925. * @param fillMode defines the primitive to use
  120926. * @param verticesStart defines the index of first vertex to draw
  120927. * @param verticesCount defines the count of vertices to draw
  120928. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  120929. */
  120930. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  120931. createPipelineContext(): IPipelineContext;
  120932. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  120933. /** @hidden */
  120934. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  120935. /** @hidden */
  120936. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  120937. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120938. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  120939. protected _setProgram(program: WebGLProgram): void;
  120940. _releaseEffect(effect: Effect): void;
  120941. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  120942. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  120943. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  120944. bindSamplers(effect: Effect): void;
  120945. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  120946. getRenderWidth(useScreen?: boolean): number;
  120947. getRenderHeight(useScreen?: boolean): number;
  120948. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  120949. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  120950. /**
  120951. * Set the z offset to apply to current rendering
  120952. * @param value defines the offset to apply
  120953. */
  120954. setZOffset(value: number): void;
  120955. /**
  120956. * Gets the current value of the zOffset
  120957. * @returns the current zOffset state
  120958. */
  120959. getZOffset(): number;
  120960. /**
  120961. * Enable or disable depth buffering
  120962. * @param enable defines the state to set
  120963. */
  120964. setDepthBuffer(enable: boolean): void;
  120965. /**
  120966. * Gets a boolean indicating if depth writing is enabled
  120967. * @returns the current depth writing state
  120968. */
  120969. getDepthWrite(): boolean;
  120970. /**
  120971. * Enable or disable depth writing
  120972. * @param enable defines the state to set
  120973. */
  120974. setDepthWrite(enable: boolean): void;
  120975. /**
  120976. * Enable or disable color writing
  120977. * @param enable defines the state to set
  120978. */
  120979. setColorWrite(enable: boolean): void;
  120980. /**
  120981. * Gets a boolean indicating if color writing is enabled
  120982. * @returns the current color writing state
  120983. */
  120984. getColorWrite(): boolean;
  120985. /**
  120986. * Sets alpha constants used by some alpha blending modes
  120987. * @param r defines the red component
  120988. * @param g defines the green component
  120989. * @param b defines the blue component
  120990. * @param a defines the alpha component
  120991. */
  120992. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  120993. /**
  120994. * Sets the current alpha mode
  120995. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  120996. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  120997. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  120998. */
  120999. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  121000. /**
  121001. * Gets the current alpha mode
  121002. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121003. * @returns the current alpha mode
  121004. */
  121005. getAlphaMode(): number;
  121006. setInt(uniform: WebGLUniformLocation, int: number): void;
  121007. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  121008. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  121009. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  121010. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  121011. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  121012. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  121013. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  121014. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  121015. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  121016. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  121017. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  121018. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  121019. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  121020. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121021. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121022. setFloat(uniform: WebGLUniformLocation, value: number): void;
  121023. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  121024. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  121025. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  121026. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  121027. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  121028. wipeCaches(bruteForce?: boolean): void;
  121029. _createTexture(): WebGLTexture;
  121030. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  121031. /**
  121032. * Usually called from BABYLON.Texture.ts.
  121033. * Passed information to create a WebGLTexture
  121034. * @param urlArg defines a value which contains one of the following:
  121035. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121036. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121037. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121038. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121039. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  121040. * @param scene needed for loading to the correct scene
  121041. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  121042. * @param onLoad optional callback to be called upon successful completion
  121043. * @param onError optional callback to be called upon failure
  121044. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  121045. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121046. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121047. * @param forcedExtension defines the extension to use to pick the right loader
  121048. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121049. */
  121050. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>): InternalTexture;
  121051. /**
  121052. * Creates a cube texture
  121053. * @param rootUrl defines the url where the files to load is located
  121054. * @param scene defines the current scene
  121055. * @param files defines the list of files to load (1 per face)
  121056. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  121057. * @param onLoad defines an optional callback raised when the texture is loaded
  121058. * @param onError defines an optional callback raised if there is an issue to load the texture
  121059. * @param format defines the format of the data
  121060. * @param forcedExtension defines the extension to use to pick the right loader
  121061. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  121062. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  121063. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  121064. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  121065. * @returns the cube texture as an InternalTexture
  121066. */
  121067. 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;
  121068. private _getSamplingFilter;
  121069. private static _GetNativeTextureFormat;
  121070. createRenderTargetTexture(size: number | {
  121071. width: number;
  121072. height: number;
  121073. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  121074. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  121075. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  121076. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121077. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  121078. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  121079. /**
  121080. * Updates a dynamic vertex buffer.
  121081. * @param vertexBuffer the vertex buffer to update
  121082. * @param data the data used to update the vertex buffer
  121083. * @param byteOffset the byte offset of the data (optional)
  121084. * @param byteLength the byte length of the data (optional)
  121085. */
  121086. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  121087. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  121088. private _updateAnisotropicLevel;
  121089. private _getAddressMode;
  121090. /** @hidden */
  121091. _bindTexture(channel: number, texture: InternalTexture): void;
  121092. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  121093. releaseEffects(): void;
  121094. /** @hidden */
  121095. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121096. /** @hidden */
  121097. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121098. /** @hidden */
  121099. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121100. /** @hidden */
  121101. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121102. }
  121103. }
  121104. declare module BABYLON {
  121105. /**
  121106. * Gather the list of clipboard event types as constants.
  121107. */
  121108. export class ClipboardEventTypes {
  121109. /**
  121110. * The clipboard event is fired when a copy command is active (pressed).
  121111. */
  121112. static readonly COPY: number;
  121113. /**
  121114. * The clipboard event is fired when a cut command is active (pressed).
  121115. */
  121116. static readonly CUT: number;
  121117. /**
  121118. * The clipboard event is fired when a paste command is active (pressed).
  121119. */
  121120. static readonly PASTE: number;
  121121. }
  121122. /**
  121123. * This class is used to store clipboard related info for the onClipboardObservable event.
  121124. */
  121125. export class ClipboardInfo {
  121126. /**
  121127. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121128. */
  121129. type: number;
  121130. /**
  121131. * Defines the related dom event
  121132. */
  121133. event: ClipboardEvent;
  121134. /**
  121135. *Creates an instance of ClipboardInfo.
  121136. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  121137. * @param event Defines the related dom event
  121138. */
  121139. constructor(
  121140. /**
  121141. * Defines the type of event (BABYLON.ClipboardEventTypes)
  121142. */
  121143. type: number,
  121144. /**
  121145. * Defines the related dom event
  121146. */
  121147. event: ClipboardEvent);
  121148. /**
  121149. * Get the clipboard event's type from the keycode.
  121150. * @param keyCode Defines the keyCode for the current keyboard event.
  121151. * @return {number}
  121152. */
  121153. static GetTypeFromCharacter(keyCode: number): number;
  121154. }
  121155. }
  121156. declare module BABYLON {
  121157. /**
  121158. * Google Daydream controller
  121159. */
  121160. export class DaydreamController extends WebVRController {
  121161. /**
  121162. * Base Url for the controller model.
  121163. */
  121164. static MODEL_BASE_URL: string;
  121165. /**
  121166. * File name for the controller model.
  121167. */
  121168. static MODEL_FILENAME: string;
  121169. /**
  121170. * Gamepad Id prefix used to identify Daydream Controller.
  121171. */
  121172. static readonly GAMEPAD_ID_PREFIX: string;
  121173. /**
  121174. * Creates a new DaydreamController from a gamepad
  121175. * @param vrGamepad the gamepad that the controller should be created from
  121176. */
  121177. constructor(vrGamepad: any);
  121178. /**
  121179. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121180. * @param scene scene in which to add meshes
  121181. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121182. */
  121183. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121184. /**
  121185. * Called once for each button that changed state since the last frame
  121186. * @param buttonIdx Which button index changed
  121187. * @param state New state of the button
  121188. * @param changes Which properties on the state changed since last frame
  121189. */
  121190. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121191. }
  121192. }
  121193. declare module BABYLON {
  121194. /**
  121195. * Gear VR Controller
  121196. */
  121197. export class GearVRController extends WebVRController {
  121198. /**
  121199. * Base Url for the controller model.
  121200. */
  121201. static MODEL_BASE_URL: string;
  121202. /**
  121203. * File name for the controller model.
  121204. */
  121205. static MODEL_FILENAME: string;
  121206. /**
  121207. * Gamepad Id prefix used to identify this controller.
  121208. */
  121209. static readonly GAMEPAD_ID_PREFIX: string;
  121210. private readonly _buttonIndexToObservableNameMap;
  121211. /**
  121212. * Creates a new GearVRController from a gamepad
  121213. * @param vrGamepad the gamepad that the controller should be created from
  121214. */
  121215. constructor(vrGamepad: any);
  121216. /**
  121217. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121218. * @param scene scene in which to add meshes
  121219. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121220. */
  121221. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121222. /**
  121223. * Called once for each button that changed state since the last frame
  121224. * @param buttonIdx Which button index changed
  121225. * @param state New state of the button
  121226. * @param changes Which properties on the state changed since last frame
  121227. */
  121228. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121229. }
  121230. }
  121231. declare module BABYLON {
  121232. /**
  121233. * Generic Controller
  121234. */
  121235. export class GenericController extends WebVRController {
  121236. /**
  121237. * Base Url for the controller model.
  121238. */
  121239. static readonly MODEL_BASE_URL: string;
  121240. /**
  121241. * File name for the controller model.
  121242. */
  121243. static readonly MODEL_FILENAME: string;
  121244. /**
  121245. * Creates a new GenericController from a gamepad
  121246. * @param vrGamepad the gamepad that the controller should be created from
  121247. */
  121248. constructor(vrGamepad: any);
  121249. /**
  121250. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121251. * @param scene scene in which to add meshes
  121252. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121253. */
  121254. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121255. /**
  121256. * Called once for each button that changed state since the last frame
  121257. * @param buttonIdx Which button index changed
  121258. * @param state New state of the button
  121259. * @param changes Which properties on the state changed since last frame
  121260. */
  121261. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121262. }
  121263. }
  121264. declare module BABYLON {
  121265. /**
  121266. * Oculus Touch Controller
  121267. */
  121268. export class OculusTouchController extends WebVRController {
  121269. /**
  121270. * Base Url for the controller model.
  121271. */
  121272. static MODEL_BASE_URL: string;
  121273. /**
  121274. * File name for the left controller model.
  121275. */
  121276. static MODEL_LEFT_FILENAME: string;
  121277. /**
  121278. * File name for the right controller model.
  121279. */
  121280. static MODEL_RIGHT_FILENAME: string;
  121281. /**
  121282. * Base Url for the Quest controller model.
  121283. */
  121284. static QUEST_MODEL_BASE_URL: string;
  121285. /**
  121286. * @hidden
  121287. * If the controllers are running on a device that needs the updated Quest controller models
  121288. */
  121289. static _IsQuest: boolean;
  121290. /**
  121291. * Fired when the secondary trigger on this controller is modified
  121292. */
  121293. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  121294. /**
  121295. * Fired when the thumb rest on this controller is modified
  121296. */
  121297. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  121298. /**
  121299. * Creates a new OculusTouchController from a gamepad
  121300. * @param vrGamepad the gamepad that the controller should be created from
  121301. */
  121302. constructor(vrGamepad: any);
  121303. /**
  121304. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121305. * @param scene scene in which to add meshes
  121306. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121307. */
  121308. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121309. /**
  121310. * Fired when the A button on this controller is modified
  121311. */
  121312. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121313. /**
  121314. * Fired when the B button on this controller is modified
  121315. */
  121316. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121317. /**
  121318. * Fired when the X button on this controller is modified
  121319. */
  121320. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121321. /**
  121322. * Fired when the Y button on this controller is modified
  121323. */
  121324. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121325. /**
  121326. * Called once for each button that changed state since the last frame
  121327. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  121328. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  121329. * 2) secondary trigger (same)
  121330. * 3) A (right) X (left), touch, pressed = value
  121331. * 4) B / Y
  121332. * 5) thumb rest
  121333. * @param buttonIdx Which button index changed
  121334. * @param state New state of the button
  121335. * @param changes Which properties on the state changed since last frame
  121336. */
  121337. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121338. }
  121339. }
  121340. declare module BABYLON {
  121341. /**
  121342. * Vive Controller
  121343. */
  121344. export class ViveController extends WebVRController {
  121345. /**
  121346. * Base Url for the controller model.
  121347. */
  121348. static MODEL_BASE_URL: string;
  121349. /**
  121350. * File name for the controller model.
  121351. */
  121352. static MODEL_FILENAME: string;
  121353. /**
  121354. * Creates a new ViveController from a gamepad
  121355. * @param vrGamepad the gamepad that the controller should be created from
  121356. */
  121357. constructor(vrGamepad: any);
  121358. /**
  121359. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121360. * @param scene scene in which to add meshes
  121361. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121362. */
  121363. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  121364. /**
  121365. * Fired when the left button on this controller is modified
  121366. */
  121367. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121368. /**
  121369. * Fired when the right button on this controller is modified
  121370. */
  121371. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121372. /**
  121373. * Fired when the menu button on this controller is modified
  121374. */
  121375. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121376. /**
  121377. * Called once for each button that changed state since the last frame
  121378. * Vive mapping:
  121379. * 0: touchpad
  121380. * 1: trigger
  121381. * 2: left AND right buttons
  121382. * 3: menu button
  121383. * @param buttonIdx Which button index changed
  121384. * @param state New state of the button
  121385. * @param changes Which properties on the state changed since last frame
  121386. */
  121387. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121388. }
  121389. }
  121390. declare module BABYLON {
  121391. /**
  121392. * Defines the WindowsMotionController object that the state of the windows motion controller
  121393. */
  121394. export class WindowsMotionController extends WebVRController {
  121395. /**
  121396. * The base url used to load the left and right controller models
  121397. */
  121398. static MODEL_BASE_URL: string;
  121399. /**
  121400. * The name of the left controller model file
  121401. */
  121402. static MODEL_LEFT_FILENAME: string;
  121403. /**
  121404. * The name of the right controller model file
  121405. */
  121406. static MODEL_RIGHT_FILENAME: string;
  121407. /**
  121408. * The controller name prefix for this controller type
  121409. */
  121410. static readonly GAMEPAD_ID_PREFIX: string;
  121411. /**
  121412. * The controller id pattern for this controller type
  121413. */
  121414. private static readonly GAMEPAD_ID_PATTERN;
  121415. private _loadedMeshInfo;
  121416. protected readonly _mapping: {
  121417. buttons: string[];
  121418. buttonMeshNames: {
  121419. 'trigger': string;
  121420. 'menu': string;
  121421. 'grip': string;
  121422. 'thumbstick': string;
  121423. 'trackpad': string;
  121424. };
  121425. buttonObservableNames: {
  121426. 'trigger': string;
  121427. 'menu': string;
  121428. 'grip': string;
  121429. 'thumbstick': string;
  121430. 'trackpad': string;
  121431. };
  121432. axisMeshNames: string[];
  121433. pointingPoseMeshName: string;
  121434. };
  121435. /**
  121436. * Fired when the trackpad on this controller is clicked
  121437. */
  121438. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121439. /**
  121440. * Fired when the trackpad on this controller is modified
  121441. */
  121442. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121443. /**
  121444. * The current x and y values of this controller's trackpad
  121445. */
  121446. trackpad: StickValues;
  121447. /**
  121448. * Creates a new WindowsMotionController from a gamepad
  121449. * @param vrGamepad the gamepad that the controller should be created from
  121450. */
  121451. constructor(vrGamepad: any);
  121452. /**
  121453. * Fired when the trigger on this controller is modified
  121454. */
  121455. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121456. /**
  121457. * Fired when the menu button on this controller is modified
  121458. */
  121459. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121460. /**
  121461. * Fired when the grip button on this controller is modified
  121462. */
  121463. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121464. /**
  121465. * Fired when the thumbstick button on this controller is modified
  121466. */
  121467. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121468. /**
  121469. * Fired when the touchpad button on this controller is modified
  121470. */
  121471. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121472. /**
  121473. * Fired when the touchpad values on this controller are modified
  121474. */
  121475. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  121476. protected _updateTrackpad(): void;
  121477. /**
  121478. * Called once per frame by the engine.
  121479. */
  121480. update(): void;
  121481. /**
  121482. * Called once for each button that changed state since the last frame
  121483. * @param buttonIdx Which button index changed
  121484. * @param state New state of the button
  121485. * @param changes Which properties on the state changed since last frame
  121486. */
  121487. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  121488. /**
  121489. * Moves the buttons on the controller mesh based on their current state
  121490. * @param buttonName the name of the button to move
  121491. * @param buttonValue the value of the button which determines the buttons new position
  121492. */
  121493. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  121494. /**
  121495. * Moves the axis on the controller mesh based on its current state
  121496. * @param axis the index of the axis
  121497. * @param axisValue the value of the axis which determines the meshes new position
  121498. * @hidden
  121499. */
  121500. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  121501. /**
  121502. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  121503. * @param scene scene in which to add meshes
  121504. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  121505. */
  121506. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  121507. /**
  121508. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  121509. * can be transformed by button presses and axes values, based on this._mapping.
  121510. *
  121511. * @param scene scene in which the meshes exist
  121512. * @param meshes list of meshes that make up the controller model to process
  121513. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  121514. */
  121515. private processModel;
  121516. private createMeshInfo;
  121517. /**
  121518. * Gets the ray of the controller in the direction the controller is pointing
  121519. * @param length the length the resulting ray should be
  121520. * @returns a ray in the direction the controller is pointing
  121521. */
  121522. getForwardRay(length?: number): Ray;
  121523. /**
  121524. * Disposes of the controller
  121525. */
  121526. dispose(): void;
  121527. }
  121528. /**
  121529. * This class represents a new windows motion controller in XR.
  121530. */
  121531. export class XRWindowsMotionController extends WindowsMotionController {
  121532. /**
  121533. * Changing the original WIndowsMotionController mapping to fir the new mapping
  121534. */
  121535. protected readonly _mapping: {
  121536. buttons: string[];
  121537. buttonMeshNames: {
  121538. 'trigger': string;
  121539. 'menu': string;
  121540. 'grip': string;
  121541. 'thumbstick': string;
  121542. 'trackpad': string;
  121543. };
  121544. buttonObservableNames: {
  121545. 'trigger': string;
  121546. 'menu': string;
  121547. 'grip': string;
  121548. 'thumbstick': string;
  121549. 'trackpad': string;
  121550. };
  121551. axisMeshNames: string[];
  121552. pointingPoseMeshName: string;
  121553. };
  121554. /**
  121555. * Construct a new XR-Based windows motion controller
  121556. *
  121557. * @param gamepadInfo the gamepad object from the browser
  121558. */
  121559. constructor(gamepadInfo: any);
  121560. /**
  121561. * holds the thumbstick values (X,Y)
  121562. */
  121563. thumbstickValues: StickValues;
  121564. /**
  121565. * Fired when the thumbstick on this controller is clicked
  121566. */
  121567. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  121568. /**
  121569. * Fired when the thumbstick on this controller is modified
  121570. */
  121571. onThumbstickValuesChangedObservable: Observable<StickValues>;
  121572. /**
  121573. * Fired when the touchpad button on this controller is modified
  121574. */
  121575. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  121576. /**
  121577. * Fired when the touchpad values on this controller are modified
  121578. */
  121579. onTrackpadValuesChangedObservable: Observable<StickValues>;
  121580. /**
  121581. * Fired when the thumbstick button on this controller is modified
  121582. * here to prevent breaking changes
  121583. */
  121584. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  121585. /**
  121586. * updating the thumbstick(!) and not the trackpad.
  121587. * This is named this way due to the difference between WebVR and XR and to avoid
  121588. * changing the parent class.
  121589. */
  121590. protected _updateTrackpad(): void;
  121591. /**
  121592. * Disposes the class with joy
  121593. */
  121594. dispose(): void;
  121595. }
  121596. }
  121597. declare module BABYLON {
  121598. /**
  121599. * Class containing static functions to help procedurally build meshes
  121600. */
  121601. export class PolyhedronBuilder {
  121602. /**
  121603. * Creates a polyhedron mesh
  121604. * * 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
  121605. * * The parameter `size` (positive float, default 1) sets the polygon size
  121606. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  121607. * * 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`
  121608. * * 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
  121609. * * 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)`)
  121610. * * 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
  121611. * * 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
  121612. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  121613. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  121614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  121615. * @param name defines the name of the mesh
  121616. * @param options defines the options used to create the mesh
  121617. * @param scene defines the hosting scene
  121618. * @returns the polyhedron mesh
  121619. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  121620. */
  121621. static CreatePolyhedron(name: string, options: {
  121622. type?: number;
  121623. size?: number;
  121624. sizeX?: number;
  121625. sizeY?: number;
  121626. sizeZ?: number;
  121627. custom?: any;
  121628. faceUV?: Vector4[];
  121629. faceColors?: Color4[];
  121630. flat?: boolean;
  121631. updatable?: boolean;
  121632. sideOrientation?: number;
  121633. frontUVs?: Vector4;
  121634. backUVs?: Vector4;
  121635. }, scene?: Nullable<Scene>): Mesh;
  121636. }
  121637. }
  121638. declare module BABYLON {
  121639. /**
  121640. * Gizmo that enables scaling a mesh along 3 axis
  121641. */
  121642. export class ScaleGizmo extends Gizmo {
  121643. /**
  121644. * Internal gizmo used for interactions on the x axis
  121645. */
  121646. xGizmo: AxisScaleGizmo;
  121647. /**
  121648. * Internal gizmo used for interactions on the y axis
  121649. */
  121650. yGizmo: AxisScaleGizmo;
  121651. /**
  121652. * Internal gizmo used for interactions on the z axis
  121653. */
  121654. zGizmo: AxisScaleGizmo;
  121655. /**
  121656. * Internal gizmo used to scale all axis equally
  121657. */
  121658. uniformScaleGizmo: AxisScaleGizmo;
  121659. private _meshAttached;
  121660. private _updateGizmoRotationToMatchAttachedMesh;
  121661. private _snapDistance;
  121662. private _scaleRatio;
  121663. private _uniformScalingMesh;
  121664. private _octahedron;
  121665. private _sensitivity;
  121666. /** Fires an event when any of it's sub gizmos are dragged */
  121667. onDragStartObservable: Observable<unknown>;
  121668. /** Fires an event when any of it's sub gizmos are released from dragging */
  121669. onDragEndObservable: Observable<unknown>;
  121670. get attachedMesh(): Nullable<AbstractMesh>;
  121671. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121672. /**
  121673. * Creates a ScaleGizmo
  121674. * @param gizmoLayer The utility layer the gizmo will be added to
  121675. */
  121676. constructor(gizmoLayer?: UtilityLayerRenderer);
  121677. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121678. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121679. /**
  121680. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121681. */
  121682. set snapDistance(value: number);
  121683. get snapDistance(): number;
  121684. /**
  121685. * Ratio for the scale of the gizmo (Default: 1)
  121686. */
  121687. set scaleRatio(value: number);
  121688. get scaleRatio(): number;
  121689. /**
  121690. * Sensitivity factor for dragging (Default: 1)
  121691. */
  121692. set sensitivity(value: number);
  121693. get sensitivity(): number;
  121694. /**
  121695. * Disposes of the gizmo
  121696. */
  121697. dispose(): void;
  121698. }
  121699. }
  121700. declare module BABYLON {
  121701. /**
  121702. * Single axis scale gizmo
  121703. */
  121704. export class AxisScaleGizmo extends Gizmo {
  121705. /**
  121706. * Drag behavior responsible for the gizmos dragging interactions
  121707. */
  121708. dragBehavior: PointerDragBehavior;
  121709. private _pointerObserver;
  121710. /**
  121711. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121712. */
  121713. snapDistance: number;
  121714. /**
  121715. * Event that fires each time the gizmo snaps to a new location.
  121716. * * snapDistance is the the change in distance
  121717. */
  121718. onSnapObservable: Observable<{
  121719. snapDistance: number;
  121720. }>;
  121721. /**
  121722. * If the scaling operation should be done on all axis (default: false)
  121723. */
  121724. uniformScaling: boolean;
  121725. /**
  121726. * Custom sensitivity value for the drag strength
  121727. */
  121728. sensitivity: number;
  121729. private _isEnabled;
  121730. private _parent;
  121731. private _arrow;
  121732. private _coloredMaterial;
  121733. private _hoverMaterial;
  121734. /**
  121735. * Creates an AxisScaleGizmo
  121736. * @param gizmoLayer The utility layer the gizmo will be added to
  121737. * @param dragAxis The axis which the gizmo will be able to scale on
  121738. * @param color The color of the gizmo
  121739. */
  121740. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  121741. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121742. /**
  121743. * If the gizmo is enabled
  121744. */
  121745. set isEnabled(value: boolean);
  121746. get isEnabled(): boolean;
  121747. /**
  121748. * Disposes of the gizmo
  121749. */
  121750. dispose(): void;
  121751. /**
  121752. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  121753. * @param mesh The mesh to replace the default mesh of the gizmo
  121754. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  121755. */
  121756. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  121757. }
  121758. }
  121759. declare module BABYLON {
  121760. /**
  121761. * Bounding box gizmo
  121762. */
  121763. export class BoundingBoxGizmo extends Gizmo {
  121764. private _lineBoundingBox;
  121765. private _rotateSpheresParent;
  121766. private _scaleBoxesParent;
  121767. private _boundingDimensions;
  121768. private _renderObserver;
  121769. private _pointerObserver;
  121770. private _scaleDragSpeed;
  121771. private _tmpQuaternion;
  121772. private _tmpVector;
  121773. private _tmpRotationMatrix;
  121774. /**
  121775. * 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)
  121776. */
  121777. ignoreChildren: boolean;
  121778. /**
  121779. * 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)
  121780. */
  121781. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  121782. /**
  121783. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  121784. */
  121785. rotationSphereSize: number;
  121786. /**
  121787. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  121788. */
  121789. scaleBoxSize: number;
  121790. /**
  121791. * 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)
  121792. */
  121793. fixedDragMeshScreenSize: boolean;
  121794. /**
  121795. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  121796. */
  121797. fixedDragMeshScreenSizeDistanceFactor: number;
  121798. /**
  121799. * Fired when a rotation sphere or scale box is dragged
  121800. */
  121801. onDragStartObservable: Observable<{}>;
  121802. /**
  121803. * Fired when a scale box is dragged
  121804. */
  121805. onScaleBoxDragObservable: Observable<{}>;
  121806. /**
  121807. * Fired when a scale box drag is ended
  121808. */
  121809. onScaleBoxDragEndObservable: Observable<{}>;
  121810. /**
  121811. * Fired when a rotation sphere is dragged
  121812. */
  121813. onRotationSphereDragObservable: Observable<{}>;
  121814. /**
  121815. * Fired when a rotation sphere drag is ended
  121816. */
  121817. onRotationSphereDragEndObservable: Observable<{}>;
  121818. /**
  121819. * 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)
  121820. */
  121821. scalePivot: Nullable<Vector3>;
  121822. /**
  121823. * Mesh used as a pivot to rotate the attached mesh
  121824. */
  121825. private _anchorMesh;
  121826. private _existingMeshScale;
  121827. private _dragMesh;
  121828. private pointerDragBehavior;
  121829. private coloredMaterial;
  121830. private hoverColoredMaterial;
  121831. /**
  121832. * Sets the color of the bounding box gizmo
  121833. * @param color the color to set
  121834. */
  121835. setColor(color: Color3): void;
  121836. /**
  121837. * Creates an BoundingBoxGizmo
  121838. * @param gizmoLayer The utility layer the gizmo will be added to
  121839. * @param color The color of the gizmo
  121840. */
  121841. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  121842. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121843. private _selectNode;
  121844. /**
  121845. * Updates the bounding box information for the Gizmo
  121846. */
  121847. updateBoundingBox(): void;
  121848. private _updateRotationSpheres;
  121849. private _updateScaleBoxes;
  121850. /**
  121851. * Enables rotation on the specified axis and disables rotation on the others
  121852. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  121853. */
  121854. setEnabledRotationAxis(axis: string): void;
  121855. /**
  121856. * Enables/disables scaling
  121857. * @param enable if scaling should be enabled
  121858. */
  121859. setEnabledScaling(enable: boolean): void;
  121860. private _updateDummy;
  121861. /**
  121862. * Enables a pointer drag behavior on the bounding box of the gizmo
  121863. */
  121864. enableDragBehavior(): void;
  121865. /**
  121866. * Disposes of the gizmo
  121867. */
  121868. dispose(): void;
  121869. /**
  121870. * 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)
  121871. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  121872. * @returns the bounding box mesh with the passed in mesh as a child
  121873. */
  121874. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  121875. /**
  121876. * CustomMeshes are not supported by this gizmo
  121877. * @param mesh The mesh to replace the default mesh of the gizmo
  121878. */
  121879. setCustomMesh(mesh: Mesh): void;
  121880. }
  121881. }
  121882. declare module BABYLON {
  121883. /**
  121884. * Single plane rotation gizmo
  121885. */
  121886. export class PlaneRotationGizmo extends Gizmo {
  121887. /**
  121888. * Drag behavior responsible for the gizmos dragging interactions
  121889. */
  121890. dragBehavior: PointerDragBehavior;
  121891. private _pointerObserver;
  121892. /**
  121893. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  121894. */
  121895. snapDistance: number;
  121896. /**
  121897. * Event that fires each time the gizmo snaps to a new location.
  121898. * * snapDistance is the the change in distance
  121899. */
  121900. onSnapObservable: Observable<{
  121901. snapDistance: number;
  121902. }>;
  121903. private _isEnabled;
  121904. private _parent;
  121905. /**
  121906. * Creates a PlaneRotationGizmo
  121907. * @param gizmoLayer The utility layer the gizmo will be added to
  121908. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  121909. * @param color The color of the gizmo
  121910. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121911. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121912. */
  121913. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  121914. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  121915. /**
  121916. * If the gizmo is enabled
  121917. */
  121918. set isEnabled(value: boolean);
  121919. get isEnabled(): boolean;
  121920. /**
  121921. * Disposes of the gizmo
  121922. */
  121923. dispose(): void;
  121924. }
  121925. }
  121926. declare module BABYLON {
  121927. /**
  121928. * Gizmo that enables rotating a mesh along 3 axis
  121929. */
  121930. export class RotationGizmo extends Gizmo {
  121931. /**
  121932. * Internal gizmo used for interactions on the x axis
  121933. */
  121934. xGizmo: PlaneRotationGizmo;
  121935. /**
  121936. * Internal gizmo used for interactions on the y axis
  121937. */
  121938. yGizmo: PlaneRotationGizmo;
  121939. /**
  121940. * Internal gizmo used for interactions on the z axis
  121941. */
  121942. zGizmo: PlaneRotationGizmo;
  121943. /** Fires an event when any of it's sub gizmos are dragged */
  121944. onDragStartObservable: Observable<unknown>;
  121945. /** Fires an event when any of it's sub gizmos are released from dragging */
  121946. onDragEndObservable: Observable<unknown>;
  121947. private _meshAttached;
  121948. get attachedMesh(): Nullable<AbstractMesh>;
  121949. set attachedMesh(mesh: Nullable<AbstractMesh>);
  121950. /**
  121951. * Creates a RotationGizmo
  121952. * @param gizmoLayer The utility layer the gizmo will be added to
  121953. * @param tessellation Amount of tessellation to be used when creating rotation circles
  121954. * @param useEulerRotation Use and update Euler angle instead of quaternion
  121955. */
  121956. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  121957. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  121958. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  121959. /**
  121960. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  121961. */
  121962. set snapDistance(value: number);
  121963. get snapDistance(): number;
  121964. /**
  121965. * Ratio for the scale of the gizmo (Default: 1)
  121966. */
  121967. set scaleRatio(value: number);
  121968. get scaleRatio(): number;
  121969. /**
  121970. * Disposes of the gizmo
  121971. */
  121972. dispose(): void;
  121973. /**
  121974. * CustomMeshes are not supported by this gizmo
  121975. * @param mesh The mesh to replace the default mesh of the gizmo
  121976. */
  121977. setCustomMesh(mesh: Mesh): void;
  121978. }
  121979. }
  121980. declare module BABYLON {
  121981. /**
  121982. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  121983. */
  121984. export class GizmoManager implements IDisposable {
  121985. private scene;
  121986. /**
  121987. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  121988. */
  121989. gizmos: {
  121990. positionGizmo: Nullable<PositionGizmo>;
  121991. rotationGizmo: Nullable<RotationGizmo>;
  121992. scaleGizmo: Nullable<ScaleGizmo>;
  121993. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  121994. };
  121995. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  121996. clearGizmoOnEmptyPointerEvent: boolean;
  121997. /** Fires an event when the manager is attached to a mesh */
  121998. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  121999. private _gizmosEnabled;
  122000. private _pointerObserver;
  122001. private _attachedMesh;
  122002. private _boundingBoxColor;
  122003. private _defaultUtilityLayer;
  122004. private _defaultKeepDepthUtilityLayer;
  122005. /**
  122006. * When bounding box gizmo is enabled, this can be used to track drag/end events
  122007. */
  122008. boundingBoxDragBehavior: SixDofDragBehavior;
  122009. /**
  122010. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  122011. */
  122012. attachableMeshes: Nullable<Array<AbstractMesh>>;
  122013. /**
  122014. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  122015. */
  122016. usePointerToAttachGizmos: boolean;
  122017. /**
  122018. * Utility layer that the bounding box gizmo belongs to
  122019. */
  122020. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  122021. /**
  122022. * Utility layer that all gizmos besides bounding box belong to
  122023. */
  122024. get utilityLayer(): UtilityLayerRenderer;
  122025. /**
  122026. * Instatiates a gizmo manager
  122027. * @param scene the scene to overlay the gizmos on top of
  122028. */
  122029. constructor(scene: Scene);
  122030. /**
  122031. * Attaches a set of gizmos to the specified mesh
  122032. * @param mesh The mesh the gizmo's should be attached to
  122033. */
  122034. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  122035. /**
  122036. * If the position gizmo is enabled
  122037. */
  122038. set positionGizmoEnabled(value: boolean);
  122039. get positionGizmoEnabled(): boolean;
  122040. /**
  122041. * If the rotation gizmo is enabled
  122042. */
  122043. set rotationGizmoEnabled(value: boolean);
  122044. get rotationGizmoEnabled(): boolean;
  122045. /**
  122046. * If the scale gizmo is enabled
  122047. */
  122048. set scaleGizmoEnabled(value: boolean);
  122049. get scaleGizmoEnabled(): boolean;
  122050. /**
  122051. * If the boundingBox gizmo is enabled
  122052. */
  122053. set boundingBoxGizmoEnabled(value: boolean);
  122054. get boundingBoxGizmoEnabled(): boolean;
  122055. /**
  122056. * Disposes of the gizmo manager
  122057. */
  122058. dispose(): void;
  122059. }
  122060. }
  122061. declare module BABYLON {
  122062. /**
  122063. * A directional light is defined by a direction (what a surprise!).
  122064. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  122065. * 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.
  122066. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122067. */
  122068. export class DirectionalLight extends ShadowLight {
  122069. private _shadowFrustumSize;
  122070. /**
  122071. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  122072. */
  122073. get shadowFrustumSize(): number;
  122074. /**
  122075. * Specifies a fix frustum size for the shadow generation.
  122076. */
  122077. set shadowFrustumSize(value: number);
  122078. private _shadowOrthoScale;
  122079. /**
  122080. * Gets the shadow projection scale against the optimal computed one.
  122081. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122082. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122083. */
  122084. get shadowOrthoScale(): number;
  122085. /**
  122086. * Sets the shadow projection scale against the optimal computed one.
  122087. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  122088. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  122089. */
  122090. set shadowOrthoScale(value: number);
  122091. /**
  122092. * Automatically compute the projection matrix to best fit (including all the casters)
  122093. * on each frame.
  122094. */
  122095. autoUpdateExtends: boolean;
  122096. /**
  122097. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  122098. * on each frame. autoUpdateExtends must be set to true for this to work
  122099. */
  122100. autoCalcShadowZBounds: boolean;
  122101. private _orthoLeft;
  122102. private _orthoRight;
  122103. private _orthoTop;
  122104. private _orthoBottom;
  122105. /**
  122106. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  122107. * The directional light is emitted from everywhere in the given direction.
  122108. * It can cast shadows.
  122109. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122110. * @param name The friendly name of the light
  122111. * @param direction The direction of the light
  122112. * @param scene The scene the light belongs to
  122113. */
  122114. constructor(name: string, direction: Vector3, scene: Scene);
  122115. /**
  122116. * Returns the string "DirectionalLight".
  122117. * @return The class name
  122118. */
  122119. getClassName(): string;
  122120. /**
  122121. * Returns the integer 1.
  122122. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122123. */
  122124. getTypeID(): number;
  122125. /**
  122126. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  122127. * Returns the DirectionalLight Shadow projection matrix.
  122128. */
  122129. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122130. /**
  122131. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  122132. * Returns the DirectionalLight Shadow projection matrix.
  122133. */
  122134. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  122135. /**
  122136. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  122137. * Returns the DirectionalLight Shadow projection matrix.
  122138. */
  122139. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122140. protected _buildUniformLayout(): void;
  122141. /**
  122142. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  122143. * @param effect The effect to update
  122144. * @param lightIndex The index of the light in the effect to update
  122145. * @returns The directional light
  122146. */
  122147. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  122148. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  122149. /**
  122150. * Gets the minZ used for shadow according to both the scene and the light.
  122151. *
  122152. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122153. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122154. * @param activeCamera The camera we are returning the min for
  122155. * @returns the depth min z
  122156. */
  122157. getDepthMinZ(activeCamera: Camera): number;
  122158. /**
  122159. * Gets the maxZ used for shadow according to both the scene and the light.
  122160. *
  122161. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  122162. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  122163. * @param activeCamera The camera we are returning the max for
  122164. * @returns the depth max z
  122165. */
  122166. getDepthMaxZ(activeCamera: Camera): number;
  122167. /**
  122168. * Prepares the list of defines specific to the light type.
  122169. * @param defines the list of defines
  122170. * @param lightIndex defines the index of the light for the effect
  122171. */
  122172. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122173. }
  122174. }
  122175. declare module BABYLON {
  122176. /**
  122177. * Class containing static functions to help procedurally build meshes
  122178. */
  122179. export class HemisphereBuilder {
  122180. /**
  122181. * Creates a hemisphere mesh
  122182. * @param name defines the name of the mesh
  122183. * @param options defines the options used to create the mesh
  122184. * @param scene defines the hosting scene
  122185. * @returns the hemisphere mesh
  122186. */
  122187. static CreateHemisphere(name: string, options: {
  122188. segments?: number;
  122189. diameter?: number;
  122190. sideOrientation?: number;
  122191. }, scene: any): Mesh;
  122192. }
  122193. }
  122194. declare module BABYLON {
  122195. /**
  122196. * A spot light is defined by a position, a direction, an angle, and an exponent.
  122197. * These values define a cone of light starting from the position, emitting toward the direction.
  122198. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  122199. * and the exponent defines the speed of the decay of the light with distance (reach).
  122200. * Documentation: https://doc.babylonjs.com/babylon101/lights
  122201. */
  122202. export class SpotLight extends ShadowLight {
  122203. private _angle;
  122204. private _innerAngle;
  122205. private _cosHalfAngle;
  122206. private _lightAngleScale;
  122207. private _lightAngleOffset;
  122208. /**
  122209. * Gets the cone angle of the spot light in Radians.
  122210. */
  122211. get angle(): number;
  122212. /**
  122213. * Sets the cone angle of the spot light in Radians.
  122214. */
  122215. set angle(value: number);
  122216. /**
  122217. * Only used in gltf falloff mode, this defines the angle where
  122218. * the directional falloff will start before cutting at angle which could be seen
  122219. * as outer angle.
  122220. */
  122221. get innerAngle(): number;
  122222. /**
  122223. * Only used in gltf falloff mode, this defines the angle where
  122224. * the directional falloff will start before cutting at angle which could be seen
  122225. * as outer angle.
  122226. */
  122227. set innerAngle(value: number);
  122228. private _shadowAngleScale;
  122229. /**
  122230. * Allows scaling the angle of the light for shadow generation only.
  122231. */
  122232. get shadowAngleScale(): number;
  122233. /**
  122234. * Allows scaling the angle of the light for shadow generation only.
  122235. */
  122236. set shadowAngleScale(value: number);
  122237. /**
  122238. * The light decay speed with the distance from the emission spot.
  122239. */
  122240. exponent: number;
  122241. private _projectionTextureMatrix;
  122242. /**
  122243. * Allows reading the projecton texture
  122244. */
  122245. get projectionTextureMatrix(): Matrix;
  122246. protected _projectionTextureLightNear: number;
  122247. /**
  122248. * Gets the near clip of the Spotlight for texture projection.
  122249. */
  122250. get projectionTextureLightNear(): number;
  122251. /**
  122252. * Sets the near clip of the Spotlight for texture projection.
  122253. */
  122254. set projectionTextureLightNear(value: number);
  122255. protected _projectionTextureLightFar: number;
  122256. /**
  122257. * Gets the far clip of the Spotlight for texture projection.
  122258. */
  122259. get projectionTextureLightFar(): number;
  122260. /**
  122261. * Sets the far clip of the Spotlight for texture projection.
  122262. */
  122263. set projectionTextureLightFar(value: number);
  122264. protected _projectionTextureUpDirection: Vector3;
  122265. /**
  122266. * Gets the Up vector of the Spotlight for texture projection.
  122267. */
  122268. get projectionTextureUpDirection(): Vector3;
  122269. /**
  122270. * Sets the Up vector of the Spotlight for texture projection.
  122271. */
  122272. set projectionTextureUpDirection(value: Vector3);
  122273. private _projectionTexture;
  122274. /**
  122275. * Gets the projection texture of the light.
  122276. */
  122277. get projectionTexture(): Nullable<BaseTexture>;
  122278. /**
  122279. * Sets the projection texture of the light.
  122280. */
  122281. set projectionTexture(value: Nullable<BaseTexture>);
  122282. private _projectionTextureViewLightDirty;
  122283. private _projectionTextureProjectionLightDirty;
  122284. private _projectionTextureDirty;
  122285. private _projectionTextureViewTargetVector;
  122286. private _projectionTextureViewLightMatrix;
  122287. private _projectionTextureProjectionLightMatrix;
  122288. private _projectionTextureScalingMatrix;
  122289. /**
  122290. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  122291. * It can cast shadows.
  122292. * Documentation : https://doc.babylonjs.com/babylon101/lights
  122293. * @param name The light friendly name
  122294. * @param position The position of the spot light in the scene
  122295. * @param direction The direction of the light in the scene
  122296. * @param angle The cone angle of the light in Radians
  122297. * @param exponent The light decay speed with the distance from the emission spot
  122298. * @param scene The scene the lights belongs to
  122299. */
  122300. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  122301. /**
  122302. * Returns the string "SpotLight".
  122303. * @returns the class name
  122304. */
  122305. getClassName(): string;
  122306. /**
  122307. * Returns the integer 2.
  122308. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  122309. */
  122310. getTypeID(): number;
  122311. /**
  122312. * Overrides the direction setter to recompute the projection texture view light Matrix.
  122313. */
  122314. protected _setDirection(value: Vector3): void;
  122315. /**
  122316. * Overrides the position setter to recompute the projection texture view light Matrix.
  122317. */
  122318. protected _setPosition(value: Vector3): void;
  122319. /**
  122320. * 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.
  122321. * Returns the SpotLight.
  122322. */
  122323. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  122324. protected _computeProjectionTextureViewLightMatrix(): void;
  122325. protected _computeProjectionTextureProjectionLightMatrix(): void;
  122326. /**
  122327. * Main function for light texture projection matrix computing.
  122328. */
  122329. protected _computeProjectionTextureMatrix(): void;
  122330. protected _buildUniformLayout(): void;
  122331. private _computeAngleValues;
  122332. /**
  122333. * Sets the passed Effect "effect" with the Light textures.
  122334. * @param effect The effect to update
  122335. * @param lightIndex The index of the light in the effect to update
  122336. * @returns The light
  122337. */
  122338. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  122339. /**
  122340. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  122341. * @param effect The effect to update
  122342. * @param lightIndex The index of the light in the effect to update
  122343. * @returns The spot light
  122344. */
  122345. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  122346. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  122347. /**
  122348. * Disposes the light and the associated resources.
  122349. */
  122350. dispose(): void;
  122351. /**
  122352. * Prepares the list of defines specific to the light type.
  122353. * @param defines the list of defines
  122354. * @param lightIndex defines the index of the light for the effect
  122355. */
  122356. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  122357. }
  122358. }
  122359. declare module BABYLON {
  122360. /**
  122361. * Gizmo that enables viewing a light
  122362. */
  122363. export class LightGizmo extends Gizmo {
  122364. private _lightMesh;
  122365. private _material;
  122366. private _cachedPosition;
  122367. private _cachedForward;
  122368. private _attachedMeshParent;
  122369. /**
  122370. * Creates a LightGizmo
  122371. * @param gizmoLayer The utility layer the gizmo will be added to
  122372. */
  122373. constructor(gizmoLayer?: UtilityLayerRenderer);
  122374. private _light;
  122375. /**
  122376. * The light that the gizmo is attached to
  122377. */
  122378. set light(light: Nullable<Light>);
  122379. get light(): Nullable<Light>;
  122380. /**
  122381. * Gets the material used to render the light gizmo
  122382. */
  122383. get material(): StandardMaterial;
  122384. /**
  122385. * @hidden
  122386. * Updates the gizmo to match the attached mesh's position/rotation
  122387. */
  122388. protected _update(): void;
  122389. private static _Scale;
  122390. /**
  122391. * Creates the lines for a light mesh
  122392. */
  122393. private static _CreateLightLines;
  122394. /**
  122395. * Disposes of the light gizmo
  122396. */
  122397. dispose(): void;
  122398. private static _CreateHemisphericLightMesh;
  122399. private static _CreatePointLightMesh;
  122400. private static _CreateSpotLightMesh;
  122401. private static _CreateDirectionalLightMesh;
  122402. }
  122403. }
  122404. declare module BABYLON {
  122405. /** @hidden */
  122406. export var backgroundFragmentDeclaration: {
  122407. name: string;
  122408. shader: string;
  122409. };
  122410. }
  122411. declare module BABYLON {
  122412. /** @hidden */
  122413. export var backgroundUboDeclaration: {
  122414. name: string;
  122415. shader: string;
  122416. };
  122417. }
  122418. declare module BABYLON {
  122419. /** @hidden */
  122420. export var backgroundPixelShader: {
  122421. name: string;
  122422. shader: string;
  122423. };
  122424. }
  122425. declare module BABYLON {
  122426. /** @hidden */
  122427. export var backgroundVertexDeclaration: {
  122428. name: string;
  122429. shader: string;
  122430. };
  122431. }
  122432. declare module BABYLON {
  122433. /** @hidden */
  122434. export var backgroundVertexShader: {
  122435. name: string;
  122436. shader: string;
  122437. };
  122438. }
  122439. declare module BABYLON {
  122440. /**
  122441. * Background material used to create an efficient environement around your scene.
  122442. */
  122443. export class BackgroundMaterial extends PushMaterial {
  122444. /**
  122445. * Standard reflectance value at parallel view angle.
  122446. */
  122447. static StandardReflectance0: number;
  122448. /**
  122449. * Standard reflectance value at grazing angle.
  122450. */
  122451. static StandardReflectance90: number;
  122452. protected _primaryColor: Color3;
  122453. /**
  122454. * Key light Color (multiply against the environement texture)
  122455. */
  122456. primaryColor: Color3;
  122457. protected __perceptualColor: Nullable<Color3>;
  122458. /**
  122459. * Experimental Internal Use Only.
  122460. *
  122461. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  122462. * This acts as a helper to set the primary color to a more "human friendly" value.
  122463. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  122464. * output color as close as possible from the chosen value.
  122465. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  122466. * part of lighting setup.)
  122467. */
  122468. get _perceptualColor(): Nullable<Color3>;
  122469. set _perceptualColor(value: Nullable<Color3>);
  122470. protected _primaryColorShadowLevel: float;
  122471. /**
  122472. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  122473. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  122474. */
  122475. get primaryColorShadowLevel(): float;
  122476. set primaryColorShadowLevel(value: float);
  122477. protected _primaryColorHighlightLevel: float;
  122478. /**
  122479. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  122480. * The primary color is used at the level chosen to define what the white area would look.
  122481. */
  122482. get primaryColorHighlightLevel(): float;
  122483. set primaryColorHighlightLevel(value: float);
  122484. protected _reflectionTexture: Nullable<BaseTexture>;
  122485. /**
  122486. * Reflection Texture used in the material.
  122487. * Should be author in a specific way for the best result (refer to the documentation).
  122488. */
  122489. reflectionTexture: Nullable<BaseTexture>;
  122490. protected _reflectionBlur: float;
  122491. /**
  122492. * Reflection Texture level of blur.
  122493. *
  122494. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  122495. * texture twice.
  122496. */
  122497. reflectionBlur: float;
  122498. protected _diffuseTexture: Nullable<BaseTexture>;
  122499. /**
  122500. * Diffuse Texture used in the material.
  122501. * Should be author in a specific way for the best result (refer to the documentation).
  122502. */
  122503. diffuseTexture: Nullable<BaseTexture>;
  122504. protected _shadowLights: Nullable<IShadowLight[]>;
  122505. /**
  122506. * Specify the list of lights casting shadow on the material.
  122507. * All scene shadow lights will be included if null.
  122508. */
  122509. shadowLights: Nullable<IShadowLight[]>;
  122510. protected _shadowLevel: float;
  122511. /**
  122512. * Helps adjusting the shadow to a softer level if required.
  122513. * 0 means black shadows and 1 means no shadows.
  122514. */
  122515. shadowLevel: float;
  122516. protected _sceneCenter: Vector3;
  122517. /**
  122518. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  122519. * It is usually zero but might be interesting to modify according to your setup.
  122520. */
  122521. sceneCenter: Vector3;
  122522. protected _opacityFresnel: boolean;
  122523. /**
  122524. * This helps specifying that the material is falling off to the sky box at grazing angle.
  122525. * This helps ensuring a nice transition when the camera goes under the ground.
  122526. */
  122527. opacityFresnel: boolean;
  122528. protected _reflectionFresnel: boolean;
  122529. /**
  122530. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  122531. * This helps adding a mirror texture on the ground.
  122532. */
  122533. reflectionFresnel: boolean;
  122534. protected _reflectionFalloffDistance: number;
  122535. /**
  122536. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  122537. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  122538. */
  122539. reflectionFalloffDistance: number;
  122540. protected _reflectionAmount: number;
  122541. /**
  122542. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  122543. */
  122544. reflectionAmount: number;
  122545. protected _reflectionReflectance0: number;
  122546. /**
  122547. * This specifies the weight of the reflection at grazing angle.
  122548. */
  122549. reflectionReflectance0: number;
  122550. protected _reflectionReflectance90: number;
  122551. /**
  122552. * This specifies the weight of the reflection at a perpendicular point of view.
  122553. */
  122554. reflectionReflectance90: number;
  122555. /**
  122556. * Sets the reflection reflectance fresnel values according to the default standard
  122557. * empirically know to work well :-)
  122558. */
  122559. set reflectionStandardFresnelWeight(value: number);
  122560. protected _useRGBColor: boolean;
  122561. /**
  122562. * Helps to directly use the maps channels instead of their level.
  122563. */
  122564. useRGBColor: boolean;
  122565. protected _enableNoise: boolean;
  122566. /**
  122567. * This helps reducing the banding effect that could occur on the background.
  122568. */
  122569. enableNoise: boolean;
  122570. /**
  122571. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  122572. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  122573. * Recommended to be keep at 1.0 except for special cases.
  122574. */
  122575. get fovMultiplier(): number;
  122576. set fovMultiplier(value: number);
  122577. private _fovMultiplier;
  122578. /**
  122579. * Enable the FOV adjustment feature controlled by fovMultiplier.
  122580. */
  122581. useEquirectangularFOV: boolean;
  122582. private _maxSimultaneousLights;
  122583. /**
  122584. * Number of Simultaneous lights allowed on the material.
  122585. */
  122586. maxSimultaneousLights: int;
  122587. /**
  122588. * Default configuration related to image processing available in the Background Material.
  122589. */
  122590. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  122591. /**
  122592. * Keep track of the image processing observer to allow dispose and replace.
  122593. */
  122594. private _imageProcessingObserver;
  122595. /**
  122596. * Attaches a new image processing configuration to the PBR Material.
  122597. * @param configuration (if null the scene configuration will be use)
  122598. */
  122599. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  122600. /**
  122601. * Gets the image processing configuration used either in this material.
  122602. */
  122603. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  122604. /**
  122605. * Sets the Default image processing configuration used either in the this material.
  122606. *
  122607. * If sets to null, the scene one is in use.
  122608. */
  122609. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  122610. /**
  122611. * Gets wether the color curves effect is enabled.
  122612. */
  122613. get cameraColorCurvesEnabled(): boolean;
  122614. /**
  122615. * Sets wether the color curves effect is enabled.
  122616. */
  122617. set cameraColorCurvesEnabled(value: boolean);
  122618. /**
  122619. * Gets wether the color grading effect is enabled.
  122620. */
  122621. get cameraColorGradingEnabled(): boolean;
  122622. /**
  122623. * Gets wether the color grading effect is enabled.
  122624. */
  122625. set cameraColorGradingEnabled(value: boolean);
  122626. /**
  122627. * Gets wether tonemapping is enabled or not.
  122628. */
  122629. get cameraToneMappingEnabled(): boolean;
  122630. /**
  122631. * Sets wether tonemapping is enabled or not
  122632. */
  122633. set cameraToneMappingEnabled(value: boolean);
  122634. /**
  122635. * The camera exposure used on this material.
  122636. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122637. * This corresponds to a photographic exposure.
  122638. */
  122639. get cameraExposure(): float;
  122640. /**
  122641. * The camera exposure used on this material.
  122642. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  122643. * This corresponds to a photographic exposure.
  122644. */
  122645. set cameraExposure(value: float);
  122646. /**
  122647. * Gets The camera contrast used on this material.
  122648. */
  122649. get cameraContrast(): float;
  122650. /**
  122651. * Sets The camera contrast used on this material.
  122652. */
  122653. set cameraContrast(value: float);
  122654. /**
  122655. * Gets the Color Grading 2D Lookup Texture.
  122656. */
  122657. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  122658. /**
  122659. * Sets the Color Grading 2D Lookup Texture.
  122660. */
  122661. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  122662. /**
  122663. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122664. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122665. * 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;
  122666. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122667. */
  122668. get cameraColorCurves(): Nullable<ColorCurves>;
  122669. /**
  122670. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  122671. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  122672. * 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;
  122673. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  122674. */
  122675. set cameraColorCurves(value: Nullable<ColorCurves>);
  122676. /**
  122677. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  122678. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  122679. */
  122680. switchToBGR: boolean;
  122681. private _renderTargets;
  122682. private _reflectionControls;
  122683. private _white;
  122684. private _primaryShadowColor;
  122685. private _primaryHighlightColor;
  122686. /**
  122687. * Instantiates a Background Material in the given scene
  122688. * @param name The friendly name of the material
  122689. * @param scene The scene to add the material to
  122690. */
  122691. constructor(name: string, scene: Scene);
  122692. /**
  122693. * Gets a boolean indicating that current material needs to register RTT
  122694. */
  122695. get hasRenderTargetTextures(): boolean;
  122696. /**
  122697. * The entire material has been created in order to prevent overdraw.
  122698. * @returns false
  122699. */
  122700. needAlphaTesting(): boolean;
  122701. /**
  122702. * The entire material has been created in order to prevent overdraw.
  122703. * @returns true if blending is enable
  122704. */
  122705. needAlphaBlending(): boolean;
  122706. /**
  122707. * Checks wether the material is ready to be rendered for a given mesh.
  122708. * @param mesh The mesh to render
  122709. * @param subMesh The submesh to check against
  122710. * @param useInstances Specify wether or not the material is used with instances
  122711. * @returns true if all the dependencies are ready (Textures, Effects...)
  122712. */
  122713. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  122714. /**
  122715. * Compute the primary color according to the chosen perceptual color.
  122716. */
  122717. private _computePrimaryColorFromPerceptualColor;
  122718. /**
  122719. * Compute the highlights and shadow colors according to their chosen levels.
  122720. */
  122721. private _computePrimaryColors;
  122722. /**
  122723. * Build the uniform buffer used in the material.
  122724. */
  122725. buildUniformLayout(): void;
  122726. /**
  122727. * Unbind the material.
  122728. */
  122729. unbind(): void;
  122730. /**
  122731. * Bind only the world matrix to the material.
  122732. * @param world The world matrix to bind.
  122733. */
  122734. bindOnlyWorldMatrix(world: Matrix): void;
  122735. /**
  122736. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  122737. * @param world The world matrix to bind.
  122738. * @param subMesh The submesh to bind for.
  122739. */
  122740. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  122741. /**
  122742. * Checks to see if a texture is used in the material.
  122743. * @param texture - Base texture to use.
  122744. * @returns - Boolean specifying if a texture is used in the material.
  122745. */
  122746. hasTexture(texture: BaseTexture): boolean;
  122747. /**
  122748. * Dispose the material.
  122749. * @param forceDisposeEffect Force disposal of the associated effect.
  122750. * @param forceDisposeTextures Force disposal of the associated textures.
  122751. */
  122752. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  122753. /**
  122754. * Clones the material.
  122755. * @param name The cloned name.
  122756. * @returns The cloned material.
  122757. */
  122758. clone(name: string): BackgroundMaterial;
  122759. /**
  122760. * Serializes the current material to its JSON representation.
  122761. * @returns The JSON representation.
  122762. */
  122763. serialize(): any;
  122764. /**
  122765. * Gets the class name of the material
  122766. * @returns "BackgroundMaterial"
  122767. */
  122768. getClassName(): string;
  122769. /**
  122770. * Parse a JSON input to create back a background material.
  122771. * @param source The JSON data to parse
  122772. * @param scene The scene to create the parsed material in
  122773. * @param rootUrl The root url of the assets the material depends upon
  122774. * @returns the instantiated BackgroundMaterial.
  122775. */
  122776. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  122777. }
  122778. }
  122779. declare module BABYLON {
  122780. /**
  122781. * Represents the different options available during the creation of
  122782. * a Environment helper.
  122783. *
  122784. * This can control the default ground, skybox and image processing setup of your scene.
  122785. */
  122786. export interface IEnvironmentHelperOptions {
  122787. /**
  122788. * Specifies whether or not to create a ground.
  122789. * True by default.
  122790. */
  122791. createGround: boolean;
  122792. /**
  122793. * Specifies the ground size.
  122794. * 15 by default.
  122795. */
  122796. groundSize: number;
  122797. /**
  122798. * The texture used on the ground for the main color.
  122799. * Comes from the BabylonJS CDN by default.
  122800. *
  122801. * Remarks: Can be either a texture or a url.
  122802. */
  122803. groundTexture: string | BaseTexture;
  122804. /**
  122805. * The color mixed in the ground texture by default.
  122806. * BabylonJS clearColor by default.
  122807. */
  122808. groundColor: Color3;
  122809. /**
  122810. * Specifies the ground opacity.
  122811. * 1 by default.
  122812. */
  122813. groundOpacity: number;
  122814. /**
  122815. * Enables the ground to receive shadows.
  122816. * True by default.
  122817. */
  122818. enableGroundShadow: boolean;
  122819. /**
  122820. * Helps preventing the shadow to be fully black on the ground.
  122821. * 0.5 by default.
  122822. */
  122823. groundShadowLevel: number;
  122824. /**
  122825. * Creates a mirror texture attach to the ground.
  122826. * false by default.
  122827. */
  122828. enableGroundMirror: boolean;
  122829. /**
  122830. * Specifies the ground mirror size ratio.
  122831. * 0.3 by default as the default kernel is 64.
  122832. */
  122833. groundMirrorSizeRatio: number;
  122834. /**
  122835. * Specifies the ground mirror blur kernel size.
  122836. * 64 by default.
  122837. */
  122838. groundMirrorBlurKernel: number;
  122839. /**
  122840. * Specifies the ground mirror visibility amount.
  122841. * 1 by default
  122842. */
  122843. groundMirrorAmount: number;
  122844. /**
  122845. * Specifies the ground mirror reflectance weight.
  122846. * This uses the standard weight of the background material to setup the fresnel effect
  122847. * of the mirror.
  122848. * 1 by default.
  122849. */
  122850. groundMirrorFresnelWeight: number;
  122851. /**
  122852. * Specifies the ground mirror Falloff distance.
  122853. * This can helps reducing the size of the reflection.
  122854. * 0 by Default.
  122855. */
  122856. groundMirrorFallOffDistance: number;
  122857. /**
  122858. * Specifies the ground mirror texture type.
  122859. * Unsigned Int by Default.
  122860. */
  122861. groundMirrorTextureType: number;
  122862. /**
  122863. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  122864. * the shown objects.
  122865. */
  122866. groundYBias: number;
  122867. /**
  122868. * Specifies whether or not to create a skybox.
  122869. * True by default.
  122870. */
  122871. createSkybox: boolean;
  122872. /**
  122873. * Specifies the skybox size.
  122874. * 20 by default.
  122875. */
  122876. skyboxSize: number;
  122877. /**
  122878. * The texture used on the skybox for the main color.
  122879. * Comes from the BabylonJS CDN by default.
  122880. *
  122881. * Remarks: Can be either a texture or a url.
  122882. */
  122883. skyboxTexture: string | BaseTexture;
  122884. /**
  122885. * The color mixed in the skybox texture by default.
  122886. * BabylonJS clearColor by default.
  122887. */
  122888. skyboxColor: Color3;
  122889. /**
  122890. * The background rotation around the Y axis of the scene.
  122891. * This helps aligning the key lights of your scene with the background.
  122892. * 0 by default.
  122893. */
  122894. backgroundYRotation: number;
  122895. /**
  122896. * Compute automatically the size of the elements to best fit with the scene.
  122897. */
  122898. sizeAuto: boolean;
  122899. /**
  122900. * Default position of the rootMesh if autoSize is not true.
  122901. */
  122902. rootPosition: Vector3;
  122903. /**
  122904. * Sets up the image processing in the scene.
  122905. * true by default.
  122906. */
  122907. setupImageProcessing: boolean;
  122908. /**
  122909. * The texture used as your environment texture in the scene.
  122910. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  122911. *
  122912. * Remarks: Can be either a texture or a url.
  122913. */
  122914. environmentTexture: string | BaseTexture;
  122915. /**
  122916. * The value of the exposure to apply to the scene.
  122917. * 0.6 by default if setupImageProcessing is true.
  122918. */
  122919. cameraExposure: number;
  122920. /**
  122921. * The value of the contrast to apply to the scene.
  122922. * 1.6 by default if setupImageProcessing is true.
  122923. */
  122924. cameraContrast: number;
  122925. /**
  122926. * Specifies whether or not tonemapping should be enabled in the scene.
  122927. * true by default if setupImageProcessing is true.
  122928. */
  122929. toneMappingEnabled: boolean;
  122930. }
  122931. /**
  122932. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  122933. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  122934. * It also helps with the default setup of your imageProcessing configuration.
  122935. */
  122936. export class EnvironmentHelper {
  122937. /**
  122938. * Default ground texture URL.
  122939. */
  122940. private static _groundTextureCDNUrl;
  122941. /**
  122942. * Default skybox texture URL.
  122943. */
  122944. private static _skyboxTextureCDNUrl;
  122945. /**
  122946. * Default environment texture URL.
  122947. */
  122948. private static _environmentTextureCDNUrl;
  122949. /**
  122950. * Creates the default options for the helper.
  122951. */
  122952. private static _getDefaultOptions;
  122953. private _rootMesh;
  122954. /**
  122955. * Gets the root mesh created by the helper.
  122956. */
  122957. get rootMesh(): Mesh;
  122958. private _skybox;
  122959. /**
  122960. * Gets the skybox created by the helper.
  122961. */
  122962. get skybox(): Nullable<Mesh>;
  122963. private _skyboxTexture;
  122964. /**
  122965. * Gets the skybox texture created by the helper.
  122966. */
  122967. get skyboxTexture(): Nullable<BaseTexture>;
  122968. private _skyboxMaterial;
  122969. /**
  122970. * Gets the skybox material created by the helper.
  122971. */
  122972. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  122973. private _ground;
  122974. /**
  122975. * Gets the ground mesh created by the helper.
  122976. */
  122977. get ground(): Nullable<Mesh>;
  122978. private _groundTexture;
  122979. /**
  122980. * Gets the ground texture created by the helper.
  122981. */
  122982. get groundTexture(): Nullable<BaseTexture>;
  122983. private _groundMirror;
  122984. /**
  122985. * Gets the ground mirror created by the helper.
  122986. */
  122987. get groundMirror(): Nullable<MirrorTexture>;
  122988. /**
  122989. * Gets the ground mirror render list to helps pushing the meshes
  122990. * you wish in the ground reflection.
  122991. */
  122992. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  122993. private _groundMaterial;
  122994. /**
  122995. * Gets the ground material created by the helper.
  122996. */
  122997. get groundMaterial(): Nullable<BackgroundMaterial>;
  122998. /**
  122999. * Stores the creation options.
  123000. */
  123001. private readonly _scene;
  123002. private _options;
  123003. /**
  123004. * This observable will be notified with any error during the creation of the environment,
  123005. * mainly texture creation errors.
  123006. */
  123007. onErrorObservable: Observable<{
  123008. message?: string;
  123009. exception?: any;
  123010. }>;
  123011. /**
  123012. * constructor
  123013. * @param options Defines the options we want to customize the helper
  123014. * @param scene The scene to add the material to
  123015. */
  123016. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  123017. /**
  123018. * Updates the background according to the new options
  123019. * @param options
  123020. */
  123021. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  123022. /**
  123023. * Sets the primary color of all the available elements.
  123024. * @param color the main color to affect to the ground and the background
  123025. */
  123026. setMainColor(color: Color3): void;
  123027. /**
  123028. * Setup the image processing according to the specified options.
  123029. */
  123030. private _setupImageProcessing;
  123031. /**
  123032. * Setup the environment texture according to the specified options.
  123033. */
  123034. private _setupEnvironmentTexture;
  123035. /**
  123036. * Setup the background according to the specified options.
  123037. */
  123038. private _setupBackground;
  123039. /**
  123040. * Get the scene sizes according to the setup.
  123041. */
  123042. private _getSceneSize;
  123043. /**
  123044. * Setup the ground according to the specified options.
  123045. */
  123046. private _setupGround;
  123047. /**
  123048. * Setup the ground material according to the specified options.
  123049. */
  123050. private _setupGroundMaterial;
  123051. /**
  123052. * Setup the ground diffuse texture according to the specified options.
  123053. */
  123054. private _setupGroundDiffuseTexture;
  123055. /**
  123056. * Setup the ground mirror texture according to the specified options.
  123057. */
  123058. private _setupGroundMirrorTexture;
  123059. /**
  123060. * Setup the ground to receive the mirror texture.
  123061. */
  123062. private _setupMirrorInGroundMaterial;
  123063. /**
  123064. * Setup the skybox according to the specified options.
  123065. */
  123066. private _setupSkybox;
  123067. /**
  123068. * Setup the skybox material according to the specified options.
  123069. */
  123070. private _setupSkyboxMaterial;
  123071. /**
  123072. * Setup the skybox reflection texture according to the specified options.
  123073. */
  123074. private _setupSkyboxReflectionTexture;
  123075. private _errorHandler;
  123076. /**
  123077. * Dispose all the elements created by the Helper.
  123078. */
  123079. dispose(): void;
  123080. }
  123081. }
  123082. declare module BABYLON {
  123083. /**
  123084. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  123085. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  123086. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  123087. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  123088. */
  123089. export class PhotoDome extends TransformNode {
  123090. /**
  123091. * Define the image as a Monoscopic panoramic 360 image.
  123092. */
  123093. static readonly MODE_MONOSCOPIC: number;
  123094. /**
  123095. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123096. */
  123097. static readonly MODE_TOPBOTTOM: number;
  123098. /**
  123099. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123100. */
  123101. static readonly MODE_SIDEBYSIDE: number;
  123102. private _useDirectMapping;
  123103. /**
  123104. * The texture being displayed on the sphere
  123105. */
  123106. protected _photoTexture: Texture;
  123107. /**
  123108. * Gets or sets the texture being displayed on the sphere
  123109. */
  123110. get photoTexture(): Texture;
  123111. set photoTexture(value: Texture);
  123112. /**
  123113. * Observable raised when an error occured while loading the 360 image
  123114. */
  123115. onLoadErrorObservable: Observable<string>;
  123116. /**
  123117. * The skybox material
  123118. */
  123119. protected _material: BackgroundMaterial;
  123120. /**
  123121. * The surface used for the skybox
  123122. */
  123123. protected _mesh: Mesh;
  123124. /**
  123125. * Gets the mesh used for the skybox.
  123126. */
  123127. get mesh(): Mesh;
  123128. /**
  123129. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123130. * Also see the options.resolution property.
  123131. */
  123132. get fovMultiplier(): number;
  123133. set fovMultiplier(value: number);
  123134. private _imageMode;
  123135. /**
  123136. * Gets or set the current video mode for the video. It can be:
  123137. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  123138. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  123139. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  123140. */
  123141. get imageMode(): number;
  123142. set imageMode(value: number);
  123143. /**
  123144. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  123145. * @param name Element's name, child elements will append suffixes for their own names.
  123146. * @param urlsOfPhoto defines the url of the photo to display
  123147. * @param options defines an object containing optional or exposed sub element properties
  123148. * @param onError defines a callback called when an error occured while loading the texture
  123149. */
  123150. constructor(name: string, urlOfPhoto: string, options: {
  123151. resolution?: number;
  123152. size?: number;
  123153. useDirectMapping?: boolean;
  123154. faceForward?: boolean;
  123155. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  123156. private _onBeforeCameraRenderObserver;
  123157. private _changeImageMode;
  123158. /**
  123159. * Releases resources associated with this node.
  123160. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  123161. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  123162. */
  123163. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  123164. }
  123165. }
  123166. declare module BABYLON {
  123167. /**
  123168. * Class used to host RGBD texture specific utilities
  123169. */
  123170. export class RGBDTextureTools {
  123171. /**
  123172. * Expand the RGBD Texture from RGBD to Half Float if possible.
  123173. * @param texture the texture to expand.
  123174. */
  123175. static ExpandRGBDTexture(texture: Texture): void;
  123176. }
  123177. }
  123178. declare module BABYLON {
  123179. /**
  123180. * Class used to host texture specific utilities
  123181. */
  123182. export class BRDFTextureTools {
  123183. /**
  123184. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  123185. * @param scene defines the hosting scene
  123186. * @returns the environment BRDF texture
  123187. */
  123188. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  123189. private static _environmentBRDFBase64Texture;
  123190. }
  123191. }
  123192. declare module BABYLON {
  123193. /**
  123194. * @hidden
  123195. */
  123196. export interface IMaterialClearCoatDefines {
  123197. CLEARCOAT: boolean;
  123198. CLEARCOAT_DEFAULTIOR: boolean;
  123199. CLEARCOAT_TEXTURE: boolean;
  123200. CLEARCOAT_TEXTUREDIRECTUV: number;
  123201. CLEARCOAT_BUMP: boolean;
  123202. CLEARCOAT_BUMPDIRECTUV: number;
  123203. CLEARCOAT_TINT: boolean;
  123204. CLEARCOAT_TINT_TEXTURE: boolean;
  123205. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  123206. /** @hidden */
  123207. _areTexturesDirty: boolean;
  123208. }
  123209. /**
  123210. * Define the code related to the clear coat parameters of the pbr material.
  123211. */
  123212. export class PBRClearCoatConfiguration {
  123213. /**
  123214. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123215. * The default fits with a polyurethane material.
  123216. */
  123217. private static readonly _DefaultIndexOfRefraction;
  123218. private _isEnabled;
  123219. /**
  123220. * Defines if the clear coat is enabled in the material.
  123221. */
  123222. isEnabled: boolean;
  123223. /**
  123224. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  123225. */
  123226. intensity: number;
  123227. /**
  123228. * Defines the clear coat layer roughness.
  123229. */
  123230. roughness: number;
  123231. private _indexOfRefraction;
  123232. /**
  123233. * Defines the index of refraction of the clear coat.
  123234. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  123235. * The default fits with a polyurethane material.
  123236. * Changing the default value is more performance intensive.
  123237. */
  123238. indexOfRefraction: number;
  123239. private _texture;
  123240. /**
  123241. * Stores the clear coat values in a texture.
  123242. */
  123243. texture: Nullable<BaseTexture>;
  123244. private _bumpTexture;
  123245. /**
  123246. * Define the clear coat specific bump texture.
  123247. */
  123248. bumpTexture: Nullable<BaseTexture>;
  123249. private _isTintEnabled;
  123250. /**
  123251. * Defines if the clear coat tint is enabled in the material.
  123252. */
  123253. isTintEnabled: boolean;
  123254. /**
  123255. * Defines the clear coat tint of the material.
  123256. * This is only use if tint is enabled
  123257. */
  123258. tintColor: Color3;
  123259. /**
  123260. * Defines the distance at which the tint color should be found in the
  123261. * clear coat media.
  123262. * This is only use if tint is enabled
  123263. */
  123264. tintColorAtDistance: number;
  123265. /**
  123266. * Defines the clear coat layer thickness.
  123267. * This is only use if tint is enabled
  123268. */
  123269. tintThickness: number;
  123270. private _tintTexture;
  123271. /**
  123272. * Stores the clear tint values in a texture.
  123273. * rgb is tint
  123274. * a is a thickness factor
  123275. */
  123276. tintTexture: Nullable<BaseTexture>;
  123277. /** @hidden */
  123278. private _internalMarkAllSubMeshesAsTexturesDirty;
  123279. /** @hidden */
  123280. _markAllSubMeshesAsTexturesDirty(): void;
  123281. /**
  123282. * Instantiate a new istance of clear coat configuration.
  123283. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123284. */
  123285. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123286. /**
  123287. * Gets wehter the submesh is ready to be used or not.
  123288. * @param defines the list of "defines" to update.
  123289. * @param scene defines the scene the material belongs to.
  123290. * @param engine defines the engine the material belongs to.
  123291. * @param disableBumpMap defines wether the material disables bump or not.
  123292. * @returns - boolean indicating that the submesh is ready or not.
  123293. */
  123294. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  123295. /**
  123296. * Checks to see if a texture is used in the material.
  123297. * @param defines the list of "defines" to update.
  123298. * @param scene defines the scene to the material belongs to.
  123299. */
  123300. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  123301. /**
  123302. * Binds the material data.
  123303. * @param uniformBuffer defines the Uniform buffer to fill in.
  123304. * @param scene defines the scene the material belongs to.
  123305. * @param engine defines the engine the material belongs to.
  123306. * @param disableBumpMap defines wether the material disables bump or not.
  123307. * @param isFrozen defines wether the material is frozen or not.
  123308. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  123309. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  123310. */
  123311. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  123312. /**
  123313. * Checks to see if a texture is used in the material.
  123314. * @param texture - Base texture to use.
  123315. * @returns - Boolean specifying if a texture is used in the material.
  123316. */
  123317. hasTexture(texture: BaseTexture): boolean;
  123318. /**
  123319. * Returns an array of the actively used textures.
  123320. * @param activeTextures Array of BaseTextures
  123321. */
  123322. getActiveTextures(activeTextures: BaseTexture[]): void;
  123323. /**
  123324. * Returns the animatable textures.
  123325. * @param animatables Array of animatable textures.
  123326. */
  123327. getAnimatables(animatables: IAnimatable[]): void;
  123328. /**
  123329. * Disposes the resources of the material.
  123330. * @param forceDisposeTextures - Forces the disposal of all textures.
  123331. */
  123332. dispose(forceDisposeTextures?: boolean): void;
  123333. /**
  123334. * Get the current class name of the texture useful for serialization or dynamic coding.
  123335. * @returns "PBRClearCoatConfiguration"
  123336. */
  123337. getClassName(): string;
  123338. /**
  123339. * Add fallbacks to the effect fallbacks list.
  123340. * @param defines defines the Base texture to use.
  123341. * @param fallbacks defines the current fallback list.
  123342. * @param currentRank defines the current fallback rank.
  123343. * @returns the new fallback rank.
  123344. */
  123345. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123346. /**
  123347. * Add the required uniforms to the current list.
  123348. * @param uniforms defines the current uniform list.
  123349. */
  123350. static AddUniforms(uniforms: string[]): void;
  123351. /**
  123352. * Add the required samplers to the current list.
  123353. * @param samplers defines the current sampler list.
  123354. */
  123355. static AddSamplers(samplers: string[]): void;
  123356. /**
  123357. * Add the required uniforms to the current buffer.
  123358. * @param uniformBuffer defines the current uniform buffer.
  123359. */
  123360. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123361. /**
  123362. * Makes a duplicate of the current configuration into another one.
  123363. * @param clearCoatConfiguration define the config where to copy the info
  123364. */
  123365. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  123366. /**
  123367. * Serializes this clear coat configuration.
  123368. * @returns - An object with the serialized config.
  123369. */
  123370. serialize(): any;
  123371. /**
  123372. * Parses a anisotropy Configuration from a serialized object.
  123373. * @param source - Serialized object.
  123374. * @param scene Defines the scene we are parsing for
  123375. * @param rootUrl Defines the rootUrl to load from
  123376. */
  123377. parse(source: any, scene: Scene, rootUrl: string): void;
  123378. }
  123379. }
  123380. declare module BABYLON {
  123381. /**
  123382. * @hidden
  123383. */
  123384. export interface IMaterialAnisotropicDefines {
  123385. ANISOTROPIC: boolean;
  123386. ANISOTROPIC_TEXTURE: boolean;
  123387. ANISOTROPIC_TEXTUREDIRECTUV: number;
  123388. MAINUV1: boolean;
  123389. _areTexturesDirty: boolean;
  123390. _needUVs: boolean;
  123391. }
  123392. /**
  123393. * Define the code related to the anisotropic parameters of the pbr material.
  123394. */
  123395. export class PBRAnisotropicConfiguration {
  123396. private _isEnabled;
  123397. /**
  123398. * Defines if the anisotropy is enabled in the material.
  123399. */
  123400. isEnabled: boolean;
  123401. /**
  123402. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  123403. */
  123404. intensity: number;
  123405. /**
  123406. * Defines if the effect is along the tangents, bitangents or in between.
  123407. * By default, the effect is "strectching" the highlights along the tangents.
  123408. */
  123409. direction: Vector2;
  123410. private _texture;
  123411. /**
  123412. * Stores the anisotropy values in a texture.
  123413. * rg is direction (like normal from -1 to 1)
  123414. * b is a intensity
  123415. */
  123416. texture: Nullable<BaseTexture>;
  123417. /** @hidden */
  123418. private _internalMarkAllSubMeshesAsTexturesDirty;
  123419. /** @hidden */
  123420. _markAllSubMeshesAsTexturesDirty(): void;
  123421. /**
  123422. * Instantiate a new istance of anisotropy configuration.
  123423. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123424. */
  123425. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123426. /**
  123427. * Specifies that the submesh is ready to be used.
  123428. * @param defines the list of "defines" to update.
  123429. * @param scene defines the scene the material belongs to.
  123430. * @returns - boolean indicating that the submesh is ready or not.
  123431. */
  123432. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  123433. /**
  123434. * Checks to see if a texture is used in the material.
  123435. * @param defines the list of "defines" to update.
  123436. * @param mesh the mesh we are preparing the defines for.
  123437. * @param scene defines the scene the material belongs to.
  123438. */
  123439. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  123440. /**
  123441. * Binds the material data.
  123442. * @param uniformBuffer defines the Uniform buffer to fill in.
  123443. * @param scene defines the scene the material belongs to.
  123444. * @param isFrozen defines wether the material is frozen or not.
  123445. */
  123446. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123447. /**
  123448. * Checks to see if a texture is used in the material.
  123449. * @param texture - Base texture to use.
  123450. * @returns - Boolean specifying if a texture is used in the material.
  123451. */
  123452. hasTexture(texture: BaseTexture): boolean;
  123453. /**
  123454. * Returns an array of the actively used textures.
  123455. * @param activeTextures Array of BaseTextures
  123456. */
  123457. getActiveTextures(activeTextures: BaseTexture[]): void;
  123458. /**
  123459. * Returns the animatable textures.
  123460. * @param animatables Array of animatable textures.
  123461. */
  123462. getAnimatables(animatables: IAnimatable[]): void;
  123463. /**
  123464. * Disposes the resources of the material.
  123465. * @param forceDisposeTextures - Forces the disposal of all textures.
  123466. */
  123467. dispose(forceDisposeTextures?: boolean): void;
  123468. /**
  123469. * Get the current class name of the texture useful for serialization or dynamic coding.
  123470. * @returns "PBRAnisotropicConfiguration"
  123471. */
  123472. getClassName(): string;
  123473. /**
  123474. * Add fallbacks to the effect fallbacks list.
  123475. * @param defines defines the Base texture to use.
  123476. * @param fallbacks defines the current fallback list.
  123477. * @param currentRank defines the current fallback rank.
  123478. * @returns the new fallback rank.
  123479. */
  123480. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123481. /**
  123482. * Add the required uniforms to the current list.
  123483. * @param uniforms defines the current uniform list.
  123484. */
  123485. static AddUniforms(uniforms: string[]): void;
  123486. /**
  123487. * Add the required uniforms to the current buffer.
  123488. * @param uniformBuffer defines the current uniform buffer.
  123489. */
  123490. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123491. /**
  123492. * Add the required samplers to the current list.
  123493. * @param samplers defines the current sampler list.
  123494. */
  123495. static AddSamplers(samplers: string[]): void;
  123496. /**
  123497. * Makes a duplicate of the current configuration into another one.
  123498. * @param anisotropicConfiguration define the config where to copy the info
  123499. */
  123500. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  123501. /**
  123502. * Serializes this anisotropy configuration.
  123503. * @returns - An object with the serialized config.
  123504. */
  123505. serialize(): any;
  123506. /**
  123507. * Parses a anisotropy Configuration from a serialized object.
  123508. * @param source - Serialized object.
  123509. * @param scene Defines the scene we are parsing for
  123510. * @param rootUrl Defines the rootUrl to load from
  123511. */
  123512. parse(source: any, scene: Scene, rootUrl: string): void;
  123513. }
  123514. }
  123515. declare module BABYLON {
  123516. /**
  123517. * @hidden
  123518. */
  123519. export interface IMaterialBRDFDefines {
  123520. BRDF_V_HEIGHT_CORRELATED: boolean;
  123521. MS_BRDF_ENERGY_CONSERVATION: boolean;
  123522. SPHERICAL_HARMONICS: boolean;
  123523. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  123524. /** @hidden */
  123525. _areMiscDirty: boolean;
  123526. }
  123527. /**
  123528. * Define the code related to the BRDF parameters of the pbr material.
  123529. */
  123530. export class PBRBRDFConfiguration {
  123531. /**
  123532. * Default value used for the energy conservation.
  123533. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123534. */
  123535. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  123536. /**
  123537. * Default value used for the Smith Visibility Height Correlated mode.
  123538. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  123539. */
  123540. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  123541. /**
  123542. * Default value used for the IBL diffuse part.
  123543. * This can help switching back to the polynomials mode globally which is a tiny bit
  123544. * less GPU intensive at the drawback of a lower quality.
  123545. */
  123546. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  123547. /**
  123548. * Default value used for activating energy conservation for the specular workflow.
  123549. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123550. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123551. */
  123552. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  123553. private _useEnergyConservation;
  123554. /**
  123555. * Defines if the material uses energy conservation.
  123556. */
  123557. useEnergyConservation: boolean;
  123558. private _useSmithVisibilityHeightCorrelated;
  123559. /**
  123560. * LEGACY Mode set to false
  123561. * Defines if the material uses height smith correlated visibility term.
  123562. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  123563. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  123564. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  123565. * Not relying on height correlated will also disable energy conservation.
  123566. */
  123567. useSmithVisibilityHeightCorrelated: boolean;
  123568. private _useSphericalHarmonics;
  123569. /**
  123570. * LEGACY Mode set to false
  123571. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  123572. * diffuse part of the IBL.
  123573. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  123574. * to the ground truth.
  123575. */
  123576. useSphericalHarmonics: boolean;
  123577. private _useSpecularGlossinessInputEnergyConservation;
  123578. /**
  123579. * Defines if the material uses energy conservation, when the specular workflow is active.
  123580. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  123581. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  123582. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  123583. */
  123584. useSpecularGlossinessInputEnergyConservation: boolean;
  123585. /** @hidden */
  123586. private _internalMarkAllSubMeshesAsMiscDirty;
  123587. /** @hidden */
  123588. _markAllSubMeshesAsMiscDirty(): void;
  123589. /**
  123590. * Instantiate a new istance of clear coat configuration.
  123591. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  123592. */
  123593. constructor(markAllSubMeshesAsMiscDirty: () => void);
  123594. /**
  123595. * Checks to see if a texture is used in the material.
  123596. * @param defines the list of "defines" to update.
  123597. */
  123598. prepareDefines(defines: IMaterialBRDFDefines): void;
  123599. /**
  123600. * Get the current class name of the texture useful for serialization or dynamic coding.
  123601. * @returns "PBRClearCoatConfiguration"
  123602. */
  123603. getClassName(): string;
  123604. /**
  123605. * Makes a duplicate of the current configuration into another one.
  123606. * @param brdfConfiguration define the config where to copy the info
  123607. */
  123608. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  123609. /**
  123610. * Serializes this BRDF configuration.
  123611. * @returns - An object with the serialized config.
  123612. */
  123613. serialize(): any;
  123614. /**
  123615. * Parses a anisotropy Configuration from a serialized object.
  123616. * @param source - Serialized object.
  123617. * @param scene Defines the scene we are parsing for
  123618. * @param rootUrl Defines the rootUrl to load from
  123619. */
  123620. parse(source: any, scene: Scene, rootUrl: string): void;
  123621. }
  123622. }
  123623. declare module BABYLON {
  123624. /**
  123625. * @hidden
  123626. */
  123627. export interface IMaterialSheenDefines {
  123628. SHEEN: boolean;
  123629. SHEEN_TEXTURE: boolean;
  123630. SHEEN_TEXTUREDIRECTUV: number;
  123631. SHEEN_LINKWITHALBEDO: boolean;
  123632. /** @hidden */
  123633. _areTexturesDirty: boolean;
  123634. }
  123635. /**
  123636. * Define the code related to the Sheen parameters of the pbr material.
  123637. */
  123638. export class PBRSheenConfiguration {
  123639. private _isEnabled;
  123640. /**
  123641. * Defines if the material uses sheen.
  123642. */
  123643. isEnabled: boolean;
  123644. private _linkSheenWithAlbedo;
  123645. /**
  123646. * Defines if the sheen is linked to the sheen color.
  123647. */
  123648. linkSheenWithAlbedo: boolean;
  123649. /**
  123650. * Defines the sheen intensity.
  123651. */
  123652. intensity: number;
  123653. /**
  123654. * Defines the sheen color.
  123655. */
  123656. color: Color3;
  123657. private _texture;
  123658. /**
  123659. * Stores the sheen tint values in a texture.
  123660. * rgb is tint
  123661. * a is a intensity
  123662. */
  123663. texture: Nullable<BaseTexture>;
  123664. /** @hidden */
  123665. private _internalMarkAllSubMeshesAsTexturesDirty;
  123666. /** @hidden */
  123667. _markAllSubMeshesAsTexturesDirty(): void;
  123668. /**
  123669. * Instantiate a new istance of clear coat configuration.
  123670. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123671. */
  123672. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123673. /**
  123674. * Specifies that the submesh is ready to be used.
  123675. * @param defines the list of "defines" to update.
  123676. * @param scene defines the scene the material belongs to.
  123677. * @returns - boolean indicating that the submesh is ready or not.
  123678. */
  123679. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  123680. /**
  123681. * Checks to see if a texture is used in the material.
  123682. * @param defines the list of "defines" to update.
  123683. * @param scene defines the scene the material belongs to.
  123684. */
  123685. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  123686. /**
  123687. * Binds the material data.
  123688. * @param uniformBuffer defines the Uniform buffer to fill in.
  123689. * @param scene defines the scene the material belongs to.
  123690. * @param isFrozen defines wether the material is frozen or not.
  123691. */
  123692. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  123693. /**
  123694. * Checks to see if a texture is used in the material.
  123695. * @param texture - Base texture to use.
  123696. * @returns - Boolean specifying if a texture is used in the material.
  123697. */
  123698. hasTexture(texture: BaseTexture): boolean;
  123699. /**
  123700. * Returns an array of the actively used textures.
  123701. * @param activeTextures Array of BaseTextures
  123702. */
  123703. getActiveTextures(activeTextures: BaseTexture[]): void;
  123704. /**
  123705. * Returns the animatable textures.
  123706. * @param animatables Array of animatable textures.
  123707. */
  123708. getAnimatables(animatables: IAnimatable[]): void;
  123709. /**
  123710. * Disposes the resources of the material.
  123711. * @param forceDisposeTextures - Forces the disposal of all textures.
  123712. */
  123713. dispose(forceDisposeTextures?: boolean): void;
  123714. /**
  123715. * Get the current class name of the texture useful for serialization or dynamic coding.
  123716. * @returns "PBRSheenConfiguration"
  123717. */
  123718. getClassName(): string;
  123719. /**
  123720. * Add fallbacks to the effect fallbacks list.
  123721. * @param defines defines the Base texture to use.
  123722. * @param fallbacks defines the current fallback list.
  123723. * @param currentRank defines the current fallback rank.
  123724. * @returns the new fallback rank.
  123725. */
  123726. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123727. /**
  123728. * Add the required uniforms to the current list.
  123729. * @param uniforms defines the current uniform list.
  123730. */
  123731. static AddUniforms(uniforms: string[]): void;
  123732. /**
  123733. * Add the required uniforms to the current buffer.
  123734. * @param uniformBuffer defines the current uniform buffer.
  123735. */
  123736. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123737. /**
  123738. * Add the required samplers to the current list.
  123739. * @param samplers defines the current sampler list.
  123740. */
  123741. static AddSamplers(samplers: string[]): void;
  123742. /**
  123743. * Makes a duplicate of the current configuration into another one.
  123744. * @param sheenConfiguration define the config where to copy the info
  123745. */
  123746. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  123747. /**
  123748. * Serializes this BRDF configuration.
  123749. * @returns - An object with the serialized config.
  123750. */
  123751. serialize(): any;
  123752. /**
  123753. * Parses a anisotropy Configuration from a serialized object.
  123754. * @param source - Serialized object.
  123755. * @param scene Defines the scene we are parsing for
  123756. * @param rootUrl Defines the rootUrl to load from
  123757. */
  123758. parse(source: any, scene: Scene, rootUrl: string): void;
  123759. }
  123760. }
  123761. declare module BABYLON {
  123762. /**
  123763. * @hidden
  123764. */
  123765. export interface IMaterialSubSurfaceDefines {
  123766. SUBSURFACE: boolean;
  123767. SS_REFRACTION: boolean;
  123768. SS_TRANSLUCENCY: boolean;
  123769. SS_SCATERRING: boolean;
  123770. SS_THICKNESSANDMASK_TEXTURE: boolean;
  123771. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  123772. SS_REFRACTIONMAP_3D: boolean;
  123773. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  123774. SS_LODINREFRACTIONALPHA: boolean;
  123775. SS_GAMMAREFRACTION: boolean;
  123776. SS_RGBDREFRACTION: boolean;
  123777. SS_LINEARSPECULARREFRACTION: boolean;
  123778. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  123779. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  123780. /** @hidden */
  123781. _areTexturesDirty: boolean;
  123782. }
  123783. /**
  123784. * Define the code related to the sub surface parameters of the pbr material.
  123785. */
  123786. export class PBRSubSurfaceConfiguration {
  123787. private _isRefractionEnabled;
  123788. /**
  123789. * Defines if the refraction is enabled in the material.
  123790. */
  123791. isRefractionEnabled: boolean;
  123792. private _isTranslucencyEnabled;
  123793. /**
  123794. * Defines if the translucency is enabled in the material.
  123795. */
  123796. isTranslucencyEnabled: boolean;
  123797. private _isScatteringEnabled;
  123798. /**
  123799. * Defines the refraction intensity of the material.
  123800. * The refraction when enabled replaces the Diffuse part of the material.
  123801. * The intensity helps transitionning between diffuse and refraction.
  123802. */
  123803. refractionIntensity: number;
  123804. /**
  123805. * Defines the translucency intensity of the material.
  123806. * When translucency has been enabled, this defines how much of the "translucency"
  123807. * is addded to the diffuse part of the material.
  123808. */
  123809. translucencyIntensity: number;
  123810. /**
  123811. * Defines the scattering intensity of the material.
  123812. * When scattering has been enabled, this defines how much of the "scattered light"
  123813. * is addded to the diffuse part of the material.
  123814. */
  123815. scatteringIntensity: number;
  123816. private _thicknessTexture;
  123817. /**
  123818. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  123819. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  123820. * 0 would mean minimumThickness
  123821. * 1 would mean maximumThickness
  123822. * The other channels might be use as a mask to vary the different effects intensity.
  123823. */
  123824. thicknessTexture: Nullable<BaseTexture>;
  123825. private _refractionTexture;
  123826. /**
  123827. * Defines the texture to use for refraction.
  123828. */
  123829. refractionTexture: Nullable<BaseTexture>;
  123830. private _indexOfRefraction;
  123831. /**
  123832. * Defines the index of refraction used in the material.
  123833. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  123834. */
  123835. indexOfRefraction: number;
  123836. private _invertRefractionY;
  123837. /**
  123838. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  123839. */
  123840. invertRefractionY: boolean;
  123841. private _linkRefractionWithTransparency;
  123842. /**
  123843. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  123844. * Materials half opaque for instance using refraction could benefit from this control.
  123845. */
  123846. linkRefractionWithTransparency: boolean;
  123847. /**
  123848. * Defines the minimum thickness stored in the thickness map.
  123849. * If no thickness map is defined, this value will be used to simulate thickness.
  123850. */
  123851. minimumThickness: number;
  123852. /**
  123853. * Defines the maximum thickness stored in the thickness map.
  123854. */
  123855. maximumThickness: number;
  123856. /**
  123857. * Defines the volume tint of the material.
  123858. * This is used for both translucency and scattering.
  123859. */
  123860. tintColor: Color3;
  123861. /**
  123862. * Defines the distance at which the tint color should be found in the media.
  123863. * This is used for refraction only.
  123864. */
  123865. tintColorAtDistance: number;
  123866. /**
  123867. * Defines how far each channel transmit through the media.
  123868. * It is defined as a color to simplify it selection.
  123869. */
  123870. diffusionDistance: Color3;
  123871. private _useMaskFromThicknessTexture;
  123872. /**
  123873. * Stores the intensity of the different subsurface effects in the thickness texture.
  123874. * * the green channel is the translucency intensity.
  123875. * * the blue channel is the scattering intensity.
  123876. * * the alpha channel is the refraction intensity.
  123877. */
  123878. useMaskFromThicknessTexture: boolean;
  123879. /** @hidden */
  123880. private _internalMarkAllSubMeshesAsTexturesDirty;
  123881. /** @hidden */
  123882. _markAllSubMeshesAsTexturesDirty(): void;
  123883. /**
  123884. * Instantiate a new istance of sub surface configuration.
  123885. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  123886. */
  123887. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  123888. /**
  123889. * Gets wehter the submesh is ready to be used or not.
  123890. * @param defines the list of "defines" to update.
  123891. * @param scene defines the scene the material belongs to.
  123892. * @returns - boolean indicating that the submesh is ready or not.
  123893. */
  123894. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  123895. /**
  123896. * Checks to see if a texture is used in the material.
  123897. * @param defines the list of "defines" to update.
  123898. * @param scene defines the scene to the material belongs to.
  123899. */
  123900. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  123901. /**
  123902. * Binds the material data.
  123903. * @param uniformBuffer defines the Uniform buffer to fill in.
  123904. * @param scene defines the scene the material belongs to.
  123905. * @param engine defines the engine the material belongs to.
  123906. * @param isFrozen defines wether the material is frozen or not.
  123907. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  123908. */
  123909. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  123910. /**
  123911. * Unbinds the material from the mesh.
  123912. * @param activeEffect defines the effect that should be unbound from.
  123913. * @returns true if unbound, otherwise false
  123914. */
  123915. unbind(activeEffect: Effect): boolean;
  123916. /**
  123917. * Returns the texture used for refraction or null if none is used.
  123918. * @param scene defines the scene the material belongs to.
  123919. * @returns - Refraction texture if present. If no refraction texture and refraction
  123920. * is linked with transparency, returns environment texture. Otherwise, returns null.
  123921. */
  123922. private _getRefractionTexture;
  123923. /**
  123924. * Returns true if alpha blending should be disabled.
  123925. */
  123926. get disableAlphaBlending(): boolean;
  123927. /**
  123928. * Fills the list of render target textures.
  123929. * @param renderTargets the list of render targets to update
  123930. */
  123931. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  123932. /**
  123933. * Checks to see if a texture is used in the material.
  123934. * @param texture - Base texture to use.
  123935. * @returns - Boolean specifying if a texture is used in the material.
  123936. */
  123937. hasTexture(texture: BaseTexture): boolean;
  123938. /**
  123939. * Gets a boolean indicating that current material needs to register RTT
  123940. * @returns true if this uses a render target otherwise false.
  123941. */
  123942. hasRenderTargetTextures(): boolean;
  123943. /**
  123944. * Returns an array of the actively used textures.
  123945. * @param activeTextures Array of BaseTextures
  123946. */
  123947. getActiveTextures(activeTextures: BaseTexture[]): void;
  123948. /**
  123949. * Returns the animatable textures.
  123950. * @param animatables Array of animatable textures.
  123951. */
  123952. getAnimatables(animatables: IAnimatable[]): void;
  123953. /**
  123954. * Disposes the resources of the material.
  123955. * @param forceDisposeTextures - Forces the disposal of all textures.
  123956. */
  123957. dispose(forceDisposeTextures?: boolean): void;
  123958. /**
  123959. * Get the current class name of the texture useful for serialization or dynamic coding.
  123960. * @returns "PBRSubSurfaceConfiguration"
  123961. */
  123962. getClassName(): string;
  123963. /**
  123964. * Add fallbacks to the effect fallbacks list.
  123965. * @param defines defines the Base texture to use.
  123966. * @param fallbacks defines the current fallback list.
  123967. * @param currentRank defines the current fallback rank.
  123968. * @returns the new fallback rank.
  123969. */
  123970. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  123971. /**
  123972. * Add the required uniforms to the current list.
  123973. * @param uniforms defines the current uniform list.
  123974. */
  123975. static AddUniforms(uniforms: string[]): void;
  123976. /**
  123977. * Add the required samplers to the current list.
  123978. * @param samplers defines the current sampler list.
  123979. */
  123980. static AddSamplers(samplers: string[]): void;
  123981. /**
  123982. * Add the required uniforms to the current buffer.
  123983. * @param uniformBuffer defines the current uniform buffer.
  123984. */
  123985. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  123986. /**
  123987. * Makes a duplicate of the current configuration into another one.
  123988. * @param configuration define the config where to copy the info
  123989. */
  123990. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  123991. /**
  123992. * Serializes this Sub Surface configuration.
  123993. * @returns - An object with the serialized config.
  123994. */
  123995. serialize(): any;
  123996. /**
  123997. * Parses a anisotropy Configuration from a serialized object.
  123998. * @param source - Serialized object.
  123999. * @param scene Defines the scene we are parsing for
  124000. * @param rootUrl Defines the rootUrl to load from
  124001. */
  124002. parse(source: any, scene: Scene, rootUrl: string): void;
  124003. }
  124004. }
  124005. declare module BABYLON {
  124006. /** @hidden */
  124007. export var pbrFragmentDeclaration: {
  124008. name: string;
  124009. shader: string;
  124010. };
  124011. }
  124012. declare module BABYLON {
  124013. /** @hidden */
  124014. export var pbrUboDeclaration: {
  124015. name: string;
  124016. shader: string;
  124017. };
  124018. }
  124019. declare module BABYLON {
  124020. /** @hidden */
  124021. export var pbrFragmentExtraDeclaration: {
  124022. name: string;
  124023. shader: string;
  124024. };
  124025. }
  124026. declare module BABYLON {
  124027. /** @hidden */
  124028. export var pbrFragmentSamplersDeclaration: {
  124029. name: string;
  124030. shader: string;
  124031. };
  124032. }
  124033. declare module BABYLON {
  124034. /** @hidden */
  124035. export var pbrHelperFunctions: {
  124036. name: string;
  124037. shader: string;
  124038. };
  124039. }
  124040. declare module BABYLON {
  124041. /** @hidden */
  124042. export var harmonicsFunctions: {
  124043. name: string;
  124044. shader: string;
  124045. };
  124046. }
  124047. declare module BABYLON {
  124048. /** @hidden */
  124049. export var pbrDirectLightingSetupFunctions: {
  124050. name: string;
  124051. shader: string;
  124052. };
  124053. }
  124054. declare module BABYLON {
  124055. /** @hidden */
  124056. export var pbrDirectLightingFalloffFunctions: {
  124057. name: string;
  124058. shader: string;
  124059. };
  124060. }
  124061. declare module BABYLON {
  124062. /** @hidden */
  124063. export var pbrBRDFFunctions: {
  124064. name: string;
  124065. shader: string;
  124066. };
  124067. }
  124068. declare module BABYLON {
  124069. /** @hidden */
  124070. export var pbrDirectLightingFunctions: {
  124071. name: string;
  124072. shader: string;
  124073. };
  124074. }
  124075. declare module BABYLON {
  124076. /** @hidden */
  124077. export var pbrIBLFunctions: {
  124078. name: string;
  124079. shader: string;
  124080. };
  124081. }
  124082. declare module BABYLON {
  124083. /** @hidden */
  124084. export var pbrDebug: {
  124085. name: string;
  124086. shader: string;
  124087. };
  124088. }
  124089. declare module BABYLON {
  124090. /** @hidden */
  124091. export var pbrPixelShader: {
  124092. name: string;
  124093. shader: string;
  124094. };
  124095. }
  124096. declare module BABYLON {
  124097. /** @hidden */
  124098. export var pbrVertexDeclaration: {
  124099. name: string;
  124100. shader: string;
  124101. };
  124102. }
  124103. declare module BABYLON {
  124104. /** @hidden */
  124105. export var pbrVertexShader: {
  124106. name: string;
  124107. shader: string;
  124108. };
  124109. }
  124110. declare module BABYLON {
  124111. /**
  124112. * Manages the defines for the PBR Material.
  124113. * @hidden
  124114. */
  124115. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  124116. PBR: boolean;
  124117. MAINUV1: boolean;
  124118. MAINUV2: boolean;
  124119. UV1: boolean;
  124120. UV2: boolean;
  124121. ALBEDO: boolean;
  124122. ALBEDODIRECTUV: number;
  124123. VERTEXCOLOR: boolean;
  124124. AMBIENT: boolean;
  124125. AMBIENTDIRECTUV: number;
  124126. AMBIENTINGRAYSCALE: boolean;
  124127. OPACITY: boolean;
  124128. VERTEXALPHA: boolean;
  124129. OPACITYDIRECTUV: number;
  124130. OPACITYRGB: boolean;
  124131. ALPHATEST: boolean;
  124132. DEPTHPREPASS: boolean;
  124133. ALPHABLEND: boolean;
  124134. ALPHAFROMALBEDO: boolean;
  124135. ALPHATESTVALUE: string;
  124136. SPECULAROVERALPHA: boolean;
  124137. RADIANCEOVERALPHA: boolean;
  124138. ALPHAFRESNEL: boolean;
  124139. LINEARALPHAFRESNEL: boolean;
  124140. PREMULTIPLYALPHA: boolean;
  124141. EMISSIVE: boolean;
  124142. EMISSIVEDIRECTUV: number;
  124143. REFLECTIVITY: boolean;
  124144. REFLECTIVITYDIRECTUV: number;
  124145. SPECULARTERM: boolean;
  124146. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  124147. MICROSURFACEAUTOMATIC: boolean;
  124148. LODBASEDMICROSFURACE: boolean;
  124149. MICROSURFACEMAP: boolean;
  124150. MICROSURFACEMAPDIRECTUV: number;
  124151. METALLICWORKFLOW: boolean;
  124152. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  124153. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  124154. METALLNESSSTOREINMETALMAPBLUE: boolean;
  124155. AOSTOREINMETALMAPRED: boolean;
  124156. METALLICF0FACTORFROMMETALLICMAP: boolean;
  124157. ENVIRONMENTBRDF: boolean;
  124158. ENVIRONMENTBRDF_RGBD: boolean;
  124159. NORMAL: boolean;
  124160. TANGENT: boolean;
  124161. BUMP: boolean;
  124162. BUMPDIRECTUV: number;
  124163. OBJECTSPACE_NORMALMAP: boolean;
  124164. PARALLAX: boolean;
  124165. PARALLAXOCCLUSION: boolean;
  124166. NORMALXYSCALE: boolean;
  124167. LIGHTMAP: boolean;
  124168. LIGHTMAPDIRECTUV: number;
  124169. USELIGHTMAPASSHADOWMAP: boolean;
  124170. GAMMALIGHTMAP: boolean;
  124171. RGBDLIGHTMAP: boolean;
  124172. REFLECTION: boolean;
  124173. REFLECTIONMAP_3D: boolean;
  124174. REFLECTIONMAP_SPHERICAL: boolean;
  124175. REFLECTIONMAP_PLANAR: boolean;
  124176. REFLECTIONMAP_CUBIC: boolean;
  124177. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  124178. REFLECTIONMAP_PROJECTION: boolean;
  124179. REFLECTIONMAP_SKYBOX: boolean;
  124180. REFLECTIONMAP_EXPLICIT: boolean;
  124181. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  124182. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  124183. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  124184. INVERTCUBICMAP: boolean;
  124185. USESPHERICALFROMREFLECTIONMAP: boolean;
  124186. USEIRRADIANCEMAP: boolean;
  124187. SPHERICAL_HARMONICS: boolean;
  124188. USESPHERICALINVERTEX: boolean;
  124189. REFLECTIONMAP_OPPOSITEZ: boolean;
  124190. LODINREFLECTIONALPHA: boolean;
  124191. GAMMAREFLECTION: boolean;
  124192. RGBDREFLECTION: boolean;
  124193. LINEARSPECULARREFLECTION: boolean;
  124194. RADIANCEOCCLUSION: boolean;
  124195. HORIZONOCCLUSION: boolean;
  124196. INSTANCES: boolean;
  124197. NUM_BONE_INFLUENCERS: number;
  124198. BonesPerMesh: number;
  124199. BONETEXTURE: boolean;
  124200. NONUNIFORMSCALING: boolean;
  124201. MORPHTARGETS: boolean;
  124202. MORPHTARGETS_NORMAL: boolean;
  124203. MORPHTARGETS_TANGENT: boolean;
  124204. MORPHTARGETS_UV: boolean;
  124205. NUM_MORPH_INFLUENCERS: number;
  124206. IMAGEPROCESSING: boolean;
  124207. VIGNETTE: boolean;
  124208. VIGNETTEBLENDMODEMULTIPLY: boolean;
  124209. VIGNETTEBLENDMODEOPAQUE: boolean;
  124210. TONEMAPPING: boolean;
  124211. TONEMAPPING_ACES: boolean;
  124212. CONTRAST: boolean;
  124213. COLORCURVES: boolean;
  124214. COLORGRADING: boolean;
  124215. COLORGRADING3D: boolean;
  124216. SAMPLER3DGREENDEPTH: boolean;
  124217. SAMPLER3DBGRMAP: boolean;
  124218. IMAGEPROCESSINGPOSTPROCESS: boolean;
  124219. EXPOSURE: boolean;
  124220. MULTIVIEW: boolean;
  124221. USEPHYSICALLIGHTFALLOFF: boolean;
  124222. USEGLTFLIGHTFALLOFF: boolean;
  124223. TWOSIDEDLIGHTING: boolean;
  124224. SHADOWFLOAT: boolean;
  124225. CLIPPLANE: boolean;
  124226. CLIPPLANE2: boolean;
  124227. CLIPPLANE3: boolean;
  124228. CLIPPLANE4: boolean;
  124229. CLIPPLANE5: boolean;
  124230. CLIPPLANE6: boolean;
  124231. POINTSIZE: boolean;
  124232. FOG: boolean;
  124233. LOGARITHMICDEPTH: boolean;
  124234. FORCENORMALFORWARD: boolean;
  124235. SPECULARAA: boolean;
  124236. CLEARCOAT: boolean;
  124237. CLEARCOAT_DEFAULTIOR: boolean;
  124238. CLEARCOAT_TEXTURE: boolean;
  124239. CLEARCOAT_TEXTUREDIRECTUV: number;
  124240. CLEARCOAT_BUMP: boolean;
  124241. CLEARCOAT_BUMPDIRECTUV: number;
  124242. CLEARCOAT_TINT: boolean;
  124243. CLEARCOAT_TINT_TEXTURE: boolean;
  124244. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124245. ANISOTROPIC: boolean;
  124246. ANISOTROPIC_TEXTURE: boolean;
  124247. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124248. BRDF_V_HEIGHT_CORRELATED: boolean;
  124249. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124250. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124251. SHEEN: boolean;
  124252. SHEEN_TEXTURE: boolean;
  124253. SHEEN_TEXTUREDIRECTUV: number;
  124254. SHEEN_LINKWITHALBEDO: boolean;
  124255. SUBSURFACE: boolean;
  124256. SS_REFRACTION: boolean;
  124257. SS_TRANSLUCENCY: boolean;
  124258. SS_SCATERRING: boolean;
  124259. SS_THICKNESSANDMASK_TEXTURE: boolean;
  124260. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  124261. SS_REFRACTIONMAP_3D: boolean;
  124262. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  124263. SS_LODINREFRACTIONALPHA: boolean;
  124264. SS_GAMMAREFRACTION: boolean;
  124265. SS_RGBDREFRACTION: boolean;
  124266. SS_LINEARSPECULARREFRACTION: boolean;
  124267. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  124268. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  124269. UNLIT: boolean;
  124270. DEBUGMODE: number;
  124271. /**
  124272. * Initializes the PBR Material defines.
  124273. */
  124274. constructor();
  124275. /**
  124276. * Resets the PBR Material defines.
  124277. */
  124278. reset(): void;
  124279. }
  124280. /**
  124281. * The Physically based material base class of BJS.
  124282. *
  124283. * This offers the main features of a standard PBR material.
  124284. * For more information, please refer to the documentation :
  124285. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124286. */
  124287. export abstract class PBRBaseMaterial extends PushMaterial {
  124288. /**
  124289. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124290. */
  124291. static readonly PBRMATERIAL_OPAQUE: number;
  124292. /**
  124293. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124294. */
  124295. static readonly PBRMATERIAL_ALPHATEST: number;
  124296. /**
  124297. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124298. */
  124299. static readonly PBRMATERIAL_ALPHABLEND: number;
  124300. /**
  124301. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124302. * They are also discarded below the alpha cutoff threshold to improve performances.
  124303. */
  124304. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124305. /**
  124306. * Defines the default value of how much AO map is occluding the analytical lights
  124307. * (point spot...).
  124308. */
  124309. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124310. /**
  124311. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  124312. */
  124313. static readonly LIGHTFALLOFF_PHYSICAL: number;
  124314. /**
  124315. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  124316. * to enhance interoperability with other engines.
  124317. */
  124318. static readonly LIGHTFALLOFF_GLTF: number;
  124319. /**
  124320. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  124321. * to enhance interoperability with other materials.
  124322. */
  124323. static readonly LIGHTFALLOFF_STANDARD: number;
  124324. /**
  124325. * Intensity of the direct lights e.g. the four lights available in your scene.
  124326. * This impacts both the direct diffuse and specular highlights.
  124327. */
  124328. protected _directIntensity: number;
  124329. /**
  124330. * Intensity of the emissive part of the material.
  124331. * This helps controlling the emissive effect without modifying the emissive color.
  124332. */
  124333. protected _emissiveIntensity: number;
  124334. /**
  124335. * Intensity of the environment e.g. how much the environment will light the object
  124336. * either through harmonics for rough material or through the refelction for shiny ones.
  124337. */
  124338. protected _environmentIntensity: number;
  124339. /**
  124340. * This is a special control allowing the reduction of the specular highlights coming from the
  124341. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124342. */
  124343. protected _specularIntensity: number;
  124344. /**
  124345. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  124346. */
  124347. private _lightingInfos;
  124348. /**
  124349. * Debug Control allowing disabling the bump map on this material.
  124350. */
  124351. protected _disableBumpMap: boolean;
  124352. /**
  124353. * AKA Diffuse Texture in standard nomenclature.
  124354. */
  124355. protected _albedoTexture: Nullable<BaseTexture>;
  124356. /**
  124357. * AKA Occlusion Texture in other nomenclature.
  124358. */
  124359. protected _ambientTexture: Nullable<BaseTexture>;
  124360. /**
  124361. * AKA Occlusion Texture Intensity in other nomenclature.
  124362. */
  124363. protected _ambientTextureStrength: number;
  124364. /**
  124365. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124366. * 1 means it completely occludes it
  124367. * 0 mean it has no impact
  124368. */
  124369. protected _ambientTextureImpactOnAnalyticalLights: number;
  124370. /**
  124371. * Stores the alpha values in a texture.
  124372. */
  124373. protected _opacityTexture: Nullable<BaseTexture>;
  124374. /**
  124375. * Stores the reflection values in a texture.
  124376. */
  124377. protected _reflectionTexture: Nullable<BaseTexture>;
  124378. /**
  124379. * Stores the emissive values in a texture.
  124380. */
  124381. protected _emissiveTexture: Nullable<BaseTexture>;
  124382. /**
  124383. * AKA Specular texture in other nomenclature.
  124384. */
  124385. protected _reflectivityTexture: Nullable<BaseTexture>;
  124386. /**
  124387. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124388. */
  124389. protected _metallicTexture: Nullable<BaseTexture>;
  124390. /**
  124391. * Specifies the metallic scalar of the metallic/roughness workflow.
  124392. * Can also be used to scale the metalness values of the metallic texture.
  124393. */
  124394. protected _metallic: Nullable<number>;
  124395. /**
  124396. * Specifies the roughness scalar of the metallic/roughness workflow.
  124397. * Can also be used to scale the roughness values of the metallic texture.
  124398. */
  124399. protected _roughness: Nullable<number>;
  124400. /**
  124401. * Specifies the an F0 factor to help configuring the material F0.
  124402. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124403. * to 0.5 the previously hard coded value stays the same.
  124404. * Can also be used to scale the F0 values of the metallic texture.
  124405. */
  124406. protected _metallicF0Factor: number;
  124407. /**
  124408. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124409. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124410. * your expectation as it multiplies with the texture data.
  124411. */
  124412. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  124413. /**
  124414. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124415. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124416. */
  124417. protected _microSurfaceTexture: Nullable<BaseTexture>;
  124418. /**
  124419. * Stores surface normal data used to displace a mesh in a texture.
  124420. */
  124421. protected _bumpTexture: Nullable<BaseTexture>;
  124422. /**
  124423. * Stores the pre-calculated light information of a mesh in a texture.
  124424. */
  124425. protected _lightmapTexture: Nullable<BaseTexture>;
  124426. /**
  124427. * The color of a material in ambient lighting.
  124428. */
  124429. protected _ambientColor: Color3;
  124430. /**
  124431. * AKA Diffuse Color in other nomenclature.
  124432. */
  124433. protected _albedoColor: Color3;
  124434. /**
  124435. * AKA Specular Color in other nomenclature.
  124436. */
  124437. protected _reflectivityColor: Color3;
  124438. /**
  124439. * The color applied when light is reflected from a material.
  124440. */
  124441. protected _reflectionColor: Color3;
  124442. /**
  124443. * The color applied when light is emitted from a material.
  124444. */
  124445. protected _emissiveColor: Color3;
  124446. /**
  124447. * AKA Glossiness in other nomenclature.
  124448. */
  124449. protected _microSurface: number;
  124450. /**
  124451. * Specifies that the material will use the light map as a show map.
  124452. */
  124453. protected _useLightmapAsShadowmap: boolean;
  124454. /**
  124455. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  124456. * makes the reflect vector face the model (under horizon).
  124457. */
  124458. protected _useHorizonOcclusion: boolean;
  124459. /**
  124460. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  124461. * too much the area relying on ambient texture to define their ambient occlusion.
  124462. */
  124463. protected _useRadianceOcclusion: boolean;
  124464. /**
  124465. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124466. */
  124467. protected _useAlphaFromAlbedoTexture: boolean;
  124468. /**
  124469. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  124470. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124471. */
  124472. protected _useSpecularOverAlpha: boolean;
  124473. /**
  124474. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124475. */
  124476. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124477. /**
  124478. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124479. */
  124480. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  124481. /**
  124482. * Specifies if the metallic texture contains the roughness information in its green channel.
  124483. */
  124484. protected _useRoughnessFromMetallicTextureGreen: boolean;
  124485. /**
  124486. * Specifies if the metallic texture contains the metallness information in its blue channel.
  124487. */
  124488. protected _useMetallnessFromMetallicTextureBlue: boolean;
  124489. /**
  124490. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  124491. */
  124492. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  124493. /**
  124494. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  124495. */
  124496. protected _useAmbientInGrayScale: boolean;
  124497. /**
  124498. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  124499. * The material will try to infer what glossiness each pixel should be.
  124500. */
  124501. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  124502. /**
  124503. * Defines the falloff type used in this material.
  124504. * It by default is Physical.
  124505. */
  124506. protected _lightFalloff: number;
  124507. /**
  124508. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  124509. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  124510. */
  124511. protected _useRadianceOverAlpha: boolean;
  124512. /**
  124513. * Allows using an object space normal map (instead of tangent space).
  124514. */
  124515. protected _useObjectSpaceNormalMap: boolean;
  124516. /**
  124517. * Allows using the bump map in parallax mode.
  124518. */
  124519. protected _useParallax: boolean;
  124520. /**
  124521. * Allows using the bump map in parallax occlusion mode.
  124522. */
  124523. protected _useParallaxOcclusion: boolean;
  124524. /**
  124525. * Controls the scale bias of the parallax mode.
  124526. */
  124527. protected _parallaxScaleBias: number;
  124528. /**
  124529. * If sets to true, disables all the lights affecting the material.
  124530. */
  124531. protected _disableLighting: boolean;
  124532. /**
  124533. * Number of Simultaneous lights allowed on the material.
  124534. */
  124535. protected _maxSimultaneousLights: number;
  124536. /**
  124537. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124538. */
  124539. protected _invertNormalMapX: boolean;
  124540. /**
  124541. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124542. */
  124543. protected _invertNormalMapY: boolean;
  124544. /**
  124545. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  124546. */
  124547. protected _twoSidedLighting: boolean;
  124548. /**
  124549. * Defines the alpha limits in alpha test mode.
  124550. */
  124551. protected _alphaCutOff: number;
  124552. /**
  124553. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124554. */
  124555. protected _forceAlphaTest: boolean;
  124556. /**
  124557. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124558. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  124559. */
  124560. protected _useAlphaFresnel: boolean;
  124561. /**
  124562. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  124563. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  124564. */
  124565. protected _useLinearAlphaFresnel: boolean;
  124566. /**
  124567. * The transparency mode of the material.
  124568. */
  124569. protected _transparencyMode: Nullable<number>;
  124570. /**
  124571. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  124572. * from cos thetav and roughness:
  124573. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  124574. */
  124575. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  124576. /**
  124577. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  124578. */
  124579. protected _forceIrradianceInFragment: boolean;
  124580. /**
  124581. * Force normal to face away from face.
  124582. */
  124583. protected _forceNormalForward: boolean;
  124584. /**
  124585. * Enables specular anti aliasing in the PBR shader.
  124586. * It will both interacts on the Geometry for analytical and IBL lighting.
  124587. * It also prefilter the roughness map based on the bump values.
  124588. */
  124589. protected _enableSpecularAntiAliasing: boolean;
  124590. /**
  124591. * Default configuration related to image processing available in the PBR Material.
  124592. */
  124593. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124594. /**
  124595. * Keep track of the image processing observer to allow dispose and replace.
  124596. */
  124597. private _imageProcessingObserver;
  124598. /**
  124599. * Attaches a new image processing configuration to the PBR Material.
  124600. * @param configuration
  124601. */
  124602. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124603. /**
  124604. * Stores the available render targets.
  124605. */
  124606. private _renderTargets;
  124607. /**
  124608. * Sets the global ambient color for the material used in lighting calculations.
  124609. */
  124610. private _globalAmbientColor;
  124611. /**
  124612. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  124613. */
  124614. private _useLogarithmicDepth;
  124615. /**
  124616. * If set to true, no lighting calculations will be applied.
  124617. */
  124618. private _unlit;
  124619. private _debugMode;
  124620. /**
  124621. * @hidden
  124622. * This is reserved for the inspector.
  124623. * Defines the material debug mode.
  124624. * It helps seeing only some components of the material while troubleshooting.
  124625. */
  124626. debugMode: number;
  124627. /**
  124628. * @hidden
  124629. * This is reserved for the inspector.
  124630. * Specify from where on screen the debug mode should start.
  124631. * The value goes from -1 (full screen) to 1 (not visible)
  124632. * It helps with side by side comparison against the final render
  124633. * This defaults to -1
  124634. */
  124635. private debugLimit;
  124636. /**
  124637. * @hidden
  124638. * This is reserved for the inspector.
  124639. * As the default viewing range might not be enough (if the ambient is really small for instance)
  124640. * You can use the factor to better multiply the final value.
  124641. */
  124642. private debugFactor;
  124643. /**
  124644. * Defines the clear coat layer parameters for the material.
  124645. */
  124646. readonly clearCoat: PBRClearCoatConfiguration;
  124647. /**
  124648. * Defines the anisotropic parameters for the material.
  124649. */
  124650. readonly anisotropy: PBRAnisotropicConfiguration;
  124651. /**
  124652. * Defines the BRDF parameters for the material.
  124653. */
  124654. readonly brdf: PBRBRDFConfiguration;
  124655. /**
  124656. * Defines the Sheen parameters for the material.
  124657. */
  124658. readonly sheen: PBRSheenConfiguration;
  124659. /**
  124660. * Defines the SubSurface parameters for the material.
  124661. */
  124662. readonly subSurface: PBRSubSurfaceConfiguration;
  124663. /**
  124664. * Custom callback helping to override the default shader used in the material.
  124665. */
  124666. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  124667. protected _rebuildInParallel: boolean;
  124668. /**
  124669. * Instantiates a new PBRMaterial instance.
  124670. *
  124671. * @param name The material name
  124672. * @param scene The scene the material will be use in.
  124673. */
  124674. constructor(name: string, scene: Scene);
  124675. /**
  124676. * Gets a boolean indicating that current material needs to register RTT
  124677. */
  124678. get hasRenderTargetTextures(): boolean;
  124679. /**
  124680. * Gets the name of the material class.
  124681. */
  124682. getClassName(): string;
  124683. /**
  124684. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124685. */
  124686. get useLogarithmicDepth(): boolean;
  124687. /**
  124688. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  124689. */
  124690. set useLogarithmicDepth(value: boolean);
  124691. /**
  124692. * Gets the current transparency mode.
  124693. */
  124694. get transparencyMode(): Nullable<number>;
  124695. /**
  124696. * Sets the transparency mode of the material.
  124697. *
  124698. * | Value | Type | Description |
  124699. * | ----- | ----------------------------------- | ----------- |
  124700. * | 0 | OPAQUE | |
  124701. * | 1 | ALPHATEST | |
  124702. * | 2 | ALPHABLEND | |
  124703. * | 3 | ALPHATESTANDBLEND | |
  124704. *
  124705. */
  124706. set transparencyMode(value: Nullable<number>);
  124707. /**
  124708. * Returns true if alpha blending should be disabled.
  124709. */
  124710. private get _disableAlphaBlending();
  124711. /**
  124712. * Specifies whether or not this material should be rendered in alpha blend mode.
  124713. */
  124714. needAlphaBlending(): boolean;
  124715. /**
  124716. * Specifies if the mesh will require alpha blending.
  124717. * @param mesh - BJS mesh.
  124718. */
  124719. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  124720. /**
  124721. * Specifies whether or not this material should be rendered in alpha test mode.
  124722. */
  124723. needAlphaTesting(): boolean;
  124724. /**
  124725. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  124726. */
  124727. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  124728. /**
  124729. * Gets the texture used for the alpha test.
  124730. */
  124731. getAlphaTestTexture(): Nullable<BaseTexture>;
  124732. /**
  124733. * Specifies that the submesh is ready to be used.
  124734. * @param mesh - BJS mesh.
  124735. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  124736. * @param useInstances - Specifies that instances should be used.
  124737. * @returns - boolean indicating that the submesh is ready or not.
  124738. */
  124739. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124740. /**
  124741. * Specifies if the material uses metallic roughness workflow.
  124742. * @returns boolean specifiying if the material uses metallic roughness workflow.
  124743. */
  124744. isMetallicWorkflow(): boolean;
  124745. private _prepareEffect;
  124746. private _prepareDefines;
  124747. /**
  124748. * Force shader compilation
  124749. */
  124750. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  124751. /**
  124752. * Initializes the uniform buffer layout for the shader.
  124753. */
  124754. buildUniformLayout(): void;
  124755. /**
  124756. * Unbinds the material from the mesh
  124757. */
  124758. unbind(): void;
  124759. /**
  124760. * Binds the submesh data.
  124761. * @param world - The world matrix.
  124762. * @param mesh - The BJS mesh.
  124763. * @param subMesh - A submesh of the BJS mesh.
  124764. */
  124765. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124766. /**
  124767. * Returns the animatable textures.
  124768. * @returns - Array of animatable textures.
  124769. */
  124770. getAnimatables(): IAnimatable[];
  124771. /**
  124772. * Returns the texture used for reflections.
  124773. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  124774. */
  124775. private _getReflectionTexture;
  124776. /**
  124777. * Returns an array of the actively used textures.
  124778. * @returns - Array of BaseTextures
  124779. */
  124780. getActiveTextures(): BaseTexture[];
  124781. /**
  124782. * Checks to see if a texture is used in the material.
  124783. * @param texture - Base texture to use.
  124784. * @returns - Boolean specifying if a texture is used in the material.
  124785. */
  124786. hasTexture(texture: BaseTexture): boolean;
  124787. /**
  124788. * Disposes the resources of the material.
  124789. * @param forceDisposeEffect - Forces the disposal of effects.
  124790. * @param forceDisposeTextures - Forces the disposal of all textures.
  124791. */
  124792. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124793. }
  124794. }
  124795. declare module BABYLON {
  124796. /**
  124797. * The Physically based material of BJS.
  124798. *
  124799. * This offers the main features of a standard PBR material.
  124800. * For more information, please refer to the documentation :
  124801. * https://doc.babylonjs.com/how_to/physically_based_rendering
  124802. */
  124803. export class PBRMaterial extends PBRBaseMaterial {
  124804. /**
  124805. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  124806. */
  124807. static readonly PBRMATERIAL_OPAQUE: number;
  124808. /**
  124809. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  124810. */
  124811. static readonly PBRMATERIAL_ALPHATEST: number;
  124812. /**
  124813. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124814. */
  124815. static readonly PBRMATERIAL_ALPHABLEND: number;
  124816. /**
  124817. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  124818. * They are also discarded below the alpha cutoff threshold to improve performances.
  124819. */
  124820. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  124821. /**
  124822. * Defines the default value of how much AO map is occluding the analytical lights
  124823. * (point spot...).
  124824. */
  124825. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  124826. /**
  124827. * Intensity of the direct lights e.g. the four lights available in your scene.
  124828. * This impacts both the direct diffuse and specular highlights.
  124829. */
  124830. directIntensity: number;
  124831. /**
  124832. * Intensity of the emissive part of the material.
  124833. * This helps controlling the emissive effect without modifying the emissive color.
  124834. */
  124835. emissiveIntensity: number;
  124836. /**
  124837. * Intensity of the environment e.g. how much the environment will light the object
  124838. * either through harmonics for rough material or through the refelction for shiny ones.
  124839. */
  124840. environmentIntensity: number;
  124841. /**
  124842. * This is a special control allowing the reduction of the specular highlights coming from the
  124843. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  124844. */
  124845. specularIntensity: number;
  124846. /**
  124847. * Debug Control allowing disabling the bump map on this material.
  124848. */
  124849. disableBumpMap: boolean;
  124850. /**
  124851. * AKA Diffuse Texture in standard nomenclature.
  124852. */
  124853. albedoTexture: BaseTexture;
  124854. /**
  124855. * AKA Occlusion Texture in other nomenclature.
  124856. */
  124857. ambientTexture: BaseTexture;
  124858. /**
  124859. * AKA Occlusion Texture Intensity in other nomenclature.
  124860. */
  124861. ambientTextureStrength: number;
  124862. /**
  124863. * Defines how much the AO map is occluding the analytical lights (point spot...).
  124864. * 1 means it completely occludes it
  124865. * 0 mean it has no impact
  124866. */
  124867. ambientTextureImpactOnAnalyticalLights: number;
  124868. /**
  124869. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  124870. */
  124871. opacityTexture: BaseTexture;
  124872. /**
  124873. * Stores the reflection values in a texture.
  124874. */
  124875. reflectionTexture: Nullable<BaseTexture>;
  124876. /**
  124877. * Stores the emissive values in a texture.
  124878. */
  124879. emissiveTexture: BaseTexture;
  124880. /**
  124881. * AKA Specular texture in other nomenclature.
  124882. */
  124883. reflectivityTexture: BaseTexture;
  124884. /**
  124885. * Used to switch from specular/glossiness to metallic/roughness workflow.
  124886. */
  124887. metallicTexture: BaseTexture;
  124888. /**
  124889. * Specifies the metallic scalar of the metallic/roughness workflow.
  124890. * Can also be used to scale the metalness values of the metallic texture.
  124891. */
  124892. metallic: Nullable<number>;
  124893. /**
  124894. * Specifies the roughness scalar of the metallic/roughness workflow.
  124895. * Can also be used to scale the roughness values of the metallic texture.
  124896. */
  124897. roughness: Nullable<number>;
  124898. /**
  124899. * Specifies the an F0 factor to help configuring the material F0.
  124900. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  124901. * to 0.5 the previously hard coded value stays the same.
  124902. * Can also be used to scale the F0 values of the metallic texture.
  124903. */
  124904. metallicF0Factor: number;
  124905. /**
  124906. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  124907. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  124908. * your expectation as it multiplies with the texture data.
  124909. */
  124910. useMetallicF0FactorFromMetallicTexture: boolean;
  124911. /**
  124912. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  124913. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  124914. */
  124915. microSurfaceTexture: BaseTexture;
  124916. /**
  124917. * Stores surface normal data used to displace a mesh in a texture.
  124918. */
  124919. bumpTexture: BaseTexture;
  124920. /**
  124921. * Stores the pre-calculated light information of a mesh in a texture.
  124922. */
  124923. lightmapTexture: BaseTexture;
  124924. /**
  124925. * Stores the refracted light information in a texture.
  124926. */
  124927. get refractionTexture(): Nullable<BaseTexture>;
  124928. set refractionTexture(value: Nullable<BaseTexture>);
  124929. /**
  124930. * The color of a material in ambient lighting.
  124931. */
  124932. ambientColor: Color3;
  124933. /**
  124934. * AKA Diffuse Color in other nomenclature.
  124935. */
  124936. albedoColor: Color3;
  124937. /**
  124938. * AKA Specular Color in other nomenclature.
  124939. */
  124940. reflectivityColor: Color3;
  124941. /**
  124942. * The color reflected from the material.
  124943. */
  124944. reflectionColor: Color3;
  124945. /**
  124946. * The color emitted from the material.
  124947. */
  124948. emissiveColor: Color3;
  124949. /**
  124950. * AKA Glossiness in other nomenclature.
  124951. */
  124952. microSurface: number;
  124953. /**
  124954. * source material index of refraction (IOR)' / 'destination material IOR.
  124955. */
  124956. get indexOfRefraction(): number;
  124957. set indexOfRefraction(value: number);
  124958. /**
  124959. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  124960. */
  124961. get invertRefractionY(): boolean;
  124962. set invertRefractionY(value: boolean);
  124963. /**
  124964. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  124965. * Materials half opaque for instance using refraction could benefit from this control.
  124966. */
  124967. get linkRefractionWithTransparency(): boolean;
  124968. set linkRefractionWithTransparency(value: boolean);
  124969. /**
  124970. * If true, the light map contains occlusion information instead of lighting info.
  124971. */
  124972. useLightmapAsShadowmap: boolean;
  124973. /**
  124974. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  124975. */
  124976. useAlphaFromAlbedoTexture: boolean;
  124977. /**
  124978. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  124979. */
  124980. forceAlphaTest: boolean;
  124981. /**
  124982. * Defines the alpha limits in alpha test mode.
  124983. */
  124984. alphaCutOff: number;
  124985. /**
  124986. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  124987. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  124988. */
  124989. useSpecularOverAlpha: boolean;
  124990. /**
  124991. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  124992. */
  124993. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  124994. /**
  124995. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  124996. */
  124997. useRoughnessFromMetallicTextureAlpha: boolean;
  124998. /**
  124999. * Specifies if the metallic texture contains the roughness information in its green channel.
  125000. */
  125001. useRoughnessFromMetallicTextureGreen: boolean;
  125002. /**
  125003. * Specifies if the metallic texture contains the metallness information in its blue channel.
  125004. */
  125005. useMetallnessFromMetallicTextureBlue: boolean;
  125006. /**
  125007. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  125008. */
  125009. useAmbientOcclusionFromMetallicTextureRed: boolean;
  125010. /**
  125011. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  125012. */
  125013. useAmbientInGrayScale: boolean;
  125014. /**
  125015. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  125016. * The material will try to infer what glossiness each pixel should be.
  125017. */
  125018. useAutoMicroSurfaceFromReflectivityMap: boolean;
  125019. /**
  125020. * BJS is using an harcoded light falloff based on a manually sets up range.
  125021. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  125022. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  125023. */
  125024. get usePhysicalLightFalloff(): boolean;
  125025. /**
  125026. * BJS is using an harcoded light falloff based on a manually sets up range.
  125027. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  125028. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  125029. */
  125030. set usePhysicalLightFalloff(value: boolean);
  125031. /**
  125032. * In order to support the falloff compatibility with gltf, a special mode has been added
  125033. * to reproduce the gltf light falloff.
  125034. */
  125035. get useGLTFLightFalloff(): boolean;
  125036. /**
  125037. * In order to support the falloff compatibility with gltf, a special mode has been added
  125038. * to reproduce the gltf light falloff.
  125039. */
  125040. set useGLTFLightFalloff(value: boolean);
  125041. /**
  125042. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  125043. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  125044. */
  125045. useRadianceOverAlpha: boolean;
  125046. /**
  125047. * Allows using an object space normal map (instead of tangent space).
  125048. */
  125049. useObjectSpaceNormalMap: boolean;
  125050. /**
  125051. * Allows using the bump map in parallax mode.
  125052. */
  125053. useParallax: boolean;
  125054. /**
  125055. * Allows using the bump map in parallax occlusion mode.
  125056. */
  125057. useParallaxOcclusion: boolean;
  125058. /**
  125059. * Controls the scale bias of the parallax mode.
  125060. */
  125061. parallaxScaleBias: number;
  125062. /**
  125063. * If sets to true, disables all the lights affecting the material.
  125064. */
  125065. disableLighting: boolean;
  125066. /**
  125067. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  125068. */
  125069. forceIrradianceInFragment: boolean;
  125070. /**
  125071. * Number of Simultaneous lights allowed on the material.
  125072. */
  125073. maxSimultaneousLights: number;
  125074. /**
  125075. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  125076. */
  125077. invertNormalMapX: boolean;
  125078. /**
  125079. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  125080. */
  125081. invertNormalMapY: boolean;
  125082. /**
  125083. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  125084. */
  125085. twoSidedLighting: boolean;
  125086. /**
  125087. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125088. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  125089. */
  125090. useAlphaFresnel: boolean;
  125091. /**
  125092. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  125093. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  125094. */
  125095. useLinearAlphaFresnel: boolean;
  125096. /**
  125097. * Let user defines the brdf lookup texture used for IBL.
  125098. * A default 8bit version is embedded but you could point at :
  125099. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  125100. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  125101. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  125102. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  125103. */
  125104. environmentBRDFTexture: Nullable<BaseTexture>;
  125105. /**
  125106. * Force normal to face away from face.
  125107. */
  125108. forceNormalForward: boolean;
  125109. /**
  125110. * Enables specular anti aliasing in the PBR shader.
  125111. * It will both interacts on the Geometry for analytical and IBL lighting.
  125112. * It also prefilter the roughness map based on the bump values.
  125113. */
  125114. enableSpecularAntiAliasing: boolean;
  125115. /**
  125116. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  125117. * makes the reflect vector face the model (under horizon).
  125118. */
  125119. useHorizonOcclusion: boolean;
  125120. /**
  125121. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  125122. * too much the area relying on ambient texture to define their ambient occlusion.
  125123. */
  125124. useRadianceOcclusion: boolean;
  125125. /**
  125126. * If set to true, no lighting calculations will be applied.
  125127. */
  125128. unlit: boolean;
  125129. /**
  125130. * Gets the image processing configuration used either in this material.
  125131. */
  125132. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  125133. /**
  125134. * Sets the Default image processing configuration used either in the this material.
  125135. *
  125136. * If sets to null, the scene one is in use.
  125137. */
  125138. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  125139. /**
  125140. * Gets wether the color curves effect is enabled.
  125141. */
  125142. get cameraColorCurvesEnabled(): boolean;
  125143. /**
  125144. * Sets wether the color curves effect is enabled.
  125145. */
  125146. set cameraColorCurvesEnabled(value: boolean);
  125147. /**
  125148. * Gets wether the color grading effect is enabled.
  125149. */
  125150. get cameraColorGradingEnabled(): boolean;
  125151. /**
  125152. * Gets wether the color grading effect is enabled.
  125153. */
  125154. set cameraColorGradingEnabled(value: boolean);
  125155. /**
  125156. * Gets wether tonemapping is enabled or not.
  125157. */
  125158. get cameraToneMappingEnabled(): boolean;
  125159. /**
  125160. * Sets wether tonemapping is enabled or not
  125161. */
  125162. set cameraToneMappingEnabled(value: boolean);
  125163. /**
  125164. * The camera exposure used on this material.
  125165. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125166. * This corresponds to a photographic exposure.
  125167. */
  125168. get cameraExposure(): number;
  125169. /**
  125170. * The camera exposure used on this material.
  125171. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  125172. * This corresponds to a photographic exposure.
  125173. */
  125174. set cameraExposure(value: number);
  125175. /**
  125176. * Gets The camera contrast used on this material.
  125177. */
  125178. get cameraContrast(): number;
  125179. /**
  125180. * Sets The camera contrast used on this material.
  125181. */
  125182. set cameraContrast(value: number);
  125183. /**
  125184. * Gets the Color Grading 2D Lookup Texture.
  125185. */
  125186. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  125187. /**
  125188. * Sets the Color Grading 2D Lookup Texture.
  125189. */
  125190. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  125191. /**
  125192. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125193. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125194. * 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;
  125195. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125196. */
  125197. get cameraColorCurves(): Nullable<ColorCurves>;
  125198. /**
  125199. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  125200. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  125201. * 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;
  125202. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  125203. */
  125204. set cameraColorCurves(value: Nullable<ColorCurves>);
  125205. /**
  125206. * Instantiates a new PBRMaterial instance.
  125207. *
  125208. * @param name The material name
  125209. * @param scene The scene the material will be use in.
  125210. */
  125211. constructor(name: string, scene: Scene);
  125212. /**
  125213. * Returns the name of this material class.
  125214. */
  125215. getClassName(): string;
  125216. /**
  125217. * Makes a duplicate of the current material.
  125218. * @param name - name to use for the new material.
  125219. */
  125220. clone(name: string): PBRMaterial;
  125221. /**
  125222. * Serializes this PBR Material.
  125223. * @returns - An object with the serialized material.
  125224. */
  125225. serialize(): any;
  125226. /**
  125227. * Parses a PBR Material from a serialized object.
  125228. * @param source - Serialized object.
  125229. * @param scene - BJS scene instance.
  125230. * @param rootUrl - url for the scene object
  125231. * @returns - PBRMaterial
  125232. */
  125233. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  125234. }
  125235. }
  125236. declare module BABYLON {
  125237. /**
  125238. * Direct draw surface info
  125239. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  125240. */
  125241. export interface DDSInfo {
  125242. /**
  125243. * Width of the texture
  125244. */
  125245. width: number;
  125246. /**
  125247. * Width of the texture
  125248. */
  125249. height: number;
  125250. /**
  125251. * Number of Mipmaps for the texture
  125252. * @see https://en.wikipedia.org/wiki/Mipmap
  125253. */
  125254. mipmapCount: number;
  125255. /**
  125256. * If the textures format is a known fourCC format
  125257. * @see https://www.fourcc.org/
  125258. */
  125259. isFourCC: boolean;
  125260. /**
  125261. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  125262. */
  125263. isRGB: boolean;
  125264. /**
  125265. * If the texture is a lumincance format
  125266. */
  125267. isLuminance: boolean;
  125268. /**
  125269. * If this is a cube texture
  125270. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  125271. */
  125272. isCube: boolean;
  125273. /**
  125274. * If the texture is a compressed format eg. FOURCC_DXT1
  125275. */
  125276. isCompressed: boolean;
  125277. /**
  125278. * The dxgiFormat of the texture
  125279. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  125280. */
  125281. dxgiFormat: number;
  125282. /**
  125283. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  125284. */
  125285. textureType: number;
  125286. /**
  125287. * Sphericle polynomial created for the dds texture
  125288. */
  125289. sphericalPolynomial?: SphericalPolynomial;
  125290. }
  125291. /**
  125292. * Class used to provide DDS decompression tools
  125293. */
  125294. export class DDSTools {
  125295. /**
  125296. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  125297. */
  125298. static StoreLODInAlphaChannel: boolean;
  125299. /**
  125300. * Gets DDS information from an array buffer
  125301. * @param data defines the array buffer view to read data from
  125302. * @returns the DDS information
  125303. */
  125304. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  125305. private static _FloatView;
  125306. private static _Int32View;
  125307. private static _ToHalfFloat;
  125308. private static _FromHalfFloat;
  125309. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  125310. private static _GetHalfFloatRGBAArrayBuffer;
  125311. private static _GetFloatRGBAArrayBuffer;
  125312. private static _GetFloatAsUIntRGBAArrayBuffer;
  125313. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  125314. private static _GetRGBAArrayBuffer;
  125315. private static _ExtractLongWordOrder;
  125316. private static _GetRGBArrayBuffer;
  125317. private static _GetLuminanceArrayBuffer;
  125318. /**
  125319. * Uploads DDS Levels to a Babylon Texture
  125320. * @hidden
  125321. */
  125322. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  125323. }
  125324. interface ThinEngine {
  125325. /**
  125326. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  125327. * @param rootUrl defines the url where the file to load is located
  125328. * @param scene defines the current scene
  125329. * @param lodScale defines scale to apply to the mip map selection
  125330. * @param lodOffset defines offset to apply to the mip map selection
  125331. * @param onLoad defines an optional callback raised when the texture is loaded
  125332. * @param onError defines an optional callback raised if there is an issue to load the texture
  125333. * @param format defines the format of the data
  125334. * @param forcedExtension defines the extension to use to pick the right loader
  125335. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  125336. * @returns the cube texture as an InternalTexture
  125337. */
  125338. 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;
  125339. }
  125340. }
  125341. declare module BABYLON {
  125342. /**
  125343. * Implementation of the DDS Texture Loader.
  125344. * @hidden
  125345. */
  125346. export class _DDSTextureLoader implements IInternalTextureLoader {
  125347. /**
  125348. * Defines wether the loader supports cascade loading the different faces.
  125349. */
  125350. readonly supportCascades: boolean;
  125351. /**
  125352. * This returns if the loader support the current file information.
  125353. * @param extension defines the file extension of the file being loaded
  125354. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125355. * @param fallback defines the fallback internal texture if any
  125356. * @param isBase64 defines whether the texture is encoded as a base64
  125357. * @param isBuffer defines whether the texture data are stored as a buffer
  125358. * @returns true if the loader can load the specified file
  125359. */
  125360. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125361. /**
  125362. * Transform the url before loading if required.
  125363. * @param rootUrl the url of the texture
  125364. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125365. * @returns the transformed texture
  125366. */
  125367. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125368. /**
  125369. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125370. * @param rootUrl the url of the texture
  125371. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125372. * @returns the fallback texture
  125373. */
  125374. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125375. /**
  125376. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125377. * @param data contains the texture data
  125378. * @param texture defines the BabylonJS internal texture
  125379. * @param createPolynomials will be true if polynomials have been requested
  125380. * @param onLoad defines the callback to trigger once the texture is ready
  125381. * @param onError defines the callback to trigger in case of error
  125382. */
  125383. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125384. /**
  125385. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125386. * @param data contains the texture data
  125387. * @param texture defines the BabylonJS internal texture
  125388. * @param callback defines the method to call once ready to upload
  125389. */
  125390. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125391. }
  125392. }
  125393. declare module BABYLON {
  125394. /**
  125395. * Implementation of the ENV Texture Loader.
  125396. * @hidden
  125397. */
  125398. export class _ENVTextureLoader implements IInternalTextureLoader {
  125399. /**
  125400. * Defines wether the loader supports cascade loading the different faces.
  125401. */
  125402. readonly supportCascades: boolean;
  125403. /**
  125404. * This returns if the loader support the current file information.
  125405. * @param extension defines the file extension of the file being loaded
  125406. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125407. * @param fallback defines the fallback internal texture if any
  125408. * @param isBase64 defines whether the texture is encoded as a base64
  125409. * @param isBuffer defines whether the texture data are stored as a buffer
  125410. * @returns true if the loader can load the specified file
  125411. */
  125412. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125413. /**
  125414. * Transform the url before loading if required.
  125415. * @param rootUrl the url of the texture
  125416. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125417. * @returns the transformed texture
  125418. */
  125419. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125420. /**
  125421. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125422. * @param rootUrl the url of the texture
  125423. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125424. * @returns the fallback texture
  125425. */
  125426. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125427. /**
  125428. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125429. * @param data contains the texture data
  125430. * @param texture defines the BabylonJS internal texture
  125431. * @param createPolynomials will be true if polynomials have been requested
  125432. * @param onLoad defines the callback to trigger once the texture is ready
  125433. * @param onError defines the callback to trigger in case of error
  125434. */
  125435. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125436. /**
  125437. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125438. * @param data contains the texture data
  125439. * @param texture defines the BabylonJS internal texture
  125440. * @param callback defines the method to call once ready to upload
  125441. */
  125442. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  125443. }
  125444. }
  125445. declare module BABYLON {
  125446. /**
  125447. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  125448. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  125449. */
  125450. export class KhronosTextureContainer {
  125451. /** contents of the KTX container file */
  125452. data: ArrayBufferView;
  125453. private static HEADER_LEN;
  125454. private static COMPRESSED_2D;
  125455. private static COMPRESSED_3D;
  125456. private static TEX_2D;
  125457. private static TEX_3D;
  125458. /**
  125459. * Gets the openGL type
  125460. */
  125461. glType: number;
  125462. /**
  125463. * Gets the openGL type size
  125464. */
  125465. glTypeSize: number;
  125466. /**
  125467. * Gets the openGL format
  125468. */
  125469. glFormat: number;
  125470. /**
  125471. * Gets the openGL internal format
  125472. */
  125473. glInternalFormat: number;
  125474. /**
  125475. * Gets the base internal format
  125476. */
  125477. glBaseInternalFormat: number;
  125478. /**
  125479. * Gets image width in pixel
  125480. */
  125481. pixelWidth: number;
  125482. /**
  125483. * Gets image height in pixel
  125484. */
  125485. pixelHeight: number;
  125486. /**
  125487. * Gets image depth in pixels
  125488. */
  125489. pixelDepth: number;
  125490. /**
  125491. * Gets the number of array elements
  125492. */
  125493. numberOfArrayElements: number;
  125494. /**
  125495. * Gets the number of faces
  125496. */
  125497. numberOfFaces: number;
  125498. /**
  125499. * Gets the number of mipmap levels
  125500. */
  125501. numberOfMipmapLevels: number;
  125502. /**
  125503. * Gets the bytes of key value data
  125504. */
  125505. bytesOfKeyValueData: number;
  125506. /**
  125507. * Gets the load type
  125508. */
  125509. loadType: number;
  125510. /**
  125511. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  125512. */
  125513. isInvalid: boolean;
  125514. /**
  125515. * Creates a new KhronosTextureContainer
  125516. * @param data contents of the KTX container file
  125517. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  125518. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  125519. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  125520. */
  125521. constructor(
  125522. /** contents of the KTX container file */
  125523. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  125524. /**
  125525. * Uploads KTX content to a Babylon Texture.
  125526. * It is assumed that the texture has already been created & is currently bound
  125527. * @hidden
  125528. */
  125529. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  125530. private _upload2DCompressedLevels;
  125531. }
  125532. }
  125533. declare module BABYLON {
  125534. /**
  125535. * Implementation of the KTX Texture Loader.
  125536. * @hidden
  125537. */
  125538. export class _KTXTextureLoader implements IInternalTextureLoader {
  125539. /**
  125540. * Defines wether the loader supports cascade loading the different faces.
  125541. */
  125542. readonly supportCascades: boolean;
  125543. /**
  125544. * This returns if the loader support the current file information.
  125545. * @param extension defines the file extension of the file being loaded
  125546. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125547. * @param fallback defines the fallback internal texture if any
  125548. * @param isBase64 defines whether the texture is encoded as a base64
  125549. * @param isBuffer defines whether the texture data are stored as a buffer
  125550. * @returns true if the loader can load the specified file
  125551. */
  125552. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  125553. /**
  125554. * Transform the url before loading if required.
  125555. * @param rootUrl the url of the texture
  125556. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125557. * @returns the transformed texture
  125558. */
  125559. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  125560. /**
  125561. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  125562. * @param rootUrl the url of the texture
  125563. * @param textureFormatInUse defines the current compressed format in use iun the engine
  125564. * @returns the fallback texture
  125565. */
  125566. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  125567. /**
  125568. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  125569. * @param data contains the texture data
  125570. * @param texture defines the BabylonJS internal texture
  125571. * @param createPolynomials will be true if polynomials have been requested
  125572. * @param onLoad defines the callback to trigger once the texture is ready
  125573. * @param onError defines the callback to trigger in case of error
  125574. */
  125575. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  125576. /**
  125577. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  125578. * @param data contains the texture data
  125579. * @param texture defines the BabylonJS internal texture
  125580. * @param callback defines the method to call once ready to upload
  125581. */
  125582. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  125583. }
  125584. }
  125585. declare module BABYLON {
  125586. /** @hidden */
  125587. export var _forceSceneHelpersToBundle: boolean;
  125588. interface Scene {
  125589. /**
  125590. * Creates a default light for the scene.
  125591. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  125592. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  125593. */
  125594. createDefaultLight(replace?: boolean): void;
  125595. /**
  125596. * Creates a default camera for the scene.
  125597. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  125598. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125599. * @param replace has default false, when true replaces the active camera in the scene
  125600. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  125601. */
  125602. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125603. /**
  125604. * Creates a default camera and a default light.
  125605. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  125606. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  125607. * @param replace has the default false, when true replaces the active camera/light in the scene
  125608. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  125609. */
  125610. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  125611. /**
  125612. * Creates a new sky box
  125613. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  125614. * @param environmentTexture defines the texture to use as environment texture
  125615. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  125616. * @param scale defines the overall scale of the skybox
  125617. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  125618. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  125619. * @returns a new mesh holding the sky box
  125620. */
  125621. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  125622. /**
  125623. * Creates a new environment
  125624. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  125625. * @param options defines the options you can use to configure the environment
  125626. * @returns the new EnvironmentHelper
  125627. */
  125628. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  125629. /**
  125630. * Creates a new VREXperienceHelper
  125631. * @see http://doc.babylonjs.com/how_to/webvr_helper
  125632. * @param webVROptions defines the options used to create the new VREXperienceHelper
  125633. * @returns a new VREXperienceHelper
  125634. */
  125635. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  125636. /**
  125637. * Creates a new WebXRDefaultExperience
  125638. * @see http://doc.babylonjs.com/how_to/webxr
  125639. * @param options experience options
  125640. * @returns a promise for a new WebXRDefaultExperience
  125641. */
  125642. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  125643. }
  125644. }
  125645. declare module BABYLON {
  125646. /**
  125647. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  125648. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  125649. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  125650. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  125651. */
  125652. export class VideoDome extends TransformNode {
  125653. /**
  125654. * Define the video source as a Monoscopic panoramic 360 video.
  125655. */
  125656. static readonly MODE_MONOSCOPIC: number;
  125657. /**
  125658. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125659. */
  125660. static readonly MODE_TOPBOTTOM: number;
  125661. /**
  125662. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125663. */
  125664. static readonly MODE_SIDEBYSIDE: number;
  125665. private _halfDome;
  125666. private _useDirectMapping;
  125667. /**
  125668. * The video texture being displayed on the sphere
  125669. */
  125670. protected _videoTexture: VideoTexture;
  125671. /**
  125672. * Gets the video texture being displayed on the sphere
  125673. */
  125674. get videoTexture(): VideoTexture;
  125675. /**
  125676. * The skybox material
  125677. */
  125678. protected _material: BackgroundMaterial;
  125679. /**
  125680. * The surface used for the skybox
  125681. */
  125682. protected _mesh: Mesh;
  125683. /**
  125684. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  125685. */
  125686. private _halfDomeMask;
  125687. /**
  125688. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  125689. * Also see the options.resolution property.
  125690. */
  125691. get fovMultiplier(): number;
  125692. set fovMultiplier(value: number);
  125693. private _videoMode;
  125694. /**
  125695. * Gets or set the current video mode for the video. It can be:
  125696. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  125697. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  125698. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  125699. */
  125700. get videoMode(): number;
  125701. set videoMode(value: number);
  125702. /**
  125703. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  125704. *
  125705. */
  125706. get halfDome(): boolean;
  125707. /**
  125708. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  125709. */
  125710. set halfDome(enabled: boolean);
  125711. /**
  125712. * Oberserver used in Stereoscopic VR Mode.
  125713. */
  125714. private _onBeforeCameraRenderObserver;
  125715. /**
  125716. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  125717. * @param name Element's name, child elements will append suffixes for their own names.
  125718. * @param urlsOrVideo defines the url(s) or the video element to use
  125719. * @param options An object containing optional or exposed sub element properties
  125720. */
  125721. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  125722. resolution?: number;
  125723. clickToPlay?: boolean;
  125724. autoPlay?: boolean;
  125725. loop?: boolean;
  125726. size?: number;
  125727. poster?: string;
  125728. faceForward?: boolean;
  125729. useDirectMapping?: boolean;
  125730. halfDomeMode?: boolean;
  125731. }, scene: Scene);
  125732. private _changeVideoMode;
  125733. /**
  125734. * Releases resources associated with this node.
  125735. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  125736. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  125737. */
  125738. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  125739. }
  125740. }
  125741. declare module BABYLON {
  125742. /**
  125743. * This class can be used to get instrumentation data from a Babylon engine
  125744. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125745. */
  125746. export class EngineInstrumentation implements IDisposable {
  125747. /**
  125748. * Define the instrumented engine.
  125749. */
  125750. engine: Engine;
  125751. private _captureGPUFrameTime;
  125752. private _gpuFrameTimeToken;
  125753. private _gpuFrameTime;
  125754. private _captureShaderCompilationTime;
  125755. private _shaderCompilationTime;
  125756. private _onBeginFrameObserver;
  125757. private _onEndFrameObserver;
  125758. private _onBeforeShaderCompilationObserver;
  125759. private _onAfterShaderCompilationObserver;
  125760. /**
  125761. * Gets the perf counter used for GPU frame time
  125762. */
  125763. get gpuFrameTimeCounter(): PerfCounter;
  125764. /**
  125765. * Gets the GPU frame time capture status
  125766. */
  125767. get captureGPUFrameTime(): boolean;
  125768. /**
  125769. * Enable or disable the GPU frame time capture
  125770. */
  125771. set captureGPUFrameTime(value: boolean);
  125772. /**
  125773. * Gets the perf counter used for shader compilation time
  125774. */
  125775. get shaderCompilationTimeCounter(): PerfCounter;
  125776. /**
  125777. * Gets the shader compilation time capture status
  125778. */
  125779. get captureShaderCompilationTime(): boolean;
  125780. /**
  125781. * Enable or disable the shader compilation time capture
  125782. */
  125783. set captureShaderCompilationTime(value: boolean);
  125784. /**
  125785. * Instantiates a new engine instrumentation.
  125786. * This class can be used to get instrumentation data from a Babylon engine
  125787. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  125788. * @param engine Defines the engine to instrument
  125789. */
  125790. constructor(
  125791. /**
  125792. * Define the instrumented engine.
  125793. */
  125794. engine: Engine);
  125795. /**
  125796. * Dispose and release associated resources.
  125797. */
  125798. dispose(): void;
  125799. }
  125800. }
  125801. declare module BABYLON {
  125802. /**
  125803. * This class can be used to get instrumentation data from a Babylon engine
  125804. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125805. */
  125806. export class SceneInstrumentation implements IDisposable {
  125807. /**
  125808. * Defines the scene to instrument
  125809. */
  125810. scene: Scene;
  125811. private _captureActiveMeshesEvaluationTime;
  125812. private _activeMeshesEvaluationTime;
  125813. private _captureRenderTargetsRenderTime;
  125814. private _renderTargetsRenderTime;
  125815. private _captureFrameTime;
  125816. private _frameTime;
  125817. private _captureRenderTime;
  125818. private _renderTime;
  125819. private _captureInterFrameTime;
  125820. private _interFrameTime;
  125821. private _captureParticlesRenderTime;
  125822. private _particlesRenderTime;
  125823. private _captureSpritesRenderTime;
  125824. private _spritesRenderTime;
  125825. private _capturePhysicsTime;
  125826. private _physicsTime;
  125827. private _captureAnimationsTime;
  125828. private _animationsTime;
  125829. private _captureCameraRenderTime;
  125830. private _cameraRenderTime;
  125831. private _onBeforeActiveMeshesEvaluationObserver;
  125832. private _onAfterActiveMeshesEvaluationObserver;
  125833. private _onBeforeRenderTargetsRenderObserver;
  125834. private _onAfterRenderTargetsRenderObserver;
  125835. private _onAfterRenderObserver;
  125836. private _onBeforeDrawPhaseObserver;
  125837. private _onAfterDrawPhaseObserver;
  125838. private _onBeforeAnimationsObserver;
  125839. private _onBeforeParticlesRenderingObserver;
  125840. private _onAfterParticlesRenderingObserver;
  125841. private _onBeforeSpritesRenderingObserver;
  125842. private _onAfterSpritesRenderingObserver;
  125843. private _onBeforePhysicsObserver;
  125844. private _onAfterPhysicsObserver;
  125845. private _onAfterAnimationsObserver;
  125846. private _onBeforeCameraRenderObserver;
  125847. private _onAfterCameraRenderObserver;
  125848. /**
  125849. * Gets the perf counter used for active meshes evaluation time
  125850. */
  125851. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  125852. /**
  125853. * Gets the active meshes evaluation time capture status
  125854. */
  125855. get captureActiveMeshesEvaluationTime(): boolean;
  125856. /**
  125857. * Enable or disable the active meshes evaluation time capture
  125858. */
  125859. set captureActiveMeshesEvaluationTime(value: boolean);
  125860. /**
  125861. * Gets the perf counter used for render targets render time
  125862. */
  125863. get renderTargetsRenderTimeCounter(): PerfCounter;
  125864. /**
  125865. * Gets the render targets render time capture status
  125866. */
  125867. get captureRenderTargetsRenderTime(): boolean;
  125868. /**
  125869. * Enable or disable the render targets render time capture
  125870. */
  125871. set captureRenderTargetsRenderTime(value: boolean);
  125872. /**
  125873. * Gets the perf counter used for particles render time
  125874. */
  125875. get particlesRenderTimeCounter(): PerfCounter;
  125876. /**
  125877. * Gets the particles render time capture status
  125878. */
  125879. get captureParticlesRenderTime(): boolean;
  125880. /**
  125881. * Enable or disable the particles render time capture
  125882. */
  125883. set captureParticlesRenderTime(value: boolean);
  125884. /**
  125885. * Gets the perf counter used for sprites render time
  125886. */
  125887. get spritesRenderTimeCounter(): PerfCounter;
  125888. /**
  125889. * Gets the sprites render time capture status
  125890. */
  125891. get captureSpritesRenderTime(): boolean;
  125892. /**
  125893. * Enable or disable the sprites render time capture
  125894. */
  125895. set captureSpritesRenderTime(value: boolean);
  125896. /**
  125897. * Gets the perf counter used for physics time
  125898. */
  125899. get physicsTimeCounter(): PerfCounter;
  125900. /**
  125901. * Gets the physics time capture status
  125902. */
  125903. get capturePhysicsTime(): boolean;
  125904. /**
  125905. * Enable or disable the physics time capture
  125906. */
  125907. set capturePhysicsTime(value: boolean);
  125908. /**
  125909. * Gets the perf counter used for animations time
  125910. */
  125911. get animationsTimeCounter(): PerfCounter;
  125912. /**
  125913. * Gets the animations time capture status
  125914. */
  125915. get captureAnimationsTime(): boolean;
  125916. /**
  125917. * Enable or disable the animations time capture
  125918. */
  125919. set captureAnimationsTime(value: boolean);
  125920. /**
  125921. * Gets the perf counter used for frame time capture
  125922. */
  125923. get frameTimeCounter(): PerfCounter;
  125924. /**
  125925. * Gets the frame time capture status
  125926. */
  125927. get captureFrameTime(): boolean;
  125928. /**
  125929. * Enable or disable the frame time capture
  125930. */
  125931. set captureFrameTime(value: boolean);
  125932. /**
  125933. * Gets the perf counter used for inter-frames time capture
  125934. */
  125935. get interFrameTimeCounter(): PerfCounter;
  125936. /**
  125937. * Gets the inter-frames time capture status
  125938. */
  125939. get captureInterFrameTime(): boolean;
  125940. /**
  125941. * Enable or disable the inter-frames time capture
  125942. */
  125943. set captureInterFrameTime(value: boolean);
  125944. /**
  125945. * Gets the perf counter used for render time capture
  125946. */
  125947. get renderTimeCounter(): PerfCounter;
  125948. /**
  125949. * Gets the render time capture status
  125950. */
  125951. get captureRenderTime(): boolean;
  125952. /**
  125953. * Enable or disable the render time capture
  125954. */
  125955. set captureRenderTime(value: boolean);
  125956. /**
  125957. * Gets the perf counter used for camera render time capture
  125958. */
  125959. get cameraRenderTimeCounter(): PerfCounter;
  125960. /**
  125961. * Gets the camera render time capture status
  125962. */
  125963. get captureCameraRenderTime(): boolean;
  125964. /**
  125965. * Enable or disable the camera render time capture
  125966. */
  125967. set captureCameraRenderTime(value: boolean);
  125968. /**
  125969. * Gets the perf counter used for draw calls
  125970. */
  125971. get drawCallsCounter(): PerfCounter;
  125972. /**
  125973. * Instantiates a new scene instrumentation.
  125974. * This class can be used to get instrumentation data from a Babylon engine
  125975. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  125976. * @param scene Defines the scene to instrument
  125977. */
  125978. constructor(
  125979. /**
  125980. * Defines the scene to instrument
  125981. */
  125982. scene: Scene);
  125983. /**
  125984. * Dispose and release associated resources.
  125985. */
  125986. dispose(): void;
  125987. }
  125988. }
  125989. declare module BABYLON {
  125990. /** @hidden */
  125991. export var glowMapGenerationPixelShader: {
  125992. name: string;
  125993. shader: string;
  125994. };
  125995. }
  125996. declare module BABYLON {
  125997. /** @hidden */
  125998. export var glowMapGenerationVertexShader: {
  125999. name: string;
  126000. shader: string;
  126001. };
  126002. }
  126003. declare module BABYLON {
  126004. /**
  126005. * Effect layer options. This helps customizing the behaviour
  126006. * of the effect layer.
  126007. */
  126008. export interface IEffectLayerOptions {
  126009. /**
  126010. * Multiplication factor apply to the canvas size to compute the render target size
  126011. * used to generated the objects (the smaller the faster).
  126012. */
  126013. mainTextureRatio: number;
  126014. /**
  126015. * Enforces a fixed size texture to ensure effect stability across devices.
  126016. */
  126017. mainTextureFixedSize?: number;
  126018. /**
  126019. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  126020. */
  126021. alphaBlendingMode: number;
  126022. /**
  126023. * The camera attached to the layer.
  126024. */
  126025. camera: Nullable<Camera>;
  126026. /**
  126027. * The rendering group to draw the layer in.
  126028. */
  126029. renderingGroupId: number;
  126030. }
  126031. /**
  126032. * The effect layer Helps adding post process effect blended with the main pass.
  126033. *
  126034. * This can be for instance use to generate glow or higlight effects on the scene.
  126035. *
  126036. * The effect layer class can not be used directly and is intented to inherited from to be
  126037. * customized per effects.
  126038. */
  126039. export abstract class EffectLayer {
  126040. private _vertexBuffers;
  126041. private _indexBuffer;
  126042. private _cachedDefines;
  126043. private _effectLayerMapGenerationEffect;
  126044. private _effectLayerOptions;
  126045. private _mergeEffect;
  126046. protected _scene: Scene;
  126047. protected _engine: Engine;
  126048. protected _maxSize: number;
  126049. protected _mainTextureDesiredSize: ISize;
  126050. protected _mainTexture: RenderTargetTexture;
  126051. protected _shouldRender: boolean;
  126052. protected _postProcesses: PostProcess[];
  126053. protected _textures: BaseTexture[];
  126054. protected _emissiveTextureAndColor: {
  126055. texture: Nullable<BaseTexture>;
  126056. color: Color4;
  126057. };
  126058. /**
  126059. * The name of the layer
  126060. */
  126061. name: string;
  126062. /**
  126063. * The clear color of the texture used to generate the glow map.
  126064. */
  126065. neutralColor: Color4;
  126066. /**
  126067. * Specifies whether the highlight layer is enabled or not.
  126068. */
  126069. isEnabled: boolean;
  126070. /**
  126071. * Gets the camera attached to the layer.
  126072. */
  126073. get camera(): Nullable<Camera>;
  126074. /**
  126075. * Gets the rendering group id the layer should render in.
  126076. */
  126077. get renderingGroupId(): number;
  126078. set renderingGroupId(renderingGroupId: number);
  126079. /**
  126080. * An event triggered when the effect layer has been disposed.
  126081. */
  126082. onDisposeObservable: Observable<EffectLayer>;
  126083. /**
  126084. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  126085. */
  126086. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  126087. /**
  126088. * An event triggered when the generated texture is being merged in the scene.
  126089. */
  126090. onBeforeComposeObservable: Observable<EffectLayer>;
  126091. /**
  126092. * An event triggered when the mesh is rendered into the effect render target.
  126093. */
  126094. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  126095. /**
  126096. * An event triggered after the mesh has been rendered into the effect render target.
  126097. */
  126098. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  126099. /**
  126100. * An event triggered when the generated texture has been merged in the scene.
  126101. */
  126102. onAfterComposeObservable: Observable<EffectLayer>;
  126103. /**
  126104. * An event triggered when the efffect layer changes its size.
  126105. */
  126106. onSizeChangedObservable: Observable<EffectLayer>;
  126107. /** @hidden */
  126108. static _SceneComponentInitialization: (scene: Scene) => void;
  126109. /**
  126110. * Instantiates a new effect Layer and references it in the scene.
  126111. * @param name The name of the layer
  126112. * @param scene The scene to use the layer in
  126113. */
  126114. constructor(
  126115. /** The Friendly of the effect in the scene */
  126116. name: string, scene: Scene);
  126117. /**
  126118. * Get the effect name of the layer.
  126119. * @return The effect name
  126120. */
  126121. abstract getEffectName(): string;
  126122. /**
  126123. * Checks for the readiness of the element composing the layer.
  126124. * @param subMesh the mesh to check for
  126125. * @param useInstances specify whether or not to use instances to render the mesh
  126126. * @return true if ready otherwise, false
  126127. */
  126128. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126129. /**
  126130. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126131. * @returns true if the effect requires stencil during the main canvas render pass.
  126132. */
  126133. abstract needStencil(): boolean;
  126134. /**
  126135. * Create the merge effect. This is the shader use to blit the information back
  126136. * to the main canvas at the end of the scene rendering.
  126137. * @returns The effect containing the shader used to merge the effect on the main canvas
  126138. */
  126139. protected abstract _createMergeEffect(): Effect;
  126140. /**
  126141. * Creates the render target textures and post processes used in the effect layer.
  126142. */
  126143. protected abstract _createTextureAndPostProcesses(): void;
  126144. /**
  126145. * Implementation specific of rendering the generating effect on the main canvas.
  126146. * @param effect The effect used to render through
  126147. */
  126148. protected abstract _internalRender(effect: Effect): void;
  126149. /**
  126150. * Sets the required values for both the emissive texture and and the main color.
  126151. */
  126152. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126153. /**
  126154. * Free any resources and references associated to a mesh.
  126155. * Internal use
  126156. * @param mesh The mesh to free.
  126157. */
  126158. abstract _disposeMesh(mesh: Mesh): void;
  126159. /**
  126160. * Serializes this layer (Glow or Highlight for example)
  126161. * @returns a serialized layer object
  126162. */
  126163. abstract serialize?(): any;
  126164. /**
  126165. * Initializes the effect layer with the required options.
  126166. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  126167. */
  126168. protected _init(options: Partial<IEffectLayerOptions>): void;
  126169. /**
  126170. * Generates the index buffer of the full screen quad blending to the main canvas.
  126171. */
  126172. private _generateIndexBuffer;
  126173. /**
  126174. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  126175. */
  126176. private _generateVertexBuffer;
  126177. /**
  126178. * Sets the main texture desired size which is the closest power of two
  126179. * of the engine canvas size.
  126180. */
  126181. private _setMainTextureSize;
  126182. /**
  126183. * Creates the main texture for the effect layer.
  126184. */
  126185. protected _createMainTexture(): void;
  126186. /**
  126187. * Adds specific effects defines.
  126188. * @param defines The defines to add specifics to.
  126189. */
  126190. protected _addCustomEffectDefines(defines: string[]): void;
  126191. /**
  126192. * Checks for the readiness of the element composing the layer.
  126193. * @param subMesh the mesh to check for
  126194. * @param useInstances specify whether or not to use instances to render the mesh
  126195. * @param emissiveTexture the associated emissive texture used to generate the glow
  126196. * @return true if ready otherwise, false
  126197. */
  126198. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  126199. /**
  126200. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  126201. */
  126202. render(): void;
  126203. /**
  126204. * Determine if a given mesh will be used in the current effect.
  126205. * @param mesh mesh to test
  126206. * @returns true if the mesh will be used
  126207. */
  126208. hasMesh(mesh: AbstractMesh): boolean;
  126209. /**
  126210. * Returns true if the layer contains information to display, otherwise false.
  126211. * @returns true if the glow layer should be rendered
  126212. */
  126213. shouldRender(): boolean;
  126214. /**
  126215. * Returns true if the mesh should render, otherwise false.
  126216. * @param mesh The mesh to render
  126217. * @returns true if it should render otherwise false
  126218. */
  126219. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  126220. /**
  126221. * Returns true if the mesh can be rendered, otherwise false.
  126222. * @param mesh The mesh to render
  126223. * @param material The material used on the mesh
  126224. * @returns true if it can be rendered otherwise false
  126225. */
  126226. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126227. /**
  126228. * Returns true if the mesh should render, otherwise false.
  126229. * @param mesh The mesh to render
  126230. * @returns true if it should render otherwise false
  126231. */
  126232. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  126233. /**
  126234. * Renders the submesh passed in parameter to the generation map.
  126235. */
  126236. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  126237. /**
  126238. * Defines whether the current material of the mesh should be use to render the effect.
  126239. * @param mesh defines the current mesh to render
  126240. */
  126241. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126242. /**
  126243. * Rebuild the required buffers.
  126244. * @hidden Internal use only.
  126245. */
  126246. _rebuild(): void;
  126247. /**
  126248. * Dispose only the render target textures and post process.
  126249. */
  126250. private _disposeTextureAndPostProcesses;
  126251. /**
  126252. * Dispose the highlight layer and free resources.
  126253. */
  126254. dispose(): void;
  126255. /**
  126256. * Gets the class name of the effect layer
  126257. * @returns the string with the class name of the effect layer
  126258. */
  126259. getClassName(): string;
  126260. /**
  126261. * Creates an effect layer from parsed effect layer data
  126262. * @param parsedEffectLayer defines effect layer data
  126263. * @param scene defines the current scene
  126264. * @param rootUrl defines the root URL containing the effect layer information
  126265. * @returns a parsed effect Layer
  126266. */
  126267. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  126268. }
  126269. }
  126270. declare module BABYLON {
  126271. interface AbstractScene {
  126272. /**
  126273. * The list of effect layers (highlights/glow) added to the scene
  126274. * @see http://doc.babylonjs.com/how_to/highlight_layer
  126275. * @see http://doc.babylonjs.com/how_to/glow_layer
  126276. */
  126277. effectLayers: Array<EffectLayer>;
  126278. /**
  126279. * Removes the given effect layer from this scene.
  126280. * @param toRemove defines the effect layer to remove
  126281. * @returns the index of the removed effect layer
  126282. */
  126283. removeEffectLayer(toRemove: EffectLayer): number;
  126284. /**
  126285. * Adds the given effect layer to this scene
  126286. * @param newEffectLayer defines the effect layer to add
  126287. */
  126288. addEffectLayer(newEffectLayer: EffectLayer): void;
  126289. }
  126290. /**
  126291. * Defines the layer scene component responsible to manage any effect layers
  126292. * in a given scene.
  126293. */
  126294. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  126295. /**
  126296. * The component name helpfull to identify the component in the list of scene components.
  126297. */
  126298. readonly name: string;
  126299. /**
  126300. * The scene the component belongs to.
  126301. */
  126302. scene: Scene;
  126303. private _engine;
  126304. private _renderEffects;
  126305. private _needStencil;
  126306. private _previousStencilState;
  126307. /**
  126308. * Creates a new instance of the component for the given scene
  126309. * @param scene Defines the scene to register the component in
  126310. */
  126311. constructor(scene: Scene);
  126312. /**
  126313. * Registers the component in a given scene
  126314. */
  126315. register(): void;
  126316. /**
  126317. * Rebuilds the elements related to this component in case of
  126318. * context lost for instance.
  126319. */
  126320. rebuild(): void;
  126321. /**
  126322. * Serializes the component data to the specified json object
  126323. * @param serializationObject The object to serialize to
  126324. */
  126325. serialize(serializationObject: any): void;
  126326. /**
  126327. * Adds all the elements from the container to the scene
  126328. * @param container the container holding the elements
  126329. */
  126330. addFromContainer(container: AbstractScene): void;
  126331. /**
  126332. * Removes all the elements in the container from the scene
  126333. * @param container contains the elements to remove
  126334. * @param dispose if the removed element should be disposed (default: false)
  126335. */
  126336. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126337. /**
  126338. * Disposes the component and the associated ressources.
  126339. */
  126340. dispose(): void;
  126341. private _isReadyForMesh;
  126342. private _renderMainTexture;
  126343. private _setStencil;
  126344. private _setStencilBack;
  126345. private _draw;
  126346. private _drawCamera;
  126347. private _drawRenderingGroup;
  126348. }
  126349. }
  126350. declare module BABYLON {
  126351. /** @hidden */
  126352. export var glowMapMergePixelShader: {
  126353. name: string;
  126354. shader: string;
  126355. };
  126356. }
  126357. declare module BABYLON {
  126358. /** @hidden */
  126359. export var glowMapMergeVertexShader: {
  126360. name: string;
  126361. shader: string;
  126362. };
  126363. }
  126364. declare module BABYLON {
  126365. interface AbstractScene {
  126366. /**
  126367. * Return a the first highlight layer of the scene with a given name.
  126368. * @param name The name of the highlight layer to look for.
  126369. * @return The highlight layer if found otherwise null.
  126370. */
  126371. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  126372. }
  126373. /**
  126374. * Glow layer options. This helps customizing the behaviour
  126375. * of the glow layer.
  126376. */
  126377. export interface IGlowLayerOptions {
  126378. /**
  126379. * Multiplication factor apply to the canvas size to compute the render target size
  126380. * used to generated the glowing objects (the smaller the faster).
  126381. */
  126382. mainTextureRatio: number;
  126383. /**
  126384. * Enforces a fixed size texture to ensure resize independant blur.
  126385. */
  126386. mainTextureFixedSize?: number;
  126387. /**
  126388. * How big is the kernel of the blur texture.
  126389. */
  126390. blurKernelSize: number;
  126391. /**
  126392. * The camera attached to the layer.
  126393. */
  126394. camera: Nullable<Camera>;
  126395. /**
  126396. * Enable MSAA by chosing the number of samples.
  126397. */
  126398. mainTextureSamples?: number;
  126399. /**
  126400. * The rendering group to draw the layer in.
  126401. */
  126402. renderingGroupId: number;
  126403. }
  126404. /**
  126405. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  126406. *
  126407. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  126408. *
  126409. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  126410. */
  126411. export class GlowLayer extends EffectLayer {
  126412. /**
  126413. * Effect Name of the layer.
  126414. */
  126415. static readonly EffectName: string;
  126416. /**
  126417. * The default blur kernel size used for the glow.
  126418. */
  126419. static DefaultBlurKernelSize: number;
  126420. /**
  126421. * The default texture size ratio used for the glow.
  126422. */
  126423. static DefaultTextureRatio: number;
  126424. /**
  126425. * Sets the kernel size of the blur.
  126426. */
  126427. set blurKernelSize(value: number);
  126428. /**
  126429. * Gets the kernel size of the blur.
  126430. */
  126431. get blurKernelSize(): number;
  126432. /**
  126433. * Sets the glow intensity.
  126434. */
  126435. set intensity(value: number);
  126436. /**
  126437. * Gets the glow intensity.
  126438. */
  126439. get intensity(): number;
  126440. private _options;
  126441. private _intensity;
  126442. private _horizontalBlurPostprocess1;
  126443. private _verticalBlurPostprocess1;
  126444. private _horizontalBlurPostprocess2;
  126445. private _verticalBlurPostprocess2;
  126446. private _blurTexture1;
  126447. private _blurTexture2;
  126448. private _postProcesses1;
  126449. private _postProcesses2;
  126450. private _includedOnlyMeshes;
  126451. private _excludedMeshes;
  126452. private _meshesUsingTheirOwnMaterials;
  126453. /**
  126454. * Callback used to let the user override the color selection on a per mesh basis
  126455. */
  126456. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  126457. /**
  126458. * Callback used to let the user override the texture selection on a per mesh basis
  126459. */
  126460. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  126461. /**
  126462. * Instantiates a new glow Layer and references it to the scene.
  126463. * @param name The name of the layer
  126464. * @param scene The scene to use the layer in
  126465. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  126466. */
  126467. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  126468. /**
  126469. * Get the effect name of the layer.
  126470. * @return The effect name
  126471. */
  126472. getEffectName(): string;
  126473. /**
  126474. * Create the merge effect. This is the shader use to blit the information back
  126475. * to the main canvas at the end of the scene rendering.
  126476. */
  126477. protected _createMergeEffect(): Effect;
  126478. /**
  126479. * Creates the render target textures and post processes used in the glow layer.
  126480. */
  126481. protected _createTextureAndPostProcesses(): void;
  126482. /**
  126483. * Checks for the readiness of the element composing the layer.
  126484. * @param subMesh the mesh to check for
  126485. * @param useInstances specify wether or not to use instances to render the mesh
  126486. * @param emissiveTexture the associated emissive texture used to generate the glow
  126487. * @return true if ready otherwise, false
  126488. */
  126489. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126490. /**
  126491. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  126492. */
  126493. needStencil(): boolean;
  126494. /**
  126495. * Returns true if the mesh can be rendered, otherwise false.
  126496. * @param mesh The mesh to render
  126497. * @param material The material used on the mesh
  126498. * @returns true if it can be rendered otherwise false
  126499. */
  126500. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  126501. /**
  126502. * Implementation specific of rendering the generating effect on the main canvas.
  126503. * @param effect The effect used to render through
  126504. */
  126505. protected _internalRender(effect: Effect): void;
  126506. /**
  126507. * Sets the required values for both the emissive texture and and the main color.
  126508. */
  126509. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126510. /**
  126511. * Returns true if the mesh should render, otherwise false.
  126512. * @param mesh The mesh to render
  126513. * @returns true if it should render otherwise false
  126514. */
  126515. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126516. /**
  126517. * Adds specific effects defines.
  126518. * @param defines The defines to add specifics to.
  126519. */
  126520. protected _addCustomEffectDefines(defines: string[]): void;
  126521. /**
  126522. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  126523. * @param mesh The mesh to exclude from the glow layer
  126524. */
  126525. addExcludedMesh(mesh: Mesh): void;
  126526. /**
  126527. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  126528. * @param mesh The mesh to remove
  126529. */
  126530. removeExcludedMesh(mesh: Mesh): void;
  126531. /**
  126532. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  126533. * @param mesh The mesh to include in the glow layer
  126534. */
  126535. addIncludedOnlyMesh(mesh: Mesh): void;
  126536. /**
  126537. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  126538. * @param mesh The mesh to remove
  126539. */
  126540. removeIncludedOnlyMesh(mesh: Mesh): void;
  126541. /**
  126542. * Determine if a given mesh will be used in the glow layer
  126543. * @param mesh The mesh to test
  126544. * @returns true if the mesh will be highlighted by the current glow layer
  126545. */
  126546. hasMesh(mesh: AbstractMesh): boolean;
  126547. /**
  126548. * Defines whether the current material of the mesh should be use to render the effect.
  126549. * @param mesh defines the current mesh to render
  126550. */
  126551. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  126552. /**
  126553. * Add a mesh to be rendered through its own material and not with emissive only.
  126554. * @param mesh The mesh for which we need to use its material
  126555. */
  126556. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  126557. /**
  126558. * Remove a mesh from being rendered through its own material and not with emissive only.
  126559. * @param mesh The mesh for which we need to not use its material
  126560. */
  126561. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  126562. /**
  126563. * Free any resources and references associated to a mesh.
  126564. * Internal use
  126565. * @param mesh The mesh to free.
  126566. * @hidden
  126567. */
  126568. _disposeMesh(mesh: Mesh): void;
  126569. /**
  126570. * Gets the class name of the effect layer
  126571. * @returns the string with the class name of the effect layer
  126572. */
  126573. getClassName(): string;
  126574. /**
  126575. * Serializes this glow layer
  126576. * @returns a serialized glow layer object
  126577. */
  126578. serialize(): any;
  126579. /**
  126580. * Creates a Glow Layer from parsed glow layer data
  126581. * @param parsedGlowLayer defines glow layer data
  126582. * @param scene defines the current scene
  126583. * @param rootUrl defines the root URL containing the glow layer information
  126584. * @returns a parsed Glow Layer
  126585. */
  126586. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  126587. }
  126588. }
  126589. declare module BABYLON {
  126590. /** @hidden */
  126591. export var glowBlurPostProcessPixelShader: {
  126592. name: string;
  126593. shader: string;
  126594. };
  126595. }
  126596. declare module BABYLON {
  126597. interface AbstractScene {
  126598. /**
  126599. * Return a the first highlight layer of the scene with a given name.
  126600. * @param name The name of the highlight layer to look for.
  126601. * @return The highlight layer if found otherwise null.
  126602. */
  126603. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  126604. }
  126605. /**
  126606. * Highlight layer options. This helps customizing the behaviour
  126607. * of the highlight layer.
  126608. */
  126609. export interface IHighlightLayerOptions {
  126610. /**
  126611. * Multiplication factor apply to the canvas size to compute the render target size
  126612. * used to generated the glowing objects (the smaller the faster).
  126613. */
  126614. mainTextureRatio: number;
  126615. /**
  126616. * Enforces a fixed size texture to ensure resize independant blur.
  126617. */
  126618. mainTextureFixedSize?: number;
  126619. /**
  126620. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  126621. * of the picture to blur (the smaller the faster).
  126622. */
  126623. blurTextureSizeRatio: number;
  126624. /**
  126625. * How big in texel of the blur texture is the vertical blur.
  126626. */
  126627. blurVerticalSize: number;
  126628. /**
  126629. * How big in texel of the blur texture is the horizontal blur.
  126630. */
  126631. blurHorizontalSize: number;
  126632. /**
  126633. * Alpha blending mode used to apply the blur. Default is combine.
  126634. */
  126635. alphaBlendingMode: number;
  126636. /**
  126637. * The camera attached to the layer.
  126638. */
  126639. camera: Nullable<Camera>;
  126640. /**
  126641. * Should we display highlight as a solid stroke?
  126642. */
  126643. isStroke?: boolean;
  126644. /**
  126645. * The rendering group to draw the layer in.
  126646. */
  126647. renderingGroupId: number;
  126648. }
  126649. /**
  126650. * The highlight layer Helps adding a glow effect around a mesh.
  126651. *
  126652. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  126653. * glowy meshes to your scene.
  126654. *
  126655. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  126656. */
  126657. export class HighlightLayer extends EffectLayer {
  126658. name: string;
  126659. /**
  126660. * Effect Name of the highlight layer.
  126661. */
  126662. static readonly EffectName: string;
  126663. /**
  126664. * The neutral color used during the preparation of the glow effect.
  126665. * This is black by default as the blend operation is a blend operation.
  126666. */
  126667. static NeutralColor: Color4;
  126668. /**
  126669. * Stencil value used for glowing meshes.
  126670. */
  126671. static GlowingMeshStencilReference: number;
  126672. /**
  126673. * Stencil value used for the other meshes in the scene.
  126674. */
  126675. static NormalMeshStencilReference: number;
  126676. /**
  126677. * Specifies whether or not the inner glow is ACTIVE in the layer.
  126678. */
  126679. innerGlow: boolean;
  126680. /**
  126681. * Specifies whether or not the outer glow is ACTIVE in the layer.
  126682. */
  126683. outerGlow: boolean;
  126684. /**
  126685. * Specifies the horizontal size of the blur.
  126686. */
  126687. set blurHorizontalSize(value: number);
  126688. /**
  126689. * Specifies the vertical size of the blur.
  126690. */
  126691. set blurVerticalSize(value: number);
  126692. /**
  126693. * Gets the horizontal size of the blur.
  126694. */
  126695. get blurHorizontalSize(): number;
  126696. /**
  126697. * Gets the vertical size of the blur.
  126698. */
  126699. get blurVerticalSize(): number;
  126700. /**
  126701. * An event triggered when the highlight layer is being blurred.
  126702. */
  126703. onBeforeBlurObservable: Observable<HighlightLayer>;
  126704. /**
  126705. * An event triggered when the highlight layer has been blurred.
  126706. */
  126707. onAfterBlurObservable: Observable<HighlightLayer>;
  126708. private _instanceGlowingMeshStencilReference;
  126709. private _options;
  126710. private _downSamplePostprocess;
  126711. private _horizontalBlurPostprocess;
  126712. private _verticalBlurPostprocess;
  126713. private _blurTexture;
  126714. private _meshes;
  126715. private _excludedMeshes;
  126716. /**
  126717. * Instantiates a new highlight Layer and references it to the scene..
  126718. * @param name The name of the layer
  126719. * @param scene The scene to use the layer in
  126720. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  126721. */
  126722. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  126723. /**
  126724. * Get the effect name of the layer.
  126725. * @return The effect name
  126726. */
  126727. getEffectName(): string;
  126728. /**
  126729. * Create the merge effect. This is the shader use to blit the information back
  126730. * to the main canvas at the end of the scene rendering.
  126731. */
  126732. protected _createMergeEffect(): Effect;
  126733. /**
  126734. * Creates the render target textures and post processes used in the highlight layer.
  126735. */
  126736. protected _createTextureAndPostProcesses(): void;
  126737. /**
  126738. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  126739. */
  126740. needStencil(): boolean;
  126741. /**
  126742. * Checks for the readiness of the element composing the layer.
  126743. * @param subMesh the mesh to check for
  126744. * @param useInstances specify wether or not to use instances to render the mesh
  126745. * @param emissiveTexture the associated emissive texture used to generate the glow
  126746. * @return true if ready otherwise, false
  126747. */
  126748. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126749. /**
  126750. * Implementation specific of rendering the generating effect on the main canvas.
  126751. * @param effect The effect used to render through
  126752. */
  126753. protected _internalRender(effect: Effect): void;
  126754. /**
  126755. * Returns true if the layer contains information to display, otherwise false.
  126756. */
  126757. shouldRender(): boolean;
  126758. /**
  126759. * Returns true if the mesh should render, otherwise false.
  126760. * @param mesh The mesh to render
  126761. * @returns true if it should render otherwise false
  126762. */
  126763. protected _shouldRenderMesh(mesh: Mesh): boolean;
  126764. /**
  126765. * Sets the required values for both the emissive texture and and the main color.
  126766. */
  126767. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  126768. /**
  126769. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  126770. * @param mesh The mesh to exclude from the highlight layer
  126771. */
  126772. addExcludedMesh(mesh: Mesh): void;
  126773. /**
  126774. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  126775. * @param mesh The mesh to highlight
  126776. */
  126777. removeExcludedMesh(mesh: Mesh): void;
  126778. /**
  126779. * Determine if a given mesh will be highlighted by the current HighlightLayer
  126780. * @param mesh mesh to test
  126781. * @returns true if the mesh will be highlighted by the current HighlightLayer
  126782. */
  126783. hasMesh(mesh: AbstractMesh): boolean;
  126784. /**
  126785. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  126786. * @param mesh The mesh to highlight
  126787. * @param color The color of the highlight
  126788. * @param glowEmissiveOnly Extract the glow from the emissive texture
  126789. */
  126790. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  126791. /**
  126792. * Remove a mesh from the highlight layer in order to make it stop glowing.
  126793. * @param mesh The mesh to highlight
  126794. */
  126795. removeMesh(mesh: Mesh): void;
  126796. /**
  126797. * Force the stencil to the normal expected value for none glowing parts
  126798. */
  126799. private _defaultStencilReference;
  126800. /**
  126801. * Free any resources and references associated to a mesh.
  126802. * Internal use
  126803. * @param mesh The mesh to free.
  126804. * @hidden
  126805. */
  126806. _disposeMesh(mesh: Mesh): void;
  126807. /**
  126808. * Dispose the highlight layer and free resources.
  126809. */
  126810. dispose(): void;
  126811. /**
  126812. * Gets the class name of the effect layer
  126813. * @returns the string with the class name of the effect layer
  126814. */
  126815. getClassName(): string;
  126816. /**
  126817. * Serializes this Highlight layer
  126818. * @returns a serialized Highlight layer object
  126819. */
  126820. serialize(): any;
  126821. /**
  126822. * Creates a Highlight layer from parsed Highlight layer data
  126823. * @param parsedHightlightLayer defines the Highlight layer data
  126824. * @param scene defines the current scene
  126825. * @param rootUrl defines the root URL containing the Highlight layer information
  126826. * @returns a parsed Highlight layer
  126827. */
  126828. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  126829. }
  126830. }
  126831. declare module BABYLON {
  126832. interface AbstractScene {
  126833. /**
  126834. * The list of layers (background and foreground) of the scene
  126835. */
  126836. layers: Array<Layer>;
  126837. }
  126838. /**
  126839. * Defines the layer scene component responsible to manage any layers
  126840. * in a given scene.
  126841. */
  126842. export class LayerSceneComponent implements ISceneComponent {
  126843. /**
  126844. * The component name helpfull to identify the component in the list of scene components.
  126845. */
  126846. readonly name: string;
  126847. /**
  126848. * The scene the component belongs to.
  126849. */
  126850. scene: Scene;
  126851. private _engine;
  126852. /**
  126853. * Creates a new instance of the component for the given scene
  126854. * @param scene Defines the scene to register the component in
  126855. */
  126856. constructor(scene: Scene);
  126857. /**
  126858. * Registers the component in a given scene
  126859. */
  126860. register(): void;
  126861. /**
  126862. * Rebuilds the elements related to this component in case of
  126863. * context lost for instance.
  126864. */
  126865. rebuild(): void;
  126866. /**
  126867. * Disposes the component and the associated ressources.
  126868. */
  126869. dispose(): void;
  126870. private _draw;
  126871. private _drawCameraPredicate;
  126872. private _drawCameraBackground;
  126873. private _drawCameraForeground;
  126874. private _drawRenderTargetPredicate;
  126875. private _drawRenderTargetBackground;
  126876. private _drawRenderTargetForeground;
  126877. /**
  126878. * Adds all the elements from the container to the scene
  126879. * @param container the container holding the elements
  126880. */
  126881. addFromContainer(container: AbstractScene): void;
  126882. /**
  126883. * Removes all the elements in the container from the scene
  126884. * @param container contains the elements to remove
  126885. * @param dispose if the removed element should be disposed (default: false)
  126886. */
  126887. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  126888. }
  126889. }
  126890. declare module BABYLON {
  126891. /** @hidden */
  126892. export var layerPixelShader: {
  126893. name: string;
  126894. shader: string;
  126895. };
  126896. }
  126897. declare module BABYLON {
  126898. /** @hidden */
  126899. export var layerVertexShader: {
  126900. name: string;
  126901. shader: string;
  126902. };
  126903. }
  126904. declare module BABYLON {
  126905. /**
  126906. * This represents a full screen 2d layer.
  126907. * This can be useful to display a picture in the background of your scene for instance.
  126908. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126909. */
  126910. export class Layer {
  126911. /**
  126912. * Define the name of the layer.
  126913. */
  126914. name: string;
  126915. /**
  126916. * Define the texture the layer should display.
  126917. */
  126918. texture: Nullable<Texture>;
  126919. /**
  126920. * Is the layer in background or foreground.
  126921. */
  126922. isBackground: boolean;
  126923. /**
  126924. * Define the color of the layer (instead of texture).
  126925. */
  126926. color: Color4;
  126927. /**
  126928. * Define the scale of the layer in order to zoom in out of the texture.
  126929. */
  126930. scale: Vector2;
  126931. /**
  126932. * Define an offset for the layer in order to shift the texture.
  126933. */
  126934. offset: Vector2;
  126935. /**
  126936. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  126937. */
  126938. alphaBlendingMode: number;
  126939. /**
  126940. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  126941. * Alpha test will not mix with the background color in case of transparency.
  126942. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  126943. */
  126944. alphaTest: boolean;
  126945. /**
  126946. * Define a mask to restrict the layer to only some of the scene cameras.
  126947. */
  126948. layerMask: number;
  126949. /**
  126950. * Define the list of render target the layer is visible into.
  126951. */
  126952. renderTargetTextures: RenderTargetTexture[];
  126953. /**
  126954. * Define if the layer is only used in renderTarget or if it also
  126955. * renders in the main frame buffer of the canvas.
  126956. */
  126957. renderOnlyInRenderTargetTextures: boolean;
  126958. private _scene;
  126959. private _vertexBuffers;
  126960. private _indexBuffer;
  126961. private _effect;
  126962. private _previousDefines;
  126963. /**
  126964. * An event triggered when the layer is disposed.
  126965. */
  126966. onDisposeObservable: Observable<Layer>;
  126967. private _onDisposeObserver;
  126968. /**
  126969. * Back compatibility with callback before the onDisposeObservable existed.
  126970. * The set callback will be triggered when the layer has been disposed.
  126971. */
  126972. set onDispose(callback: () => void);
  126973. /**
  126974. * An event triggered before rendering the scene
  126975. */
  126976. onBeforeRenderObservable: Observable<Layer>;
  126977. private _onBeforeRenderObserver;
  126978. /**
  126979. * Back compatibility with callback before the onBeforeRenderObservable existed.
  126980. * The set callback will be triggered just before rendering the layer.
  126981. */
  126982. set onBeforeRender(callback: () => void);
  126983. /**
  126984. * An event triggered after rendering the scene
  126985. */
  126986. onAfterRenderObservable: Observable<Layer>;
  126987. private _onAfterRenderObserver;
  126988. /**
  126989. * Back compatibility with callback before the onAfterRenderObservable existed.
  126990. * The set callback will be triggered just after rendering the layer.
  126991. */
  126992. set onAfterRender(callback: () => void);
  126993. /**
  126994. * Instantiates a new layer.
  126995. * This represents a full screen 2d layer.
  126996. * This can be useful to display a picture in the background of your scene for instance.
  126997. * @see https://www.babylonjs-playground.com/#08A2BS#1
  126998. * @param name Define the name of the layer in the scene
  126999. * @param imgUrl Define the url of the texture to display in the layer
  127000. * @param scene Define the scene the layer belongs to
  127001. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  127002. * @param color Defines a color for the layer
  127003. */
  127004. constructor(
  127005. /**
  127006. * Define the name of the layer.
  127007. */
  127008. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  127009. private _createIndexBuffer;
  127010. /** @hidden */
  127011. _rebuild(): void;
  127012. /**
  127013. * Renders the layer in the scene.
  127014. */
  127015. render(): void;
  127016. /**
  127017. * Disposes and releases the associated ressources.
  127018. */
  127019. dispose(): void;
  127020. }
  127021. }
  127022. declare module BABYLON {
  127023. /** @hidden */
  127024. export var lensFlarePixelShader: {
  127025. name: string;
  127026. shader: string;
  127027. };
  127028. }
  127029. declare module BABYLON {
  127030. /** @hidden */
  127031. export var lensFlareVertexShader: {
  127032. name: string;
  127033. shader: string;
  127034. };
  127035. }
  127036. declare module BABYLON {
  127037. /**
  127038. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  127039. * It is usually composed of several `lensFlare`.
  127040. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127041. */
  127042. export class LensFlareSystem {
  127043. /**
  127044. * Define the name of the lens flare system
  127045. */
  127046. name: string;
  127047. /**
  127048. * List of lens flares used in this system.
  127049. */
  127050. lensFlares: LensFlare[];
  127051. /**
  127052. * Define a limit from the border the lens flare can be visible.
  127053. */
  127054. borderLimit: number;
  127055. /**
  127056. * Define a viewport border we do not want to see the lens flare in.
  127057. */
  127058. viewportBorder: number;
  127059. /**
  127060. * Define a predicate which could limit the list of meshes able to occlude the effect.
  127061. */
  127062. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  127063. /**
  127064. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  127065. */
  127066. layerMask: number;
  127067. /**
  127068. * Define the id of the lens flare system in the scene.
  127069. * (equal to name by default)
  127070. */
  127071. id: string;
  127072. private _scene;
  127073. private _emitter;
  127074. private _vertexBuffers;
  127075. private _indexBuffer;
  127076. private _effect;
  127077. private _positionX;
  127078. private _positionY;
  127079. private _isEnabled;
  127080. /** @hidden */
  127081. static _SceneComponentInitialization: (scene: Scene) => void;
  127082. /**
  127083. * Instantiates a lens flare system.
  127084. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  127085. * It is usually composed of several `lensFlare`.
  127086. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127087. * @param name Define the name of the lens flare system in the scene
  127088. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  127089. * @param scene Define the scene the lens flare system belongs to
  127090. */
  127091. constructor(
  127092. /**
  127093. * Define the name of the lens flare system
  127094. */
  127095. name: string, emitter: any, scene: Scene);
  127096. /**
  127097. * Define if the lens flare system is enabled.
  127098. */
  127099. get isEnabled(): boolean;
  127100. set isEnabled(value: boolean);
  127101. /**
  127102. * Get the scene the effects belongs to.
  127103. * @returns the scene holding the lens flare system
  127104. */
  127105. getScene(): Scene;
  127106. /**
  127107. * Get the emitter of the lens flare system.
  127108. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127109. * @returns the emitter of the lens flare system
  127110. */
  127111. getEmitter(): any;
  127112. /**
  127113. * Set the emitter of the lens flare system.
  127114. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  127115. * @param newEmitter Define the new emitter of the system
  127116. */
  127117. setEmitter(newEmitter: any): void;
  127118. /**
  127119. * Get the lens flare system emitter position.
  127120. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  127121. * @returns the position
  127122. */
  127123. getEmitterPosition(): Vector3;
  127124. /**
  127125. * @hidden
  127126. */
  127127. computeEffectivePosition(globalViewport: Viewport): boolean;
  127128. /** @hidden */
  127129. _isVisible(): boolean;
  127130. /**
  127131. * @hidden
  127132. */
  127133. render(): boolean;
  127134. /**
  127135. * Dispose and release the lens flare with its associated resources.
  127136. */
  127137. dispose(): void;
  127138. /**
  127139. * Parse a lens flare system from a JSON repressentation
  127140. * @param parsedLensFlareSystem Define the JSON to parse
  127141. * @param scene Define the scene the parsed system should be instantiated in
  127142. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  127143. * @returns the parsed system
  127144. */
  127145. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  127146. /**
  127147. * Serialize the current Lens Flare System into a JSON representation.
  127148. * @returns the serialized JSON
  127149. */
  127150. serialize(): any;
  127151. }
  127152. }
  127153. declare module BABYLON {
  127154. /**
  127155. * This represents one of the lens effect in a `lensFlareSystem`.
  127156. * It controls one of the indiviual texture used in the effect.
  127157. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127158. */
  127159. export class LensFlare {
  127160. /**
  127161. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127162. */
  127163. size: number;
  127164. /**
  127165. * 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.
  127166. */
  127167. position: number;
  127168. /**
  127169. * Define the lens color.
  127170. */
  127171. color: Color3;
  127172. /**
  127173. * Define the lens texture.
  127174. */
  127175. texture: Nullable<Texture>;
  127176. /**
  127177. * Define the alpha mode to render this particular lens.
  127178. */
  127179. alphaMode: number;
  127180. private _system;
  127181. /**
  127182. * Creates a new Lens Flare.
  127183. * This represents one of the lens effect in a `lensFlareSystem`.
  127184. * It controls one of the indiviual texture used in the effect.
  127185. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127186. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  127187. * @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.
  127188. * @param color Define the lens color
  127189. * @param imgUrl Define the lens texture url
  127190. * @param system Define the `lensFlareSystem` this flare is part of
  127191. * @returns The newly created Lens Flare
  127192. */
  127193. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  127194. /**
  127195. * Instantiates a new Lens Flare.
  127196. * This represents one of the lens effect in a `lensFlareSystem`.
  127197. * It controls one of the indiviual texture used in the effect.
  127198. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127199. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  127200. * @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.
  127201. * @param color Define the lens color
  127202. * @param imgUrl Define the lens texture url
  127203. * @param system Define the `lensFlareSystem` this flare is part of
  127204. */
  127205. constructor(
  127206. /**
  127207. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  127208. */
  127209. size: number,
  127210. /**
  127211. * 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.
  127212. */
  127213. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  127214. /**
  127215. * Dispose and release the lens flare with its associated resources.
  127216. */
  127217. dispose(): void;
  127218. }
  127219. }
  127220. declare module BABYLON {
  127221. interface AbstractScene {
  127222. /**
  127223. * The list of lens flare system added to the scene
  127224. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  127225. */
  127226. lensFlareSystems: Array<LensFlareSystem>;
  127227. /**
  127228. * Removes the given lens flare system from this scene.
  127229. * @param toRemove The lens flare system to remove
  127230. * @returns The index of the removed lens flare system
  127231. */
  127232. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  127233. /**
  127234. * Adds the given lens flare system to this scene
  127235. * @param newLensFlareSystem The lens flare system to add
  127236. */
  127237. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  127238. /**
  127239. * Gets a lens flare system using its name
  127240. * @param name defines the name to look for
  127241. * @returns the lens flare system or null if not found
  127242. */
  127243. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  127244. /**
  127245. * Gets a lens flare system using its id
  127246. * @param id defines the id to look for
  127247. * @returns the lens flare system or null if not found
  127248. */
  127249. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  127250. }
  127251. /**
  127252. * Defines the lens flare scene component responsible to manage any lens flares
  127253. * in a given scene.
  127254. */
  127255. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  127256. /**
  127257. * The component name helpfull to identify the component in the list of scene components.
  127258. */
  127259. readonly name: string;
  127260. /**
  127261. * The scene the component belongs to.
  127262. */
  127263. scene: Scene;
  127264. /**
  127265. * Creates a new instance of the component for the given scene
  127266. * @param scene Defines the scene to register the component in
  127267. */
  127268. constructor(scene: Scene);
  127269. /**
  127270. * Registers the component in a given scene
  127271. */
  127272. register(): void;
  127273. /**
  127274. * Rebuilds the elements related to this component in case of
  127275. * context lost for instance.
  127276. */
  127277. rebuild(): void;
  127278. /**
  127279. * Adds all the elements from the container to the scene
  127280. * @param container the container holding the elements
  127281. */
  127282. addFromContainer(container: AbstractScene): void;
  127283. /**
  127284. * Removes all the elements in the container from the scene
  127285. * @param container contains the elements to remove
  127286. * @param dispose if the removed element should be disposed (default: false)
  127287. */
  127288. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127289. /**
  127290. * Serializes the component data to the specified json object
  127291. * @param serializationObject The object to serialize to
  127292. */
  127293. serialize(serializationObject: any): void;
  127294. /**
  127295. * Disposes the component and the associated ressources.
  127296. */
  127297. dispose(): void;
  127298. private _draw;
  127299. }
  127300. }
  127301. declare module BABYLON {
  127302. /** @hidden */
  127303. export var depthPixelShader: {
  127304. name: string;
  127305. shader: string;
  127306. };
  127307. }
  127308. declare module BABYLON {
  127309. /** @hidden */
  127310. export var depthVertexShader: {
  127311. name: string;
  127312. shader: string;
  127313. };
  127314. }
  127315. declare module BABYLON {
  127316. /**
  127317. * This represents a depth renderer in Babylon.
  127318. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  127319. */
  127320. export class DepthRenderer {
  127321. private _scene;
  127322. private _depthMap;
  127323. private _effect;
  127324. private readonly _storeNonLinearDepth;
  127325. private readonly _clearColor;
  127326. /** Get if the depth renderer is using packed depth or not */
  127327. readonly isPacked: boolean;
  127328. private _cachedDefines;
  127329. private _camera;
  127330. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  127331. enabled: boolean;
  127332. /**
  127333. * Specifiess that the depth renderer will only be used within
  127334. * the camera it is created for.
  127335. * This can help forcing its rendering during the camera processing.
  127336. */
  127337. useOnlyInActiveCamera: boolean;
  127338. /** @hidden */
  127339. static _SceneComponentInitialization: (scene: Scene) => void;
  127340. /**
  127341. * Instantiates a depth renderer
  127342. * @param scene The scene the renderer belongs to
  127343. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  127344. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  127345. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  127346. */
  127347. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  127348. /**
  127349. * Creates the depth rendering effect and checks if the effect is ready.
  127350. * @param subMesh The submesh to be used to render the depth map of
  127351. * @param useInstances If multiple world instances should be used
  127352. * @returns if the depth renderer is ready to render the depth map
  127353. */
  127354. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127355. /**
  127356. * Gets the texture which the depth map will be written to.
  127357. * @returns The depth map texture
  127358. */
  127359. getDepthMap(): RenderTargetTexture;
  127360. /**
  127361. * Disposes of the depth renderer.
  127362. */
  127363. dispose(): void;
  127364. }
  127365. }
  127366. declare module BABYLON {
  127367. /** @hidden */
  127368. export var minmaxReduxPixelShader: {
  127369. name: string;
  127370. shader: string;
  127371. };
  127372. }
  127373. declare module BABYLON {
  127374. /**
  127375. * This class computes a min/max reduction from a texture: it means it computes the minimum
  127376. * and maximum values from all values of the texture.
  127377. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  127378. * The source values are read from the red channel of the texture.
  127379. */
  127380. export class MinMaxReducer {
  127381. /**
  127382. * Observable triggered when the computation has been performed
  127383. */
  127384. onAfterReductionPerformed: Observable<{
  127385. min: number;
  127386. max: number;
  127387. }>;
  127388. protected _camera: Camera;
  127389. protected _sourceTexture: Nullable<RenderTargetTexture>;
  127390. protected _reductionSteps: Nullable<Array<PostProcess>>;
  127391. protected _postProcessManager: PostProcessManager;
  127392. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  127393. protected _forceFullscreenViewport: boolean;
  127394. /**
  127395. * Creates a min/max reducer
  127396. * @param camera The camera to use for the post processes
  127397. */
  127398. constructor(camera: Camera);
  127399. /**
  127400. * Gets the texture used to read the values from.
  127401. */
  127402. get sourceTexture(): Nullable<RenderTargetTexture>;
  127403. /**
  127404. * Sets the source texture to read the values from.
  127405. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  127406. * because in such textures '1' value must not be taken into account to compute the maximum
  127407. * as this value is used to clear the texture.
  127408. * Note that the computation is not activated by calling this function, you must call activate() for that!
  127409. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  127410. * @param depthRedux Indicates if the texture is a depth texture or not
  127411. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  127412. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127413. */
  127414. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127415. /**
  127416. * Defines the refresh rate of the computation.
  127417. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127418. */
  127419. get refreshRate(): number;
  127420. set refreshRate(value: number);
  127421. protected _activated: boolean;
  127422. /**
  127423. * Gets the activation status of the reducer
  127424. */
  127425. get activated(): boolean;
  127426. /**
  127427. * Activates the reduction computation.
  127428. * When activated, the observers registered in onAfterReductionPerformed are
  127429. * called after the compuation is performed
  127430. */
  127431. activate(): void;
  127432. /**
  127433. * Deactivates the reduction computation.
  127434. */
  127435. deactivate(): void;
  127436. /**
  127437. * Disposes the min/max reducer
  127438. * @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.
  127439. */
  127440. dispose(disposeAll?: boolean): void;
  127441. }
  127442. }
  127443. declare module BABYLON {
  127444. /**
  127445. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  127446. */
  127447. export class DepthReducer extends MinMaxReducer {
  127448. private _depthRenderer;
  127449. private _depthRendererId;
  127450. /**
  127451. * Gets the depth renderer used for the computation.
  127452. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  127453. */
  127454. get depthRenderer(): Nullable<DepthRenderer>;
  127455. /**
  127456. * Creates a depth reducer
  127457. * @param camera The camera used to render the depth texture
  127458. */
  127459. constructor(camera: Camera);
  127460. /**
  127461. * Sets the depth renderer to use to generate the depth map
  127462. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  127463. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  127464. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  127465. */
  127466. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  127467. /** @hidden */
  127468. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  127469. /**
  127470. * Activates the reduction computation.
  127471. * When activated, the observers registered in onAfterReductionPerformed are
  127472. * called after the compuation is performed
  127473. */
  127474. activate(): void;
  127475. /**
  127476. * Deactivates the reduction computation.
  127477. */
  127478. deactivate(): void;
  127479. /**
  127480. * Disposes the depth reducer
  127481. * @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.
  127482. */
  127483. dispose(disposeAll?: boolean): void;
  127484. }
  127485. }
  127486. declare module BABYLON {
  127487. /**
  127488. * A CSM implementation allowing casting shadows on large scenes.
  127489. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127490. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  127491. */
  127492. export class CascadedShadowGenerator extends ShadowGenerator {
  127493. private static readonly frustumCornersNDCSpace;
  127494. /**
  127495. * Name of the CSM class
  127496. */
  127497. static CLASSNAME: string;
  127498. /**
  127499. * Defines the default number of cascades used by the CSM.
  127500. */
  127501. static readonly DEFAULT_CASCADES_COUNT: number;
  127502. /**
  127503. * Defines the minimum number of cascades used by the CSM.
  127504. */
  127505. static readonly MIN_CASCADES_COUNT: number;
  127506. /**
  127507. * Defines the maximum number of cascades used by the CSM.
  127508. */
  127509. static readonly MAX_CASCADES_COUNT: number;
  127510. protected _validateFilter(filter: number): number;
  127511. /**
  127512. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  127513. */
  127514. penumbraDarkness: number;
  127515. private _numCascades;
  127516. /**
  127517. * Gets or set the number of cascades used by the CSM.
  127518. */
  127519. get numCascades(): number;
  127520. set numCascades(value: number);
  127521. /**
  127522. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  127523. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  127524. */
  127525. stabilizeCascades: boolean;
  127526. private _freezeShadowCastersBoundingInfo;
  127527. private _freezeShadowCastersBoundingInfoObservable;
  127528. /**
  127529. * Enables or disables the shadow casters bounding info computation.
  127530. * If your shadow casters don't move, you can disable this feature.
  127531. * If it is enabled, the bounding box computation is done every frame.
  127532. */
  127533. get freezeShadowCastersBoundingInfo(): boolean;
  127534. set freezeShadowCastersBoundingInfo(freeze: boolean);
  127535. private _scbiMin;
  127536. private _scbiMax;
  127537. protected _computeShadowCastersBoundingInfo(): void;
  127538. protected _shadowCastersBoundingInfo: BoundingInfo;
  127539. /**
  127540. * Gets or sets the shadow casters bounding info.
  127541. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  127542. * so that the system won't overwrite the bounds you provide
  127543. */
  127544. get shadowCastersBoundingInfo(): BoundingInfo;
  127545. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  127546. protected _breaksAreDirty: boolean;
  127547. protected _minDistance: number;
  127548. protected _maxDistance: number;
  127549. /**
  127550. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  127551. *
  127552. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  127553. * If you don't know these values, simply leave them to their defaults and don't call this function.
  127554. * @param min minimal distance for the breaks (default to 0.)
  127555. * @param max maximal distance for the breaks (default to 1.)
  127556. */
  127557. setMinMaxDistance(min: number, max: number): void;
  127558. /** Gets the minimal distance used in the cascade break computation */
  127559. get minDistance(): number;
  127560. /** Gets the maximal distance used in the cascade break computation */
  127561. get maxDistance(): number;
  127562. /**
  127563. * Gets the class name of that object
  127564. * @returns "CascadedShadowGenerator"
  127565. */
  127566. getClassName(): string;
  127567. private _cascadeMinExtents;
  127568. private _cascadeMaxExtents;
  127569. /**
  127570. * Gets a cascade minimum extents
  127571. * @param cascadeIndex index of the cascade
  127572. * @returns the minimum cascade extents
  127573. */
  127574. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  127575. /**
  127576. * Gets a cascade maximum extents
  127577. * @param cascadeIndex index of the cascade
  127578. * @returns the maximum cascade extents
  127579. */
  127580. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  127581. private _cascades;
  127582. private _currentLayer;
  127583. private _viewSpaceFrustumsZ;
  127584. private _viewMatrices;
  127585. private _projectionMatrices;
  127586. private _transformMatrices;
  127587. private _transformMatricesAsArray;
  127588. private _frustumLengths;
  127589. private _lightSizeUVCorrection;
  127590. private _depthCorrection;
  127591. private _frustumCornersWorldSpace;
  127592. private _frustumCenter;
  127593. private _shadowCameraPos;
  127594. private _shadowMaxZ;
  127595. /**
  127596. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  127597. * It defaults to camera.maxZ
  127598. */
  127599. get shadowMaxZ(): number;
  127600. /**
  127601. * Sets the shadow max z distance.
  127602. */
  127603. set shadowMaxZ(value: number);
  127604. protected _debug: boolean;
  127605. /**
  127606. * Gets or sets the debug flag.
  127607. * When enabled, the cascades are materialized by different colors on the screen.
  127608. */
  127609. get debug(): boolean;
  127610. set debug(dbg: boolean);
  127611. private _depthClamp;
  127612. /**
  127613. * Gets or sets the depth clamping value.
  127614. *
  127615. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  127616. * to account for the shadow casters far away.
  127617. *
  127618. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  127619. */
  127620. get depthClamp(): boolean;
  127621. set depthClamp(value: boolean);
  127622. private _cascadeBlendPercentage;
  127623. /**
  127624. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  127625. * It defaults to 0.1 (10% blending).
  127626. */
  127627. get cascadeBlendPercentage(): number;
  127628. set cascadeBlendPercentage(value: number);
  127629. private _lambda;
  127630. /**
  127631. * Gets or set the lambda parameter.
  127632. * This parameter is used to split the camera frustum and create the cascades.
  127633. * 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.
  127634. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  127635. */
  127636. get lambda(): number;
  127637. set lambda(value: number);
  127638. /**
  127639. * Gets the view matrix corresponding to a given cascade
  127640. * @param cascadeNum cascade to retrieve the view matrix from
  127641. * @returns the cascade view matrix
  127642. */
  127643. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  127644. /**
  127645. * Gets the projection matrix corresponding to a given cascade
  127646. * @param cascadeNum cascade to retrieve the projection matrix from
  127647. * @returns the cascade projection matrix
  127648. */
  127649. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  127650. /**
  127651. * Gets the transformation matrix corresponding to a given cascade
  127652. * @param cascadeNum cascade to retrieve the transformation matrix from
  127653. * @returns the cascade transformation matrix
  127654. */
  127655. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  127656. private _depthRenderer;
  127657. /**
  127658. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  127659. *
  127660. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  127661. *
  127662. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  127663. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  127664. * @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
  127665. */
  127666. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  127667. private _depthReducer;
  127668. private _autoCalcDepthBounds;
  127669. /**
  127670. * Gets or sets the autoCalcDepthBounds property.
  127671. *
  127672. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  127673. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  127674. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  127675. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  127676. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  127677. */
  127678. get autoCalcDepthBounds(): boolean;
  127679. set autoCalcDepthBounds(value: boolean);
  127680. /**
  127681. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  127682. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  127683. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  127684. * for setting the refresh rate on the renderer yourself!
  127685. */
  127686. get autoCalcDepthBoundsRefreshRate(): number;
  127687. set autoCalcDepthBoundsRefreshRate(value: number);
  127688. /**
  127689. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  127690. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  127691. * you change the camera near/far planes!
  127692. */
  127693. splitFrustum(): void;
  127694. private _splitFrustum;
  127695. private _computeMatrices;
  127696. private _computeFrustumInWorldSpace;
  127697. private _computeCascadeFrustum;
  127698. /** @hidden */
  127699. static _SceneComponentInitialization: (scene: Scene) => void;
  127700. /**
  127701. * Creates a Cascaded Shadow Generator object.
  127702. * A ShadowGenerator is the required tool to use the shadows.
  127703. * Each directional light casting shadows needs to use its own ShadowGenerator.
  127704. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  127705. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  127706. * @param light The directional light object generating the shadows.
  127707. * @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.
  127708. */
  127709. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  127710. protected _initializeGenerator(): void;
  127711. protected _createTargetRenderTexture(): void;
  127712. protected _initializeShadowMap(): void;
  127713. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  127714. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  127715. /**
  127716. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  127717. * @param defines Defines of the material we want to update
  127718. * @param lightIndex Index of the light in the enabled light list of the material
  127719. */
  127720. prepareDefines(defines: any, lightIndex: number): void;
  127721. /**
  127722. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  127723. * defined in the generator but impacting the effect).
  127724. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  127725. * @param effect The effect we are binfing the information for
  127726. */
  127727. bindShadowLight(lightIndex: string, effect: Effect): void;
  127728. /**
  127729. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  127730. * (eq to view projection * shadow projection matrices)
  127731. * @returns The transform matrix used to create the shadow map
  127732. */
  127733. getTransformMatrix(): Matrix;
  127734. /**
  127735. * Disposes the ShadowGenerator.
  127736. * Returns nothing.
  127737. */
  127738. dispose(): void;
  127739. /**
  127740. * Serializes the shadow generator setup to a json object.
  127741. * @returns The serialized JSON object
  127742. */
  127743. serialize(): any;
  127744. /**
  127745. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  127746. * @param parsedShadowGenerator The JSON object to parse
  127747. * @param scene The scene to create the shadow map for
  127748. * @returns The parsed shadow generator
  127749. */
  127750. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  127751. }
  127752. }
  127753. declare module BABYLON {
  127754. /**
  127755. * Defines the shadow generator component responsible to manage any shadow generators
  127756. * in a given scene.
  127757. */
  127758. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  127759. /**
  127760. * The component name helpfull to identify the component in the list of scene components.
  127761. */
  127762. readonly name: string;
  127763. /**
  127764. * The scene the component belongs to.
  127765. */
  127766. scene: Scene;
  127767. /**
  127768. * Creates a new instance of the component for the given scene
  127769. * @param scene Defines the scene to register the component in
  127770. */
  127771. constructor(scene: Scene);
  127772. /**
  127773. * Registers the component in a given scene
  127774. */
  127775. register(): void;
  127776. /**
  127777. * Rebuilds the elements related to this component in case of
  127778. * context lost for instance.
  127779. */
  127780. rebuild(): void;
  127781. /**
  127782. * Serializes the component data to the specified json object
  127783. * @param serializationObject The object to serialize to
  127784. */
  127785. serialize(serializationObject: any): void;
  127786. /**
  127787. * Adds all the elements from the container to the scene
  127788. * @param container the container holding the elements
  127789. */
  127790. addFromContainer(container: AbstractScene): void;
  127791. /**
  127792. * Removes all the elements in the container from the scene
  127793. * @param container contains the elements to remove
  127794. * @param dispose if the removed element should be disposed (default: false)
  127795. */
  127796. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127797. /**
  127798. * Rebuilds the elements related to this component in case of
  127799. * context lost for instance.
  127800. */
  127801. dispose(): void;
  127802. private _gatherRenderTargets;
  127803. }
  127804. }
  127805. declare module BABYLON {
  127806. /**
  127807. * A point light is a light defined by an unique point in world space.
  127808. * The light is emitted in every direction from this point.
  127809. * A good example of a point light is a standard light bulb.
  127810. * Documentation: https://doc.babylonjs.com/babylon101/lights
  127811. */
  127812. export class PointLight extends ShadowLight {
  127813. private _shadowAngle;
  127814. /**
  127815. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127816. * This specifies what angle the shadow will use to be created.
  127817. *
  127818. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127819. */
  127820. get shadowAngle(): number;
  127821. /**
  127822. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127823. * This specifies what angle the shadow will use to be created.
  127824. *
  127825. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  127826. */
  127827. set shadowAngle(value: number);
  127828. /**
  127829. * Gets the direction if it has been set.
  127830. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127831. */
  127832. get direction(): Vector3;
  127833. /**
  127834. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  127835. */
  127836. set direction(value: Vector3);
  127837. /**
  127838. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  127839. * A PointLight emits the light in every direction.
  127840. * It can cast shadows.
  127841. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  127842. * ```javascript
  127843. * var pointLight = new PointLight("pl", camera.position, scene);
  127844. * ```
  127845. * Documentation : https://doc.babylonjs.com/babylon101/lights
  127846. * @param name The light friendly name
  127847. * @param position The position of the point light in the scene
  127848. * @param scene The scene the lights belongs to
  127849. */
  127850. constructor(name: string, position: Vector3, scene: Scene);
  127851. /**
  127852. * Returns the string "PointLight"
  127853. * @returns the class name
  127854. */
  127855. getClassName(): string;
  127856. /**
  127857. * Returns the integer 0.
  127858. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  127859. */
  127860. getTypeID(): number;
  127861. /**
  127862. * Specifies wether or not the shadowmap should be a cube texture.
  127863. * @returns true if the shadowmap needs to be a cube texture.
  127864. */
  127865. needCube(): boolean;
  127866. /**
  127867. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  127868. * @param faceIndex The index of the face we are computed the direction to generate shadow
  127869. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  127870. */
  127871. getShadowDirection(faceIndex?: number): Vector3;
  127872. /**
  127873. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  127874. * - fov = PI / 2
  127875. * - aspect ratio : 1.0
  127876. * - z-near and far equal to the active camera minZ and maxZ.
  127877. * Returns the PointLight.
  127878. */
  127879. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  127880. protected _buildUniformLayout(): void;
  127881. /**
  127882. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  127883. * @param effect The effect to update
  127884. * @param lightIndex The index of the light in the effect to update
  127885. * @returns The point light
  127886. */
  127887. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  127888. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  127889. /**
  127890. * Prepares the list of defines specific to the light type.
  127891. * @param defines the list of defines
  127892. * @param lightIndex defines the index of the light for the effect
  127893. */
  127894. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  127895. }
  127896. }
  127897. declare module BABYLON {
  127898. /**
  127899. * Header information of HDR texture files.
  127900. */
  127901. export interface HDRInfo {
  127902. /**
  127903. * The height of the texture in pixels.
  127904. */
  127905. height: number;
  127906. /**
  127907. * The width of the texture in pixels.
  127908. */
  127909. width: number;
  127910. /**
  127911. * The index of the beginning of the data in the binary file.
  127912. */
  127913. dataPosition: number;
  127914. }
  127915. /**
  127916. * This groups tools to convert HDR texture to native colors array.
  127917. */
  127918. export class HDRTools {
  127919. private static Ldexp;
  127920. private static Rgbe2float;
  127921. private static readStringLine;
  127922. /**
  127923. * Reads header information from an RGBE texture stored in a native array.
  127924. * More information on this format are available here:
  127925. * https://en.wikipedia.org/wiki/RGBE_image_format
  127926. *
  127927. * @param uint8array The binary file stored in native array.
  127928. * @return The header information.
  127929. */
  127930. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  127931. /**
  127932. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  127933. * This RGBE texture needs to store the information as a panorama.
  127934. *
  127935. * More information on this format are available here:
  127936. * https://en.wikipedia.org/wiki/RGBE_image_format
  127937. *
  127938. * @param buffer The binary file stored in an array buffer.
  127939. * @param size The expected size of the extracted cubemap.
  127940. * @return The Cube Map information.
  127941. */
  127942. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  127943. /**
  127944. * Returns the pixels data extracted from an RGBE texture.
  127945. * This pixels will be stored left to right up to down in the R G B order in one array.
  127946. *
  127947. * More information on this format are available here:
  127948. * https://en.wikipedia.org/wiki/RGBE_image_format
  127949. *
  127950. * @param uint8array The binary file stored in an array buffer.
  127951. * @param hdrInfo The header information of the file.
  127952. * @return The pixels data in RGB right to left up to down order.
  127953. */
  127954. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  127955. private static RGBE_ReadPixels_RLE;
  127956. }
  127957. }
  127958. declare module BABYLON {
  127959. /**
  127960. * This represents a texture coming from an HDR input.
  127961. *
  127962. * The only supported format is currently panorama picture stored in RGBE format.
  127963. * Example of such files can be found on HDRLib: http://hdrlib.com/
  127964. */
  127965. export class HDRCubeTexture extends BaseTexture {
  127966. private static _facesMapping;
  127967. private _generateHarmonics;
  127968. private _noMipmap;
  127969. private _textureMatrix;
  127970. private _size;
  127971. private _onLoad;
  127972. private _onError;
  127973. /**
  127974. * The texture URL.
  127975. */
  127976. url: string;
  127977. /**
  127978. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  127979. */
  127980. coordinatesMode: number;
  127981. protected _isBlocking: boolean;
  127982. /**
  127983. * Sets wether or not the texture is blocking during loading.
  127984. */
  127985. set isBlocking(value: boolean);
  127986. /**
  127987. * Gets wether or not the texture is blocking during loading.
  127988. */
  127989. get isBlocking(): boolean;
  127990. protected _rotationY: number;
  127991. /**
  127992. * Sets texture matrix rotation angle around Y axis in radians.
  127993. */
  127994. set rotationY(value: number);
  127995. /**
  127996. * Gets texture matrix rotation angle around Y axis radians.
  127997. */
  127998. get rotationY(): number;
  127999. /**
  128000. * Gets or sets the center of the bounding box associated with the cube texture
  128001. * It must define where the camera used to render the texture was set
  128002. */
  128003. boundingBoxPosition: Vector3;
  128004. private _boundingBoxSize;
  128005. /**
  128006. * Gets or sets the size of the bounding box associated with the cube texture
  128007. * When defined, the cubemap will switch to local mode
  128008. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  128009. * @example https://www.babylonjs-playground.com/#RNASML
  128010. */
  128011. set boundingBoxSize(value: Vector3);
  128012. get boundingBoxSize(): Vector3;
  128013. /**
  128014. * Instantiates an HDRTexture from the following parameters.
  128015. *
  128016. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  128017. * @param scene The scene the texture will be used in
  128018. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  128019. * @param noMipmap Forces to not generate the mipmap if true
  128020. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  128021. * @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)
  128022. * @param reserved Reserved flag for internal use.
  128023. */
  128024. 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>);
  128025. /**
  128026. * Get the current class name of the texture useful for serialization or dynamic coding.
  128027. * @returns "HDRCubeTexture"
  128028. */
  128029. getClassName(): string;
  128030. /**
  128031. * Occurs when the file is raw .hdr file.
  128032. */
  128033. private loadTexture;
  128034. clone(): HDRCubeTexture;
  128035. delayLoad(): void;
  128036. /**
  128037. * Get the texture reflection matrix used to rotate/transform the reflection.
  128038. * @returns the reflection matrix
  128039. */
  128040. getReflectionTextureMatrix(): Matrix;
  128041. /**
  128042. * Set the texture reflection matrix used to rotate/transform the reflection.
  128043. * @param value Define the reflection matrix to set
  128044. */
  128045. setReflectionTextureMatrix(value: Matrix): void;
  128046. /**
  128047. * Parses a JSON representation of an HDR Texture in order to create the texture
  128048. * @param parsedTexture Define the JSON representation
  128049. * @param scene Define the scene the texture should be created in
  128050. * @param rootUrl Define the root url in case we need to load relative dependencies
  128051. * @returns the newly created texture after parsing
  128052. */
  128053. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  128054. serialize(): any;
  128055. }
  128056. }
  128057. declare module BABYLON {
  128058. /**
  128059. * Class used to control physics engine
  128060. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  128061. */
  128062. export class PhysicsEngine implements IPhysicsEngine {
  128063. private _physicsPlugin;
  128064. /**
  128065. * Global value used to control the smallest number supported by the simulation
  128066. */
  128067. static Epsilon: number;
  128068. private _impostors;
  128069. private _joints;
  128070. private _subTimeStep;
  128071. /**
  128072. * Gets the gravity vector used by the simulation
  128073. */
  128074. gravity: Vector3;
  128075. /**
  128076. * Factory used to create the default physics plugin.
  128077. * @returns The default physics plugin
  128078. */
  128079. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  128080. /**
  128081. * Creates a new Physics Engine
  128082. * @param gravity defines the gravity vector used by the simulation
  128083. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  128084. */
  128085. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  128086. /**
  128087. * Sets the gravity vector used by the simulation
  128088. * @param gravity defines the gravity vector to use
  128089. */
  128090. setGravity(gravity: Vector3): void;
  128091. /**
  128092. * Set the time step of the physics engine.
  128093. * Default is 1/60.
  128094. * To slow it down, enter 1/600 for example.
  128095. * To speed it up, 1/30
  128096. * @param newTimeStep defines the new timestep to apply to this world.
  128097. */
  128098. setTimeStep(newTimeStep?: number): void;
  128099. /**
  128100. * Get the time step of the physics engine.
  128101. * @returns the current time step
  128102. */
  128103. getTimeStep(): number;
  128104. /**
  128105. * Set the sub time step of the physics engine.
  128106. * Default is 0 meaning there is no sub steps
  128107. * To increase physics resolution precision, set a small value (like 1 ms)
  128108. * @param subTimeStep defines the new sub timestep used for physics resolution.
  128109. */
  128110. setSubTimeStep(subTimeStep?: number): void;
  128111. /**
  128112. * Get the sub time step of the physics engine.
  128113. * @returns the current sub time step
  128114. */
  128115. getSubTimeStep(): number;
  128116. /**
  128117. * Release all resources
  128118. */
  128119. dispose(): void;
  128120. /**
  128121. * Gets the name of the current physics plugin
  128122. * @returns the name of the plugin
  128123. */
  128124. getPhysicsPluginName(): string;
  128125. /**
  128126. * Adding a new impostor for the impostor tracking.
  128127. * This will be done by the impostor itself.
  128128. * @param impostor the impostor to add
  128129. */
  128130. addImpostor(impostor: PhysicsImpostor): void;
  128131. /**
  128132. * Remove an impostor from the engine.
  128133. * This impostor and its mesh will not longer be updated by the physics engine.
  128134. * @param impostor the impostor to remove
  128135. */
  128136. removeImpostor(impostor: PhysicsImpostor): void;
  128137. /**
  128138. * Add a joint to the physics engine
  128139. * @param mainImpostor defines the main impostor to which the joint is added.
  128140. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  128141. * @param joint defines the joint that will connect both impostors.
  128142. */
  128143. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128144. /**
  128145. * Removes a joint from the simulation
  128146. * @param mainImpostor defines the impostor used with the joint
  128147. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  128148. * @param joint defines the joint to remove
  128149. */
  128150. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  128151. /**
  128152. * Called by the scene. No need to call it.
  128153. * @param delta defines the timespam between frames
  128154. */
  128155. _step(delta: number): void;
  128156. /**
  128157. * Gets the current plugin used to run the simulation
  128158. * @returns current plugin
  128159. */
  128160. getPhysicsPlugin(): IPhysicsEnginePlugin;
  128161. /**
  128162. * Gets the list of physic impostors
  128163. * @returns an array of PhysicsImpostor
  128164. */
  128165. getImpostors(): Array<PhysicsImpostor>;
  128166. /**
  128167. * Gets the impostor for a physics enabled object
  128168. * @param object defines the object impersonated by the impostor
  128169. * @returns the PhysicsImpostor or null if not found
  128170. */
  128171. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  128172. /**
  128173. * Gets the impostor for a physics body object
  128174. * @param body defines physics body used by the impostor
  128175. * @returns the PhysicsImpostor or null if not found
  128176. */
  128177. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  128178. /**
  128179. * Does a raycast in the physics world
  128180. * @param from when should the ray start?
  128181. * @param to when should the ray end?
  128182. * @returns PhysicsRaycastResult
  128183. */
  128184. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128185. }
  128186. }
  128187. declare module BABYLON {
  128188. /** @hidden */
  128189. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  128190. private _useDeltaForWorldStep;
  128191. world: any;
  128192. name: string;
  128193. private _physicsMaterials;
  128194. private _fixedTimeStep;
  128195. private _cannonRaycastResult;
  128196. private _raycastResult;
  128197. private _physicsBodysToRemoveAfterStep;
  128198. BJSCANNON: any;
  128199. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  128200. setGravity(gravity: Vector3): void;
  128201. setTimeStep(timeStep: number): void;
  128202. getTimeStep(): number;
  128203. executeStep(delta: number): void;
  128204. private _removeMarkedPhysicsBodiesFromWorld;
  128205. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128206. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128207. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128208. private _processChildMeshes;
  128209. removePhysicsBody(impostor: PhysicsImpostor): void;
  128210. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128211. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128212. private _addMaterial;
  128213. private _checkWithEpsilon;
  128214. private _createShape;
  128215. private _createHeightmap;
  128216. private _minus90X;
  128217. private _plus90X;
  128218. private _tmpPosition;
  128219. private _tmpDeltaPosition;
  128220. private _tmpUnityRotation;
  128221. private _updatePhysicsBodyTransformation;
  128222. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128223. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128224. isSupported(): boolean;
  128225. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128226. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128227. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128228. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128229. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128230. getBodyMass(impostor: PhysicsImpostor): number;
  128231. getBodyFriction(impostor: PhysicsImpostor): number;
  128232. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128233. getBodyRestitution(impostor: PhysicsImpostor): number;
  128234. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128235. sleepBody(impostor: PhysicsImpostor): void;
  128236. wakeUpBody(impostor: PhysicsImpostor): void;
  128237. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  128238. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128239. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128240. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128241. getRadius(impostor: PhysicsImpostor): number;
  128242. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128243. dispose(): void;
  128244. private _extendNamespace;
  128245. /**
  128246. * Does a raycast in the physics world
  128247. * @param from when should the ray start?
  128248. * @param to when should the ray end?
  128249. * @returns PhysicsRaycastResult
  128250. */
  128251. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128252. }
  128253. }
  128254. declare module BABYLON {
  128255. /** @hidden */
  128256. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  128257. world: any;
  128258. name: string;
  128259. BJSOIMO: any;
  128260. private _raycastResult;
  128261. constructor(iterations?: number, oimoInjection?: any);
  128262. setGravity(gravity: Vector3): void;
  128263. setTimeStep(timeStep: number): void;
  128264. getTimeStep(): number;
  128265. private _tmpImpostorsArray;
  128266. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128267. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128268. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128269. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128270. private _tmpPositionVector;
  128271. removePhysicsBody(impostor: PhysicsImpostor): void;
  128272. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128273. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128274. isSupported(): boolean;
  128275. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128276. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128277. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128278. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128279. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128280. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128281. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128282. getBodyMass(impostor: PhysicsImpostor): number;
  128283. getBodyFriction(impostor: PhysicsImpostor): number;
  128284. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128285. getBodyRestitution(impostor: PhysicsImpostor): number;
  128286. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128287. sleepBody(impostor: PhysicsImpostor): void;
  128288. wakeUpBody(impostor: PhysicsImpostor): void;
  128289. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128290. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  128291. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  128292. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128293. getRadius(impostor: PhysicsImpostor): number;
  128294. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128295. dispose(): void;
  128296. /**
  128297. * Does a raycast in the physics world
  128298. * @param from when should the ray start?
  128299. * @param to when should the ray end?
  128300. * @returns PhysicsRaycastResult
  128301. */
  128302. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128303. }
  128304. }
  128305. declare module BABYLON {
  128306. /**
  128307. * Class containing static functions to help procedurally build meshes
  128308. */
  128309. export class RibbonBuilder {
  128310. /**
  128311. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  128312. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  128313. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  128314. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  128315. * * 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
  128316. * * 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
  128317. * * 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
  128318. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128319. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128320. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128321. * * 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
  128322. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  128323. * * 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
  128324. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  128325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128326. * @param name defines the name of the mesh
  128327. * @param options defines the options used to create the mesh
  128328. * @param scene defines the hosting scene
  128329. * @returns the ribbon mesh
  128330. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  128331. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128332. */
  128333. static CreateRibbon(name: string, options: {
  128334. pathArray: Vector3[][];
  128335. closeArray?: boolean;
  128336. closePath?: boolean;
  128337. offset?: number;
  128338. updatable?: boolean;
  128339. sideOrientation?: number;
  128340. frontUVs?: Vector4;
  128341. backUVs?: Vector4;
  128342. instance?: Mesh;
  128343. invertUV?: boolean;
  128344. uvs?: Vector2[];
  128345. colors?: Color4[];
  128346. }, scene?: Nullable<Scene>): Mesh;
  128347. }
  128348. }
  128349. declare module BABYLON {
  128350. /**
  128351. * Class containing static functions to help procedurally build meshes
  128352. */
  128353. export class ShapeBuilder {
  128354. /**
  128355. * 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.
  128356. * * 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.
  128357. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128358. * * 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.
  128359. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  128360. * * 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
  128361. * * 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
  128362. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  128363. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128364. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128365. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  128366. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  128367. * @param name defines the name of the mesh
  128368. * @param options defines the options used to create the mesh
  128369. * @param scene defines the hosting scene
  128370. * @returns the extruded shape mesh
  128371. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128372. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128373. */
  128374. static ExtrudeShape(name: string, options: {
  128375. shape: Vector3[];
  128376. path: Vector3[];
  128377. scale?: number;
  128378. rotation?: number;
  128379. cap?: number;
  128380. updatable?: boolean;
  128381. sideOrientation?: number;
  128382. frontUVs?: Vector4;
  128383. backUVs?: Vector4;
  128384. instance?: Mesh;
  128385. invertUV?: boolean;
  128386. }, scene?: Nullable<Scene>): Mesh;
  128387. /**
  128388. * Creates an custom extruded shape mesh.
  128389. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  128390. * * 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.
  128391. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  128392. * * 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
  128393. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  128394. * * 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
  128395. * * It must returns a float value that will be the scale value applied to the shape on each path point
  128396. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  128397. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  128398. * * 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
  128399. * * 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
  128400. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  128401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  128402. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  128403. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  128404. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  128405. * @param name defines the name of the mesh
  128406. * @param options defines the options used to create the mesh
  128407. * @param scene defines the hosting scene
  128408. * @returns the custom extruded shape mesh
  128409. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  128410. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  128411. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  128412. */
  128413. static ExtrudeShapeCustom(name: string, options: {
  128414. shape: Vector3[];
  128415. path: Vector3[];
  128416. scaleFunction?: any;
  128417. rotationFunction?: any;
  128418. ribbonCloseArray?: boolean;
  128419. ribbonClosePath?: boolean;
  128420. cap?: number;
  128421. updatable?: boolean;
  128422. sideOrientation?: number;
  128423. frontUVs?: Vector4;
  128424. backUVs?: Vector4;
  128425. instance?: Mesh;
  128426. invertUV?: boolean;
  128427. }, scene?: Nullable<Scene>): Mesh;
  128428. private static _ExtrudeShapeGeneric;
  128429. }
  128430. }
  128431. declare module BABYLON {
  128432. /**
  128433. * AmmoJS Physics plugin
  128434. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  128435. * @see https://github.com/kripken/ammo.js/
  128436. */
  128437. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  128438. private _useDeltaForWorldStep;
  128439. /**
  128440. * Reference to the Ammo library
  128441. */
  128442. bjsAMMO: any;
  128443. /**
  128444. * Created ammoJS world which physics bodies are added to
  128445. */
  128446. world: any;
  128447. /**
  128448. * Name of the plugin
  128449. */
  128450. name: string;
  128451. private _timeStep;
  128452. private _fixedTimeStep;
  128453. private _maxSteps;
  128454. private _tmpQuaternion;
  128455. private _tmpAmmoTransform;
  128456. private _tmpAmmoQuaternion;
  128457. private _tmpAmmoConcreteContactResultCallback;
  128458. private _collisionConfiguration;
  128459. private _dispatcher;
  128460. private _overlappingPairCache;
  128461. private _solver;
  128462. private _softBodySolver;
  128463. private _tmpAmmoVectorA;
  128464. private _tmpAmmoVectorB;
  128465. private _tmpAmmoVectorC;
  128466. private _tmpAmmoVectorD;
  128467. private _tmpContactCallbackResult;
  128468. private _tmpAmmoVectorRCA;
  128469. private _tmpAmmoVectorRCB;
  128470. private _raycastResult;
  128471. private static readonly DISABLE_COLLISION_FLAG;
  128472. private static readonly KINEMATIC_FLAG;
  128473. private static readonly DISABLE_DEACTIVATION_FLAG;
  128474. /**
  128475. * Initializes the ammoJS plugin
  128476. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  128477. * @param ammoInjection can be used to inject your own ammo reference
  128478. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  128479. */
  128480. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  128481. /**
  128482. * Sets the gravity of the physics world (m/(s^2))
  128483. * @param gravity Gravity to set
  128484. */
  128485. setGravity(gravity: Vector3): void;
  128486. /**
  128487. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  128488. * @param timeStep timestep to use in seconds
  128489. */
  128490. setTimeStep(timeStep: number): void;
  128491. /**
  128492. * 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)
  128493. * @param fixedTimeStep fixedTimeStep to use in seconds
  128494. */
  128495. setFixedTimeStep(fixedTimeStep: number): void;
  128496. /**
  128497. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  128498. * @param maxSteps the maximum number of steps by the physics engine per frame
  128499. */
  128500. setMaxSteps(maxSteps: number): void;
  128501. /**
  128502. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  128503. * @returns the current timestep in seconds
  128504. */
  128505. getTimeStep(): number;
  128506. /**
  128507. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  128508. */
  128509. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  128510. private _isImpostorInContact;
  128511. private _isImpostorPairInContact;
  128512. private _stepSimulation;
  128513. /**
  128514. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  128515. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  128516. * After the step the babylon meshes are set to the position of the physics imposters
  128517. * @param delta amount of time to step forward
  128518. * @param impostors array of imposters to update before/after the step
  128519. */
  128520. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  128521. /**
  128522. * Update babylon mesh to match physics world object
  128523. * @param impostor imposter to match
  128524. */
  128525. private _afterSoftStep;
  128526. /**
  128527. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128528. * @param impostor imposter to match
  128529. */
  128530. private _ropeStep;
  128531. /**
  128532. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  128533. * @param impostor imposter to match
  128534. */
  128535. private _softbodyOrClothStep;
  128536. private _tmpVector;
  128537. private _tmpMatrix;
  128538. /**
  128539. * Applies an impulse on the imposter
  128540. * @param impostor imposter to apply impulse to
  128541. * @param force amount of force to be applied to the imposter
  128542. * @param contactPoint the location to apply the impulse on the imposter
  128543. */
  128544. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128545. /**
  128546. * Applies a force on the imposter
  128547. * @param impostor imposter to apply force
  128548. * @param force amount of force to be applied to the imposter
  128549. * @param contactPoint the location to apply the force on the imposter
  128550. */
  128551. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  128552. /**
  128553. * Creates a physics body using the plugin
  128554. * @param impostor the imposter to create the physics body on
  128555. */
  128556. generatePhysicsBody(impostor: PhysicsImpostor): void;
  128557. /**
  128558. * Removes the physics body from the imposter and disposes of the body's memory
  128559. * @param impostor imposter to remove the physics body from
  128560. */
  128561. removePhysicsBody(impostor: PhysicsImpostor): void;
  128562. /**
  128563. * Generates a joint
  128564. * @param impostorJoint the imposter joint to create the joint with
  128565. */
  128566. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  128567. /**
  128568. * Removes a joint
  128569. * @param impostorJoint the imposter joint to remove the joint from
  128570. */
  128571. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  128572. private _addMeshVerts;
  128573. /**
  128574. * Initialise the soft body vertices to match its object's (mesh) vertices
  128575. * Softbody vertices (nodes) are in world space and to match this
  128576. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  128577. * @param impostor to create the softbody for
  128578. */
  128579. private _softVertexData;
  128580. /**
  128581. * Create an impostor's soft body
  128582. * @param impostor to create the softbody for
  128583. */
  128584. private _createSoftbody;
  128585. /**
  128586. * Create cloth for an impostor
  128587. * @param impostor to create the softbody for
  128588. */
  128589. private _createCloth;
  128590. /**
  128591. * Create rope for an impostor
  128592. * @param impostor to create the softbody for
  128593. */
  128594. private _createRope;
  128595. /**
  128596. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  128597. * @param impostor to create the custom physics shape for
  128598. */
  128599. private _createCustom;
  128600. private _addHullVerts;
  128601. private _createShape;
  128602. /**
  128603. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  128604. * @param impostor imposter containing the physics body and babylon object
  128605. */
  128606. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  128607. /**
  128608. * Sets the babylon object's position/rotation from the physics body's position/rotation
  128609. * @param impostor imposter containing the physics body and babylon object
  128610. * @param newPosition new position
  128611. * @param newRotation new rotation
  128612. */
  128613. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  128614. /**
  128615. * If this plugin is supported
  128616. * @returns true if its supported
  128617. */
  128618. isSupported(): boolean;
  128619. /**
  128620. * Sets the linear velocity of the physics body
  128621. * @param impostor imposter to set the velocity on
  128622. * @param velocity velocity to set
  128623. */
  128624. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128625. /**
  128626. * Sets the angular velocity of the physics body
  128627. * @param impostor imposter to set the velocity on
  128628. * @param velocity velocity to set
  128629. */
  128630. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  128631. /**
  128632. * gets the linear velocity
  128633. * @param impostor imposter to get linear velocity from
  128634. * @returns linear velocity
  128635. */
  128636. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128637. /**
  128638. * gets the angular velocity
  128639. * @param impostor imposter to get angular velocity from
  128640. * @returns angular velocity
  128641. */
  128642. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  128643. /**
  128644. * Sets the mass of physics body
  128645. * @param impostor imposter to set the mass on
  128646. * @param mass mass to set
  128647. */
  128648. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  128649. /**
  128650. * Gets the mass of the physics body
  128651. * @param impostor imposter to get the mass from
  128652. * @returns mass
  128653. */
  128654. getBodyMass(impostor: PhysicsImpostor): number;
  128655. /**
  128656. * Gets friction of the impostor
  128657. * @param impostor impostor to get friction from
  128658. * @returns friction value
  128659. */
  128660. getBodyFriction(impostor: PhysicsImpostor): number;
  128661. /**
  128662. * Sets friction of the impostor
  128663. * @param impostor impostor to set friction on
  128664. * @param friction friction value
  128665. */
  128666. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  128667. /**
  128668. * Gets restitution of the impostor
  128669. * @param impostor impostor to get restitution from
  128670. * @returns restitution value
  128671. */
  128672. getBodyRestitution(impostor: PhysicsImpostor): number;
  128673. /**
  128674. * Sets resitution of the impostor
  128675. * @param impostor impostor to set resitution on
  128676. * @param restitution resitution value
  128677. */
  128678. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  128679. /**
  128680. * Gets pressure inside the impostor
  128681. * @param impostor impostor to get pressure from
  128682. * @returns pressure value
  128683. */
  128684. getBodyPressure(impostor: PhysicsImpostor): number;
  128685. /**
  128686. * Sets pressure inside a soft body impostor
  128687. * Cloth and rope must remain 0 pressure
  128688. * @param impostor impostor to set pressure on
  128689. * @param pressure pressure value
  128690. */
  128691. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  128692. /**
  128693. * Gets stiffness of the impostor
  128694. * @param impostor impostor to get stiffness from
  128695. * @returns pressure value
  128696. */
  128697. getBodyStiffness(impostor: PhysicsImpostor): number;
  128698. /**
  128699. * Sets stiffness of the impostor
  128700. * @param impostor impostor to set stiffness on
  128701. * @param stiffness stiffness value from 0 to 1
  128702. */
  128703. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  128704. /**
  128705. * Gets velocityIterations of the impostor
  128706. * @param impostor impostor to get velocity iterations from
  128707. * @returns velocityIterations value
  128708. */
  128709. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  128710. /**
  128711. * Sets velocityIterations of the impostor
  128712. * @param impostor impostor to set velocity iterations on
  128713. * @param velocityIterations velocityIterations value
  128714. */
  128715. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  128716. /**
  128717. * Gets positionIterations of the impostor
  128718. * @param impostor impostor to get position iterations from
  128719. * @returns positionIterations value
  128720. */
  128721. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  128722. /**
  128723. * Sets positionIterations of the impostor
  128724. * @param impostor impostor to set position on
  128725. * @param positionIterations positionIterations value
  128726. */
  128727. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  128728. /**
  128729. * Append an anchor to a cloth object
  128730. * @param impostor is the cloth impostor to add anchor to
  128731. * @param otherImpostor is the rigid impostor to anchor to
  128732. * @param width ratio across width from 0 to 1
  128733. * @param height ratio up height from 0 to 1
  128734. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  128735. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128736. */
  128737. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128738. /**
  128739. * Append an hook to a rope object
  128740. * @param impostor is the rope impostor to add hook to
  128741. * @param otherImpostor is the rigid impostor to hook to
  128742. * @param length ratio along the rope from 0 to 1
  128743. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  128744. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  128745. */
  128746. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  128747. /**
  128748. * Sleeps the physics body and stops it from being active
  128749. * @param impostor impostor to sleep
  128750. */
  128751. sleepBody(impostor: PhysicsImpostor): void;
  128752. /**
  128753. * Activates the physics body
  128754. * @param impostor impostor to activate
  128755. */
  128756. wakeUpBody(impostor: PhysicsImpostor): void;
  128757. /**
  128758. * Updates the distance parameters of the joint
  128759. * @param joint joint to update
  128760. * @param maxDistance maximum distance of the joint
  128761. * @param minDistance minimum distance of the joint
  128762. */
  128763. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  128764. /**
  128765. * Sets a motor on the joint
  128766. * @param joint joint to set motor on
  128767. * @param speed speed of the motor
  128768. * @param maxForce maximum force of the motor
  128769. * @param motorIndex index of the motor
  128770. */
  128771. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  128772. /**
  128773. * Sets the motors limit
  128774. * @param joint joint to set limit on
  128775. * @param upperLimit upper limit
  128776. * @param lowerLimit lower limit
  128777. */
  128778. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  128779. /**
  128780. * Syncs the position and rotation of a mesh with the impostor
  128781. * @param mesh mesh to sync
  128782. * @param impostor impostor to update the mesh with
  128783. */
  128784. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  128785. /**
  128786. * Gets the radius of the impostor
  128787. * @param impostor impostor to get radius from
  128788. * @returns the radius
  128789. */
  128790. getRadius(impostor: PhysicsImpostor): number;
  128791. /**
  128792. * Gets the box size of the impostor
  128793. * @param impostor impostor to get box size from
  128794. * @param result the resulting box size
  128795. */
  128796. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  128797. /**
  128798. * Disposes of the impostor
  128799. */
  128800. dispose(): void;
  128801. /**
  128802. * Does a raycast in the physics world
  128803. * @param from when should the ray start?
  128804. * @param to when should the ray end?
  128805. * @returns PhysicsRaycastResult
  128806. */
  128807. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  128808. }
  128809. }
  128810. declare module BABYLON {
  128811. interface AbstractScene {
  128812. /**
  128813. * The list of reflection probes added to the scene
  128814. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128815. */
  128816. reflectionProbes: Array<ReflectionProbe>;
  128817. /**
  128818. * Removes the given reflection probe from this scene.
  128819. * @param toRemove The reflection probe to remove
  128820. * @returns The index of the removed reflection probe
  128821. */
  128822. removeReflectionProbe(toRemove: ReflectionProbe): number;
  128823. /**
  128824. * Adds the given reflection probe to this scene.
  128825. * @param newReflectionProbe The reflection probe to add
  128826. */
  128827. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  128828. }
  128829. /**
  128830. * Class used to generate realtime reflection / refraction cube textures
  128831. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  128832. */
  128833. export class ReflectionProbe {
  128834. /** defines the name of the probe */
  128835. name: string;
  128836. private _scene;
  128837. private _renderTargetTexture;
  128838. private _projectionMatrix;
  128839. private _viewMatrix;
  128840. private _target;
  128841. private _add;
  128842. private _attachedMesh;
  128843. private _invertYAxis;
  128844. /** Gets or sets probe position (center of the cube map) */
  128845. position: Vector3;
  128846. /**
  128847. * Creates a new reflection probe
  128848. * @param name defines the name of the probe
  128849. * @param size defines the texture resolution (for each face)
  128850. * @param scene defines the hosting scene
  128851. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  128852. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  128853. */
  128854. constructor(
  128855. /** defines the name of the probe */
  128856. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  128857. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  128858. get samples(): number;
  128859. set samples(value: number);
  128860. /** Gets or sets the refresh rate to use (on every frame by default) */
  128861. get refreshRate(): number;
  128862. set refreshRate(value: number);
  128863. /**
  128864. * Gets the hosting scene
  128865. * @returns a Scene
  128866. */
  128867. getScene(): Scene;
  128868. /** Gets the internal CubeTexture used to render to */
  128869. get cubeTexture(): RenderTargetTexture;
  128870. /** Gets the list of meshes to render */
  128871. get renderList(): Nullable<AbstractMesh[]>;
  128872. /**
  128873. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  128874. * @param mesh defines the mesh to attach to
  128875. */
  128876. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  128877. /**
  128878. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  128879. * @param renderingGroupId The rendering group id corresponding to its index
  128880. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  128881. */
  128882. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  128883. /**
  128884. * Clean all associated resources
  128885. */
  128886. dispose(): void;
  128887. /**
  128888. * Converts the reflection probe information to a readable string for debug purpose.
  128889. * @param fullDetails Supports for multiple levels of logging within scene loading
  128890. * @returns the human readable reflection probe info
  128891. */
  128892. toString(fullDetails?: boolean): string;
  128893. /**
  128894. * Get the class name of the relfection probe.
  128895. * @returns "ReflectionProbe"
  128896. */
  128897. getClassName(): string;
  128898. /**
  128899. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  128900. * @returns The JSON representation of the texture
  128901. */
  128902. serialize(): any;
  128903. /**
  128904. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  128905. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  128906. * @param scene Define the scene the parsed reflection probe should be instantiated in
  128907. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  128908. * @returns The parsed reflection probe if successful
  128909. */
  128910. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  128911. }
  128912. }
  128913. declare module BABYLON {
  128914. /** @hidden */
  128915. export var _BabylonLoaderRegistered: boolean;
  128916. /**
  128917. * Helps setting up some configuration for the babylon file loader.
  128918. */
  128919. export class BabylonFileLoaderConfiguration {
  128920. /**
  128921. * The loader does not allow injecting custom physix engine into the plugins.
  128922. * Unfortunately in ES6, we need to manually inject them into the plugin.
  128923. * So you could set this variable to your engine import to make it work.
  128924. */
  128925. static LoaderInjectedPhysicsEngine: any;
  128926. }
  128927. }
  128928. declare module BABYLON {
  128929. /**
  128930. * The Physically based simple base material of BJS.
  128931. *
  128932. * This enables better naming and convention enforcements on top of the pbrMaterial.
  128933. * It is used as the base class for both the specGloss and metalRough conventions.
  128934. */
  128935. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  128936. /**
  128937. * Number of Simultaneous lights allowed on the material.
  128938. */
  128939. maxSimultaneousLights: number;
  128940. /**
  128941. * If sets to true, disables all the lights affecting the material.
  128942. */
  128943. disableLighting: boolean;
  128944. /**
  128945. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  128946. */
  128947. environmentTexture: BaseTexture;
  128948. /**
  128949. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  128950. */
  128951. invertNormalMapX: boolean;
  128952. /**
  128953. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  128954. */
  128955. invertNormalMapY: boolean;
  128956. /**
  128957. * Normal map used in the model.
  128958. */
  128959. normalTexture: BaseTexture;
  128960. /**
  128961. * Emissivie color used to self-illuminate the model.
  128962. */
  128963. emissiveColor: Color3;
  128964. /**
  128965. * Emissivie texture used to self-illuminate the model.
  128966. */
  128967. emissiveTexture: BaseTexture;
  128968. /**
  128969. * Occlusion Channel Strenght.
  128970. */
  128971. occlusionStrength: number;
  128972. /**
  128973. * Occlusion Texture of the material (adding extra occlusion effects).
  128974. */
  128975. occlusionTexture: BaseTexture;
  128976. /**
  128977. * Defines the alpha limits in alpha test mode.
  128978. */
  128979. alphaCutOff: number;
  128980. /**
  128981. * Gets the current double sided mode.
  128982. */
  128983. get doubleSided(): boolean;
  128984. /**
  128985. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  128986. */
  128987. set doubleSided(value: boolean);
  128988. /**
  128989. * Stores the pre-calculated light information of a mesh in a texture.
  128990. */
  128991. lightmapTexture: BaseTexture;
  128992. /**
  128993. * If true, the light map contains occlusion information instead of lighting info.
  128994. */
  128995. useLightmapAsShadowmap: boolean;
  128996. /**
  128997. * Instantiates a new PBRMaterial instance.
  128998. *
  128999. * @param name The material name
  129000. * @param scene The scene the material will be use in.
  129001. */
  129002. constructor(name: string, scene: Scene);
  129003. getClassName(): string;
  129004. }
  129005. }
  129006. declare module BABYLON {
  129007. /**
  129008. * The PBR material of BJS following the metal roughness convention.
  129009. *
  129010. * This fits to the PBR convention in the GLTF definition:
  129011. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  129012. */
  129013. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  129014. /**
  129015. * The base color has two different interpretations depending on the value of metalness.
  129016. * When the material is a metal, the base color is the specific measured reflectance value
  129017. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  129018. * of the material.
  129019. */
  129020. baseColor: Color3;
  129021. /**
  129022. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  129023. * well as opacity information in the alpha channel.
  129024. */
  129025. baseTexture: BaseTexture;
  129026. /**
  129027. * Specifies the metallic scalar value of the material.
  129028. * Can also be used to scale the metalness values of the metallic texture.
  129029. */
  129030. metallic: number;
  129031. /**
  129032. * Specifies the roughness scalar value of the material.
  129033. * Can also be used to scale the roughness values of the metallic texture.
  129034. */
  129035. roughness: number;
  129036. /**
  129037. * Texture containing both the metallic value in the B channel and the
  129038. * roughness value in the G channel to keep better precision.
  129039. */
  129040. metallicRoughnessTexture: BaseTexture;
  129041. /**
  129042. * Instantiates a new PBRMetalRoughnessMaterial instance.
  129043. *
  129044. * @param name The material name
  129045. * @param scene The scene the material will be use in.
  129046. */
  129047. constructor(name: string, scene: Scene);
  129048. /**
  129049. * Return the currrent class name of the material.
  129050. */
  129051. getClassName(): string;
  129052. /**
  129053. * Makes a duplicate of the current material.
  129054. * @param name - name to use for the new material.
  129055. */
  129056. clone(name: string): PBRMetallicRoughnessMaterial;
  129057. /**
  129058. * Serialize the material to a parsable JSON object.
  129059. */
  129060. serialize(): any;
  129061. /**
  129062. * Parses a JSON object correponding to the serialize function.
  129063. */
  129064. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  129065. }
  129066. }
  129067. declare module BABYLON {
  129068. /**
  129069. * The PBR material of BJS following the specular glossiness convention.
  129070. *
  129071. * This fits to the PBR convention in the GLTF definition:
  129072. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  129073. */
  129074. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  129075. /**
  129076. * Specifies the diffuse color of the material.
  129077. */
  129078. diffuseColor: Color3;
  129079. /**
  129080. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  129081. * channel.
  129082. */
  129083. diffuseTexture: BaseTexture;
  129084. /**
  129085. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  129086. */
  129087. specularColor: Color3;
  129088. /**
  129089. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  129090. */
  129091. glossiness: number;
  129092. /**
  129093. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  129094. */
  129095. specularGlossinessTexture: BaseTexture;
  129096. /**
  129097. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  129098. *
  129099. * @param name The material name
  129100. * @param scene The scene the material will be use in.
  129101. */
  129102. constructor(name: string, scene: Scene);
  129103. /**
  129104. * Return the currrent class name of the material.
  129105. */
  129106. getClassName(): string;
  129107. /**
  129108. * Makes a duplicate of the current material.
  129109. * @param name - name to use for the new material.
  129110. */
  129111. clone(name: string): PBRSpecularGlossinessMaterial;
  129112. /**
  129113. * Serialize the material to a parsable JSON object.
  129114. */
  129115. serialize(): any;
  129116. /**
  129117. * Parses a JSON object correponding to the serialize function.
  129118. */
  129119. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  129120. }
  129121. }
  129122. declare module BABYLON {
  129123. /**
  129124. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  129125. * It can help converting any input color in a desired output one. This can then be used to create effects
  129126. * from sepia, black and white to sixties or futuristic rendering...
  129127. *
  129128. * The only supported format is currently 3dl.
  129129. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  129130. */
  129131. export class ColorGradingTexture extends BaseTexture {
  129132. /**
  129133. * The current texture matrix. (will always be identity in color grading texture)
  129134. */
  129135. private _textureMatrix;
  129136. /**
  129137. * The texture URL.
  129138. */
  129139. url: string;
  129140. /**
  129141. * Empty line regex stored for GC.
  129142. */
  129143. private static _noneEmptyLineRegex;
  129144. private _engine;
  129145. /**
  129146. * Instantiates a ColorGradingTexture from the following parameters.
  129147. *
  129148. * @param url The location of the color gradind data (currently only supporting 3dl)
  129149. * @param scene The scene the texture will be used in
  129150. */
  129151. constructor(url: string, scene: Scene);
  129152. /**
  129153. * Returns the texture matrix used in most of the material.
  129154. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  129155. */
  129156. getTextureMatrix(): Matrix;
  129157. /**
  129158. * Occurs when the file being loaded is a .3dl LUT file.
  129159. */
  129160. private load3dlTexture;
  129161. /**
  129162. * Starts the loading process of the texture.
  129163. */
  129164. private loadTexture;
  129165. /**
  129166. * Clones the color gradind texture.
  129167. */
  129168. clone(): ColorGradingTexture;
  129169. /**
  129170. * Called during delayed load for textures.
  129171. */
  129172. delayLoad(): void;
  129173. /**
  129174. * Parses a color grading texture serialized by Babylon.
  129175. * @param parsedTexture The texture information being parsedTexture
  129176. * @param scene The scene to load the texture in
  129177. * @param rootUrl The root url of the data assets to load
  129178. * @return A color gradind texture
  129179. */
  129180. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  129181. /**
  129182. * Serializes the LUT texture to json format.
  129183. */
  129184. serialize(): any;
  129185. }
  129186. }
  129187. declare module BABYLON {
  129188. /**
  129189. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  129190. */
  129191. export class EquiRectangularCubeTexture extends BaseTexture {
  129192. /** The six faces of the cube. */
  129193. private static _FacesMapping;
  129194. private _noMipmap;
  129195. private _onLoad;
  129196. private _onError;
  129197. /** The size of the cubemap. */
  129198. private _size;
  129199. /** The buffer of the image. */
  129200. private _buffer;
  129201. /** The width of the input image. */
  129202. private _width;
  129203. /** The height of the input image. */
  129204. private _height;
  129205. /** The URL to the image. */
  129206. url: string;
  129207. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  129208. coordinatesMode: number;
  129209. /**
  129210. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  129211. * @param url The location of the image
  129212. * @param scene The scene the texture will be used in
  129213. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129214. * @param noMipmap Forces to not generate the mipmap if true
  129215. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129216. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129217. * @param onLoad — defines a callback called when texture is loaded
  129218. * @param onError — defines a callback called if there is an error
  129219. */
  129220. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  129221. /**
  129222. * Load the image data, by putting the image on a canvas and extracting its buffer.
  129223. */
  129224. private loadImage;
  129225. /**
  129226. * Convert the image buffer into a cubemap and create a CubeTexture.
  129227. */
  129228. private loadTexture;
  129229. /**
  129230. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  129231. * @param buffer The ArrayBuffer that should be converted.
  129232. * @returns The buffer as Float32Array.
  129233. */
  129234. private getFloat32ArrayFromArrayBuffer;
  129235. /**
  129236. * Get the current class name of the texture useful for serialization or dynamic coding.
  129237. * @returns "EquiRectangularCubeTexture"
  129238. */
  129239. getClassName(): string;
  129240. /**
  129241. * Create a clone of the current EquiRectangularCubeTexture and return it.
  129242. * @returns A clone of the current EquiRectangularCubeTexture.
  129243. */
  129244. clone(): EquiRectangularCubeTexture;
  129245. }
  129246. }
  129247. declare module BABYLON {
  129248. /**
  129249. * Based on jsTGALoader - Javascript loader for TGA file
  129250. * By Vincent Thibault
  129251. * @see http://blog.robrowser.com/javascript-tga-loader.html
  129252. */
  129253. export class TGATools {
  129254. private static _TYPE_INDEXED;
  129255. private static _TYPE_RGB;
  129256. private static _TYPE_GREY;
  129257. private static _TYPE_RLE_INDEXED;
  129258. private static _TYPE_RLE_RGB;
  129259. private static _TYPE_RLE_GREY;
  129260. private static _ORIGIN_MASK;
  129261. private static _ORIGIN_SHIFT;
  129262. private static _ORIGIN_BL;
  129263. private static _ORIGIN_BR;
  129264. private static _ORIGIN_UL;
  129265. private static _ORIGIN_UR;
  129266. /**
  129267. * Gets the header of a TGA file
  129268. * @param data defines the TGA data
  129269. * @returns the header
  129270. */
  129271. static GetTGAHeader(data: Uint8Array): any;
  129272. /**
  129273. * Uploads TGA content to a Babylon Texture
  129274. * @hidden
  129275. */
  129276. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  129277. /** @hidden */
  129278. 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;
  129279. /** @hidden */
  129280. 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;
  129281. /** @hidden */
  129282. 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;
  129283. /** @hidden */
  129284. 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;
  129285. /** @hidden */
  129286. 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;
  129287. /** @hidden */
  129288. 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;
  129289. }
  129290. }
  129291. declare module BABYLON {
  129292. /**
  129293. * Implementation of the TGA Texture Loader.
  129294. * @hidden
  129295. */
  129296. export class _TGATextureLoader implements IInternalTextureLoader {
  129297. /**
  129298. * Defines wether the loader supports cascade loading the different faces.
  129299. */
  129300. readonly supportCascades: boolean;
  129301. /**
  129302. * This returns if the loader support the current file information.
  129303. * @param extension defines the file extension of the file being loaded
  129304. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129305. * @param fallback defines the fallback internal texture if any
  129306. * @param isBase64 defines whether the texture is encoded as a base64
  129307. * @param isBuffer defines whether the texture data are stored as a buffer
  129308. * @returns true if the loader can load the specified file
  129309. */
  129310. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  129311. /**
  129312. * Transform the url before loading if required.
  129313. * @param rootUrl the url of the texture
  129314. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129315. * @returns the transformed texture
  129316. */
  129317. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  129318. /**
  129319. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  129320. * @param rootUrl the url of the texture
  129321. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129322. * @returns the fallback texture
  129323. */
  129324. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  129325. /**
  129326. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  129327. * @param data contains the texture data
  129328. * @param texture defines the BabylonJS internal texture
  129329. * @param createPolynomials will be true if polynomials have been requested
  129330. * @param onLoad defines the callback to trigger once the texture is ready
  129331. * @param onError defines the callback to trigger in case of error
  129332. */
  129333. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129334. /**
  129335. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  129336. * @param data contains the texture data
  129337. * @param texture defines the BabylonJS internal texture
  129338. * @param callback defines the method to call once ready to upload
  129339. */
  129340. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129341. }
  129342. }
  129343. declare module BABYLON {
  129344. /**
  129345. * Info about the .basis files
  129346. */
  129347. class BasisFileInfo {
  129348. /**
  129349. * If the file has alpha
  129350. */
  129351. hasAlpha: boolean;
  129352. /**
  129353. * Info about each image of the basis file
  129354. */
  129355. images: Array<{
  129356. levels: Array<{
  129357. width: number;
  129358. height: number;
  129359. transcodedPixels: ArrayBufferView;
  129360. }>;
  129361. }>;
  129362. }
  129363. /**
  129364. * Result of transcoding a basis file
  129365. */
  129366. class TranscodeResult {
  129367. /**
  129368. * Info about the .basis file
  129369. */
  129370. fileInfo: BasisFileInfo;
  129371. /**
  129372. * Format to use when loading the file
  129373. */
  129374. format: number;
  129375. }
  129376. /**
  129377. * Configuration options for the Basis transcoder
  129378. */
  129379. export class BasisTranscodeConfiguration {
  129380. /**
  129381. * Supported compression formats used to determine the supported output format of the transcoder
  129382. */
  129383. supportedCompressionFormats?: {
  129384. /**
  129385. * etc1 compression format
  129386. */
  129387. etc1?: boolean;
  129388. /**
  129389. * s3tc compression format
  129390. */
  129391. s3tc?: boolean;
  129392. /**
  129393. * pvrtc compression format
  129394. */
  129395. pvrtc?: boolean;
  129396. /**
  129397. * etc2 compression format
  129398. */
  129399. etc2?: boolean;
  129400. };
  129401. /**
  129402. * If mipmap levels should be loaded for transcoded images (Default: true)
  129403. */
  129404. loadMipmapLevels?: boolean;
  129405. /**
  129406. * Index of a single image to load (Default: all images)
  129407. */
  129408. loadSingleImage?: number;
  129409. }
  129410. /**
  129411. * Used to load .Basis files
  129412. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  129413. */
  129414. export class BasisTools {
  129415. private static _IgnoreSupportedFormats;
  129416. /**
  129417. * URL to use when loading the basis transcoder
  129418. */
  129419. static JSModuleURL: string;
  129420. /**
  129421. * URL to use when loading the wasm module for the transcoder
  129422. */
  129423. static WasmModuleURL: string;
  129424. /**
  129425. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  129426. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  129427. * @returns internal format corresponding to the Basis format
  129428. */
  129429. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  129430. private static _WorkerPromise;
  129431. private static _Worker;
  129432. private static _actionId;
  129433. private static _CreateWorkerAsync;
  129434. /**
  129435. * Transcodes a loaded image file to compressed pixel data
  129436. * @param data image data to transcode
  129437. * @param config configuration options for the transcoding
  129438. * @returns a promise resulting in the transcoded image
  129439. */
  129440. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  129441. /**
  129442. * Loads a texture from the transcode result
  129443. * @param texture texture load to
  129444. * @param transcodeResult the result of transcoding the basis file to load from
  129445. */
  129446. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  129447. }
  129448. }
  129449. declare module BABYLON {
  129450. /**
  129451. * Loader for .basis file format
  129452. */
  129453. export class _BasisTextureLoader implements IInternalTextureLoader {
  129454. /**
  129455. * Defines whether the loader supports cascade loading the different faces.
  129456. */
  129457. readonly supportCascades: boolean;
  129458. /**
  129459. * This returns if the loader support the current file information.
  129460. * @param extension defines the file extension of the file being loaded
  129461. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129462. * @param fallback defines the fallback internal texture if any
  129463. * @param isBase64 defines whether the texture is encoded as a base64
  129464. * @param isBuffer defines whether the texture data are stored as a buffer
  129465. * @returns true if the loader can load the specified file
  129466. */
  129467. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  129468. /**
  129469. * Transform the url before loading if required.
  129470. * @param rootUrl the url of the texture
  129471. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129472. * @returns the transformed texture
  129473. */
  129474. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  129475. /**
  129476. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  129477. * @param rootUrl the url of the texture
  129478. * @param textureFormatInUse defines the current compressed format in use iun the engine
  129479. * @returns the fallback texture
  129480. */
  129481. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  129482. /**
  129483. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  129484. * @param data contains the texture data
  129485. * @param texture defines the BabylonJS internal texture
  129486. * @param createPolynomials will be true if polynomials have been requested
  129487. * @param onLoad defines the callback to trigger once the texture is ready
  129488. * @param onError defines the callback to trigger in case of error
  129489. */
  129490. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  129491. /**
  129492. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  129493. * @param data contains the texture data
  129494. * @param texture defines the BabylonJS internal texture
  129495. * @param callback defines the method to call once ready to upload
  129496. */
  129497. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  129498. }
  129499. }
  129500. declare module BABYLON {
  129501. /**
  129502. * 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.
  129503. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129504. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129505. */
  129506. export class CustomProceduralTexture extends ProceduralTexture {
  129507. private _animate;
  129508. private _time;
  129509. private _config;
  129510. private _texturePath;
  129511. /**
  129512. * Instantiates a new Custom Procedural Texture.
  129513. * 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.
  129514. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  129515. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  129516. * @param name Define the name of the texture
  129517. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  129518. * @param size Define the size of the texture to create
  129519. * @param scene Define the scene the texture belongs to
  129520. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  129521. * @param generateMipMaps Define if the texture should creates mip maps or not
  129522. */
  129523. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129524. private _loadJson;
  129525. /**
  129526. * Is the texture ready to be used ? (rendered at least once)
  129527. * @returns true if ready, otherwise, false.
  129528. */
  129529. isReady(): boolean;
  129530. /**
  129531. * Render the texture to its associated render target.
  129532. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  129533. */
  129534. render(useCameraPostProcess?: boolean): void;
  129535. /**
  129536. * Update the list of dependant textures samplers in the shader.
  129537. */
  129538. updateTextures(): void;
  129539. /**
  129540. * Update the uniform values of the procedural texture in the shader.
  129541. */
  129542. updateShaderUniforms(): void;
  129543. /**
  129544. * Define if the texture animates or not.
  129545. */
  129546. get animate(): boolean;
  129547. set animate(value: boolean);
  129548. }
  129549. }
  129550. declare module BABYLON {
  129551. /** @hidden */
  129552. export var noisePixelShader: {
  129553. name: string;
  129554. shader: string;
  129555. };
  129556. }
  129557. declare module BABYLON {
  129558. /**
  129559. * Class used to generate noise procedural textures
  129560. */
  129561. export class NoiseProceduralTexture extends ProceduralTexture {
  129562. private _time;
  129563. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  129564. brightness: number;
  129565. /** Defines the number of octaves to process */
  129566. octaves: number;
  129567. /** Defines the level of persistence (0.8 by default) */
  129568. persistence: number;
  129569. /** Gets or sets animation speed factor (default is 1) */
  129570. animationSpeedFactor: number;
  129571. /**
  129572. * Creates a new NoiseProceduralTexture
  129573. * @param name defines the name fo the texture
  129574. * @param size defines the size of the texture (default is 256)
  129575. * @param scene defines the hosting scene
  129576. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  129577. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  129578. */
  129579. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  129580. private _updateShaderUniforms;
  129581. protected _getDefines(): string;
  129582. /** Generate the current state of the procedural texture */
  129583. render(useCameraPostProcess?: boolean): void;
  129584. /**
  129585. * Serializes this noise procedural texture
  129586. * @returns a serialized noise procedural texture object
  129587. */
  129588. serialize(): any;
  129589. /**
  129590. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  129591. * @param parsedTexture defines parsed texture data
  129592. * @param scene defines the current scene
  129593. * @param rootUrl defines the root URL containing noise procedural texture information
  129594. * @returns a parsed NoiseProceduralTexture
  129595. */
  129596. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  129597. }
  129598. }
  129599. declare module BABYLON {
  129600. /**
  129601. * Raw cube texture where the raw buffers are passed in
  129602. */
  129603. export class RawCubeTexture extends CubeTexture {
  129604. /**
  129605. * Creates a cube texture where the raw buffers are passed in.
  129606. * @param scene defines the scene the texture is attached to
  129607. * @param data defines the array of data to use to create each face
  129608. * @param size defines the size of the textures
  129609. * @param format defines the format of the data
  129610. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  129611. * @param generateMipMaps defines if the engine should generate the mip levels
  129612. * @param invertY defines if data must be stored with Y axis inverted
  129613. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  129614. * @param compression defines the compression used (null by default)
  129615. */
  129616. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  129617. /**
  129618. * Updates the raw cube texture.
  129619. * @param data defines the data to store
  129620. * @param format defines the data format
  129621. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  129622. * @param invertY defines if data must be stored with Y axis inverted
  129623. * @param compression defines the compression used (null by default)
  129624. * @param level defines which level of the texture to update
  129625. */
  129626. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  129627. /**
  129628. * Updates a raw cube texture with RGBD encoded data.
  129629. * @param data defines the array of data [mipmap][face] to use to create each face
  129630. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  129631. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  129632. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  129633. * @returns a promsie that resolves when the operation is complete
  129634. */
  129635. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  129636. /**
  129637. * Clones the raw cube texture.
  129638. * @return a new cube texture
  129639. */
  129640. clone(): CubeTexture;
  129641. /** @hidden */
  129642. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  129643. }
  129644. }
  129645. declare module BABYLON {
  129646. /**
  129647. * Class used to store 3D textures containing user data
  129648. */
  129649. export class RawTexture3D extends Texture {
  129650. /** Gets or sets the texture format to use */
  129651. format: number;
  129652. private _engine;
  129653. /**
  129654. * Create a new RawTexture3D
  129655. * @param data defines the data of the texture
  129656. * @param width defines the width of the texture
  129657. * @param height defines the height of the texture
  129658. * @param depth defines the depth of the texture
  129659. * @param format defines the texture format to use
  129660. * @param scene defines the hosting scene
  129661. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129662. * @param invertY defines if texture must be stored with Y axis inverted
  129663. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129664. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129665. */
  129666. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129667. /** Gets or sets the texture format to use */
  129668. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129669. /**
  129670. * Update the texture with new data
  129671. * @param data defines the data to store in the texture
  129672. */
  129673. update(data: ArrayBufferView): void;
  129674. }
  129675. }
  129676. declare module BABYLON {
  129677. /**
  129678. * Class used to store 2D array textures containing user data
  129679. */
  129680. export class RawTexture2DArray extends Texture {
  129681. /** Gets or sets the texture format to use */
  129682. format: number;
  129683. private _engine;
  129684. /**
  129685. * Create a new RawTexture2DArray
  129686. * @param data defines the data of the texture
  129687. * @param width defines the width of the texture
  129688. * @param height defines the height of the texture
  129689. * @param depth defines the number of layers of the texture
  129690. * @param format defines the texture format to use
  129691. * @param scene defines the hosting scene
  129692. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  129693. * @param invertY defines if texture must be stored with Y axis inverted
  129694. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129695. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  129696. */
  129697. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  129698. /** Gets or sets the texture format to use */
  129699. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  129700. /**
  129701. * Update the texture with new data
  129702. * @param data defines the data to store in the texture
  129703. */
  129704. update(data: ArrayBufferView): void;
  129705. }
  129706. }
  129707. declare module BABYLON {
  129708. /**
  129709. * Creates a refraction texture used by refraction channel of the standard material.
  129710. * It is like a mirror but to see through a material.
  129711. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129712. */
  129713. export class RefractionTexture extends RenderTargetTexture {
  129714. /**
  129715. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  129716. * 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.
  129717. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129718. */
  129719. refractionPlane: Plane;
  129720. /**
  129721. * Define how deep under the surface we should see.
  129722. */
  129723. depth: number;
  129724. /**
  129725. * Creates a refraction texture used by refraction channel of the standard material.
  129726. * It is like a mirror but to see through a material.
  129727. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  129728. * @param name Define the texture name
  129729. * @param size Define the size of the underlying texture
  129730. * @param scene Define the scene the refraction belongs to
  129731. * @param generateMipMaps Define if we need to generate mips level for the refraction
  129732. */
  129733. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  129734. /**
  129735. * Clone the refraction texture.
  129736. * @returns the cloned texture
  129737. */
  129738. clone(): RefractionTexture;
  129739. /**
  129740. * Serialize the texture to a JSON representation you could use in Parse later on
  129741. * @returns the serialized JSON representation
  129742. */
  129743. serialize(): any;
  129744. }
  129745. }
  129746. declare module BABYLON {
  129747. /**
  129748. * Defines the options related to the creation of an HtmlElementTexture
  129749. */
  129750. export interface IHtmlElementTextureOptions {
  129751. /**
  129752. * Defines wether mip maps should be created or not.
  129753. */
  129754. generateMipMaps?: boolean;
  129755. /**
  129756. * Defines the sampling mode of the texture.
  129757. */
  129758. samplingMode?: number;
  129759. /**
  129760. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  129761. */
  129762. engine: Nullable<ThinEngine>;
  129763. /**
  129764. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  129765. */
  129766. scene: Nullable<Scene>;
  129767. }
  129768. /**
  129769. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  129770. * To be as efficient as possible depending on your constraints nothing aside the first upload
  129771. * is automatically managed.
  129772. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  129773. * in your application.
  129774. *
  129775. * As the update is not automatic, you need to call them manually.
  129776. */
  129777. export class HtmlElementTexture extends BaseTexture {
  129778. /**
  129779. * The texture URL.
  129780. */
  129781. element: HTMLVideoElement | HTMLCanvasElement;
  129782. private static readonly DefaultOptions;
  129783. private _textureMatrix;
  129784. private _engine;
  129785. private _isVideo;
  129786. private _generateMipMaps;
  129787. private _samplingMode;
  129788. /**
  129789. * Instantiates a HtmlElementTexture from the following parameters.
  129790. *
  129791. * @param name Defines the name of the texture
  129792. * @param element Defines the video or canvas the texture is filled with
  129793. * @param options Defines the other none mandatory texture creation options
  129794. */
  129795. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  129796. private _createInternalTexture;
  129797. /**
  129798. * Returns the texture matrix used in most of the material.
  129799. */
  129800. getTextureMatrix(): Matrix;
  129801. /**
  129802. * Updates the content of the texture.
  129803. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  129804. */
  129805. update(invertY?: Nullable<boolean>): void;
  129806. }
  129807. }
  129808. declare module BABYLON {
  129809. /**
  129810. * Defines the basic options interface of a TexturePacker Frame
  129811. */
  129812. export interface ITexturePackerFrame {
  129813. /**
  129814. * The frame ID
  129815. */
  129816. id: number;
  129817. /**
  129818. * The frames Scale
  129819. */
  129820. scale: Vector2;
  129821. /**
  129822. * The Frames offset
  129823. */
  129824. offset: Vector2;
  129825. }
  129826. /**
  129827. * This is a support class for frame Data on texture packer sets.
  129828. */
  129829. export class TexturePackerFrame implements ITexturePackerFrame {
  129830. /**
  129831. * The frame ID
  129832. */
  129833. id: number;
  129834. /**
  129835. * The frames Scale
  129836. */
  129837. scale: Vector2;
  129838. /**
  129839. * The Frames offset
  129840. */
  129841. offset: Vector2;
  129842. /**
  129843. * Initializes a texture package frame.
  129844. * @param id The numerical frame identifier
  129845. * @param scale Scalar Vector2 for UV frame
  129846. * @param offset Vector2 for the frame position in UV units.
  129847. * @returns TexturePackerFrame
  129848. */
  129849. constructor(id: number, scale: Vector2, offset: Vector2);
  129850. }
  129851. }
  129852. declare module BABYLON {
  129853. /**
  129854. * Defines the basic options interface of a TexturePacker
  129855. */
  129856. export interface ITexturePackerOptions {
  129857. /**
  129858. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  129859. */
  129860. map?: string[];
  129861. /**
  129862. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129863. */
  129864. uvsIn?: string;
  129865. /**
  129866. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  129867. */
  129868. uvsOut?: string;
  129869. /**
  129870. * number representing the layout style. Defaults to LAYOUT_STRIP
  129871. */
  129872. layout?: number;
  129873. /**
  129874. * number of columns if using custom column count layout(2). This defaults to 4.
  129875. */
  129876. colnum?: number;
  129877. /**
  129878. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  129879. */
  129880. updateInputMeshes?: boolean;
  129881. /**
  129882. * boolean flag to dispose all the source textures. Defaults to true.
  129883. */
  129884. disposeSources?: boolean;
  129885. /**
  129886. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  129887. */
  129888. fillBlanks?: boolean;
  129889. /**
  129890. * string value representing the context fill style color. Defaults to 'black'.
  129891. */
  129892. customFillColor?: string;
  129893. /**
  129894. * Width and Height Value of each Frame in the TexturePacker Sets
  129895. */
  129896. frameSize?: number;
  129897. /**
  129898. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  129899. */
  129900. paddingRatio?: number;
  129901. /**
  129902. * Number that declares the fill method for the padding gutter.
  129903. */
  129904. paddingMode?: number;
  129905. /**
  129906. * If in SUBUV_COLOR padding mode what color to use.
  129907. */
  129908. paddingColor?: Color3 | Color4;
  129909. }
  129910. /**
  129911. * Defines the basic interface of a TexturePacker JSON File
  129912. */
  129913. export interface ITexturePackerJSON {
  129914. /**
  129915. * The frame ID
  129916. */
  129917. name: string;
  129918. /**
  129919. * The base64 channel data
  129920. */
  129921. sets: any;
  129922. /**
  129923. * The options of the Packer
  129924. */
  129925. options: ITexturePackerOptions;
  129926. /**
  129927. * The frame data of the Packer
  129928. */
  129929. frames: Array<number>;
  129930. }
  129931. /**
  129932. * This is a support class that generates a series of packed texture sets.
  129933. * @see https://doc.babylonjs.com/babylon101/materials
  129934. */
  129935. export class TexturePacker {
  129936. /** Packer Layout Constant 0 */
  129937. static readonly LAYOUT_STRIP: number;
  129938. /** Packer Layout Constant 1 */
  129939. static readonly LAYOUT_POWER2: number;
  129940. /** Packer Layout Constant 2 */
  129941. static readonly LAYOUT_COLNUM: number;
  129942. /** Packer Layout Constant 0 */
  129943. static readonly SUBUV_WRAP: number;
  129944. /** Packer Layout Constant 1 */
  129945. static readonly SUBUV_EXTEND: number;
  129946. /** Packer Layout Constant 2 */
  129947. static readonly SUBUV_COLOR: number;
  129948. /** The Name of the Texture Package */
  129949. name: string;
  129950. /** The scene scope of the TexturePacker */
  129951. scene: Scene;
  129952. /** The Meshes to target */
  129953. meshes: AbstractMesh[];
  129954. /** Arguments passed with the Constructor */
  129955. options: ITexturePackerOptions;
  129956. /** The promise that is started upon initialization */
  129957. promise: Nullable<Promise<TexturePacker | string>>;
  129958. /** The Container object for the channel sets that are generated */
  129959. sets: object;
  129960. /** The Container array for the frames that are generated */
  129961. frames: TexturePackerFrame[];
  129962. /** The expected number of textures the system is parsing. */
  129963. private _expecting;
  129964. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  129965. private _paddingValue;
  129966. /**
  129967. * Initializes a texture package series from an array of meshes or a single mesh.
  129968. * @param name The name of the package
  129969. * @param meshes The target meshes to compose the package from
  129970. * @param options The arguments that texture packer should follow while building.
  129971. * @param scene The scene which the textures are scoped to.
  129972. * @returns TexturePacker
  129973. */
  129974. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  129975. /**
  129976. * Starts the package process
  129977. * @param resolve The promises resolution function
  129978. * @returns TexturePacker
  129979. */
  129980. private _createFrames;
  129981. /**
  129982. * Calculates the Size of the Channel Sets
  129983. * @returns Vector2
  129984. */
  129985. private _calculateSize;
  129986. /**
  129987. * Calculates the UV data for the frames.
  129988. * @param baseSize the base frameSize
  129989. * @param padding the base frame padding
  129990. * @param dtSize size of the Dynamic Texture for that channel
  129991. * @param dtUnits is 1/dtSize
  129992. * @param update flag to update the input meshes
  129993. */
  129994. private _calculateMeshUVFrames;
  129995. /**
  129996. * Calculates the frames Offset.
  129997. * @param index of the frame
  129998. * @returns Vector2
  129999. */
  130000. private _getFrameOffset;
  130001. /**
  130002. * Updates a Mesh to the frame data
  130003. * @param mesh that is the target
  130004. * @param frameID or the frame index
  130005. */
  130006. private _updateMeshUV;
  130007. /**
  130008. * Updates a Meshes materials to use the texture packer channels
  130009. * @param m is the mesh to target
  130010. * @param force all channels on the packer to be set.
  130011. */
  130012. private _updateTextureReferences;
  130013. /**
  130014. * Public method to set a Mesh to a frame
  130015. * @param m that is the target
  130016. * @param frameID or the frame index
  130017. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  130018. */
  130019. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  130020. /**
  130021. * Starts the async promise to compile the texture packer.
  130022. * @returns Promise<void>
  130023. */
  130024. processAsync(): Promise<void>;
  130025. /**
  130026. * Disposes all textures associated with this packer
  130027. */
  130028. dispose(): void;
  130029. /**
  130030. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  130031. * @param imageType is the image type to use.
  130032. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  130033. */
  130034. download(imageType?: string, quality?: number): void;
  130035. /**
  130036. * Public method to load a texturePacker JSON file.
  130037. * @param data of the JSON file in string format.
  130038. */
  130039. updateFromJSON(data: string): void;
  130040. }
  130041. }
  130042. declare module BABYLON {
  130043. /**
  130044. * Enum used to define the target of a block
  130045. */
  130046. export enum NodeMaterialBlockTargets {
  130047. /** Vertex shader */
  130048. Vertex = 1,
  130049. /** Fragment shader */
  130050. Fragment = 2,
  130051. /** Neutral */
  130052. Neutral = 4,
  130053. /** Vertex and Fragment */
  130054. VertexAndFragment = 3
  130055. }
  130056. }
  130057. declare module BABYLON {
  130058. /**
  130059. * Defines the kind of connection point for node based material
  130060. */
  130061. export enum NodeMaterialBlockConnectionPointTypes {
  130062. /** Float */
  130063. Float = 1,
  130064. /** Int */
  130065. Int = 2,
  130066. /** Vector2 */
  130067. Vector2 = 4,
  130068. /** Vector3 */
  130069. Vector3 = 8,
  130070. /** Vector4 */
  130071. Vector4 = 16,
  130072. /** Color3 */
  130073. Color3 = 32,
  130074. /** Color4 */
  130075. Color4 = 64,
  130076. /** Matrix */
  130077. Matrix = 128,
  130078. /** Detect type based on connection */
  130079. AutoDetect = 1024,
  130080. /** Output type that will be defined by input type */
  130081. BasedOnInput = 2048
  130082. }
  130083. }
  130084. declare module BABYLON {
  130085. /**
  130086. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  130087. */
  130088. export enum NodeMaterialBlockConnectionPointMode {
  130089. /** Value is an uniform */
  130090. Uniform = 0,
  130091. /** Value is a mesh attribute */
  130092. Attribute = 1,
  130093. /** Value is a varying between vertex and fragment shaders */
  130094. Varying = 2,
  130095. /** Mode is undefined */
  130096. Undefined = 3
  130097. }
  130098. }
  130099. declare module BABYLON {
  130100. /**
  130101. * Enum used to define system values e.g. values automatically provided by the system
  130102. */
  130103. export enum NodeMaterialSystemValues {
  130104. /** World */
  130105. World = 1,
  130106. /** View */
  130107. View = 2,
  130108. /** Projection */
  130109. Projection = 3,
  130110. /** ViewProjection */
  130111. ViewProjection = 4,
  130112. /** WorldView */
  130113. WorldView = 5,
  130114. /** WorldViewProjection */
  130115. WorldViewProjection = 6,
  130116. /** CameraPosition */
  130117. CameraPosition = 7,
  130118. /** Fog Color */
  130119. FogColor = 8,
  130120. /** Delta time */
  130121. DeltaTime = 9
  130122. }
  130123. }
  130124. declare module BABYLON {
  130125. /**
  130126. * Root class for all node material optimizers
  130127. */
  130128. export class NodeMaterialOptimizer {
  130129. /**
  130130. * Function used to optimize a NodeMaterial graph
  130131. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  130132. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  130133. */
  130134. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  130135. }
  130136. }
  130137. declare module BABYLON {
  130138. /**
  130139. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  130140. */
  130141. export class TransformBlock extends NodeMaterialBlock {
  130142. /**
  130143. * Defines the value to use to complement W value to transform it to a Vector4
  130144. */
  130145. complementW: number;
  130146. /**
  130147. * Defines the value to use to complement z value to transform it to a Vector4
  130148. */
  130149. complementZ: number;
  130150. /**
  130151. * Creates a new TransformBlock
  130152. * @param name defines the block name
  130153. */
  130154. constructor(name: string);
  130155. /**
  130156. * Gets the current class name
  130157. * @returns the class name
  130158. */
  130159. getClassName(): string;
  130160. /**
  130161. * Gets the vector input
  130162. */
  130163. get vector(): NodeMaterialConnectionPoint;
  130164. /**
  130165. * Gets the output component
  130166. */
  130167. get output(): NodeMaterialConnectionPoint;
  130168. /**
  130169. * Gets the matrix transform input
  130170. */
  130171. get transform(): NodeMaterialConnectionPoint;
  130172. protected _buildBlock(state: NodeMaterialBuildState): this;
  130173. serialize(): any;
  130174. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130175. protected _dumpPropertiesCode(): string;
  130176. }
  130177. }
  130178. declare module BABYLON {
  130179. /**
  130180. * Block used to output the vertex position
  130181. */
  130182. export class VertexOutputBlock extends NodeMaterialBlock {
  130183. /**
  130184. * Creates a new VertexOutputBlock
  130185. * @param name defines the block name
  130186. */
  130187. constructor(name: string);
  130188. /**
  130189. * Gets the current class name
  130190. * @returns the class name
  130191. */
  130192. getClassName(): string;
  130193. /**
  130194. * Gets the vector input component
  130195. */
  130196. get vector(): NodeMaterialConnectionPoint;
  130197. protected _buildBlock(state: NodeMaterialBuildState): this;
  130198. }
  130199. }
  130200. declare module BABYLON {
  130201. /**
  130202. * Block used to output the final color
  130203. */
  130204. export class FragmentOutputBlock extends NodeMaterialBlock {
  130205. /**
  130206. * Create a new FragmentOutputBlock
  130207. * @param name defines the block name
  130208. */
  130209. constructor(name: string);
  130210. /**
  130211. * Gets the current class name
  130212. * @returns the class name
  130213. */
  130214. getClassName(): string;
  130215. /**
  130216. * Gets the rgba input component
  130217. */
  130218. get rgba(): NodeMaterialConnectionPoint;
  130219. /**
  130220. * Gets the rgb input component
  130221. */
  130222. get rgb(): NodeMaterialConnectionPoint;
  130223. /**
  130224. * Gets the a input component
  130225. */
  130226. get a(): NodeMaterialConnectionPoint;
  130227. protected _buildBlock(state: NodeMaterialBuildState): this;
  130228. }
  130229. }
  130230. declare module BABYLON {
  130231. /**
  130232. * Block used to read a reflection texture from a sampler
  130233. */
  130234. export class ReflectionTextureBlock extends NodeMaterialBlock {
  130235. private _define3DName;
  130236. private _defineCubicName;
  130237. private _defineExplicitName;
  130238. private _defineProjectionName;
  130239. private _defineLocalCubicName;
  130240. private _defineSphericalName;
  130241. private _definePlanarName;
  130242. private _defineEquirectangularName;
  130243. private _defineMirroredEquirectangularFixedName;
  130244. private _defineEquirectangularFixedName;
  130245. private _defineSkyboxName;
  130246. private _cubeSamplerName;
  130247. private _2DSamplerName;
  130248. private _positionUVWName;
  130249. private _directionWName;
  130250. private _reflectionCoordsName;
  130251. private _reflection2DCoordsName;
  130252. private _reflectionColorName;
  130253. private _reflectionMatrixName;
  130254. /**
  130255. * Gets or sets the texture associated with the node
  130256. */
  130257. texture: Nullable<BaseTexture>;
  130258. /**
  130259. * Create a new TextureBlock
  130260. * @param name defines the block name
  130261. */
  130262. constructor(name: string);
  130263. /**
  130264. * Gets the current class name
  130265. * @returns the class name
  130266. */
  130267. getClassName(): string;
  130268. /**
  130269. * Gets the world position input component
  130270. */
  130271. get position(): NodeMaterialConnectionPoint;
  130272. /**
  130273. * Gets the world position input component
  130274. */
  130275. get worldPosition(): NodeMaterialConnectionPoint;
  130276. /**
  130277. * Gets the world normal input component
  130278. */
  130279. get worldNormal(): NodeMaterialConnectionPoint;
  130280. /**
  130281. * Gets the world input component
  130282. */
  130283. get world(): NodeMaterialConnectionPoint;
  130284. /**
  130285. * Gets the camera (or eye) position component
  130286. */
  130287. get cameraPosition(): NodeMaterialConnectionPoint;
  130288. /**
  130289. * Gets the view input component
  130290. */
  130291. get view(): NodeMaterialConnectionPoint;
  130292. /**
  130293. * Gets the rgb output component
  130294. */
  130295. get rgb(): NodeMaterialConnectionPoint;
  130296. /**
  130297. * Gets the r output component
  130298. */
  130299. get r(): NodeMaterialConnectionPoint;
  130300. /**
  130301. * Gets the g output component
  130302. */
  130303. get g(): NodeMaterialConnectionPoint;
  130304. /**
  130305. * Gets the b output component
  130306. */
  130307. get b(): NodeMaterialConnectionPoint;
  130308. autoConfigure(material: NodeMaterial): void;
  130309. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130310. isReady(): boolean;
  130311. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130312. private _injectVertexCode;
  130313. private _writeOutput;
  130314. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130315. protected _dumpPropertiesCode(): string;
  130316. serialize(): any;
  130317. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130318. }
  130319. }
  130320. declare module BABYLON {
  130321. /**
  130322. * Interface used to configure the node material editor
  130323. */
  130324. export interface INodeMaterialEditorOptions {
  130325. /** Define the URl to load node editor script */
  130326. editorURL?: string;
  130327. }
  130328. /** @hidden */
  130329. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  130330. NORMAL: boolean;
  130331. TANGENT: boolean;
  130332. UV1: boolean;
  130333. /** BONES */
  130334. NUM_BONE_INFLUENCERS: number;
  130335. BonesPerMesh: number;
  130336. BONETEXTURE: boolean;
  130337. /** MORPH TARGETS */
  130338. MORPHTARGETS: boolean;
  130339. MORPHTARGETS_NORMAL: boolean;
  130340. MORPHTARGETS_TANGENT: boolean;
  130341. MORPHTARGETS_UV: boolean;
  130342. NUM_MORPH_INFLUENCERS: number;
  130343. /** IMAGE PROCESSING */
  130344. IMAGEPROCESSING: boolean;
  130345. VIGNETTE: boolean;
  130346. VIGNETTEBLENDMODEMULTIPLY: boolean;
  130347. VIGNETTEBLENDMODEOPAQUE: boolean;
  130348. TONEMAPPING: boolean;
  130349. TONEMAPPING_ACES: boolean;
  130350. CONTRAST: boolean;
  130351. EXPOSURE: boolean;
  130352. COLORCURVES: boolean;
  130353. COLORGRADING: boolean;
  130354. COLORGRADING3D: boolean;
  130355. SAMPLER3DGREENDEPTH: boolean;
  130356. SAMPLER3DBGRMAP: boolean;
  130357. IMAGEPROCESSINGPOSTPROCESS: boolean;
  130358. /** MISC. */
  130359. BUMPDIRECTUV: number;
  130360. constructor();
  130361. setValue(name: string, value: boolean): void;
  130362. }
  130363. /**
  130364. * Class used to configure NodeMaterial
  130365. */
  130366. export interface INodeMaterialOptions {
  130367. /**
  130368. * Defines if blocks should emit comments
  130369. */
  130370. emitComments: boolean;
  130371. }
  130372. /**
  130373. * Class used to create a node based material built by assembling shader blocks
  130374. */
  130375. export class NodeMaterial extends PushMaterial {
  130376. private static _BuildIdGenerator;
  130377. private _options;
  130378. private _vertexCompilationState;
  130379. private _fragmentCompilationState;
  130380. private _sharedData;
  130381. private _buildId;
  130382. private _buildWasSuccessful;
  130383. private _cachedWorldViewMatrix;
  130384. private _cachedWorldViewProjectionMatrix;
  130385. private _optimizers;
  130386. private _animationFrame;
  130387. /** Define the Url to load node editor script */
  130388. static EditorURL: string;
  130389. /** Define the Url to load snippets */
  130390. static SnippetUrl: string;
  130391. private BJSNODEMATERIALEDITOR;
  130392. /** Get the inspector from bundle or global */
  130393. private _getGlobalNodeMaterialEditor;
  130394. /**
  130395. * Gets or sets data used by visual editor
  130396. * @see https://nme.babylonjs.com
  130397. */
  130398. editorData: any;
  130399. /**
  130400. * 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)
  130401. */
  130402. ignoreAlpha: boolean;
  130403. /**
  130404. * Defines the maximum number of lights that can be used in the material
  130405. */
  130406. maxSimultaneousLights: number;
  130407. /**
  130408. * Observable raised when the material is built
  130409. */
  130410. onBuildObservable: Observable<NodeMaterial>;
  130411. /**
  130412. * Gets or sets the root nodes of the material vertex shader
  130413. */
  130414. _vertexOutputNodes: NodeMaterialBlock[];
  130415. /**
  130416. * Gets or sets the root nodes of the material fragment (pixel) shader
  130417. */
  130418. _fragmentOutputNodes: NodeMaterialBlock[];
  130419. /** Gets or sets options to control the node material overall behavior */
  130420. get options(): INodeMaterialOptions;
  130421. set options(options: INodeMaterialOptions);
  130422. /**
  130423. * Default configuration related to image processing available in the standard Material.
  130424. */
  130425. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  130426. /**
  130427. * Gets the image processing configuration used either in this material.
  130428. */
  130429. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  130430. /**
  130431. * Sets the Default image processing configuration used either in the this material.
  130432. *
  130433. * If sets to null, the scene one is in use.
  130434. */
  130435. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  130436. /**
  130437. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  130438. */
  130439. attachedBlocks: NodeMaterialBlock[];
  130440. /**
  130441. * Create a new node based material
  130442. * @param name defines the material name
  130443. * @param scene defines the hosting scene
  130444. * @param options defines creation option
  130445. */
  130446. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  130447. /**
  130448. * Gets the current class name of the material e.g. "NodeMaterial"
  130449. * @returns the class name
  130450. */
  130451. getClassName(): string;
  130452. /**
  130453. * Keep track of the image processing observer to allow dispose and replace.
  130454. */
  130455. private _imageProcessingObserver;
  130456. /**
  130457. * Attaches a new image processing configuration to the Standard Material.
  130458. * @param configuration
  130459. */
  130460. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  130461. /**
  130462. * Get a block by its name
  130463. * @param name defines the name of the block to retrieve
  130464. * @returns the required block or null if not found
  130465. */
  130466. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  130467. /**
  130468. * Get a block by its name
  130469. * @param predicate defines the predicate used to find the good candidate
  130470. * @returns the required block or null if not found
  130471. */
  130472. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  130473. /**
  130474. * Get an input block by its name
  130475. * @param predicate defines the predicate used to find the good candidate
  130476. * @returns the required input block or null if not found
  130477. */
  130478. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  130479. /**
  130480. * Gets the list of input blocks attached to this material
  130481. * @returns an array of InputBlocks
  130482. */
  130483. getInputBlocks(): InputBlock[];
  130484. /**
  130485. * Adds a new optimizer to the list of optimizers
  130486. * @param optimizer defines the optimizers to add
  130487. * @returns the current material
  130488. */
  130489. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130490. /**
  130491. * Remove an optimizer from the list of optimizers
  130492. * @param optimizer defines the optimizers to remove
  130493. * @returns the current material
  130494. */
  130495. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  130496. /**
  130497. * Add a new block to the list of output nodes
  130498. * @param node defines the node to add
  130499. * @returns the current material
  130500. */
  130501. addOutputNode(node: NodeMaterialBlock): this;
  130502. /**
  130503. * Remove a block from the list of root nodes
  130504. * @param node defines the node to remove
  130505. * @returns the current material
  130506. */
  130507. removeOutputNode(node: NodeMaterialBlock): this;
  130508. private _addVertexOutputNode;
  130509. private _removeVertexOutputNode;
  130510. private _addFragmentOutputNode;
  130511. private _removeFragmentOutputNode;
  130512. /**
  130513. * Specifies if the material will require alpha blending
  130514. * @returns a boolean specifying if alpha blending is needed
  130515. */
  130516. needAlphaBlending(): boolean;
  130517. /**
  130518. * Specifies if this material should be rendered in alpha test mode
  130519. * @returns a boolean specifying if an alpha test is needed.
  130520. */
  130521. needAlphaTesting(): boolean;
  130522. private _initializeBlock;
  130523. private _resetDualBlocks;
  130524. /**
  130525. * Remove a block from the current node material
  130526. * @param block defines the block to remove
  130527. */
  130528. removeBlock(block: NodeMaterialBlock): void;
  130529. /**
  130530. * Build the material and generates the inner effect
  130531. * @param verbose defines if the build should log activity
  130532. */
  130533. build(verbose?: boolean): void;
  130534. /**
  130535. * Runs an otpimization phase to try to improve the shader code
  130536. */
  130537. optimize(): void;
  130538. private _prepareDefinesForAttributes;
  130539. /**
  130540. * Get if the submesh is ready to be used and all its information available.
  130541. * Child classes can use it to update shaders
  130542. * @param mesh defines the mesh to check
  130543. * @param subMesh defines which submesh to check
  130544. * @param useInstances specifies that instances should be used
  130545. * @returns a boolean indicating that the submesh is ready or not
  130546. */
  130547. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  130548. /**
  130549. * Get a string representing the shaders built by the current node graph
  130550. */
  130551. get compiledShaders(): string;
  130552. /**
  130553. * Binds the world matrix to the material
  130554. * @param world defines the world transformation matrix
  130555. */
  130556. bindOnlyWorldMatrix(world: Matrix): void;
  130557. /**
  130558. * Binds the submesh to this material by preparing the effect and shader to draw
  130559. * @param world defines the world transformation matrix
  130560. * @param mesh defines the mesh containing the submesh
  130561. * @param subMesh defines the submesh to bind the material to
  130562. */
  130563. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  130564. /**
  130565. * Gets the active textures from the material
  130566. * @returns an array of textures
  130567. */
  130568. getActiveTextures(): BaseTexture[];
  130569. /**
  130570. * Gets the list of texture blocks
  130571. * @returns an array of texture blocks
  130572. */
  130573. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  130574. /**
  130575. * Specifies if the material uses a texture
  130576. * @param texture defines the texture to check against the material
  130577. * @returns a boolean specifying if the material uses the texture
  130578. */
  130579. hasTexture(texture: BaseTexture): boolean;
  130580. /**
  130581. * Disposes the material
  130582. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  130583. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  130584. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  130585. */
  130586. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  130587. /** Creates the node editor window. */
  130588. private _createNodeEditor;
  130589. /**
  130590. * Launch the node material editor
  130591. * @param config Define the configuration of the editor
  130592. * @return a promise fulfilled when the node editor is visible
  130593. */
  130594. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  130595. /**
  130596. * Clear the current material
  130597. */
  130598. clear(): void;
  130599. /**
  130600. * Clear the current material and set it to a default state
  130601. */
  130602. setToDefault(): void;
  130603. /**
  130604. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  130605. * @param url defines the url to load from
  130606. * @returns a promise that will fullfil when the material is fully loaded
  130607. */
  130608. loadAsync(url: string): Promise<void>;
  130609. private _gatherBlocks;
  130610. /**
  130611. * Generate a string containing the code declaration required to create an equivalent of this material
  130612. * @returns a string
  130613. */
  130614. generateCode(): string;
  130615. /**
  130616. * Serializes this material in a JSON representation
  130617. * @returns the serialized material object
  130618. */
  130619. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  130620. private _restoreConnections;
  130621. /**
  130622. * Clear the current graph and load a new one from a serialization object
  130623. * @param source defines the JSON representation of the material
  130624. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130625. */
  130626. loadFromSerialization(source: any, rootUrl?: string): void;
  130627. /**
  130628. * Creates a node material from parsed material data
  130629. * @param source defines the JSON representation of the material
  130630. * @param scene defines the hosting scene
  130631. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130632. * @returns a new node material
  130633. */
  130634. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  130635. /**
  130636. * Creates a node material from a snippet saved in a remote file
  130637. * @param name defines the name of the material to create
  130638. * @param url defines the url to load from
  130639. * @param scene defines the hosting scene
  130640. * @returns a promise that will resolve to the new node material
  130641. */
  130642. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  130643. /**
  130644. * Creates a node material from a snippet saved by the node material editor
  130645. * @param snippetId defines the snippet to load
  130646. * @param scene defines the hosting scene
  130647. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  130648. * @returns a promise that will resolve to the new node material
  130649. */
  130650. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<NodeMaterial>;
  130651. /**
  130652. * Creates a new node material set to default basic configuration
  130653. * @param name defines the name of the material
  130654. * @param scene defines the hosting scene
  130655. * @returns a new NodeMaterial
  130656. */
  130657. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  130658. }
  130659. }
  130660. declare module BABYLON {
  130661. /**
  130662. * Block used to read a texture from a sampler
  130663. */
  130664. export class TextureBlock extends NodeMaterialBlock {
  130665. private _defineName;
  130666. private _linearDefineName;
  130667. private _tempTextureRead;
  130668. private _samplerName;
  130669. private _transformedUVName;
  130670. private _textureTransformName;
  130671. private _textureInfoName;
  130672. private _mainUVName;
  130673. private _mainUVDefineName;
  130674. /**
  130675. * Gets or sets the texture associated with the node
  130676. */
  130677. texture: Nullable<Texture>;
  130678. /**
  130679. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  130680. */
  130681. convertToGammaSpace: boolean;
  130682. /**
  130683. * Create a new TextureBlock
  130684. * @param name defines the block name
  130685. */
  130686. constructor(name: string);
  130687. /**
  130688. * Gets the current class name
  130689. * @returns the class name
  130690. */
  130691. getClassName(): string;
  130692. /**
  130693. * Gets the uv input component
  130694. */
  130695. get uv(): NodeMaterialConnectionPoint;
  130696. /**
  130697. * Gets the rgba output component
  130698. */
  130699. get rgba(): NodeMaterialConnectionPoint;
  130700. /**
  130701. * Gets the rgb output component
  130702. */
  130703. get rgb(): NodeMaterialConnectionPoint;
  130704. /**
  130705. * Gets the r output component
  130706. */
  130707. get r(): NodeMaterialConnectionPoint;
  130708. /**
  130709. * Gets the g output component
  130710. */
  130711. get g(): NodeMaterialConnectionPoint;
  130712. /**
  130713. * Gets the b output component
  130714. */
  130715. get b(): NodeMaterialConnectionPoint;
  130716. /**
  130717. * Gets the a output component
  130718. */
  130719. get a(): NodeMaterialConnectionPoint;
  130720. get target(): NodeMaterialBlockTargets;
  130721. autoConfigure(material: NodeMaterial): void;
  130722. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  130723. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  130724. isReady(): boolean;
  130725. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  130726. private get _isMixed();
  130727. private _injectVertexCode;
  130728. private _writeTextureRead;
  130729. private _writeOutput;
  130730. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  130731. protected _dumpPropertiesCode(): string;
  130732. serialize(): any;
  130733. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  130734. }
  130735. }
  130736. declare module BABYLON {
  130737. /**
  130738. * Class used to store shared data between 2 NodeMaterialBuildState
  130739. */
  130740. export class NodeMaterialBuildStateSharedData {
  130741. /**
  130742. * Gets the list of emitted varyings
  130743. */
  130744. temps: string[];
  130745. /**
  130746. * Gets the list of emitted varyings
  130747. */
  130748. varyings: string[];
  130749. /**
  130750. * Gets the varying declaration string
  130751. */
  130752. varyingDeclaration: string;
  130753. /**
  130754. * Input blocks
  130755. */
  130756. inputBlocks: InputBlock[];
  130757. /**
  130758. * Input blocks
  130759. */
  130760. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  130761. /**
  130762. * Bindable blocks (Blocks that need to set data to the effect)
  130763. */
  130764. bindableBlocks: NodeMaterialBlock[];
  130765. /**
  130766. * List of blocks that can provide a compilation fallback
  130767. */
  130768. blocksWithFallbacks: NodeMaterialBlock[];
  130769. /**
  130770. * List of blocks that can provide a define update
  130771. */
  130772. blocksWithDefines: NodeMaterialBlock[];
  130773. /**
  130774. * List of blocks that can provide a repeatable content
  130775. */
  130776. repeatableContentBlocks: NodeMaterialBlock[];
  130777. /**
  130778. * List of blocks that can provide a dynamic list of uniforms
  130779. */
  130780. dynamicUniformBlocks: NodeMaterialBlock[];
  130781. /**
  130782. * List of blocks that can block the isReady function for the material
  130783. */
  130784. blockingBlocks: NodeMaterialBlock[];
  130785. /**
  130786. * Gets the list of animated inputs
  130787. */
  130788. animatedInputs: InputBlock[];
  130789. /**
  130790. * Build Id used to avoid multiple recompilations
  130791. */
  130792. buildId: number;
  130793. /** List of emitted variables */
  130794. variableNames: {
  130795. [key: string]: number;
  130796. };
  130797. /** List of emitted defines */
  130798. defineNames: {
  130799. [key: string]: number;
  130800. };
  130801. /** Should emit comments? */
  130802. emitComments: boolean;
  130803. /** Emit build activity */
  130804. verbose: boolean;
  130805. /** Gets or sets the hosting scene */
  130806. scene: Scene;
  130807. /**
  130808. * Gets the compilation hints emitted at compilation time
  130809. */
  130810. hints: {
  130811. needWorldViewMatrix: boolean;
  130812. needWorldViewProjectionMatrix: boolean;
  130813. needAlphaBlending: boolean;
  130814. needAlphaTesting: boolean;
  130815. };
  130816. /**
  130817. * List of compilation checks
  130818. */
  130819. checks: {
  130820. emitVertex: boolean;
  130821. emitFragment: boolean;
  130822. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  130823. };
  130824. /** Creates a new shared data */
  130825. constructor();
  130826. /**
  130827. * Emits console errors and exceptions if there is a failing check
  130828. */
  130829. emitErrors(): void;
  130830. }
  130831. }
  130832. declare module BABYLON {
  130833. /**
  130834. * Class used to store node based material build state
  130835. */
  130836. export class NodeMaterialBuildState {
  130837. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  130838. supportUniformBuffers: boolean;
  130839. /**
  130840. * Gets the list of emitted attributes
  130841. */
  130842. attributes: string[];
  130843. /**
  130844. * Gets the list of emitted uniforms
  130845. */
  130846. uniforms: string[];
  130847. /**
  130848. * Gets the list of emitted constants
  130849. */
  130850. constants: string[];
  130851. /**
  130852. * Gets the list of emitted samplers
  130853. */
  130854. samplers: string[];
  130855. /**
  130856. * Gets the list of emitted functions
  130857. */
  130858. functions: {
  130859. [key: string]: string;
  130860. };
  130861. /**
  130862. * Gets the list of emitted extensions
  130863. */
  130864. extensions: {
  130865. [key: string]: string;
  130866. };
  130867. /**
  130868. * Gets the target of the compilation state
  130869. */
  130870. target: NodeMaterialBlockTargets;
  130871. /**
  130872. * Gets the list of emitted counters
  130873. */
  130874. counters: {
  130875. [key: string]: number;
  130876. };
  130877. /**
  130878. * Shared data between multiple NodeMaterialBuildState instances
  130879. */
  130880. sharedData: NodeMaterialBuildStateSharedData;
  130881. /** @hidden */
  130882. _vertexState: NodeMaterialBuildState;
  130883. /** @hidden */
  130884. _attributeDeclaration: string;
  130885. /** @hidden */
  130886. _uniformDeclaration: string;
  130887. /** @hidden */
  130888. _constantDeclaration: string;
  130889. /** @hidden */
  130890. _samplerDeclaration: string;
  130891. /** @hidden */
  130892. _varyingTransfer: string;
  130893. private _repeatableContentAnchorIndex;
  130894. /** @hidden */
  130895. _builtCompilationString: string;
  130896. /**
  130897. * Gets the emitted compilation strings
  130898. */
  130899. compilationString: string;
  130900. /**
  130901. * Finalize the compilation strings
  130902. * @param state defines the current compilation state
  130903. */
  130904. finalize(state: NodeMaterialBuildState): void;
  130905. /** @hidden */
  130906. get _repeatableContentAnchor(): string;
  130907. /** @hidden */
  130908. _getFreeVariableName(prefix: string): string;
  130909. /** @hidden */
  130910. _getFreeDefineName(prefix: string): string;
  130911. /** @hidden */
  130912. _excludeVariableName(name: string): void;
  130913. /** @hidden */
  130914. _emit2DSampler(name: string): void;
  130915. /** @hidden */
  130916. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  130917. /** @hidden */
  130918. _emitExtension(name: string, extension: string): void;
  130919. /** @hidden */
  130920. _emitFunction(name: string, code: string, comments: string): void;
  130921. /** @hidden */
  130922. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  130923. replaceStrings?: {
  130924. search: RegExp;
  130925. replace: string;
  130926. }[];
  130927. repeatKey?: string;
  130928. }): string;
  130929. /** @hidden */
  130930. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  130931. repeatKey?: string;
  130932. removeAttributes?: boolean;
  130933. removeUniforms?: boolean;
  130934. removeVaryings?: boolean;
  130935. removeIfDef?: boolean;
  130936. replaceStrings?: {
  130937. search: RegExp;
  130938. replace: string;
  130939. }[];
  130940. }, storeKey?: string): void;
  130941. /** @hidden */
  130942. _registerTempVariable(name: string): boolean;
  130943. /** @hidden */
  130944. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  130945. /** @hidden */
  130946. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  130947. /** @hidden */
  130948. _emitFloat(value: number): string;
  130949. }
  130950. }
  130951. declare module BABYLON {
  130952. /**
  130953. * Defines a block that can be used inside a node based material
  130954. */
  130955. export class NodeMaterialBlock {
  130956. private _buildId;
  130957. private _buildTarget;
  130958. private _target;
  130959. private _isFinalMerger;
  130960. private _isInput;
  130961. protected _isUnique: boolean;
  130962. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  130963. inputsAreExclusive: boolean;
  130964. /** @hidden */
  130965. _codeVariableName: string;
  130966. /** @hidden */
  130967. _inputs: NodeMaterialConnectionPoint[];
  130968. /** @hidden */
  130969. _outputs: NodeMaterialConnectionPoint[];
  130970. /** @hidden */
  130971. _preparationId: number;
  130972. /**
  130973. * Gets or sets the name of the block
  130974. */
  130975. name: string;
  130976. /**
  130977. * Gets or sets the unique id of the node
  130978. */
  130979. uniqueId: number;
  130980. /**
  130981. * Gets or sets the comments associated with this block
  130982. */
  130983. comments: string;
  130984. /**
  130985. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  130986. */
  130987. get isUnique(): boolean;
  130988. /**
  130989. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  130990. */
  130991. get isFinalMerger(): boolean;
  130992. /**
  130993. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  130994. */
  130995. get isInput(): boolean;
  130996. /**
  130997. * Gets or sets the build Id
  130998. */
  130999. get buildId(): number;
  131000. set buildId(value: number);
  131001. /**
  131002. * Gets or sets the target of the block
  131003. */
  131004. get target(): NodeMaterialBlockTargets;
  131005. set target(value: NodeMaterialBlockTargets);
  131006. /**
  131007. * Gets the list of input points
  131008. */
  131009. get inputs(): NodeMaterialConnectionPoint[];
  131010. /** Gets the list of output points */
  131011. get outputs(): NodeMaterialConnectionPoint[];
  131012. /**
  131013. * Find an input by its name
  131014. * @param name defines the name of the input to look for
  131015. * @returns the input or null if not found
  131016. */
  131017. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  131018. /**
  131019. * Find an output by its name
  131020. * @param name defines the name of the outputto look for
  131021. * @returns the output or null if not found
  131022. */
  131023. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  131024. /**
  131025. * Creates a new NodeMaterialBlock
  131026. * @param name defines the block name
  131027. * @param target defines the target of that block (Vertex by default)
  131028. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  131029. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  131030. */
  131031. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  131032. /**
  131033. * Initialize the block and prepare the context for build
  131034. * @param state defines the state that will be used for the build
  131035. */
  131036. initialize(state: NodeMaterialBuildState): void;
  131037. /**
  131038. * Bind data to effect. Will only be called for blocks with isBindable === true
  131039. * @param effect defines the effect to bind data to
  131040. * @param nodeMaterial defines the hosting NodeMaterial
  131041. * @param mesh defines the mesh that will be rendered
  131042. */
  131043. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131044. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  131045. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  131046. protected _writeFloat(value: number): string;
  131047. /**
  131048. * Gets the current class name e.g. "NodeMaterialBlock"
  131049. * @returns the class name
  131050. */
  131051. getClassName(): string;
  131052. /**
  131053. * Register a new input. Must be called inside a block constructor
  131054. * @param name defines the connection point name
  131055. * @param type defines the connection point type
  131056. * @param isOptional defines a boolean indicating that this input can be omitted
  131057. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  131058. * @returns the current block
  131059. */
  131060. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  131061. /**
  131062. * Register a new output. Must be called inside a block constructor
  131063. * @param name defines the connection point name
  131064. * @param type defines the connection point type
  131065. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  131066. * @returns the current block
  131067. */
  131068. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  131069. /**
  131070. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  131071. * @param forOutput defines an optional connection point to check compatibility with
  131072. * @returns the first available input or null
  131073. */
  131074. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  131075. /**
  131076. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  131077. * @param forBlock defines an optional block to check compatibility with
  131078. * @returns the first available input or null
  131079. */
  131080. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  131081. /**
  131082. * Gets the sibling of the given output
  131083. * @param current defines the current output
  131084. * @returns the next output in the list or null
  131085. */
  131086. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  131087. /**
  131088. * Connect current block with another block
  131089. * @param other defines the block to connect with
  131090. * @param options define the various options to help pick the right connections
  131091. * @returns the current block
  131092. */
  131093. connectTo(other: NodeMaterialBlock, options?: {
  131094. input?: string;
  131095. output?: string;
  131096. outputSwizzle?: string;
  131097. }): this | undefined;
  131098. protected _buildBlock(state: NodeMaterialBuildState): void;
  131099. /**
  131100. * Add uniforms, samplers and uniform buffers at compilation time
  131101. * @param state defines the state to update
  131102. * @param nodeMaterial defines the node material requesting the update
  131103. * @param defines defines the material defines to update
  131104. * @param uniformBuffers defines the list of uniform buffer names
  131105. */
  131106. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131107. /**
  131108. * Add potential fallbacks if shader compilation fails
  131109. * @param mesh defines the mesh to be rendered
  131110. * @param fallbacks defines the current prioritized list of fallbacks
  131111. */
  131112. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131113. /**
  131114. * Initialize defines for shader compilation
  131115. * @param mesh defines the mesh to be rendered
  131116. * @param nodeMaterial defines the node material requesting the update
  131117. * @param defines defines the material defines to update
  131118. * @param useInstances specifies that instances should be used
  131119. */
  131120. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131121. /**
  131122. * Update defines for shader compilation
  131123. * @param mesh defines the mesh to be rendered
  131124. * @param nodeMaterial defines the node material requesting the update
  131125. * @param defines defines the material defines to update
  131126. * @param useInstances specifies that instances should be used
  131127. */
  131128. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131129. /**
  131130. * Lets the block try to connect some inputs automatically
  131131. * @param material defines the hosting NodeMaterial
  131132. */
  131133. autoConfigure(material: NodeMaterial): void;
  131134. /**
  131135. * Function called when a block is declared as repeatable content generator
  131136. * @param vertexShaderState defines the current compilation state for the vertex shader
  131137. * @param fragmentShaderState defines the current compilation state for the fragment shader
  131138. * @param mesh defines the mesh to be rendered
  131139. * @param defines defines the material defines to update
  131140. */
  131141. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131142. /**
  131143. * Checks if the block is ready
  131144. * @param mesh defines the mesh to be rendered
  131145. * @param nodeMaterial defines the node material requesting the update
  131146. * @param defines defines the material defines to update
  131147. * @param useInstances specifies that instances should be used
  131148. * @returns true if the block is ready
  131149. */
  131150. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  131151. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  131152. private _processBuild;
  131153. /**
  131154. * Compile the current node and generate the shader code
  131155. * @param state defines the current compilation state (uniforms, samplers, current string)
  131156. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  131157. * @returns true if already built
  131158. */
  131159. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  131160. protected _inputRename(name: string): string;
  131161. protected _outputRename(name: string): string;
  131162. protected _dumpPropertiesCode(): string;
  131163. /** @hidden */
  131164. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  131165. /** @hidden */
  131166. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  131167. /**
  131168. * Clone the current block to a new identical block
  131169. * @param scene defines the hosting scene
  131170. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  131171. * @returns a copy of the current block
  131172. */
  131173. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  131174. /**
  131175. * Serializes this block in a JSON representation
  131176. * @returns the serialized block object
  131177. */
  131178. serialize(): any;
  131179. /** @hidden */
  131180. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131181. /**
  131182. * Release resources
  131183. */
  131184. dispose(): void;
  131185. }
  131186. }
  131187. declare module BABYLON {
  131188. /**
  131189. * Enum defining the type of animations supported by InputBlock
  131190. */
  131191. export enum AnimatedInputBlockTypes {
  131192. /** No animation */
  131193. None = 0,
  131194. /** Time based animation. Will only work for floats */
  131195. Time = 1
  131196. }
  131197. }
  131198. declare module BABYLON {
  131199. /**
  131200. * Block used to expose an input value
  131201. */
  131202. export class InputBlock extends NodeMaterialBlock {
  131203. private _mode;
  131204. private _associatedVariableName;
  131205. private _storedValue;
  131206. private _valueCallback;
  131207. private _type;
  131208. private _animationType;
  131209. /** Gets or set a value used to limit the range of float values */
  131210. min: number;
  131211. /** Gets or set a value used to limit the range of float values */
  131212. max: number;
  131213. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  131214. isBoolean: boolean;
  131215. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  131216. matrixMode: number;
  131217. /** @hidden */
  131218. _systemValue: Nullable<NodeMaterialSystemValues>;
  131219. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  131220. visibleInInspector: boolean;
  131221. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  131222. isConstant: boolean;
  131223. /** Gets or sets the group to use to display this block in the Inspector */
  131224. groupInInspector: string;
  131225. /**
  131226. * Gets or sets the connection point type (default is float)
  131227. */
  131228. get type(): NodeMaterialBlockConnectionPointTypes;
  131229. /**
  131230. * Creates a new InputBlock
  131231. * @param name defines the block name
  131232. * @param target defines the target of that block (Vertex by default)
  131233. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  131234. */
  131235. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  131236. /**
  131237. * Gets the output component
  131238. */
  131239. get output(): NodeMaterialConnectionPoint;
  131240. /**
  131241. * Set the source of this connection point to a vertex attribute
  131242. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  131243. * @returns the current connection point
  131244. */
  131245. setAsAttribute(attributeName?: string): InputBlock;
  131246. /**
  131247. * Set the source of this connection point to a system value
  131248. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  131249. * @returns the current connection point
  131250. */
  131251. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  131252. /**
  131253. * Gets or sets the value of that point.
  131254. * Please note that this value will be ignored if valueCallback is defined
  131255. */
  131256. get value(): any;
  131257. set value(value: any);
  131258. /**
  131259. * Gets or sets a callback used to get the value of that point.
  131260. * Please note that setting this value will force the connection point to ignore the value property
  131261. */
  131262. get valueCallback(): () => any;
  131263. set valueCallback(value: () => any);
  131264. /**
  131265. * Gets or sets the associated variable name in the shader
  131266. */
  131267. get associatedVariableName(): string;
  131268. set associatedVariableName(value: string);
  131269. /** Gets or sets the type of animation applied to the input */
  131270. get animationType(): AnimatedInputBlockTypes;
  131271. set animationType(value: AnimatedInputBlockTypes);
  131272. /**
  131273. * Gets a boolean indicating that this connection point not defined yet
  131274. */
  131275. get isUndefined(): boolean;
  131276. /**
  131277. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  131278. * In this case the connection point name must be the name of the uniform to use.
  131279. * Can only be set on inputs
  131280. */
  131281. get isUniform(): boolean;
  131282. set isUniform(value: boolean);
  131283. /**
  131284. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  131285. * In this case the connection point name must be the name of the attribute to use
  131286. * Can only be set on inputs
  131287. */
  131288. get isAttribute(): boolean;
  131289. set isAttribute(value: boolean);
  131290. /**
  131291. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  131292. * Can only be set on exit points
  131293. */
  131294. get isVarying(): boolean;
  131295. set isVarying(value: boolean);
  131296. /**
  131297. * Gets a boolean indicating that the current connection point is a system value
  131298. */
  131299. get isSystemValue(): boolean;
  131300. /**
  131301. * Gets or sets the current well known value or null if not defined as a system value
  131302. */
  131303. get systemValue(): Nullable<NodeMaterialSystemValues>;
  131304. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  131305. /**
  131306. * Gets the current class name
  131307. * @returns the class name
  131308. */
  131309. getClassName(): string;
  131310. /**
  131311. * Animate the input if animationType !== None
  131312. * @param scene defines the rendering scene
  131313. */
  131314. animate(scene: Scene): void;
  131315. private _emitDefine;
  131316. initialize(state: NodeMaterialBuildState): void;
  131317. /**
  131318. * Set the input block to its default value (based on its type)
  131319. */
  131320. setDefaultValue(): void;
  131321. private _emitConstant;
  131322. private _emit;
  131323. /** @hidden */
  131324. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  131325. /** @hidden */
  131326. _transmit(effect: Effect, scene: Scene): void;
  131327. protected _buildBlock(state: NodeMaterialBuildState): void;
  131328. protected _dumpPropertiesCode(): string;
  131329. serialize(): any;
  131330. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131331. }
  131332. }
  131333. declare module BABYLON {
  131334. /**
  131335. * Enum used to define the compatibility state between two connection points
  131336. */
  131337. export enum NodeMaterialConnectionPointCompatibilityStates {
  131338. /** Points are compatibles */
  131339. Compatible = 0,
  131340. /** Points are incompatible because of their types */
  131341. TypeIncompatible = 1,
  131342. /** Points are incompatible because of their targets (vertex vs fragment) */
  131343. TargetIncompatible = 2
  131344. }
  131345. /**
  131346. * Defines the direction of a connection point
  131347. */
  131348. export enum NodeMaterialConnectionPointDirection {
  131349. /** Input */
  131350. Input = 0,
  131351. /** Output */
  131352. Output = 1
  131353. }
  131354. /**
  131355. * Defines a connection point for a block
  131356. */
  131357. export class NodeMaterialConnectionPoint {
  131358. /** @hidden */
  131359. _ownerBlock: NodeMaterialBlock;
  131360. /** @hidden */
  131361. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  131362. private _endpoints;
  131363. private _associatedVariableName;
  131364. private _direction;
  131365. /** @hidden */
  131366. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131367. /** @hidden */
  131368. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  131369. private _type;
  131370. /** @hidden */
  131371. _enforceAssociatedVariableName: boolean;
  131372. /** Gets the direction of the point */
  131373. get direction(): NodeMaterialConnectionPointDirection;
  131374. /**
  131375. * Gets or sets the additional types supported by this connection point
  131376. */
  131377. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131378. /**
  131379. * Gets or sets the additional types excluded by this connection point
  131380. */
  131381. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  131382. /**
  131383. * Observable triggered when this point is connected
  131384. */
  131385. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  131386. /**
  131387. * Gets or sets the associated variable name in the shader
  131388. */
  131389. get associatedVariableName(): string;
  131390. set associatedVariableName(value: string);
  131391. /** Get the inner type (ie AutoDetect for isntance instead of the inferred one) */
  131392. get innerType(): NodeMaterialBlockConnectionPointTypes;
  131393. /**
  131394. * Gets or sets the connection point type (default is float)
  131395. */
  131396. get type(): NodeMaterialBlockConnectionPointTypes;
  131397. set type(value: NodeMaterialBlockConnectionPointTypes);
  131398. /**
  131399. * Gets or sets the connection point name
  131400. */
  131401. name: string;
  131402. /**
  131403. * Gets or sets a boolean indicating that this connection point can be omitted
  131404. */
  131405. isOptional: boolean;
  131406. /**
  131407. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  131408. */
  131409. define: string;
  131410. /** @hidden */
  131411. _prioritizeVertex: boolean;
  131412. private _target;
  131413. /** Gets or sets the target of that connection point */
  131414. get target(): NodeMaterialBlockTargets;
  131415. set target(value: NodeMaterialBlockTargets);
  131416. /**
  131417. * Gets a boolean indicating that the current point is connected
  131418. */
  131419. get isConnected(): boolean;
  131420. /**
  131421. * Gets a boolean indicating that the current point is connected to an input block
  131422. */
  131423. get isConnectedToInputBlock(): boolean;
  131424. /**
  131425. * Gets a the connected input block (if any)
  131426. */
  131427. get connectInputBlock(): Nullable<InputBlock>;
  131428. /** Get the other side of the connection (if any) */
  131429. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  131430. /** Get the block that owns this connection point */
  131431. get ownerBlock(): NodeMaterialBlock;
  131432. /** Get the block connected on the other side of this connection (if any) */
  131433. get sourceBlock(): Nullable<NodeMaterialBlock>;
  131434. /** Get the block connected on the endpoints of this connection (if any) */
  131435. get connectedBlocks(): Array<NodeMaterialBlock>;
  131436. /** Gets the list of connected endpoints */
  131437. get endpoints(): NodeMaterialConnectionPoint[];
  131438. /** Gets a boolean indicating if that output point is connected to at least one input */
  131439. get hasEndpoints(): boolean;
  131440. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  131441. get isConnectedInVertexShader(): boolean;
  131442. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  131443. get isConnectedInFragmentShader(): boolean;
  131444. /**
  131445. * Creates a new connection point
  131446. * @param name defines the connection point name
  131447. * @param ownerBlock defines the block hosting this connection point
  131448. * @param direction defines the direction of the connection point
  131449. */
  131450. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  131451. /**
  131452. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  131453. * @returns the class name
  131454. */
  131455. getClassName(): string;
  131456. /**
  131457. * Gets a boolean indicating if the current point can be connected to another point
  131458. * @param connectionPoint defines the other connection point
  131459. * @returns a boolean
  131460. */
  131461. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  131462. /**
  131463. * Gets a number indicating if the current point can be connected to another point
  131464. * @param connectionPoint defines the other connection point
  131465. * @returns a number defining the compatibility state
  131466. */
  131467. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  131468. /**
  131469. * Connect this point to another connection point
  131470. * @param connectionPoint defines the other connection point
  131471. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  131472. * @returns the current connection point
  131473. */
  131474. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  131475. /**
  131476. * Disconnect this point from one of his endpoint
  131477. * @param endpoint defines the other connection point
  131478. * @returns the current connection point
  131479. */
  131480. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  131481. /**
  131482. * Serializes this point in a JSON representation
  131483. * @returns the serialized point object
  131484. */
  131485. serialize(): any;
  131486. /**
  131487. * Release resources
  131488. */
  131489. dispose(): void;
  131490. }
  131491. }
  131492. declare module BABYLON {
  131493. /**
  131494. * Block used to add support for vertex skinning (bones)
  131495. */
  131496. export class BonesBlock extends NodeMaterialBlock {
  131497. /**
  131498. * Creates a new BonesBlock
  131499. * @param name defines the block name
  131500. */
  131501. constructor(name: string);
  131502. /**
  131503. * Initialize the block and prepare the context for build
  131504. * @param state defines the state that will be used for the build
  131505. */
  131506. initialize(state: NodeMaterialBuildState): void;
  131507. /**
  131508. * Gets the current class name
  131509. * @returns the class name
  131510. */
  131511. getClassName(): string;
  131512. /**
  131513. * Gets the matrix indices input component
  131514. */
  131515. get matricesIndices(): NodeMaterialConnectionPoint;
  131516. /**
  131517. * Gets the matrix weights input component
  131518. */
  131519. get matricesWeights(): NodeMaterialConnectionPoint;
  131520. /**
  131521. * Gets the extra matrix indices input component
  131522. */
  131523. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  131524. /**
  131525. * Gets the extra matrix weights input component
  131526. */
  131527. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  131528. /**
  131529. * Gets the world input component
  131530. */
  131531. get world(): NodeMaterialConnectionPoint;
  131532. /**
  131533. * Gets the output component
  131534. */
  131535. get output(): NodeMaterialConnectionPoint;
  131536. autoConfigure(material: NodeMaterial): void;
  131537. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  131538. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131539. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131540. protected _buildBlock(state: NodeMaterialBuildState): this;
  131541. }
  131542. }
  131543. declare module BABYLON {
  131544. /**
  131545. * Block used to add support for instances
  131546. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  131547. */
  131548. export class InstancesBlock extends NodeMaterialBlock {
  131549. /**
  131550. * Creates a new InstancesBlock
  131551. * @param name defines the block name
  131552. */
  131553. constructor(name: string);
  131554. /**
  131555. * Gets the current class name
  131556. * @returns the class name
  131557. */
  131558. getClassName(): string;
  131559. /**
  131560. * Gets the first world row input component
  131561. */
  131562. get world0(): NodeMaterialConnectionPoint;
  131563. /**
  131564. * Gets the second world row input component
  131565. */
  131566. get world1(): NodeMaterialConnectionPoint;
  131567. /**
  131568. * Gets the third world row input component
  131569. */
  131570. get world2(): NodeMaterialConnectionPoint;
  131571. /**
  131572. * Gets the forth world row input component
  131573. */
  131574. get world3(): NodeMaterialConnectionPoint;
  131575. /**
  131576. * Gets the world input component
  131577. */
  131578. get world(): NodeMaterialConnectionPoint;
  131579. /**
  131580. * Gets the output component
  131581. */
  131582. get output(): NodeMaterialConnectionPoint;
  131583. /**
  131584. * Gets the isntanceID component
  131585. */
  131586. get instanceID(): NodeMaterialConnectionPoint;
  131587. autoConfigure(material: NodeMaterial): void;
  131588. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  131589. protected _buildBlock(state: NodeMaterialBuildState): this;
  131590. }
  131591. }
  131592. declare module BABYLON {
  131593. /**
  131594. * Block used to add morph targets support to vertex shader
  131595. */
  131596. export class MorphTargetsBlock extends NodeMaterialBlock {
  131597. private _repeatableContentAnchor;
  131598. /**
  131599. * Create a new MorphTargetsBlock
  131600. * @param name defines the block name
  131601. */
  131602. constructor(name: string);
  131603. /**
  131604. * Gets the current class name
  131605. * @returns the class name
  131606. */
  131607. getClassName(): string;
  131608. /**
  131609. * Gets the position input component
  131610. */
  131611. get position(): NodeMaterialConnectionPoint;
  131612. /**
  131613. * Gets the normal input component
  131614. */
  131615. get normal(): NodeMaterialConnectionPoint;
  131616. /**
  131617. * Gets the tangent input component
  131618. */
  131619. get tangent(): NodeMaterialConnectionPoint;
  131620. /**
  131621. * Gets the tangent input component
  131622. */
  131623. get uv(): NodeMaterialConnectionPoint;
  131624. /**
  131625. * Gets the position output component
  131626. */
  131627. get positionOutput(): NodeMaterialConnectionPoint;
  131628. /**
  131629. * Gets the normal output component
  131630. */
  131631. get normalOutput(): NodeMaterialConnectionPoint;
  131632. /**
  131633. * Gets the tangent output component
  131634. */
  131635. get tangentOutput(): NodeMaterialConnectionPoint;
  131636. /**
  131637. * Gets the tangent output component
  131638. */
  131639. get uvOutput(): NodeMaterialConnectionPoint;
  131640. initialize(state: NodeMaterialBuildState): void;
  131641. autoConfigure(material: NodeMaterial): void;
  131642. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131643. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131644. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  131645. protected _buildBlock(state: NodeMaterialBuildState): this;
  131646. }
  131647. }
  131648. declare module BABYLON {
  131649. /**
  131650. * Block used to get data information from a light
  131651. */
  131652. export class LightInformationBlock extends NodeMaterialBlock {
  131653. private _lightDataUniformName;
  131654. private _lightColorUniformName;
  131655. private _lightTypeDefineName;
  131656. /**
  131657. * Gets or sets the light associated with this block
  131658. */
  131659. light: Nullable<Light>;
  131660. /**
  131661. * Creates a new LightInformationBlock
  131662. * @param name defines the block name
  131663. */
  131664. constructor(name: string);
  131665. /**
  131666. * Gets the current class name
  131667. * @returns the class name
  131668. */
  131669. getClassName(): string;
  131670. /**
  131671. * Gets the world position input component
  131672. */
  131673. get worldPosition(): NodeMaterialConnectionPoint;
  131674. /**
  131675. * Gets the direction output component
  131676. */
  131677. get direction(): NodeMaterialConnectionPoint;
  131678. /**
  131679. * Gets the direction output component
  131680. */
  131681. get color(): NodeMaterialConnectionPoint;
  131682. /**
  131683. * Gets the direction output component
  131684. */
  131685. get intensity(): NodeMaterialConnectionPoint;
  131686. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131687. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131688. protected _buildBlock(state: NodeMaterialBuildState): this;
  131689. serialize(): any;
  131690. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131691. }
  131692. }
  131693. declare module BABYLON {
  131694. /**
  131695. * Block used to add image processing support to fragment shader
  131696. */
  131697. export class ImageProcessingBlock extends NodeMaterialBlock {
  131698. /**
  131699. * Create a new ImageProcessingBlock
  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 color input component
  131710. */
  131711. get color(): NodeMaterialConnectionPoint;
  131712. /**
  131713. * Gets the output component
  131714. */
  131715. get output(): NodeMaterialConnectionPoint;
  131716. /**
  131717. * Initialize the block and prepare the context for build
  131718. * @param state defines the state that will be used for the build
  131719. */
  131720. initialize(state: NodeMaterialBuildState): void;
  131721. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  131722. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131723. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131724. protected _buildBlock(state: NodeMaterialBuildState): this;
  131725. }
  131726. }
  131727. declare module BABYLON {
  131728. /**
  131729. * Block used to pertub normals based on a normal map
  131730. */
  131731. export class PerturbNormalBlock extends NodeMaterialBlock {
  131732. private _tangentSpaceParameterName;
  131733. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  131734. invertX: boolean;
  131735. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  131736. invertY: boolean;
  131737. /**
  131738. * Create a new PerturbNormalBlock
  131739. * @param name defines the block name
  131740. */
  131741. constructor(name: string);
  131742. /**
  131743. * Gets the current class name
  131744. * @returns the class name
  131745. */
  131746. getClassName(): string;
  131747. /**
  131748. * Gets the world position input component
  131749. */
  131750. get worldPosition(): NodeMaterialConnectionPoint;
  131751. /**
  131752. * Gets the world normal input component
  131753. */
  131754. get worldNormal(): NodeMaterialConnectionPoint;
  131755. /**
  131756. * Gets the world tangent input component
  131757. */
  131758. get worldTangent(): NodeMaterialConnectionPoint;
  131759. /**
  131760. * Gets the uv input component
  131761. */
  131762. get uv(): NodeMaterialConnectionPoint;
  131763. /**
  131764. * Gets the normal map color input component
  131765. */
  131766. get normalMapColor(): NodeMaterialConnectionPoint;
  131767. /**
  131768. * Gets the strength input component
  131769. */
  131770. get strength(): NodeMaterialConnectionPoint;
  131771. /**
  131772. * Gets the output component
  131773. */
  131774. get output(): NodeMaterialConnectionPoint;
  131775. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131776. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131777. autoConfigure(material: NodeMaterial): void;
  131778. protected _buildBlock(state: NodeMaterialBuildState): this;
  131779. protected _dumpPropertiesCode(): string;
  131780. serialize(): any;
  131781. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131782. }
  131783. }
  131784. declare module BABYLON {
  131785. /**
  131786. * Block used to discard a pixel if a value is smaller than a cutoff
  131787. */
  131788. export class DiscardBlock extends NodeMaterialBlock {
  131789. /**
  131790. * Create a new DiscardBlock
  131791. * @param name defines the block name
  131792. */
  131793. constructor(name: string);
  131794. /**
  131795. * Gets the current class name
  131796. * @returns the class name
  131797. */
  131798. getClassName(): string;
  131799. /**
  131800. * Gets the color input component
  131801. */
  131802. get value(): NodeMaterialConnectionPoint;
  131803. /**
  131804. * Gets the cutoff input component
  131805. */
  131806. get cutoff(): NodeMaterialConnectionPoint;
  131807. protected _buildBlock(state: NodeMaterialBuildState): this;
  131808. }
  131809. }
  131810. declare module BABYLON {
  131811. /**
  131812. * Block used to test if the fragment shader is front facing
  131813. */
  131814. export class FrontFacingBlock extends NodeMaterialBlock {
  131815. /**
  131816. * Creates a new FrontFacingBlock
  131817. * @param name defines the block name
  131818. */
  131819. constructor(name: string);
  131820. /**
  131821. * Gets the current class name
  131822. * @returns the class name
  131823. */
  131824. getClassName(): string;
  131825. /**
  131826. * Gets the output component
  131827. */
  131828. get output(): NodeMaterialConnectionPoint;
  131829. protected _buildBlock(state: NodeMaterialBuildState): this;
  131830. }
  131831. }
  131832. declare module BABYLON {
  131833. /**
  131834. * Block used to get the derivative value on x and y of a given input
  131835. */
  131836. export class DerivativeBlock extends NodeMaterialBlock {
  131837. /**
  131838. * Create a new DerivativeBlock
  131839. * @param name defines the block name
  131840. */
  131841. constructor(name: string);
  131842. /**
  131843. * Gets the current class name
  131844. * @returns the class name
  131845. */
  131846. getClassName(): string;
  131847. /**
  131848. * Gets the input component
  131849. */
  131850. get input(): NodeMaterialConnectionPoint;
  131851. /**
  131852. * Gets the derivative output on x
  131853. */
  131854. get dx(): NodeMaterialConnectionPoint;
  131855. /**
  131856. * Gets the derivative output on y
  131857. */
  131858. get dy(): NodeMaterialConnectionPoint;
  131859. protected _buildBlock(state: NodeMaterialBuildState): this;
  131860. }
  131861. }
  131862. declare module BABYLON {
  131863. /**
  131864. * Block used to add support for scene fog
  131865. */
  131866. export class FogBlock extends NodeMaterialBlock {
  131867. private _fogDistanceName;
  131868. private _fogParameters;
  131869. /**
  131870. * Create a new FogBlock
  131871. * @param name defines the block name
  131872. */
  131873. constructor(name: string);
  131874. /**
  131875. * Gets the current class name
  131876. * @returns the class name
  131877. */
  131878. getClassName(): string;
  131879. /**
  131880. * Gets the world position input component
  131881. */
  131882. get worldPosition(): NodeMaterialConnectionPoint;
  131883. /**
  131884. * Gets the view input component
  131885. */
  131886. get view(): NodeMaterialConnectionPoint;
  131887. /**
  131888. * Gets the color input component
  131889. */
  131890. get input(): NodeMaterialConnectionPoint;
  131891. /**
  131892. * Gets the fog color input component
  131893. */
  131894. get fogColor(): NodeMaterialConnectionPoint;
  131895. /**
  131896. * Gets the output component
  131897. */
  131898. get output(): NodeMaterialConnectionPoint;
  131899. autoConfigure(material: NodeMaterial): void;
  131900. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131901. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131902. protected _buildBlock(state: NodeMaterialBuildState): this;
  131903. }
  131904. }
  131905. declare module BABYLON {
  131906. /**
  131907. * Block used to add light in the fragment shader
  131908. */
  131909. export class LightBlock extends NodeMaterialBlock {
  131910. private _lightId;
  131911. /**
  131912. * Gets or sets the light associated with this block
  131913. */
  131914. light: Nullable<Light>;
  131915. /**
  131916. * Create a new LightBlock
  131917. * @param name defines the block name
  131918. */
  131919. constructor(name: string);
  131920. /**
  131921. * Gets the current class name
  131922. * @returns the class name
  131923. */
  131924. getClassName(): string;
  131925. /**
  131926. * Gets the world position input component
  131927. */
  131928. get worldPosition(): NodeMaterialConnectionPoint;
  131929. /**
  131930. * Gets the world normal input component
  131931. */
  131932. get worldNormal(): NodeMaterialConnectionPoint;
  131933. /**
  131934. * Gets the camera (or eye) position component
  131935. */
  131936. get cameraPosition(): NodeMaterialConnectionPoint;
  131937. /**
  131938. * Gets the glossiness component
  131939. */
  131940. get glossiness(): NodeMaterialConnectionPoint;
  131941. /**
  131942. * Gets the glossinness power component
  131943. */
  131944. get glossPower(): NodeMaterialConnectionPoint;
  131945. /**
  131946. * Gets the diffuse color component
  131947. */
  131948. get diffuseColor(): NodeMaterialConnectionPoint;
  131949. /**
  131950. * Gets the specular color component
  131951. */
  131952. get specularColor(): NodeMaterialConnectionPoint;
  131953. /**
  131954. * Gets the diffuse output component
  131955. */
  131956. get diffuseOutput(): NodeMaterialConnectionPoint;
  131957. /**
  131958. * Gets the specular output component
  131959. */
  131960. get specularOutput(): NodeMaterialConnectionPoint;
  131961. /**
  131962. * Gets the shadow output component
  131963. */
  131964. get shadow(): NodeMaterialConnectionPoint;
  131965. autoConfigure(material: NodeMaterial): void;
  131966. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131967. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  131968. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131969. private _injectVertexCode;
  131970. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131971. serialize(): any;
  131972. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131973. }
  131974. }
  131975. declare module BABYLON {
  131976. /**
  131977. * Block used to multiply 2 values
  131978. */
  131979. export class MultiplyBlock extends NodeMaterialBlock {
  131980. /**
  131981. * Creates a new MultiplyBlock
  131982. * @param name defines the block name
  131983. */
  131984. constructor(name: string);
  131985. /**
  131986. * Gets the current class name
  131987. * @returns the class name
  131988. */
  131989. getClassName(): string;
  131990. /**
  131991. * Gets the left operand input component
  131992. */
  131993. get left(): NodeMaterialConnectionPoint;
  131994. /**
  131995. * Gets the right operand input component
  131996. */
  131997. get right(): NodeMaterialConnectionPoint;
  131998. /**
  131999. * Gets the output component
  132000. */
  132001. get output(): NodeMaterialConnectionPoint;
  132002. protected _buildBlock(state: NodeMaterialBuildState): this;
  132003. }
  132004. }
  132005. declare module BABYLON {
  132006. /**
  132007. * Block used to add 2 vectors
  132008. */
  132009. export class AddBlock extends NodeMaterialBlock {
  132010. /**
  132011. * Creates a new AddBlock
  132012. * @param name defines the block name
  132013. */
  132014. constructor(name: string);
  132015. /**
  132016. * Gets the current class name
  132017. * @returns the class name
  132018. */
  132019. getClassName(): string;
  132020. /**
  132021. * Gets the left operand input component
  132022. */
  132023. get left(): NodeMaterialConnectionPoint;
  132024. /**
  132025. * Gets the right operand input component
  132026. */
  132027. get right(): NodeMaterialConnectionPoint;
  132028. /**
  132029. * Gets the output component
  132030. */
  132031. get output(): NodeMaterialConnectionPoint;
  132032. protected _buildBlock(state: NodeMaterialBuildState): this;
  132033. }
  132034. }
  132035. declare module BABYLON {
  132036. /**
  132037. * Block used to scale a vector by a float
  132038. */
  132039. export class ScaleBlock extends NodeMaterialBlock {
  132040. /**
  132041. * Creates a new ScaleBlock
  132042. * @param name defines the block name
  132043. */
  132044. constructor(name: string);
  132045. /**
  132046. * Gets the current class name
  132047. * @returns the class name
  132048. */
  132049. getClassName(): string;
  132050. /**
  132051. * Gets the input component
  132052. */
  132053. get input(): NodeMaterialConnectionPoint;
  132054. /**
  132055. * Gets the factor input component
  132056. */
  132057. get factor(): NodeMaterialConnectionPoint;
  132058. /**
  132059. * Gets the output component
  132060. */
  132061. get output(): NodeMaterialConnectionPoint;
  132062. protected _buildBlock(state: NodeMaterialBuildState): this;
  132063. }
  132064. }
  132065. declare module BABYLON {
  132066. /**
  132067. * Block used to clamp a float
  132068. */
  132069. export class ClampBlock extends NodeMaterialBlock {
  132070. /** Gets or sets the minimum range */
  132071. minimum: number;
  132072. /** Gets or sets the maximum range */
  132073. maximum: number;
  132074. /**
  132075. * Creates a new ClampBlock
  132076. * @param name defines the block name
  132077. */
  132078. constructor(name: string);
  132079. /**
  132080. * Gets the current class name
  132081. * @returns the class name
  132082. */
  132083. getClassName(): string;
  132084. /**
  132085. * Gets the value input component
  132086. */
  132087. get value(): NodeMaterialConnectionPoint;
  132088. /**
  132089. * Gets the output component
  132090. */
  132091. get output(): NodeMaterialConnectionPoint;
  132092. protected _buildBlock(state: NodeMaterialBuildState): this;
  132093. protected _dumpPropertiesCode(): string;
  132094. serialize(): any;
  132095. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132096. }
  132097. }
  132098. declare module BABYLON {
  132099. /**
  132100. * Block used to apply a cross product between 2 vectors
  132101. */
  132102. export class CrossBlock extends NodeMaterialBlock {
  132103. /**
  132104. * Creates a new CrossBlock
  132105. * @param name defines the block name
  132106. */
  132107. constructor(name: string);
  132108. /**
  132109. * Gets the current class name
  132110. * @returns the class name
  132111. */
  132112. getClassName(): string;
  132113. /**
  132114. * Gets the left operand input component
  132115. */
  132116. get left(): NodeMaterialConnectionPoint;
  132117. /**
  132118. * Gets the right operand input component
  132119. */
  132120. get right(): NodeMaterialConnectionPoint;
  132121. /**
  132122. * Gets the output component
  132123. */
  132124. get output(): NodeMaterialConnectionPoint;
  132125. protected _buildBlock(state: NodeMaterialBuildState): this;
  132126. }
  132127. }
  132128. declare module BABYLON {
  132129. /**
  132130. * Block used to apply a dot product between 2 vectors
  132131. */
  132132. export class DotBlock extends NodeMaterialBlock {
  132133. /**
  132134. * Creates a new DotBlock
  132135. * @param name defines the block name
  132136. */
  132137. constructor(name: string);
  132138. /**
  132139. * Gets the current class name
  132140. * @returns the class name
  132141. */
  132142. getClassName(): string;
  132143. /**
  132144. * Gets the left operand input component
  132145. */
  132146. get left(): NodeMaterialConnectionPoint;
  132147. /**
  132148. * Gets the right operand input component
  132149. */
  132150. get right(): NodeMaterialConnectionPoint;
  132151. /**
  132152. * Gets the output component
  132153. */
  132154. get output(): NodeMaterialConnectionPoint;
  132155. protected _buildBlock(state: NodeMaterialBuildState): this;
  132156. }
  132157. }
  132158. declare module BABYLON {
  132159. /**
  132160. * Block used to remap a float from a range to a new one
  132161. */
  132162. export class RemapBlock extends NodeMaterialBlock {
  132163. /**
  132164. * Gets or sets the source range
  132165. */
  132166. sourceRange: Vector2;
  132167. /**
  132168. * Gets or sets the target range
  132169. */
  132170. targetRange: Vector2;
  132171. /**
  132172. * Creates a new RemapBlock
  132173. * @param name defines the block name
  132174. */
  132175. constructor(name: string);
  132176. /**
  132177. * Gets the current class name
  132178. * @returns the class name
  132179. */
  132180. getClassName(): string;
  132181. /**
  132182. * Gets the input component
  132183. */
  132184. get input(): NodeMaterialConnectionPoint;
  132185. /**
  132186. * Gets the source min input component
  132187. */
  132188. get sourceMin(): NodeMaterialConnectionPoint;
  132189. /**
  132190. * Gets the source max input component
  132191. */
  132192. get sourceMax(): NodeMaterialConnectionPoint;
  132193. /**
  132194. * Gets the target min input component
  132195. */
  132196. get targetMin(): NodeMaterialConnectionPoint;
  132197. /**
  132198. * Gets the target max input component
  132199. */
  132200. get targetMax(): NodeMaterialConnectionPoint;
  132201. /**
  132202. * Gets the output component
  132203. */
  132204. get output(): NodeMaterialConnectionPoint;
  132205. protected _buildBlock(state: NodeMaterialBuildState): this;
  132206. protected _dumpPropertiesCode(): string;
  132207. serialize(): any;
  132208. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132209. }
  132210. }
  132211. declare module BABYLON {
  132212. /**
  132213. * Block used to normalize a vector
  132214. */
  132215. export class NormalizeBlock extends NodeMaterialBlock {
  132216. /**
  132217. * Creates a new NormalizeBlock
  132218. * @param name defines the block name
  132219. */
  132220. constructor(name: string);
  132221. /**
  132222. * Gets the current class name
  132223. * @returns the class name
  132224. */
  132225. getClassName(): string;
  132226. /**
  132227. * Gets the input component
  132228. */
  132229. get input(): NodeMaterialConnectionPoint;
  132230. /**
  132231. * Gets the output component
  132232. */
  132233. get output(): NodeMaterialConnectionPoint;
  132234. protected _buildBlock(state: NodeMaterialBuildState): this;
  132235. }
  132236. }
  132237. declare module BABYLON {
  132238. /**
  132239. * Operations supported by the Trigonometry block
  132240. */
  132241. export enum TrigonometryBlockOperations {
  132242. /** Cos */
  132243. Cos = 0,
  132244. /** Sin */
  132245. Sin = 1,
  132246. /** Abs */
  132247. Abs = 2,
  132248. /** Exp */
  132249. Exp = 3,
  132250. /** Exp2 */
  132251. Exp2 = 4,
  132252. /** Round */
  132253. Round = 5,
  132254. /** Floor */
  132255. Floor = 6,
  132256. /** Ceiling */
  132257. Ceiling = 7,
  132258. /** Square root */
  132259. Sqrt = 8,
  132260. /** Log */
  132261. Log = 9,
  132262. /** Tangent */
  132263. Tan = 10,
  132264. /** Arc tangent */
  132265. ArcTan = 11,
  132266. /** Arc cosinus */
  132267. ArcCos = 12,
  132268. /** Arc sinus */
  132269. ArcSin = 13,
  132270. /** Fraction */
  132271. Fract = 14,
  132272. /** Sign */
  132273. Sign = 15,
  132274. /** To radians (from degrees) */
  132275. Radians = 16,
  132276. /** To degrees (from radians) */
  132277. Degrees = 17
  132278. }
  132279. /**
  132280. * Block used to apply trigonometry operation to floats
  132281. */
  132282. export class TrigonometryBlock extends NodeMaterialBlock {
  132283. /**
  132284. * Gets or sets the operation applied by the block
  132285. */
  132286. operation: TrigonometryBlockOperations;
  132287. /**
  132288. * Creates a new TrigonometryBlock
  132289. * @param name defines the block name
  132290. */
  132291. constructor(name: string);
  132292. /**
  132293. * Gets the current class name
  132294. * @returns the class name
  132295. */
  132296. getClassName(): string;
  132297. /**
  132298. * Gets the input component
  132299. */
  132300. get input(): NodeMaterialConnectionPoint;
  132301. /**
  132302. * Gets the output component
  132303. */
  132304. get output(): NodeMaterialConnectionPoint;
  132305. protected _buildBlock(state: NodeMaterialBuildState): this;
  132306. serialize(): any;
  132307. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132308. protected _dumpPropertiesCode(): string;
  132309. }
  132310. }
  132311. declare module BABYLON {
  132312. /**
  132313. * Block used to create a Color3/4 out of individual inputs (one for each component)
  132314. */
  132315. export class ColorMergerBlock extends NodeMaterialBlock {
  132316. /**
  132317. * Create a new ColorMergerBlock
  132318. * @param name defines the block name
  132319. */
  132320. constructor(name: string);
  132321. /**
  132322. * Gets the current class name
  132323. * @returns the class name
  132324. */
  132325. getClassName(): string;
  132326. /**
  132327. * Gets the rgb component (input)
  132328. */
  132329. get rgbIn(): NodeMaterialConnectionPoint;
  132330. /**
  132331. * Gets the r component (input)
  132332. */
  132333. get r(): NodeMaterialConnectionPoint;
  132334. /**
  132335. * Gets the g component (input)
  132336. */
  132337. get g(): NodeMaterialConnectionPoint;
  132338. /**
  132339. * Gets the b component (input)
  132340. */
  132341. get b(): NodeMaterialConnectionPoint;
  132342. /**
  132343. * Gets the a component (input)
  132344. */
  132345. get a(): NodeMaterialConnectionPoint;
  132346. /**
  132347. * Gets the rgba component (output)
  132348. */
  132349. get rgba(): NodeMaterialConnectionPoint;
  132350. /**
  132351. * Gets the rgb component (output)
  132352. */
  132353. get rgbOut(): NodeMaterialConnectionPoint;
  132354. /**
  132355. * Gets the rgb component (output)
  132356. * @deprecated Please use rgbOut instead.
  132357. */
  132358. get rgb(): NodeMaterialConnectionPoint;
  132359. protected _buildBlock(state: NodeMaterialBuildState): this;
  132360. }
  132361. }
  132362. declare module BABYLON {
  132363. /**
  132364. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  132365. */
  132366. export class VectorMergerBlock extends NodeMaterialBlock {
  132367. /**
  132368. * Create a new VectorMergerBlock
  132369. * @param name defines the block name
  132370. */
  132371. constructor(name: string);
  132372. /**
  132373. * Gets the current class name
  132374. * @returns the class name
  132375. */
  132376. getClassName(): string;
  132377. /**
  132378. * Gets the xyz component (input)
  132379. */
  132380. get xyzIn(): NodeMaterialConnectionPoint;
  132381. /**
  132382. * Gets the xy component (input)
  132383. */
  132384. get xyIn(): NodeMaterialConnectionPoint;
  132385. /**
  132386. * Gets the x component (input)
  132387. */
  132388. get x(): NodeMaterialConnectionPoint;
  132389. /**
  132390. * Gets the y component (input)
  132391. */
  132392. get y(): NodeMaterialConnectionPoint;
  132393. /**
  132394. * Gets the z component (input)
  132395. */
  132396. get z(): NodeMaterialConnectionPoint;
  132397. /**
  132398. * Gets the w component (input)
  132399. */
  132400. get w(): NodeMaterialConnectionPoint;
  132401. /**
  132402. * Gets the xyzw component (output)
  132403. */
  132404. get xyzw(): NodeMaterialConnectionPoint;
  132405. /**
  132406. * Gets the xyz component (output)
  132407. */
  132408. get xyzOut(): NodeMaterialConnectionPoint;
  132409. /**
  132410. * Gets the xy component (output)
  132411. */
  132412. get xyOut(): NodeMaterialConnectionPoint;
  132413. /**
  132414. * Gets the xy component (output)
  132415. * @deprecated Please use xyOut instead.
  132416. */
  132417. get xy(): NodeMaterialConnectionPoint;
  132418. /**
  132419. * Gets the xyz component (output)
  132420. * @deprecated Please use xyzOut instead.
  132421. */
  132422. get xyz(): NodeMaterialConnectionPoint;
  132423. protected _buildBlock(state: NodeMaterialBuildState): this;
  132424. }
  132425. }
  132426. declare module BABYLON {
  132427. /**
  132428. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  132429. */
  132430. export class ColorSplitterBlock extends NodeMaterialBlock {
  132431. /**
  132432. * Create a new ColorSplitterBlock
  132433. * @param name defines the block name
  132434. */
  132435. constructor(name: string);
  132436. /**
  132437. * Gets the current class name
  132438. * @returns the class name
  132439. */
  132440. getClassName(): string;
  132441. /**
  132442. * Gets the rgba component (input)
  132443. */
  132444. get rgba(): NodeMaterialConnectionPoint;
  132445. /**
  132446. * Gets the rgb component (input)
  132447. */
  132448. get rgbIn(): NodeMaterialConnectionPoint;
  132449. /**
  132450. * Gets the rgb component (output)
  132451. */
  132452. get rgbOut(): NodeMaterialConnectionPoint;
  132453. /**
  132454. * Gets the r component (output)
  132455. */
  132456. get r(): NodeMaterialConnectionPoint;
  132457. /**
  132458. * Gets the g component (output)
  132459. */
  132460. get g(): NodeMaterialConnectionPoint;
  132461. /**
  132462. * Gets the b component (output)
  132463. */
  132464. get b(): NodeMaterialConnectionPoint;
  132465. /**
  132466. * Gets the a component (output)
  132467. */
  132468. get a(): NodeMaterialConnectionPoint;
  132469. protected _inputRename(name: string): string;
  132470. protected _outputRename(name: string): string;
  132471. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132472. }
  132473. }
  132474. declare module BABYLON {
  132475. /**
  132476. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  132477. */
  132478. export class VectorSplitterBlock extends NodeMaterialBlock {
  132479. /**
  132480. * Create a new VectorSplitterBlock
  132481. * @param name defines the block name
  132482. */
  132483. constructor(name: string);
  132484. /**
  132485. * Gets the current class name
  132486. * @returns the class name
  132487. */
  132488. getClassName(): string;
  132489. /**
  132490. * Gets the xyzw component (input)
  132491. */
  132492. get xyzw(): NodeMaterialConnectionPoint;
  132493. /**
  132494. * Gets the xyz component (input)
  132495. */
  132496. get xyzIn(): NodeMaterialConnectionPoint;
  132497. /**
  132498. * Gets the xy component (input)
  132499. */
  132500. get xyIn(): NodeMaterialConnectionPoint;
  132501. /**
  132502. * Gets the xyz component (output)
  132503. */
  132504. get xyzOut(): NodeMaterialConnectionPoint;
  132505. /**
  132506. * Gets the xy component (output)
  132507. */
  132508. get xyOut(): NodeMaterialConnectionPoint;
  132509. /**
  132510. * Gets the x component (output)
  132511. */
  132512. get x(): NodeMaterialConnectionPoint;
  132513. /**
  132514. * Gets the y component (output)
  132515. */
  132516. get y(): NodeMaterialConnectionPoint;
  132517. /**
  132518. * Gets the z component (output)
  132519. */
  132520. get z(): NodeMaterialConnectionPoint;
  132521. /**
  132522. * Gets the w component (output)
  132523. */
  132524. get w(): NodeMaterialConnectionPoint;
  132525. protected _inputRename(name: string): string;
  132526. protected _outputRename(name: string): string;
  132527. protected _buildBlock(state: NodeMaterialBuildState): this;
  132528. }
  132529. }
  132530. declare module BABYLON {
  132531. /**
  132532. * Block used to lerp between 2 values
  132533. */
  132534. export class LerpBlock extends NodeMaterialBlock {
  132535. /**
  132536. * Creates a new LerpBlock
  132537. * @param name defines the block name
  132538. */
  132539. constructor(name: string);
  132540. /**
  132541. * Gets the current class name
  132542. * @returns the class name
  132543. */
  132544. getClassName(): string;
  132545. /**
  132546. * Gets the left operand input component
  132547. */
  132548. get left(): NodeMaterialConnectionPoint;
  132549. /**
  132550. * Gets the right operand input component
  132551. */
  132552. get right(): NodeMaterialConnectionPoint;
  132553. /**
  132554. * Gets the gradient operand input component
  132555. */
  132556. get gradient(): NodeMaterialConnectionPoint;
  132557. /**
  132558. * Gets the output component
  132559. */
  132560. get output(): NodeMaterialConnectionPoint;
  132561. protected _buildBlock(state: NodeMaterialBuildState): this;
  132562. }
  132563. }
  132564. declare module BABYLON {
  132565. /**
  132566. * Block used to divide 2 vectors
  132567. */
  132568. export class DivideBlock extends NodeMaterialBlock {
  132569. /**
  132570. * Creates a new DivideBlock
  132571. * @param name defines the block name
  132572. */
  132573. constructor(name: string);
  132574. /**
  132575. * Gets the current class name
  132576. * @returns the class name
  132577. */
  132578. getClassName(): string;
  132579. /**
  132580. * Gets the left operand input component
  132581. */
  132582. get left(): NodeMaterialConnectionPoint;
  132583. /**
  132584. * Gets the right operand input component
  132585. */
  132586. get right(): NodeMaterialConnectionPoint;
  132587. /**
  132588. * Gets the output component
  132589. */
  132590. get output(): NodeMaterialConnectionPoint;
  132591. protected _buildBlock(state: NodeMaterialBuildState): this;
  132592. }
  132593. }
  132594. declare module BABYLON {
  132595. /**
  132596. * Block used to subtract 2 vectors
  132597. */
  132598. export class SubtractBlock extends NodeMaterialBlock {
  132599. /**
  132600. * Creates a new SubtractBlock
  132601. * @param name defines the block name
  132602. */
  132603. constructor(name: string);
  132604. /**
  132605. * Gets the current class name
  132606. * @returns the class name
  132607. */
  132608. getClassName(): string;
  132609. /**
  132610. * Gets the left operand input component
  132611. */
  132612. get left(): NodeMaterialConnectionPoint;
  132613. /**
  132614. * Gets the right operand input component
  132615. */
  132616. get right(): NodeMaterialConnectionPoint;
  132617. /**
  132618. * Gets the output component
  132619. */
  132620. get output(): NodeMaterialConnectionPoint;
  132621. protected _buildBlock(state: NodeMaterialBuildState): this;
  132622. }
  132623. }
  132624. declare module BABYLON {
  132625. /**
  132626. * Block used to step a value
  132627. */
  132628. export class StepBlock extends NodeMaterialBlock {
  132629. /**
  132630. * Creates a new StepBlock
  132631. * @param name defines the block name
  132632. */
  132633. constructor(name: string);
  132634. /**
  132635. * Gets the current class name
  132636. * @returns the class name
  132637. */
  132638. getClassName(): string;
  132639. /**
  132640. * Gets the value operand input component
  132641. */
  132642. get value(): NodeMaterialConnectionPoint;
  132643. /**
  132644. * Gets the edge operand input component
  132645. */
  132646. get edge(): NodeMaterialConnectionPoint;
  132647. /**
  132648. * Gets the output component
  132649. */
  132650. get output(): NodeMaterialConnectionPoint;
  132651. protected _buildBlock(state: NodeMaterialBuildState): this;
  132652. }
  132653. }
  132654. declare module BABYLON {
  132655. /**
  132656. * Block used to get the opposite (1 - x) of a value
  132657. */
  132658. export class OneMinusBlock extends NodeMaterialBlock {
  132659. /**
  132660. * Creates a new OneMinusBlock
  132661. * @param name defines the block name
  132662. */
  132663. constructor(name: string);
  132664. /**
  132665. * Gets the current class name
  132666. * @returns the class name
  132667. */
  132668. getClassName(): string;
  132669. /**
  132670. * Gets the input component
  132671. */
  132672. get input(): NodeMaterialConnectionPoint;
  132673. /**
  132674. * Gets the output component
  132675. */
  132676. get output(): NodeMaterialConnectionPoint;
  132677. protected _buildBlock(state: NodeMaterialBuildState): this;
  132678. }
  132679. }
  132680. declare module BABYLON {
  132681. /**
  132682. * Block used to get the view direction
  132683. */
  132684. export class ViewDirectionBlock extends NodeMaterialBlock {
  132685. /**
  132686. * Creates a new ViewDirectionBlock
  132687. * @param name defines the block name
  132688. */
  132689. constructor(name: string);
  132690. /**
  132691. * Gets the current class name
  132692. * @returns the class name
  132693. */
  132694. getClassName(): string;
  132695. /**
  132696. * Gets the world position component
  132697. */
  132698. get worldPosition(): NodeMaterialConnectionPoint;
  132699. /**
  132700. * Gets the camera position component
  132701. */
  132702. get cameraPosition(): NodeMaterialConnectionPoint;
  132703. /**
  132704. * Gets the output component
  132705. */
  132706. get output(): NodeMaterialConnectionPoint;
  132707. autoConfigure(material: NodeMaterial): void;
  132708. protected _buildBlock(state: NodeMaterialBuildState): this;
  132709. }
  132710. }
  132711. declare module BABYLON {
  132712. /**
  132713. * Block used to compute fresnel value
  132714. */
  132715. export class FresnelBlock extends NodeMaterialBlock {
  132716. /**
  132717. * Create a new FresnelBlock
  132718. * @param name defines the block name
  132719. */
  132720. constructor(name: string);
  132721. /**
  132722. * Gets the current class name
  132723. * @returns the class name
  132724. */
  132725. getClassName(): string;
  132726. /**
  132727. * Gets the world normal input component
  132728. */
  132729. get worldNormal(): NodeMaterialConnectionPoint;
  132730. /**
  132731. * Gets the view direction input component
  132732. */
  132733. get viewDirection(): NodeMaterialConnectionPoint;
  132734. /**
  132735. * Gets the bias input component
  132736. */
  132737. get bias(): NodeMaterialConnectionPoint;
  132738. /**
  132739. * Gets the camera (or eye) position component
  132740. */
  132741. get power(): NodeMaterialConnectionPoint;
  132742. /**
  132743. * Gets the fresnel output component
  132744. */
  132745. get fresnel(): NodeMaterialConnectionPoint;
  132746. autoConfigure(material: NodeMaterial): void;
  132747. protected _buildBlock(state: NodeMaterialBuildState): this;
  132748. }
  132749. }
  132750. declare module BABYLON {
  132751. /**
  132752. * Block used to get the max of 2 values
  132753. */
  132754. export class MaxBlock extends NodeMaterialBlock {
  132755. /**
  132756. * Creates a new MaxBlock
  132757. * @param name defines the block name
  132758. */
  132759. constructor(name: string);
  132760. /**
  132761. * Gets the current class name
  132762. * @returns the class name
  132763. */
  132764. getClassName(): string;
  132765. /**
  132766. * Gets the left operand input component
  132767. */
  132768. get left(): NodeMaterialConnectionPoint;
  132769. /**
  132770. * Gets the right operand input component
  132771. */
  132772. get right(): NodeMaterialConnectionPoint;
  132773. /**
  132774. * Gets the output component
  132775. */
  132776. get output(): NodeMaterialConnectionPoint;
  132777. protected _buildBlock(state: NodeMaterialBuildState): this;
  132778. }
  132779. }
  132780. declare module BABYLON {
  132781. /**
  132782. * Block used to get the min of 2 values
  132783. */
  132784. export class MinBlock extends NodeMaterialBlock {
  132785. /**
  132786. * Creates a new MinBlock
  132787. * @param name defines the block name
  132788. */
  132789. constructor(name: string);
  132790. /**
  132791. * Gets the current class name
  132792. * @returns the class name
  132793. */
  132794. getClassName(): string;
  132795. /**
  132796. * Gets the left operand input component
  132797. */
  132798. get left(): NodeMaterialConnectionPoint;
  132799. /**
  132800. * Gets the right operand input component
  132801. */
  132802. get right(): NodeMaterialConnectionPoint;
  132803. /**
  132804. * Gets the output component
  132805. */
  132806. get output(): NodeMaterialConnectionPoint;
  132807. protected _buildBlock(state: NodeMaterialBuildState): this;
  132808. }
  132809. }
  132810. declare module BABYLON {
  132811. /**
  132812. * Block used to get the distance between 2 values
  132813. */
  132814. export class DistanceBlock extends NodeMaterialBlock {
  132815. /**
  132816. * Creates a new DistanceBlock
  132817. * @param name defines the block name
  132818. */
  132819. constructor(name: string);
  132820. /**
  132821. * Gets the current class name
  132822. * @returns the class name
  132823. */
  132824. getClassName(): string;
  132825. /**
  132826. * Gets the left operand input component
  132827. */
  132828. get left(): NodeMaterialConnectionPoint;
  132829. /**
  132830. * Gets the right operand input component
  132831. */
  132832. get right(): NodeMaterialConnectionPoint;
  132833. /**
  132834. * Gets the output component
  132835. */
  132836. get output(): NodeMaterialConnectionPoint;
  132837. protected _buildBlock(state: NodeMaterialBuildState): this;
  132838. }
  132839. }
  132840. declare module BABYLON {
  132841. /**
  132842. * Block used to get the length of a vector
  132843. */
  132844. export class LengthBlock extends NodeMaterialBlock {
  132845. /**
  132846. * Creates a new LengthBlock
  132847. * @param name defines the block name
  132848. */
  132849. constructor(name: string);
  132850. /**
  132851. * Gets the current class name
  132852. * @returns the class name
  132853. */
  132854. getClassName(): string;
  132855. /**
  132856. * Gets the value input component
  132857. */
  132858. get value(): NodeMaterialConnectionPoint;
  132859. /**
  132860. * Gets the output component
  132861. */
  132862. get output(): NodeMaterialConnectionPoint;
  132863. protected _buildBlock(state: NodeMaterialBuildState): this;
  132864. }
  132865. }
  132866. declare module BABYLON {
  132867. /**
  132868. * Block used to get negative version of a value (i.e. x * -1)
  132869. */
  132870. export class NegateBlock extends NodeMaterialBlock {
  132871. /**
  132872. * Creates a new NegateBlock
  132873. * @param name defines the block name
  132874. */
  132875. constructor(name: string);
  132876. /**
  132877. * Gets the current class name
  132878. * @returns the class name
  132879. */
  132880. getClassName(): string;
  132881. /**
  132882. * Gets the value input component
  132883. */
  132884. get value(): NodeMaterialConnectionPoint;
  132885. /**
  132886. * Gets the output component
  132887. */
  132888. get output(): NodeMaterialConnectionPoint;
  132889. protected _buildBlock(state: NodeMaterialBuildState): this;
  132890. }
  132891. }
  132892. declare module BABYLON {
  132893. /**
  132894. * Block used to get the value of the first parameter raised to the power of the second
  132895. */
  132896. export class PowBlock extends NodeMaterialBlock {
  132897. /**
  132898. * Creates a new PowBlock
  132899. * @param name defines the block name
  132900. */
  132901. constructor(name: string);
  132902. /**
  132903. * Gets the current class name
  132904. * @returns the class name
  132905. */
  132906. getClassName(): string;
  132907. /**
  132908. * Gets the value operand input component
  132909. */
  132910. get value(): NodeMaterialConnectionPoint;
  132911. /**
  132912. * Gets the power operand input component
  132913. */
  132914. get power(): NodeMaterialConnectionPoint;
  132915. /**
  132916. * Gets the output component
  132917. */
  132918. get output(): NodeMaterialConnectionPoint;
  132919. protected _buildBlock(state: NodeMaterialBuildState): this;
  132920. }
  132921. }
  132922. declare module BABYLON {
  132923. /**
  132924. * Block used to get a random number
  132925. */
  132926. export class RandomNumberBlock extends NodeMaterialBlock {
  132927. /**
  132928. * Creates a new RandomNumberBlock
  132929. * @param name defines the block name
  132930. */
  132931. constructor(name: string);
  132932. /**
  132933. * Gets the current class name
  132934. * @returns the class name
  132935. */
  132936. getClassName(): string;
  132937. /**
  132938. * Gets the seed input component
  132939. */
  132940. get seed(): NodeMaterialConnectionPoint;
  132941. /**
  132942. * Gets the output component
  132943. */
  132944. get output(): NodeMaterialConnectionPoint;
  132945. protected _buildBlock(state: NodeMaterialBuildState): this;
  132946. }
  132947. }
  132948. declare module BABYLON {
  132949. /**
  132950. * Block used to compute arc tangent of 2 values
  132951. */
  132952. export class ArcTan2Block extends NodeMaterialBlock {
  132953. /**
  132954. * Creates a new ArcTan2Block
  132955. * @param name defines the block name
  132956. */
  132957. constructor(name: string);
  132958. /**
  132959. * Gets the current class name
  132960. * @returns the class name
  132961. */
  132962. getClassName(): string;
  132963. /**
  132964. * Gets the x operand input component
  132965. */
  132966. get x(): NodeMaterialConnectionPoint;
  132967. /**
  132968. * Gets the y operand input component
  132969. */
  132970. get y(): NodeMaterialConnectionPoint;
  132971. /**
  132972. * Gets the output component
  132973. */
  132974. get output(): NodeMaterialConnectionPoint;
  132975. protected _buildBlock(state: NodeMaterialBuildState): this;
  132976. }
  132977. }
  132978. declare module BABYLON {
  132979. /**
  132980. * Block used to smooth step a value
  132981. */
  132982. export class SmoothStepBlock extends NodeMaterialBlock {
  132983. /**
  132984. * Creates a new SmoothStepBlock
  132985. * @param name defines the block name
  132986. */
  132987. constructor(name: string);
  132988. /**
  132989. * Gets the current class name
  132990. * @returns the class name
  132991. */
  132992. getClassName(): string;
  132993. /**
  132994. * Gets the value operand input component
  132995. */
  132996. get value(): NodeMaterialConnectionPoint;
  132997. /**
  132998. * Gets the first edge operand input component
  132999. */
  133000. get edge0(): NodeMaterialConnectionPoint;
  133001. /**
  133002. * Gets the second edge operand input component
  133003. */
  133004. get edge1(): NodeMaterialConnectionPoint;
  133005. /**
  133006. * Gets the output component
  133007. */
  133008. get output(): NodeMaterialConnectionPoint;
  133009. protected _buildBlock(state: NodeMaterialBuildState): this;
  133010. }
  133011. }
  133012. declare module BABYLON {
  133013. /**
  133014. * Block used to get the reciprocal (1 / x) of a value
  133015. */
  133016. export class ReciprocalBlock extends NodeMaterialBlock {
  133017. /**
  133018. * Creates a new ReciprocalBlock
  133019. * @param name defines the block name
  133020. */
  133021. constructor(name: string);
  133022. /**
  133023. * Gets the current class name
  133024. * @returns the class name
  133025. */
  133026. getClassName(): string;
  133027. /**
  133028. * Gets the input component
  133029. */
  133030. get input(): NodeMaterialConnectionPoint;
  133031. /**
  133032. * Gets the output component
  133033. */
  133034. get output(): NodeMaterialConnectionPoint;
  133035. protected _buildBlock(state: NodeMaterialBuildState): this;
  133036. }
  133037. }
  133038. declare module BABYLON {
  133039. /**
  133040. * Block used to replace a color by another one
  133041. */
  133042. export class ReplaceColorBlock extends NodeMaterialBlock {
  133043. /**
  133044. * Creates a new ReplaceColorBlock
  133045. * @param name defines the block name
  133046. */
  133047. constructor(name: string);
  133048. /**
  133049. * Gets the current class name
  133050. * @returns the class name
  133051. */
  133052. getClassName(): string;
  133053. /**
  133054. * Gets the value input component
  133055. */
  133056. get value(): NodeMaterialConnectionPoint;
  133057. /**
  133058. * Gets the reference input component
  133059. */
  133060. get reference(): NodeMaterialConnectionPoint;
  133061. /**
  133062. * Gets the distance input component
  133063. */
  133064. get distance(): NodeMaterialConnectionPoint;
  133065. /**
  133066. * Gets the replacement input component
  133067. */
  133068. get replacement(): NodeMaterialConnectionPoint;
  133069. /**
  133070. * Gets the output component
  133071. */
  133072. get output(): NodeMaterialConnectionPoint;
  133073. protected _buildBlock(state: NodeMaterialBuildState): this;
  133074. }
  133075. }
  133076. declare module BABYLON {
  133077. /**
  133078. * Block used to posterize a value
  133079. * @see https://en.wikipedia.org/wiki/Posterization
  133080. */
  133081. export class PosterizeBlock extends NodeMaterialBlock {
  133082. /**
  133083. * Creates a new PosterizeBlock
  133084. * @param name defines the block name
  133085. */
  133086. constructor(name: string);
  133087. /**
  133088. * Gets the current class name
  133089. * @returns the class name
  133090. */
  133091. getClassName(): string;
  133092. /**
  133093. * Gets the value input component
  133094. */
  133095. get value(): NodeMaterialConnectionPoint;
  133096. /**
  133097. * Gets the steps input component
  133098. */
  133099. get steps(): NodeMaterialConnectionPoint;
  133100. /**
  133101. * Gets the output component
  133102. */
  133103. get output(): NodeMaterialConnectionPoint;
  133104. protected _buildBlock(state: NodeMaterialBuildState): this;
  133105. }
  133106. }
  133107. declare module BABYLON {
  133108. /**
  133109. * Operations supported by the Wave block
  133110. */
  133111. export enum WaveBlockKind {
  133112. /** SawTooth */
  133113. SawTooth = 0,
  133114. /** Square */
  133115. Square = 1,
  133116. /** Triangle */
  133117. Triangle = 2
  133118. }
  133119. /**
  133120. * Block used to apply wave operation to floats
  133121. */
  133122. export class WaveBlock extends NodeMaterialBlock {
  133123. /**
  133124. * Gets or sets the kibnd of wave to be applied by the block
  133125. */
  133126. kind: WaveBlockKind;
  133127. /**
  133128. * Creates a new WaveBlock
  133129. * @param name defines the block name
  133130. */
  133131. constructor(name: string);
  133132. /**
  133133. * Gets the current class name
  133134. * @returns the class name
  133135. */
  133136. getClassName(): string;
  133137. /**
  133138. * Gets the input component
  133139. */
  133140. get input(): NodeMaterialConnectionPoint;
  133141. /**
  133142. * Gets the output component
  133143. */
  133144. get output(): NodeMaterialConnectionPoint;
  133145. protected _buildBlock(state: NodeMaterialBuildState): this;
  133146. serialize(): any;
  133147. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133148. }
  133149. }
  133150. declare module BABYLON {
  133151. /**
  133152. * Class used to store a color step for the GradientBlock
  133153. */
  133154. export class GradientBlockColorStep {
  133155. /**
  133156. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133157. */
  133158. step: number;
  133159. /**
  133160. * Gets or sets the color associated with this step
  133161. */
  133162. color: Color3;
  133163. /**
  133164. * Creates a new GradientBlockColorStep
  133165. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  133166. * @param color defines the color associated with this step
  133167. */
  133168. constructor(
  133169. /**
  133170. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  133171. */
  133172. step: number,
  133173. /**
  133174. * Gets or sets the color associated with this step
  133175. */
  133176. color: Color3);
  133177. }
  133178. /**
  133179. * Block used to return a color from a gradient based on an input value between 0 and 1
  133180. */
  133181. export class GradientBlock extends NodeMaterialBlock {
  133182. /**
  133183. * Gets or sets the list of color steps
  133184. */
  133185. colorSteps: GradientBlockColorStep[];
  133186. /**
  133187. * Creates a new GradientBlock
  133188. * @param name defines the block name
  133189. */
  133190. constructor(name: string);
  133191. /**
  133192. * Gets the current class name
  133193. * @returns the class name
  133194. */
  133195. getClassName(): string;
  133196. /**
  133197. * Gets the gradient input component
  133198. */
  133199. get gradient(): NodeMaterialConnectionPoint;
  133200. /**
  133201. * Gets the output component
  133202. */
  133203. get output(): NodeMaterialConnectionPoint;
  133204. private _writeColorConstant;
  133205. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133206. serialize(): any;
  133207. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133208. protected _dumpPropertiesCode(): string;
  133209. }
  133210. }
  133211. declare module BABYLON {
  133212. /**
  133213. * Block used to normalize lerp between 2 values
  133214. */
  133215. export class NLerpBlock extends NodeMaterialBlock {
  133216. /**
  133217. * Creates a new NLerpBlock
  133218. * @param name defines the block name
  133219. */
  133220. constructor(name: string);
  133221. /**
  133222. * Gets the current class name
  133223. * @returns the class name
  133224. */
  133225. getClassName(): string;
  133226. /**
  133227. * Gets the left operand input component
  133228. */
  133229. get left(): NodeMaterialConnectionPoint;
  133230. /**
  133231. * Gets the right operand input component
  133232. */
  133233. get right(): NodeMaterialConnectionPoint;
  133234. /**
  133235. * Gets the gradient operand input component
  133236. */
  133237. get gradient(): NodeMaterialConnectionPoint;
  133238. /**
  133239. * Gets the output component
  133240. */
  133241. get output(): NodeMaterialConnectionPoint;
  133242. protected _buildBlock(state: NodeMaterialBuildState): this;
  133243. }
  133244. }
  133245. declare module BABYLON {
  133246. /**
  133247. * block used to Generate a Worley Noise 3D Noise Pattern
  133248. */
  133249. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  133250. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133251. manhattanDistance: boolean;
  133252. /**
  133253. * Creates a new WorleyNoise3DBlock
  133254. * @param name defines the block name
  133255. */
  133256. constructor(name: string);
  133257. /**
  133258. * Gets the current class name
  133259. * @returns the class name
  133260. */
  133261. getClassName(): string;
  133262. /**
  133263. * Gets the seed input component
  133264. */
  133265. get seed(): NodeMaterialConnectionPoint;
  133266. /**
  133267. * Gets the jitter input component
  133268. */
  133269. get jitter(): NodeMaterialConnectionPoint;
  133270. /**
  133271. * Gets the output component
  133272. */
  133273. get output(): NodeMaterialConnectionPoint;
  133274. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133275. /**
  133276. * Exposes the properties to the UI?
  133277. */
  133278. protected _dumpPropertiesCode(): string;
  133279. /**
  133280. * Exposes the properties to the Seralize?
  133281. */
  133282. serialize(): any;
  133283. /**
  133284. * Exposes the properties to the deseralize?
  133285. */
  133286. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133287. }
  133288. }
  133289. declare module BABYLON {
  133290. /**
  133291. * block used to Generate a Simplex Perlin 3d Noise Pattern
  133292. */
  133293. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  133294. /**
  133295. * Creates a new SimplexPerlin3DBlock
  133296. * @param name defines the block name
  133297. */
  133298. constructor(name: string);
  133299. /**
  133300. * Gets the current class name
  133301. * @returns the class name
  133302. */
  133303. getClassName(): string;
  133304. /**
  133305. * Gets the seed operand input component
  133306. */
  133307. get seed(): NodeMaterialConnectionPoint;
  133308. /**
  133309. * Gets the output component
  133310. */
  133311. get output(): NodeMaterialConnectionPoint;
  133312. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133313. }
  133314. }
  133315. declare module BABYLON {
  133316. /**
  133317. * Block used to blend normals
  133318. */
  133319. export class NormalBlendBlock extends NodeMaterialBlock {
  133320. /**
  133321. * Creates a new NormalBlendBlock
  133322. * @param name defines the block name
  133323. */
  133324. constructor(name: string);
  133325. /**
  133326. * Gets the current class name
  133327. * @returns the class name
  133328. */
  133329. getClassName(): string;
  133330. /**
  133331. * Gets the first input component
  133332. */
  133333. get normalMap0(): NodeMaterialConnectionPoint;
  133334. /**
  133335. * Gets the second input component
  133336. */
  133337. get normalMap1(): NodeMaterialConnectionPoint;
  133338. /**
  133339. * Gets the output component
  133340. */
  133341. get output(): NodeMaterialConnectionPoint;
  133342. protected _buildBlock(state: NodeMaterialBuildState): this;
  133343. }
  133344. }
  133345. declare module BABYLON {
  133346. /**
  133347. * Block used to rotate a 2d vector by a given angle
  133348. */
  133349. export class Rotate2dBlock extends NodeMaterialBlock {
  133350. /**
  133351. * Creates a new Rotate2dBlock
  133352. * @param name defines the block name
  133353. */
  133354. constructor(name: string);
  133355. /**
  133356. * Gets the current class name
  133357. * @returns the class name
  133358. */
  133359. getClassName(): string;
  133360. /**
  133361. * Gets the input vector
  133362. */
  133363. get input(): NodeMaterialConnectionPoint;
  133364. /**
  133365. * Gets the input angle
  133366. */
  133367. get angle(): NodeMaterialConnectionPoint;
  133368. /**
  133369. * Gets the output component
  133370. */
  133371. get output(): NodeMaterialConnectionPoint;
  133372. autoConfigure(material: NodeMaterial): void;
  133373. protected _buildBlock(state: NodeMaterialBuildState): this;
  133374. }
  133375. }
  133376. declare module BABYLON {
  133377. /**
  133378. * Block used to get the reflected vector from a direction and a normal
  133379. */
  133380. export class ReflectBlock extends NodeMaterialBlock {
  133381. /**
  133382. * Creates a new ReflectBlock
  133383. * @param name defines the block name
  133384. */
  133385. constructor(name: string);
  133386. /**
  133387. * Gets the current class name
  133388. * @returns the class name
  133389. */
  133390. getClassName(): string;
  133391. /**
  133392. * Gets the incident component
  133393. */
  133394. get incident(): NodeMaterialConnectionPoint;
  133395. /**
  133396. * Gets the normal component
  133397. */
  133398. get normal(): NodeMaterialConnectionPoint;
  133399. /**
  133400. * Gets the output component
  133401. */
  133402. get output(): NodeMaterialConnectionPoint;
  133403. protected _buildBlock(state: NodeMaterialBuildState): this;
  133404. }
  133405. }
  133406. declare module BABYLON {
  133407. /**
  133408. * Block used to get the refracted vector from a direction and a normal
  133409. */
  133410. export class RefractBlock extends NodeMaterialBlock {
  133411. /**
  133412. * Creates a new RefractBlock
  133413. * @param name defines the block name
  133414. */
  133415. constructor(name: string);
  133416. /**
  133417. * Gets the current class name
  133418. * @returns the class name
  133419. */
  133420. getClassName(): string;
  133421. /**
  133422. * Gets the incident component
  133423. */
  133424. get incident(): NodeMaterialConnectionPoint;
  133425. /**
  133426. * Gets the normal component
  133427. */
  133428. get normal(): NodeMaterialConnectionPoint;
  133429. /**
  133430. * Gets the index of refraction component
  133431. */
  133432. get ior(): NodeMaterialConnectionPoint;
  133433. /**
  133434. * Gets the output component
  133435. */
  133436. get output(): NodeMaterialConnectionPoint;
  133437. protected _buildBlock(state: NodeMaterialBuildState): this;
  133438. }
  133439. }
  133440. declare module BABYLON {
  133441. /**
  133442. * Block used to desaturate a color
  133443. */
  133444. export class DesaturateBlock extends NodeMaterialBlock {
  133445. /**
  133446. * Creates a new DesaturateBlock
  133447. * @param name defines the block name
  133448. */
  133449. constructor(name: string);
  133450. /**
  133451. * Gets the current class name
  133452. * @returns the class name
  133453. */
  133454. getClassName(): string;
  133455. /**
  133456. * Gets the color operand input component
  133457. */
  133458. get color(): NodeMaterialConnectionPoint;
  133459. /**
  133460. * Gets the level operand input component
  133461. */
  133462. get level(): NodeMaterialConnectionPoint;
  133463. /**
  133464. * Gets the output component
  133465. */
  133466. get output(): NodeMaterialConnectionPoint;
  133467. protected _buildBlock(state: NodeMaterialBuildState): this;
  133468. }
  133469. }
  133470. declare module BABYLON {
  133471. /**
  133472. * Effect Render Options
  133473. */
  133474. export interface IEffectRendererOptions {
  133475. /**
  133476. * Defines the vertices positions.
  133477. */
  133478. positions?: number[];
  133479. /**
  133480. * Defines the indices.
  133481. */
  133482. indices?: number[];
  133483. }
  133484. /**
  133485. * Helper class to render one or more effects
  133486. */
  133487. export class EffectRenderer {
  133488. private engine;
  133489. private static _DefaultOptions;
  133490. private _vertexBuffers;
  133491. private _indexBuffer;
  133492. private _ringBufferIndex;
  133493. private _ringScreenBuffer;
  133494. private _fullscreenViewport;
  133495. private _getNextFrameBuffer;
  133496. /**
  133497. * Creates an effect renderer
  133498. * @param engine the engine to use for rendering
  133499. * @param options defines the options of the effect renderer
  133500. */
  133501. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  133502. /**
  133503. * Sets the current viewport in normalized coordinates 0-1
  133504. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  133505. */
  133506. setViewport(viewport?: Viewport): void;
  133507. /**
  133508. * Binds the embedded attributes buffer to the effect.
  133509. * @param effect Defines the effect to bind the attributes for
  133510. */
  133511. bindBuffers(effect: Effect): void;
  133512. /**
  133513. * Sets the current effect wrapper to use during draw.
  133514. * The effect needs to be ready before calling this api.
  133515. * This also sets the default full screen position attribute.
  133516. * @param effectWrapper Defines the effect to draw with
  133517. */
  133518. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  133519. /**
  133520. * Draws a full screen quad.
  133521. */
  133522. draw(): void;
  133523. /**
  133524. * renders one or more effects to a specified texture
  133525. * @param effectWrappers list of effects to renderer
  133526. * @param outputTexture texture to draw to, if null it will render to the screen
  133527. */
  133528. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  133529. /**
  133530. * Disposes of the effect renderer
  133531. */
  133532. dispose(): void;
  133533. }
  133534. /**
  133535. * Options to create an EffectWrapper
  133536. */
  133537. interface EffectWrapperCreationOptions {
  133538. /**
  133539. * Engine to use to create the effect
  133540. */
  133541. engine: ThinEngine;
  133542. /**
  133543. * Fragment shader for the effect
  133544. */
  133545. fragmentShader: string;
  133546. /**
  133547. * Vertex shader for the effect
  133548. */
  133549. vertexShader?: string;
  133550. /**
  133551. * Attributes to use in the shader
  133552. */
  133553. attributeNames?: Array<string>;
  133554. /**
  133555. * Uniforms to use in the shader
  133556. */
  133557. uniformNames?: Array<string>;
  133558. /**
  133559. * Texture sampler names to use in the shader
  133560. */
  133561. samplerNames?: Array<string>;
  133562. /**
  133563. * The friendly name of the effect displayed in Spector.
  133564. */
  133565. name?: string;
  133566. }
  133567. /**
  133568. * Wraps an effect to be used for rendering
  133569. */
  133570. export class EffectWrapper {
  133571. /**
  133572. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  133573. */
  133574. onApplyObservable: Observable<{}>;
  133575. /**
  133576. * The underlying effect
  133577. */
  133578. effect: Effect;
  133579. /**
  133580. * Creates an effect to be renderer
  133581. * @param creationOptions options to create the effect
  133582. */
  133583. constructor(creationOptions: EffectWrapperCreationOptions);
  133584. /**
  133585. * Disposes of the effect wrapper
  133586. */
  133587. dispose(): void;
  133588. }
  133589. }
  133590. declare module BABYLON {
  133591. /**
  133592. * Helper class to push actions to a pool of workers.
  133593. */
  133594. export class WorkerPool implements IDisposable {
  133595. private _workerInfos;
  133596. private _pendingActions;
  133597. /**
  133598. * Constructor
  133599. * @param workers Array of workers to use for actions
  133600. */
  133601. constructor(workers: Array<Worker>);
  133602. /**
  133603. * Terminates all workers and clears any pending actions.
  133604. */
  133605. dispose(): void;
  133606. /**
  133607. * Pushes an action to the worker pool. If all the workers are active, the action will be
  133608. * pended until a worker has completed its action.
  133609. * @param action The action to perform. Call onComplete when the action is complete.
  133610. */
  133611. push(action: (worker: Worker, onComplete: () => void) => void): void;
  133612. private _execute;
  133613. }
  133614. }
  133615. declare module BABYLON {
  133616. /**
  133617. * Configuration for Draco compression
  133618. */
  133619. export interface IDracoCompressionConfiguration {
  133620. /**
  133621. * Configuration for the decoder.
  133622. */
  133623. decoder: {
  133624. /**
  133625. * The url to the WebAssembly module.
  133626. */
  133627. wasmUrl?: string;
  133628. /**
  133629. * The url to the WebAssembly binary.
  133630. */
  133631. wasmBinaryUrl?: string;
  133632. /**
  133633. * The url to the fallback JavaScript module.
  133634. */
  133635. fallbackUrl?: string;
  133636. };
  133637. }
  133638. /**
  133639. * Draco compression (https://google.github.io/draco/)
  133640. *
  133641. * This class wraps the Draco module.
  133642. *
  133643. * **Encoder**
  133644. *
  133645. * The encoder is not currently implemented.
  133646. *
  133647. * **Decoder**
  133648. *
  133649. * 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.
  133650. *
  133651. * To update the configuration, use the following code:
  133652. * ```javascript
  133653. * DracoCompression.Configuration = {
  133654. * decoder: {
  133655. * wasmUrl: "<url to the WebAssembly library>",
  133656. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  133657. * fallbackUrl: "<url to the fallback JavaScript library>",
  133658. * }
  133659. * };
  133660. * ```
  133661. *
  133662. * 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.
  133663. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  133664. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  133665. *
  133666. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  133667. * ```javascript
  133668. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  133669. * ```
  133670. *
  133671. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  133672. */
  133673. export class DracoCompression implements IDisposable {
  133674. private _workerPoolPromise?;
  133675. private _decoderModulePromise?;
  133676. /**
  133677. * The configuration. Defaults to the following urls:
  133678. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  133679. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  133680. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  133681. */
  133682. static Configuration: IDracoCompressionConfiguration;
  133683. /**
  133684. * Returns true if the decoder configuration is available.
  133685. */
  133686. static get DecoderAvailable(): boolean;
  133687. /**
  133688. * Default number of workers to create when creating the draco compression object.
  133689. */
  133690. static DefaultNumWorkers: number;
  133691. private static GetDefaultNumWorkers;
  133692. private static _Default;
  133693. /**
  133694. * Default instance for the draco compression object.
  133695. */
  133696. static get Default(): DracoCompression;
  133697. /**
  133698. * Constructor
  133699. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  133700. */
  133701. constructor(numWorkers?: number);
  133702. /**
  133703. * Stop all async operations and release resources.
  133704. */
  133705. dispose(): void;
  133706. /**
  133707. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  133708. * @returns a promise that resolves when ready
  133709. */
  133710. whenReadyAsync(): Promise<void>;
  133711. /**
  133712. * Decode Draco compressed mesh data to vertex data.
  133713. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  133714. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  133715. * @returns A promise that resolves with the decoded vertex data
  133716. */
  133717. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  133718. [kind: string]: number;
  133719. }): Promise<VertexData>;
  133720. }
  133721. }
  133722. declare module BABYLON {
  133723. /**
  133724. * Class for building Constructive Solid Geometry
  133725. */
  133726. export class CSG {
  133727. private polygons;
  133728. /**
  133729. * The world matrix
  133730. */
  133731. matrix: Matrix;
  133732. /**
  133733. * Stores the position
  133734. */
  133735. position: Vector3;
  133736. /**
  133737. * Stores the rotation
  133738. */
  133739. rotation: Vector3;
  133740. /**
  133741. * Stores the rotation quaternion
  133742. */
  133743. rotationQuaternion: Nullable<Quaternion>;
  133744. /**
  133745. * Stores the scaling vector
  133746. */
  133747. scaling: Vector3;
  133748. /**
  133749. * Convert the Mesh to CSG
  133750. * @param mesh The Mesh to convert to CSG
  133751. * @returns A new CSG from the Mesh
  133752. */
  133753. static FromMesh(mesh: Mesh): CSG;
  133754. /**
  133755. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  133756. * @param polygons Polygons used to construct a CSG solid
  133757. */
  133758. private static FromPolygons;
  133759. /**
  133760. * Clones, or makes a deep copy, of the CSG
  133761. * @returns A new CSG
  133762. */
  133763. clone(): CSG;
  133764. /**
  133765. * Unions this CSG with another CSG
  133766. * @param csg The CSG to union against this CSG
  133767. * @returns The unioned CSG
  133768. */
  133769. union(csg: CSG): CSG;
  133770. /**
  133771. * Unions this CSG with another CSG in place
  133772. * @param csg The CSG to union against this CSG
  133773. */
  133774. unionInPlace(csg: CSG): void;
  133775. /**
  133776. * Subtracts this CSG with another CSG
  133777. * @param csg The CSG to subtract against this CSG
  133778. * @returns A new CSG
  133779. */
  133780. subtract(csg: CSG): CSG;
  133781. /**
  133782. * Subtracts this CSG with another CSG in place
  133783. * @param csg The CSG to subtact against this CSG
  133784. */
  133785. subtractInPlace(csg: CSG): void;
  133786. /**
  133787. * Intersect this CSG with another CSG
  133788. * @param csg The CSG to intersect against this CSG
  133789. * @returns A new CSG
  133790. */
  133791. intersect(csg: CSG): CSG;
  133792. /**
  133793. * Intersects this CSG with another CSG in place
  133794. * @param csg The CSG to intersect against this CSG
  133795. */
  133796. intersectInPlace(csg: CSG): void;
  133797. /**
  133798. * Return a new CSG solid with solid and empty space switched. This solid is
  133799. * not modified.
  133800. * @returns A new CSG solid with solid and empty space switched
  133801. */
  133802. inverse(): CSG;
  133803. /**
  133804. * Inverses the CSG in place
  133805. */
  133806. inverseInPlace(): void;
  133807. /**
  133808. * This is used to keep meshes transformations so they can be restored
  133809. * when we build back a Babylon Mesh
  133810. * NB : All CSG operations are performed in world coordinates
  133811. * @param csg The CSG to copy the transform attributes from
  133812. * @returns This CSG
  133813. */
  133814. copyTransformAttributes(csg: CSG): CSG;
  133815. /**
  133816. * Build Raw mesh from CSG
  133817. * Coordinates here are in world space
  133818. * @param name The name of the mesh geometry
  133819. * @param scene The Scene
  133820. * @param keepSubMeshes Specifies if the submeshes should be kept
  133821. * @returns A new Mesh
  133822. */
  133823. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133824. /**
  133825. * Build Mesh from CSG taking material and transforms into account
  133826. * @param name The name of the Mesh
  133827. * @param material The material of the Mesh
  133828. * @param scene The Scene
  133829. * @param keepSubMeshes Specifies if submeshes should be kept
  133830. * @returns The new Mesh
  133831. */
  133832. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  133833. }
  133834. }
  133835. declare module BABYLON {
  133836. /**
  133837. * Class used to create a trail following a mesh
  133838. */
  133839. export class TrailMesh extends Mesh {
  133840. private _generator;
  133841. private _autoStart;
  133842. private _running;
  133843. private _diameter;
  133844. private _length;
  133845. private _sectionPolygonPointsCount;
  133846. private _sectionVectors;
  133847. private _sectionNormalVectors;
  133848. private _beforeRenderObserver;
  133849. /**
  133850. * @constructor
  133851. * @param name The value used by scene.getMeshByName() to do a lookup.
  133852. * @param generator The mesh or transform node to generate a trail.
  133853. * @param scene The scene to add this mesh to.
  133854. * @param diameter Diameter of trailing mesh. Default is 1.
  133855. * @param length Length of trailing mesh. Default is 60.
  133856. * @param autoStart Automatically start trailing mesh. Default true.
  133857. */
  133858. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  133859. /**
  133860. * "TrailMesh"
  133861. * @returns "TrailMesh"
  133862. */
  133863. getClassName(): string;
  133864. private _createMesh;
  133865. /**
  133866. * Start trailing mesh.
  133867. */
  133868. start(): void;
  133869. /**
  133870. * Stop trailing mesh.
  133871. */
  133872. stop(): void;
  133873. /**
  133874. * Update trailing mesh geometry.
  133875. */
  133876. update(): void;
  133877. /**
  133878. * Returns a new TrailMesh object.
  133879. * @param name is a string, the name given to the new mesh
  133880. * @param newGenerator use new generator object for cloned trail mesh
  133881. * @returns a new mesh
  133882. */
  133883. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  133884. /**
  133885. * Serializes this trail mesh
  133886. * @param serializationObject object to write serialization to
  133887. */
  133888. serialize(serializationObject: any): void;
  133889. /**
  133890. * Parses a serialized trail mesh
  133891. * @param parsedMesh the serialized mesh
  133892. * @param scene the scene to create the trail mesh in
  133893. * @returns the created trail mesh
  133894. */
  133895. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  133896. }
  133897. }
  133898. declare module BABYLON {
  133899. /**
  133900. * Class containing static functions to help procedurally build meshes
  133901. */
  133902. export class TiledBoxBuilder {
  133903. /**
  133904. * Creates a box mesh
  133905. * 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)
  133906. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  133907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133908. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133909. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  133910. * @param name defines the name of the mesh
  133911. * @param options defines the options used to create the mesh
  133912. * @param scene defines the hosting scene
  133913. * @returns the box mesh
  133914. */
  133915. static CreateTiledBox(name: string, options: {
  133916. pattern?: number;
  133917. width?: number;
  133918. height?: number;
  133919. depth?: number;
  133920. tileSize?: number;
  133921. tileWidth?: number;
  133922. tileHeight?: number;
  133923. alignHorizontal?: number;
  133924. alignVertical?: number;
  133925. faceUV?: Vector4[];
  133926. faceColors?: Color4[];
  133927. sideOrientation?: number;
  133928. updatable?: boolean;
  133929. }, scene?: Nullable<Scene>): Mesh;
  133930. }
  133931. }
  133932. declare module BABYLON {
  133933. /**
  133934. * Class containing static functions to help procedurally build meshes
  133935. */
  133936. export class TorusKnotBuilder {
  133937. /**
  133938. * Creates a torus knot mesh
  133939. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  133940. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  133941. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  133942. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  133943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  133944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  133945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  133946. * @param name defines the name of the mesh
  133947. * @param options defines the options used to create the mesh
  133948. * @param scene defines the hosting scene
  133949. * @returns the torus knot mesh
  133950. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  133951. */
  133952. static CreateTorusKnot(name: string, options: {
  133953. radius?: number;
  133954. tube?: number;
  133955. radialSegments?: number;
  133956. tubularSegments?: number;
  133957. p?: number;
  133958. q?: number;
  133959. updatable?: boolean;
  133960. sideOrientation?: number;
  133961. frontUVs?: Vector4;
  133962. backUVs?: Vector4;
  133963. }, scene: any): Mesh;
  133964. }
  133965. }
  133966. declare module BABYLON {
  133967. /**
  133968. * Polygon
  133969. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  133970. */
  133971. export class Polygon {
  133972. /**
  133973. * Creates a rectangle
  133974. * @param xmin bottom X coord
  133975. * @param ymin bottom Y coord
  133976. * @param xmax top X coord
  133977. * @param ymax top Y coord
  133978. * @returns points that make the resulting rectation
  133979. */
  133980. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  133981. /**
  133982. * Creates a circle
  133983. * @param radius radius of circle
  133984. * @param cx scale in x
  133985. * @param cy scale in y
  133986. * @param numberOfSides number of sides that make up the circle
  133987. * @returns points that make the resulting circle
  133988. */
  133989. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  133990. /**
  133991. * Creates a polygon from input string
  133992. * @param input Input polygon data
  133993. * @returns the parsed points
  133994. */
  133995. static Parse(input: string): Vector2[];
  133996. /**
  133997. * Starts building a polygon from x and y coordinates
  133998. * @param x x coordinate
  133999. * @param y y coordinate
  134000. * @returns the started path2
  134001. */
  134002. static StartingAt(x: number, y: number): Path2;
  134003. }
  134004. /**
  134005. * Builds a polygon
  134006. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  134007. */
  134008. export class PolygonMeshBuilder {
  134009. private _points;
  134010. private _outlinepoints;
  134011. private _holes;
  134012. private _name;
  134013. private _scene;
  134014. private _epoints;
  134015. private _eholes;
  134016. private _addToepoint;
  134017. /**
  134018. * Babylon reference to the earcut plugin.
  134019. */
  134020. bjsEarcut: any;
  134021. /**
  134022. * Creates a PolygonMeshBuilder
  134023. * @param name name of the builder
  134024. * @param contours Path of the polygon
  134025. * @param scene scene to add to when creating the mesh
  134026. * @param earcutInjection can be used to inject your own earcut reference
  134027. */
  134028. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  134029. /**
  134030. * Adds a whole within the polygon
  134031. * @param hole Array of points defining the hole
  134032. * @returns this
  134033. */
  134034. addHole(hole: Vector2[]): PolygonMeshBuilder;
  134035. /**
  134036. * Creates the polygon
  134037. * @param updatable If the mesh should be updatable
  134038. * @param depth The depth of the mesh created
  134039. * @returns the created mesh
  134040. */
  134041. build(updatable?: boolean, depth?: number): Mesh;
  134042. /**
  134043. * Creates the polygon
  134044. * @param depth The depth of the mesh created
  134045. * @returns the created VertexData
  134046. */
  134047. buildVertexData(depth?: number): VertexData;
  134048. /**
  134049. * Adds a side to the polygon
  134050. * @param positions points that make the polygon
  134051. * @param normals normals of the polygon
  134052. * @param uvs uvs of the polygon
  134053. * @param indices indices of the polygon
  134054. * @param bounds bounds of the polygon
  134055. * @param points points of the polygon
  134056. * @param depth depth of the polygon
  134057. * @param flip flip of the polygon
  134058. */
  134059. private addSide;
  134060. }
  134061. }
  134062. declare module BABYLON {
  134063. /**
  134064. * Class containing static functions to help procedurally build meshes
  134065. */
  134066. export class PolygonBuilder {
  134067. /**
  134068. * Creates a polygon mesh
  134069. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134070. * * 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
  134071. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134073. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134074. * * Remember you can only change the shape positions, not their number when updating a polygon
  134075. * @param name defines the name of the mesh
  134076. * @param options defines the options used to create the mesh
  134077. * @param scene defines the hosting scene
  134078. * @param earcutInjection can be used to inject your own earcut reference
  134079. * @returns the polygon mesh
  134080. */
  134081. static CreatePolygon(name: string, options: {
  134082. shape: Vector3[];
  134083. holes?: Vector3[][];
  134084. depth?: number;
  134085. faceUV?: Vector4[];
  134086. faceColors?: Color4[];
  134087. updatable?: boolean;
  134088. sideOrientation?: number;
  134089. frontUVs?: Vector4;
  134090. backUVs?: Vector4;
  134091. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134092. /**
  134093. * Creates an extruded polygon mesh, with depth in the Y direction.
  134094. * * 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)
  134095. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134096. * @param name defines the name of the mesh
  134097. * @param options defines the options used to create the mesh
  134098. * @param scene defines the hosting scene
  134099. * @param earcutInjection can be used to inject your own earcut reference
  134100. * @returns the polygon mesh
  134101. */
  134102. static ExtrudePolygon(name: string, options: {
  134103. shape: Vector3[];
  134104. holes?: Vector3[][];
  134105. depth?: number;
  134106. faceUV?: Vector4[];
  134107. faceColors?: Color4[];
  134108. updatable?: boolean;
  134109. sideOrientation?: number;
  134110. frontUVs?: Vector4;
  134111. backUVs?: Vector4;
  134112. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134113. }
  134114. }
  134115. declare module BABYLON {
  134116. /**
  134117. * Class containing static functions to help procedurally build meshes
  134118. */
  134119. export class LatheBuilder {
  134120. /**
  134121. * Creates lathe mesh.
  134122. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134123. * * 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
  134124. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134125. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134126. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134127. * * 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
  134128. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134129. * * 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
  134130. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134131. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134132. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134134. * @param name defines the name of the mesh
  134135. * @param options defines the options used to create the mesh
  134136. * @param scene defines the hosting scene
  134137. * @returns the lathe mesh
  134138. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134139. */
  134140. static CreateLathe(name: string, options: {
  134141. shape: Vector3[];
  134142. radius?: number;
  134143. tessellation?: number;
  134144. clip?: number;
  134145. arc?: number;
  134146. closed?: boolean;
  134147. updatable?: boolean;
  134148. sideOrientation?: number;
  134149. frontUVs?: Vector4;
  134150. backUVs?: Vector4;
  134151. cap?: number;
  134152. invertUV?: boolean;
  134153. }, scene?: Nullable<Scene>): Mesh;
  134154. }
  134155. }
  134156. declare module BABYLON {
  134157. /**
  134158. * Class containing static functions to help procedurally build meshes
  134159. */
  134160. export class TiledPlaneBuilder {
  134161. /**
  134162. * Creates a tiled plane mesh
  134163. * * The parameter `pattern` will, depending on value, do nothing or
  134164. * * * flip (reflect about central vertical) alternate tiles across and up
  134165. * * * flip every tile on alternate rows
  134166. * * * rotate (180 degs) alternate tiles across and up
  134167. * * * rotate every tile on alternate rows
  134168. * * * flip and rotate alternate tiles across and up
  134169. * * * flip and rotate every tile on alternate rows
  134170. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  134171. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  134172. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134173. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134174. * * 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)
  134175. * * 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)
  134176. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134177. * @param name defines the name of the mesh
  134178. * @param options defines the options used to create the mesh
  134179. * @param scene defines the hosting scene
  134180. * @returns the box mesh
  134181. */
  134182. static CreateTiledPlane(name: string, options: {
  134183. pattern?: number;
  134184. tileSize?: number;
  134185. tileWidth?: number;
  134186. tileHeight?: number;
  134187. size?: number;
  134188. width?: number;
  134189. height?: number;
  134190. alignHorizontal?: number;
  134191. alignVertical?: number;
  134192. sideOrientation?: number;
  134193. frontUVs?: Vector4;
  134194. backUVs?: Vector4;
  134195. updatable?: boolean;
  134196. }, scene?: Nullable<Scene>): Mesh;
  134197. }
  134198. }
  134199. declare module BABYLON {
  134200. /**
  134201. * Class containing static functions to help procedurally build meshes
  134202. */
  134203. export class TubeBuilder {
  134204. /**
  134205. * Creates a tube mesh.
  134206. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134207. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134208. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134209. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134210. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134211. * * 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)
  134212. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134213. * * 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
  134214. * * 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
  134215. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134216. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134217. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134218. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134219. * @param name defines the name of the mesh
  134220. * @param options defines the options used to create the mesh
  134221. * @param scene defines the hosting scene
  134222. * @returns the tube mesh
  134223. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134224. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134225. */
  134226. static CreateTube(name: string, options: {
  134227. path: Vector3[];
  134228. radius?: number;
  134229. tessellation?: number;
  134230. radiusFunction?: {
  134231. (i: number, distance: number): number;
  134232. };
  134233. cap?: number;
  134234. arc?: number;
  134235. updatable?: boolean;
  134236. sideOrientation?: number;
  134237. frontUVs?: Vector4;
  134238. backUVs?: Vector4;
  134239. instance?: Mesh;
  134240. invertUV?: boolean;
  134241. }, scene?: Nullable<Scene>): Mesh;
  134242. }
  134243. }
  134244. declare module BABYLON {
  134245. /**
  134246. * Class containing static functions to help procedurally build meshes
  134247. */
  134248. export class IcoSphereBuilder {
  134249. /**
  134250. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134251. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134252. * * 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`)
  134253. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134254. * * 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
  134255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134256. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134258. * @param name defines the name of the mesh
  134259. * @param options defines the options used to create the mesh
  134260. * @param scene defines the hosting scene
  134261. * @returns the icosahedron mesh
  134262. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134263. */
  134264. static CreateIcoSphere(name: string, options: {
  134265. radius?: number;
  134266. radiusX?: number;
  134267. radiusY?: number;
  134268. radiusZ?: number;
  134269. flat?: boolean;
  134270. subdivisions?: number;
  134271. sideOrientation?: number;
  134272. frontUVs?: Vector4;
  134273. backUVs?: Vector4;
  134274. updatable?: boolean;
  134275. }, scene?: Nullable<Scene>): Mesh;
  134276. }
  134277. }
  134278. declare module BABYLON {
  134279. /**
  134280. * Class containing static functions to help procedurally build meshes
  134281. */
  134282. export class DecalBuilder {
  134283. /**
  134284. * Creates a decal mesh.
  134285. * 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
  134286. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  134287. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  134288. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  134289. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  134290. * @param name defines the name of the mesh
  134291. * @param sourceMesh defines the mesh where the decal must be applied
  134292. * @param options defines the options used to create the mesh
  134293. * @param scene defines the hosting scene
  134294. * @returns the decal mesh
  134295. * @see https://doc.babylonjs.com/how_to/decals
  134296. */
  134297. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  134298. position?: Vector3;
  134299. normal?: Vector3;
  134300. size?: Vector3;
  134301. angle?: number;
  134302. }): Mesh;
  134303. }
  134304. }
  134305. declare module BABYLON {
  134306. /**
  134307. * Class containing static functions to help procedurally build meshes
  134308. */
  134309. export class MeshBuilder {
  134310. /**
  134311. * Creates a box mesh
  134312. * * The parameter `size` sets the size (float) of each box side (default 1)
  134313. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  134314. * * 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)
  134315. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134316. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134317. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134318. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134319. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  134320. * @param name defines the name of the mesh
  134321. * @param options defines the options used to create the mesh
  134322. * @param scene defines the hosting scene
  134323. * @returns the box mesh
  134324. */
  134325. static CreateBox(name: string, options: {
  134326. size?: number;
  134327. width?: number;
  134328. height?: number;
  134329. depth?: number;
  134330. faceUV?: Vector4[];
  134331. faceColors?: Color4[];
  134332. sideOrientation?: number;
  134333. frontUVs?: Vector4;
  134334. backUVs?: Vector4;
  134335. updatable?: boolean;
  134336. }, scene?: Nullable<Scene>): Mesh;
  134337. /**
  134338. * Creates a tiled box mesh
  134339. * * faceTiles sets the pattern, tile size and number of tiles for a face
  134340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134341. * @param name defines the name of the mesh
  134342. * @param options defines the options used to create the mesh
  134343. * @param scene defines the hosting scene
  134344. * @returns the tiled box mesh
  134345. */
  134346. static CreateTiledBox(name: string, options: {
  134347. pattern?: number;
  134348. size?: number;
  134349. width?: number;
  134350. height?: number;
  134351. depth: number;
  134352. tileSize?: number;
  134353. tileWidth?: number;
  134354. tileHeight?: number;
  134355. faceUV?: Vector4[];
  134356. faceColors?: Color4[];
  134357. alignHorizontal?: number;
  134358. alignVertical?: number;
  134359. sideOrientation?: number;
  134360. updatable?: boolean;
  134361. }, scene?: Nullable<Scene>): Mesh;
  134362. /**
  134363. * Creates a sphere mesh
  134364. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  134365. * * 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`)
  134366. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  134367. * * 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
  134368. * * 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)
  134369. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134370. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134371. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134372. * @param name defines the name of the mesh
  134373. * @param options defines the options used to create the mesh
  134374. * @param scene defines the hosting scene
  134375. * @returns the sphere mesh
  134376. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  134377. */
  134378. static CreateSphere(name: string, options: {
  134379. segments?: number;
  134380. diameter?: number;
  134381. diameterX?: number;
  134382. diameterY?: number;
  134383. diameterZ?: number;
  134384. arc?: number;
  134385. slice?: number;
  134386. sideOrientation?: number;
  134387. frontUVs?: Vector4;
  134388. backUVs?: Vector4;
  134389. updatable?: boolean;
  134390. }, scene?: Nullable<Scene>): Mesh;
  134391. /**
  134392. * Creates a plane polygonal mesh. By default, this is a disc
  134393. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  134394. * * 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
  134395. * * 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
  134396. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134397. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134398. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134399. * @param name defines the name of the mesh
  134400. * @param options defines the options used to create the mesh
  134401. * @param scene defines the hosting scene
  134402. * @returns the plane polygonal mesh
  134403. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  134404. */
  134405. static CreateDisc(name: string, options: {
  134406. radius?: number;
  134407. tessellation?: number;
  134408. arc?: number;
  134409. updatable?: boolean;
  134410. sideOrientation?: number;
  134411. frontUVs?: Vector4;
  134412. backUVs?: Vector4;
  134413. }, scene?: Nullable<Scene>): Mesh;
  134414. /**
  134415. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  134416. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  134417. * * 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`)
  134418. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  134419. * * 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
  134420. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134421. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134422. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134423. * @param name defines the name of the mesh
  134424. * @param options defines the options used to create the mesh
  134425. * @param scene defines the hosting scene
  134426. * @returns the icosahedron mesh
  134427. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  134428. */
  134429. static CreateIcoSphere(name: string, options: {
  134430. radius?: number;
  134431. radiusX?: number;
  134432. radiusY?: number;
  134433. radiusZ?: number;
  134434. flat?: boolean;
  134435. subdivisions?: number;
  134436. sideOrientation?: number;
  134437. frontUVs?: Vector4;
  134438. backUVs?: Vector4;
  134439. updatable?: boolean;
  134440. }, scene?: Nullable<Scene>): Mesh;
  134441. /**
  134442. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134443. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  134444. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  134445. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  134446. * * 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
  134447. * * 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
  134448. * * 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
  134449. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134450. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134451. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134452. * * 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
  134453. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  134454. * * 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
  134455. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  134456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134457. * @param name defines the name of the mesh
  134458. * @param options defines the options used to create the mesh
  134459. * @param scene defines the hosting scene
  134460. * @returns the ribbon mesh
  134461. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  134462. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134463. */
  134464. static CreateRibbon(name: string, options: {
  134465. pathArray: Vector3[][];
  134466. closeArray?: boolean;
  134467. closePath?: boolean;
  134468. offset?: number;
  134469. updatable?: boolean;
  134470. sideOrientation?: number;
  134471. frontUVs?: Vector4;
  134472. backUVs?: Vector4;
  134473. instance?: Mesh;
  134474. invertUV?: boolean;
  134475. uvs?: Vector2[];
  134476. colors?: Color4[];
  134477. }, scene?: Nullable<Scene>): Mesh;
  134478. /**
  134479. * Creates a cylinder or a cone mesh
  134480. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  134481. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  134482. * * 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.
  134483. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  134484. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  134485. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  134486. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  134487. * * 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).
  134488. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  134489. * * 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).
  134490. * * 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
  134491. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  134492. * * 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
  134493. * * 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.
  134494. * * If `enclose` is false, a ring surface is one element.
  134495. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  134496. * * 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
  134497. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134498. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134499. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134500. * @param name defines the name of the mesh
  134501. * @param options defines the options used to create the mesh
  134502. * @param scene defines the hosting scene
  134503. * @returns the cylinder mesh
  134504. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  134505. */
  134506. static CreateCylinder(name: string, options: {
  134507. height?: number;
  134508. diameterTop?: number;
  134509. diameterBottom?: number;
  134510. diameter?: number;
  134511. tessellation?: number;
  134512. subdivisions?: number;
  134513. arc?: number;
  134514. faceColors?: Color4[];
  134515. faceUV?: Vector4[];
  134516. updatable?: boolean;
  134517. hasRings?: boolean;
  134518. enclose?: boolean;
  134519. cap?: number;
  134520. sideOrientation?: number;
  134521. frontUVs?: Vector4;
  134522. backUVs?: Vector4;
  134523. }, scene?: Nullable<Scene>): Mesh;
  134524. /**
  134525. * Creates a torus mesh
  134526. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  134527. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  134528. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  134529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134530. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134532. * @param name defines the name of the mesh
  134533. * @param options defines the options used to create the mesh
  134534. * @param scene defines the hosting scene
  134535. * @returns the torus mesh
  134536. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  134537. */
  134538. static CreateTorus(name: string, options: {
  134539. diameter?: number;
  134540. thickness?: number;
  134541. tessellation?: number;
  134542. updatable?: boolean;
  134543. sideOrientation?: number;
  134544. frontUVs?: Vector4;
  134545. backUVs?: Vector4;
  134546. }, scene?: Nullable<Scene>): Mesh;
  134547. /**
  134548. * Creates a torus knot mesh
  134549. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  134550. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  134551. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  134552. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  134553. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134554. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134555. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134556. * @param name defines the name of the mesh
  134557. * @param options defines the options used to create the mesh
  134558. * @param scene defines the hosting scene
  134559. * @returns the torus knot mesh
  134560. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  134561. */
  134562. static CreateTorusKnot(name: string, options: {
  134563. radius?: number;
  134564. tube?: number;
  134565. radialSegments?: number;
  134566. tubularSegments?: number;
  134567. p?: number;
  134568. q?: number;
  134569. updatable?: boolean;
  134570. sideOrientation?: number;
  134571. frontUVs?: Vector4;
  134572. backUVs?: Vector4;
  134573. }, scene?: Nullable<Scene>): Mesh;
  134574. /**
  134575. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  134576. * * 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
  134577. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  134578. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  134579. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  134580. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  134581. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  134582. * * 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
  134583. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  134584. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134585. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  134586. * @param name defines the name of the new line system
  134587. * @param options defines the options used to create the line system
  134588. * @param scene defines the hosting scene
  134589. * @returns a new line system mesh
  134590. */
  134591. static CreateLineSystem(name: string, options: {
  134592. lines: Vector3[][];
  134593. updatable?: boolean;
  134594. instance?: Nullable<LinesMesh>;
  134595. colors?: Nullable<Color4[][]>;
  134596. useVertexAlpha?: boolean;
  134597. }, scene: Nullable<Scene>): LinesMesh;
  134598. /**
  134599. * Creates a line mesh
  134600. * 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
  134601. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134602. * * The parameter `points` is an array successive Vector3
  134603. * * 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
  134604. * * The optional parameter `colors` is an array of successive Color4, one per line point
  134605. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  134606. * * When updating an instance, remember that only point positions can change, not the number of points
  134607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134608. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  134609. * @param name defines the name of the new line system
  134610. * @param options defines the options used to create the line system
  134611. * @param scene defines the hosting scene
  134612. * @returns a new line mesh
  134613. */
  134614. static CreateLines(name: string, options: {
  134615. points: Vector3[];
  134616. updatable?: boolean;
  134617. instance?: Nullable<LinesMesh>;
  134618. colors?: Color4[];
  134619. useVertexAlpha?: boolean;
  134620. }, scene?: Nullable<Scene>): LinesMesh;
  134621. /**
  134622. * Creates a dashed line mesh
  134623. * * 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
  134624. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  134625. * * The parameter `points` is an array successive Vector3
  134626. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  134627. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  134628. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  134629. * * 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
  134630. * * When updating an instance, remember that only point positions can change, not the number of points
  134631. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134632. * @param name defines the name of the mesh
  134633. * @param options defines the options used to create the mesh
  134634. * @param scene defines the hosting scene
  134635. * @returns the dashed line mesh
  134636. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  134637. */
  134638. static CreateDashedLines(name: string, options: {
  134639. points: Vector3[];
  134640. dashSize?: number;
  134641. gapSize?: number;
  134642. dashNb?: number;
  134643. updatable?: boolean;
  134644. instance?: LinesMesh;
  134645. }, scene?: Nullable<Scene>): LinesMesh;
  134646. /**
  134647. * 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.
  134648. * * 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.
  134649. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134650. * * 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.
  134651. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  134652. * * 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
  134653. * * 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
  134654. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  134655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134656. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134657. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  134658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134659. * @param name defines the name of the mesh
  134660. * @param options defines the options used to create the mesh
  134661. * @param scene defines the hosting scene
  134662. * @returns the extruded shape mesh
  134663. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134664. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134665. */
  134666. static ExtrudeShape(name: string, options: {
  134667. shape: Vector3[];
  134668. path: Vector3[];
  134669. scale?: number;
  134670. rotation?: number;
  134671. cap?: number;
  134672. updatable?: boolean;
  134673. sideOrientation?: number;
  134674. frontUVs?: Vector4;
  134675. backUVs?: Vector4;
  134676. instance?: Mesh;
  134677. invertUV?: boolean;
  134678. }, scene?: Nullable<Scene>): Mesh;
  134679. /**
  134680. * Creates an custom extruded shape mesh.
  134681. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  134682. * * 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.
  134683. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  134684. * * 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
  134685. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  134686. * * 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
  134687. * * It must returns a float value that will be the scale value applied to the shape on each path point
  134688. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  134689. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  134690. * * 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
  134691. * * 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
  134692. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  134693. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134694. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134695. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134696. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134697. * @param name defines the name of the mesh
  134698. * @param options defines the options used to create the mesh
  134699. * @param scene defines the hosting scene
  134700. * @returns the custom extruded shape mesh
  134701. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  134702. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134703. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  134704. */
  134705. static ExtrudeShapeCustom(name: string, options: {
  134706. shape: Vector3[];
  134707. path: Vector3[];
  134708. scaleFunction?: any;
  134709. rotationFunction?: any;
  134710. ribbonCloseArray?: boolean;
  134711. ribbonClosePath?: boolean;
  134712. cap?: number;
  134713. updatable?: boolean;
  134714. sideOrientation?: number;
  134715. frontUVs?: Vector4;
  134716. backUVs?: Vector4;
  134717. instance?: Mesh;
  134718. invertUV?: boolean;
  134719. }, scene?: Nullable<Scene>): Mesh;
  134720. /**
  134721. * Creates lathe mesh.
  134722. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  134723. * * 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
  134724. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  134725. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  134726. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  134727. * * 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
  134728. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  134729. * * 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
  134730. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134731. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134732. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  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. * @param name defines the name of the mesh
  134735. * @param options defines the options used to create the mesh
  134736. * @param scene defines the hosting scene
  134737. * @returns the lathe mesh
  134738. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  134739. */
  134740. static CreateLathe(name: string, options: {
  134741. shape: Vector3[];
  134742. radius?: number;
  134743. tessellation?: number;
  134744. clip?: number;
  134745. arc?: number;
  134746. closed?: boolean;
  134747. updatable?: boolean;
  134748. sideOrientation?: number;
  134749. frontUVs?: Vector4;
  134750. backUVs?: Vector4;
  134751. cap?: number;
  134752. invertUV?: boolean;
  134753. }, scene?: Nullable<Scene>): Mesh;
  134754. /**
  134755. * Creates a tiled plane mesh
  134756. * * You can set a limited pattern arrangement with the tiles
  134757. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134758. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134759. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134760. * @param name defines the name of the mesh
  134761. * @param options defines the options used to create the mesh
  134762. * @param scene defines the hosting scene
  134763. * @returns the plane mesh
  134764. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134765. */
  134766. static CreateTiledPlane(name: string, options: {
  134767. pattern?: number;
  134768. tileSize?: number;
  134769. tileWidth?: number;
  134770. tileHeight?: number;
  134771. size?: number;
  134772. width?: number;
  134773. height?: number;
  134774. alignHorizontal?: number;
  134775. alignVertical?: number;
  134776. sideOrientation?: number;
  134777. frontUVs?: Vector4;
  134778. backUVs?: Vector4;
  134779. updatable?: boolean;
  134780. }, scene?: Nullable<Scene>): Mesh;
  134781. /**
  134782. * Creates a plane mesh
  134783. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  134784. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  134785. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  134786. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134787. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134788. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134789. * @param name defines the name of the mesh
  134790. * @param options defines the options used to create the mesh
  134791. * @param scene defines the hosting scene
  134792. * @returns the plane mesh
  134793. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  134794. */
  134795. static CreatePlane(name: string, options: {
  134796. size?: number;
  134797. width?: number;
  134798. height?: number;
  134799. sideOrientation?: number;
  134800. frontUVs?: Vector4;
  134801. backUVs?: Vector4;
  134802. updatable?: boolean;
  134803. sourcePlane?: Plane;
  134804. }, scene?: Nullable<Scene>): Mesh;
  134805. /**
  134806. * Creates a ground mesh
  134807. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  134808. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  134809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134810. * @param name defines the name of the mesh
  134811. * @param options defines the options used to create the mesh
  134812. * @param scene defines the hosting scene
  134813. * @returns the ground mesh
  134814. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  134815. */
  134816. static CreateGround(name: string, options: {
  134817. width?: number;
  134818. height?: number;
  134819. subdivisions?: number;
  134820. subdivisionsX?: number;
  134821. subdivisionsY?: number;
  134822. updatable?: boolean;
  134823. }, scene?: Nullable<Scene>): Mesh;
  134824. /**
  134825. * Creates a tiled ground mesh
  134826. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  134827. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  134828. * * 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
  134829. * * 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
  134830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134831. * @param name defines the name of the mesh
  134832. * @param options defines the options used to create the mesh
  134833. * @param scene defines the hosting scene
  134834. * @returns the tiled ground mesh
  134835. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  134836. */
  134837. static CreateTiledGround(name: string, options: {
  134838. xmin: number;
  134839. zmin: number;
  134840. xmax: number;
  134841. zmax: number;
  134842. subdivisions?: {
  134843. w: number;
  134844. h: number;
  134845. };
  134846. precision?: {
  134847. w: number;
  134848. h: number;
  134849. };
  134850. updatable?: boolean;
  134851. }, scene?: Nullable<Scene>): Mesh;
  134852. /**
  134853. * Creates a ground mesh from a height map
  134854. * * The parameter `url` sets the URL of the height map image resource.
  134855. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  134856. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  134857. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  134858. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  134859. * * 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.
  134860. * * 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).
  134861. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  134862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  134863. * @param name defines the name of the mesh
  134864. * @param url defines the url to the height map
  134865. * @param options defines the options used to create the mesh
  134866. * @param scene defines the hosting scene
  134867. * @returns the ground mesh
  134868. * @see https://doc.babylonjs.com/babylon101/height_map
  134869. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  134870. */
  134871. static CreateGroundFromHeightMap(name: string, url: string, options: {
  134872. width?: number;
  134873. height?: number;
  134874. subdivisions?: number;
  134875. minHeight?: number;
  134876. maxHeight?: number;
  134877. colorFilter?: Color3;
  134878. alphaFilter?: number;
  134879. updatable?: boolean;
  134880. onReady?: (mesh: GroundMesh) => void;
  134881. }, scene?: Nullable<Scene>): GroundMesh;
  134882. /**
  134883. * Creates a polygon mesh
  134884. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  134885. * * 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
  134886. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  134887. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134888. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  134889. * * Remember you can only change the shape positions, not their number when updating a polygon
  134890. * @param name defines the name of the mesh
  134891. * @param options defines the options used to create the mesh
  134892. * @param scene defines the hosting scene
  134893. * @param earcutInjection can be used to inject your own earcut reference
  134894. * @returns the polygon mesh
  134895. */
  134896. static CreatePolygon(name: string, options: {
  134897. shape: Vector3[];
  134898. holes?: Vector3[][];
  134899. depth?: number;
  134900. faceUV?: Vector4[];
  134901. faceColors?: Color4[];
  134902. updatable?: boolean;
  134903. sideOrientation?: number;
  134904. frontUVs?: Vector4;
  134905. backUVs?: Vector4;
  134906. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134907. /**
  134908. * Creates an extruded polygon mesh, with depth in the Y direction.
  134909. * * 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)
  134910. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  134911. * @param name defines the name of the mesh
  134912. * @param options defines the options used to create the mesh
  134913. * @param scene defines the hosting scene
  134914. * @param earcutInjection can be used to inject your own earcut reference
  134915. * @returns the polygon mesh
  134916. */
  134917. static ExtrudePolygon(name: string, options: {
  134918. shape: Vector3[];
  134919. holes?: Vector3[][];
  134920. depth?: number;
  134921. faceUV?: Vector4[];
  134922. faceColors?: Color4[];
  134923. updatable?: boolean;
  134924. sideOrientation?: number;
  134925. frontUVs?: Vector4;
  134926. backUVs?: Vector4;
  134927. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  134928. /**
  134929. * Creates a tube mesh.
  134930. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  134931. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  134932. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  134933. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  134934. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  134935. * * 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)
  134936. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  134937. * * 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
  134938. * * 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
  134939. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134940. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134941. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  134942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134943. * @param name defines the name of the mesh
  134944. * @param options defines the options used to create the mesh
  134945. * @param scene defines the hosting scene
  134946. * @returns the tube mesh
  134947. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  134948. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  134949. */
  134950. static CreateTube(name: string, options: {
  134951. path: Vector3[];
  134952. radius?: number;
  134953. tessellation?: number;
  134954. radiusFunction?: {
  134955. (i: number, distance: number): number;
  134956. };
  134957. cap?: number;
  134958. arc?: number;
  134959. updatable?: boolean;
  134960. sideOrientation?: number;
  134961. frontUVs?: Vector4;
  134962. backUVs?: Vector4;
  134963. instance?: Mesh;
  134964. invertUV?: boolean;
  134965. }, scene?: Nullable<Scene>): Mesh;
  134966. /**
  134967. * Creates a polyhedron mesh
  134968. * * 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
  134969. * * The parameter `size` (positive float, default 1) sets the polygon size
  134970. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  134971. * * 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`
  134972. * * 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
  134973. * * 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)`)
  134974. * * 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
  134975. * * 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
  134976. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134977. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134979. * @param name defines the name of the mesh
  134980. * @param options defines the options used to create the mesh
  134981. * @param scene defines the hosting scene
  134982. * @returns the polyhedron mesh
  134983. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  134984. */
  134985. static CreatePolyhedron(name: string, options: {
  134986. type?: number;
  134987. size?: number;
  134988. sizeX?: number;
  134989. sizeY?: number;
  134990. sizeZ?: number;
  134991. custom?: any;
  134992. faceUV?: Vector4[];
  134993. faceColors?: Color4[];
  134994. flat?: boolean;
  134995. updatable?: boolean;
  134996. sideOrientation?: number;
  134997. frontUVs?: Vector4;
  134998. backUVs?: Vector4;
  134999. }, scene?: Nullable<Scene>): Mesh;
  135000. /**
  135001. * Creates a decal mesh.
  135002. * 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
  135003. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  135004. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  135005. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  135006. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  135007. * @param name defines the name of the mesh
  135008. * @param sourceMesh defines the mesh where the decal must be applied
  135009. * @param options defines the options used to create the mesh
  135010. * @param scene defines the hosting scene
  135011. * @returns the decal mesh
  135012. * @see https://doc.babylonjs.com/how_to/decals
  135013. */
  135014. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  135015. position?: Vector3;
  135016. normal?: Vector3;
  135017. size?: Vector3;
  135018. angle?: number;
  135019. }): Mesh;
  135020. }
  135021. }
  135022. declare module BABYLON {
  135023. /**
  135024. * A simplifier interface for future simplification implementations
  135025. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135026. */
  135027. export interface ISimplifier {
  135028. /**
  135029. * Simplification of a given mesh according to the given settings.
  135030. * Since this requires computation, it is assumed that the function runs async.
  135031. * @param settings The settings of the simplification, including quality and distance
  135032. * @param successCallback A callback that will be called after the mesh was simplified.
  135033. * @param errorCallback in case of an error, this callback will be called. optional.
  135034. */
  135035. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  135036. }
  135037. /**
  135038. * Expected simplification settings.
  135039. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  135040. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135041. */
  135042. export interface ISimplificationSettings {
  135043. /**
  135044. * Gets or sets the expected quality
  135045. */
  135046. quality: number;
  135047. /**
  135048. * Gets or sets the distance when this optimized version should be used
  135049. */
  135050. distance: number;
  135051. /**
  135052. * Gets an already optimized mesh
  135053. */
  135054. optimizeMesh?: boolean;
  135055. }
  135056. /**
  135057. * Class used to specify simplification options
  135058. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135059. */
  135060. export class SimplificationSettings implements ISimplificationSettings {
  135061. /** expected quality */
  135062. quality: number;
  135063. /** distance when this optimized version should be used */
  135064. distance: number;
  135065. /** already optimized mesh */
  135066. optimizeMesh?: boolean | undefined;
  135067. /**
  135068. * Creates a SimplificationSettings
  135069. * @param quality expected quality
  135070. * @param distance distance when this optimized version should be used
  135071. * @param optimizeMesh already optimized mesh
  135072. */
  135073. constructor(
  135074. /** expected quality */
  135075. quality: number,
  135076. /** distance when this optimized version should be used */
  135077. distance: number,
  135078. /** already optimized mesh */
  135079. optimizeMesh?: boolean | undefined);
  135080. }
  135081. /**
  135082. * Interface used to define a simplification task
  135083. */
  135084. export interface ISimplificationTask {
  135085. /**
  135086. * Array of settings
  135087. */
  135088. settings: Array<ISimplificationSettings>;
  135089. /**
  135090. * Simplification type
  135091. */
  135092. simplificationType: SimplificationType;
  135093. /**
  135094. * Mesh to simplify
  135095. */
  135096. mesh: Mesh;
  135097. /**
  135098. * Callback called on success
  135099. */
  135100. successCallback?: () => void;
  135101. /**
  135102. * Defines if parallel processing can be used
  135103. */
  135104. parallelProcessing: boolean;
  135105. }
  135106. /**
  135107. * Queue used to order the simplification tasks
  135108. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135109. */
  135110. export class SimplificationQueue {
  135111. private _simplificationArray;
  135112. /**
  135113. * Gets a boolean indicating that the process is still running
  135114. */
  135115. running: boolean;
  135116. /**
  135117. * Creates a new queue
  135118. */
  135119. constructor();
  135120. /**
  135121. * Adds a new simplification task
  135122. * @param task defines a task to add
  135123. */
  135124. addTask(task: ISimplificationTask): void;
  135125. /**
  135126. * Execute next task
  135127. */
  135128. executeNext(): void;
  135129. /**
  135130. * Execute a simplification task
  135131. * @param task defines the task to run
  135132. */
  135133. runSimplification(task: ISimplificationTask): void;
  135134. private getSimplifier;
  135135. }
  135136. /**
  135137. * The implemented types of simplification
  135138. * At the moment only Quadratic Error Decimation is implemented
  135139. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135140. */
  135141. export enum SimplificationType {
  135142. /** Quadratic error decimation */
  135143. QUADRATIC = 0
  135144. }
  135145. }
  135146. declare module BABYLON {
  135147. interface Scene {
  135148. /** @hidden (Backing field) */
  135149. _simplificationQueue: SimplificationQueue;
  135150. /**
  135151. * Gets or sets the simplification queue attached to the scene
  135152. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  135153. */
  135154. simplificationQueue: SimplificationQueue;
  135155. }
  135156. interface Mesh {
  135157. /**
  135158. * Simplify the mesh according to the given array of settings.
  135159. * Function will return immediately and will simplify async
  135160. * @param settings a collection of simplification settings
  135161. * @param parallelProcessing should all levels calculate parallel or one after the other
  135162. * @param simplificationType the type of simplification to run
  135163. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  135164. * @returns the current mesh
  135165. */
  135166. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  135167. }
  135168. /**
  135169. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  135170. * created in a scene
  135171. */
  135172. export class SimplicationQueueSceneComponent implements ISceneComponent {
  135173. /**
  135174. * The component name helpfull to identify the component in the list of scene components.
  135175. */
  135176. readonly name: string;
  135177. /**
  135178. * The scene the component belongs to.
  135179. */
  135180. scene: Scene;
  135181. /**
  135182. * Creates a new instance of the component for the given scene
  135183. * @param scene Defines the scene to register the component in
  135184. */
  135185. constructor(scene: Scene);
  135186. /**
  135187. * Registers the component in a given scene
  135188. */
  135189. register(): void;
  135190. /**
  135191. * Rebuilds the elements related to this component in case of
  135192. * context lost for instance.
  135193. */
  135194. rebuild(): void;
  135195. /**
  135196. * Disposes the component and the associated ressources
  135197. */
  135198. dispose(): void;
  135199. private _beforeCameraUpdate;
  135200. }
  135201. }
  135202. declare module BABYLON {
  135203. /**
  135204. * Navigation plugin interface to add navigation constrained by a navigation mesh
  135205. */
  135206. export interface INavigationEnginePlugin {
  135207. /**
  135208. * plugin name
  135209. */
  135210. name: string;
  135211. /**
  135212. * Creates a navigation mesh
  135213. * @param meshes array of all the geometry used to compute the navigatio mesh
  135214. * @param parameters bunch of parameters used to filter geometry
  135215. */
  135216. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135217. /**
  135218. * Create a navigation mesh debug mesh
  135219. * @param scene is where the mesh will be added
  135220. * @returns debug display mesh
  135221. */
  135222. createDebugNavMesh(scene: Scene): Mesh;
  135223. /**
  135224. * Get a navigation mesh constrained position, closest to the parameter position
  135225. * @param position world position
  135226. * @returns the closest point to position constrained by the navigation mesh
  135227. */
  135228. getClosestPoint(position: Vector3): Vector3;
  135229. /**
  135230. * Get a navigation mesh constrained position, within a particular radius
  135231. * @param position world position
  135232. * @param maxRadius the maximum distance to the constrained world position
  135233. * @returns the closest point to position constrained by the navigation mesh
  135234. */
  135235. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135236. /**
  135237. * Compute the final position from a segment made of destination-position
  135238. * @param position world position
  135239. * @param destination world position
  135240. * @returns the resulting point along the navmesh
  135241. */
  135242. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135243. /**
  135244. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135245. * @param start world position
  135246. * @param end world position
  135247. * @returns array containing world position composing the path
  135248. */
  135249. computePath(start: Vector3, end: Vector3): Vector3[];
  135250. /**
  135251. * If this plugin is supported
  135252. * @returns true if plugin is supported
  135253. */
  135254. isSupported(): boolean;
  135255. /**
  135256. * Create a new Crowd so you can add agents
  135257. * @param maxAgents the maximum agent count in the crowd
  135258. * @param maxAgentRadius the maximum radius an agent can have
  135259. * @param scene to attach the crowd to
  135260. * @returns the crowd you can add agents to
  135261. */
  135262. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135263. /**
  135264. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135265. * The queries will try to find a solution within those bounds
  135266. * default is (1,1,1)
  135267. * @param extent x,y,z value that define the extent around the queries point of reference
  135268. */
  135269. setDefaultQueryExtent(extent: Vector3): void;
  135270. /**
  135271. * Get the Bounding box extent specified by setDefaultQueryExtent
  135272. * @returns the box extent values
  135273. */
  135274. getDefaultQueryExtent(): Vector3;
  135275. /**
  135276. * Release all resources
  135277. */
  135278. dispose(): void;
  135279. }
  135280. /**
  135281. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  135282. */
  135283. export interface ICrowd {
  135284. /**
  135285. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135286. * You can attach anything to that node. The node position is updated in the scene update tick.
  135287. * @param pos world position that will be constrained by the navigation mesh
  135288. * @param parameters agent parameters
  135289. * @param transform hooked to the agent that will be update by the scene
  135290. * @returns agent index
  135291. */
  135292. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135293. /**
  135294. * Returns the agent position in world space
  135295. * @param index agent index returned by addAgent
  135296. * @returns world space position
  135297. */
  135298. getAgentPosition(index: number): Vector3;
  135299. /**
  135300. * Gets the agent velocity in world space
  135301. * @param index agent index returned by addAgent
  135302. * @returns world space velocity
  135303. */
  135304. getAgentVelocity(index: number): Vector3;
  135305. /**
  135306. * remove a particular agent previously created
  135307. * @param index agent index returned by addAgent
  135308. */
  135309. removeAgent(index: number): void;
  135310. /**
  135311. * get the list of all agents attached to this crowd
  135312. * @returns list of agent indices
  135313. */
  135314. getAgents(): number[];
  135315. /**
  135316. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135317. * @param deltaTime in seconds
  135318. */
  135319. update(deltaTime: number): void;
  135320. /**
  135321. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135322. * @param index agent index returned by addAgent
  135323. * @param destination targeted world position
  135324. */
  135325. agentGoto(index: number, destination: Vector3): void;
  135326. /**
  135327. * Teleport the agent to a new position
  135328. * @param index agent index returned by addAgent
  135329. * @param destination targeted world position
  135330. */
  135331. agentTeleport(index: number, destination: Vector3): void;
  135332. /**
  135333. * Update agent parameters
  135334. * @param index agent index returned by addAgent
  135335. * @param parameters agent parameters
  135336. */
  135337. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135338. /**
  135339. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135340. * The queries will try to find a solution within those bounds
  135341. * default is (1,1,1)
  135342. * @param extent x,y,z value that define the extent around the queries point of reference
  135343. */
  135344. setDefaultQueryExtent(extent: Vector3): void;
  135345. /**
  135346. * Get the Bounding box extent specified by setDefaultQueryExtent
  135347. * @returns the box extent values
  135348. */
  135349. getDefaultQueryExtent(): Vector3;
  135350. /**
  135351. * Release all resources
  135352. */
  135353. dispose(): void;
  135354. }
  135355. /**
  135356. * Configures an agent
  135357. */
  135358. export interface IAgentParameters {
  135359. /**
  135360. * Agent radius. [Limit: >= 0]
  135361. */
  135362. radius: number;
  135363. /**
  135364. * Agent height. [Limit: > 0]
  135365. */
  135366. height: number;
  135367. /**
  135368. * Maximum allowed acceleration. [Limit: >= 0]
  135369. */
  135370. maxAcceleration: number;
  135371. /**
  135372. * Maximum allowed speed. [Limit: >= 0]
  135373. */
  135374. maxSpeed: number;
  135375. /**
  135376. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  135377. */
  135378. collisionQueryRange: number;
  135379. /**
  135380. * The path visibility optimization range. [Limit: > 0]
  135381. */
  135382. pathOptimizationRange: number;
  135383. /**
  135384. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  135385. */
  135386. separationWeight: number;
  135387. }
  135388. /**
  135389. * Configures the navigation mesh creation
  135390. */
  135391. export interface INavMeshParameters {
  135392. /**
  135393. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  135394. */
  135395. cs: number;
  135396. /**
  135397. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  135398. */
  135399. ch: number;
  135400. /**
  135401. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  135402. */
  135403. walkableSlopeAngle: number;
  135404. /**
  135405. * Minimum floor to 'ceiling' height that will still allow the floor area to
  135406. * be considered walkable. [Limit: >= 3] [Units: vx]
  135407. */
  135408. walkableHeight: number;
  135409. /**
  135410. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  135411. */
  135412. walkableClimb: number;
  135413. /**
  135414. * The distance to erode/shrink the walkable area of the heightfield away from
  135415. * obstructions. [Limit: >=0] [Units: vx]
  135416. */
  135417. walkableRadius: number;
  135418. /**
  135419. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  135420. */
  135421. maxEdgeLen: number;
  135422. /**
  135423. * The maximum distance a simplfied contour's border edges should deviate
  135424. * the original raw contour. [Limit: >=0] [Units: vx]
  135425. */
  135426. maxSimplificationError: number;
  135427. /**
  135428. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  135429. */
  135430. minRegionArea: number;
  135431. /**
  135432. * Any regions with a span count smaller than this value will, if possible,
  135433. * be merged with larger regions. [Limit: >=0] [Units: vx]
  135434. */
  135435. mergeRegionArea: number;
  135436. /**
  135437. * The maximum number of vertices allowed for polygons generated during the
  135438. * contour to polygon conversion process. [Limit: >= 3]
  135439. */
  135440. maxVertsPerPoly: number;
  135441. /**
  135442. * Sets the sampling distance to use when generating the detail mesh.
  135443. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  135444. */
  135445. detailSampleDist: number;
  135446. /**
  135447. * The maximum distance the detail mesh surface should deviate from heightfield
  135448. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  135449. */
  135450. detailSampleMaxError: number;
  135451. }
  135452. }
  135453. declare module BABYLON {
  135454. /**
  135455. * RecastJS navigation plugin
  135456. */
  135457. export class RecastJSPlugin implements INavigationEnginePlugin {
  135458. /**
  135459. * Reference to the Recast library
  135460. */
  135461. bjsRECAST: any;
  135462. /**
  135463. * plugin name
  135464. */
  135465. name: string;
  135466. /**
  135467. * the first navmesh created. We might extend this to support multiple navmeshes
  135468. */
  135469. navMesh: any;
  135470. /**
  135471. * Initializes the recastJS plugin
  135472. * @param recastInjection can be used to inject your own recast reference
  135473. */
  135474. constructor(recastInjection?: any);
  135475. /**
  135476. * Creates a navigation mesh
  135477. * @param meshes array of all the geometry used to compute the navigatio mesh
  135478. * @param parameters bunch of parameters used to filter geometry
  135479. */
  135480. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  135481. /**
  135482. * Create a navigation mesh debug mesh
  135483. * @param scene is where the mesh will be added
  135484. * @returns debug display mesh
  135485. */
  135486. createDebugNavMesh(scene: Scene): Mesh;
  135487. /**
  135488. * Get a navigation mesh constrained position, closest to the parameter position
  135489. * @param position world position
  135490. * @returns the closest point to position constrained by the navigation mesh
  135491. */
  135492. getClosestPoint(position: Vector3): Vector3;
  135493. /**
  135494. * Get a navigation mesh constrained position, within a particular radius
  135495. * @param position world position
  135496. * @param maxRadius the maximum distance to the constrained world position
  135497. * @returns the closest point to position constrained by the navigation mesh
  135498. */
  135499. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  135500. /**
  135501. * Compute the final position from a segment made of destination-position
  135502. * @param position world position
  135503. * @param destination world position
  135504. * @returns the resulting point along the navmesh
  135505. */
  135506. moveAlong(position: Vector3, destination: Vector3): Vector3;
  135507. /**
  135508. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  135509. * @param start world position
  135510. * @param end world position
  135511. * @returns array containing world position composing the path
  135512. */
  135513. computePath(start: Vector3, end: Vector3): Vector3[];
  135514. /**
  135515. * Create a new Crowd so you can add agents
  135516. * @param maxAgents the maximum agent count in the crowd
  135517. * @param maxAgentRadius the maximum radius an agent can have
  135518. * @param scene to attach the crowd to
  135519. * @returns the crowd you can add agents to
  135520. */
  135521. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  135522. /**
  135523. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135524. * The queries will try to find a solution within those bounds
  135525. * default is (1,1,1)
  135526. * @param extent x,y,z value that define the extent around the queries point of reference
  135527. */
  135528. setDefaultQueryExtent(extent: Vector3): void;
  135529. /**
  135530. * Get the Bounding box extent specified by setDefaultQueryExtent
  135531. * @returns the box extent values
  135532. */
  135533. getDefaultQueryExtent(): Vector3;
  135534. /**
  135535. * Disposes
  135536. */
  135537. dispose(): void;
  135538. /**
  135539. * If this plugin is supported
  135540. * @returns true if plugin is supported
  135541. */
  135542. isSupported(): boolean;
  135543. }
  135544. /**
  135545. * Recast detour crowd implementation
  135546. */
  135547. export class RecastJSCrowd implements ICrowd {
  135548. /**
  135549. * Recast/detour plugin
  135550. */
  135551. bjsRECASTPlugin: RecastJSPlugin;
  135552. /**
  135553. * Link to the detour crowd
  135554. */
  135555. recastCrowd: any;
  135556. /**
  135557. * One transform per agent
  135558. */
  135559. transforms: TransformNode[];
  135560. /**
  135561. * All agents created
  135562. */
  135563. agents: number[];
  135564. /**
  135565. * Link to the scene is kept to unregister the crowd from the scene
  135566. */
  135567. private _scene;
  135568. /**
  135569. * Observer for crowd updates
  135570. */
  135571. private _onBeforeAnimationsObserver;
  135572. /**
  135573. * Constructor
  135574. * @param plugin recastJS plugin
  135575. * @param maxAgents the maximum agent count in the crowd
  135576. * @param maxAgentRadius the maximum radius an agent can have
  135577. * @param scene to attach the crowd to
  135578. * @returns the crowd you can add agents to
  135579. */
  135580. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  135581. /**
  135582. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  135583. * You can attach anything to that node. The node position is updated in the scene update tick.
  135584. * @param pos world position that will be constrained by the navigation mesh
  135585. * @param parameters agent parameters
  135586. * @param transform hooked to the agent that will be update by the scene
  135587. * @returns agent index
  135588. */
  135589. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  135590. /**
  135591. * Returns the agent position in world space
  135592. * @param index agent index returned by addAgent
  135593. * @returns world space position
  135594. */
  135595. getAgentPosition(index: number): Vector3;
  135596. /**
  135597. * Returns the agent velocity in world space
  135598. * @param index agent index returned by addAgent
  135599. * @returns world space velocity
  135600. */
  135601. getAgentVelocity(index: number): Vector3;
  135602. /**
  135603. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  135604. * @param index agent index returned by addAgent
  135605. * @param destination targeted world position
  135606. */
  135607. agentGoto(index: number, destination: Vector3): void;
  135608. /**
  135609. * Teleport the agent to a new position
  135610. * @param index agent index returned by addAgent
  135611. * @param destination targeted world position
  135612. */
  135613. agentTeleport(index: number, destination: Vector3): void;
  135614. /**
  135615. * Update agent parameters
  135616. * @param index agent index returned by addAgent
  135617. * @param parameters agent parameters
  135618. */
  135619. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  135620. /**
  135621. * remove a particular agent previously created
  135622. * @param index agent index returned by addAgent
  135623. */
  135624. removeAgent(index: number): void;
  135625. /**
  135626. * get the list of all agents attached to this crowd
  135627. * @returns list of agent indices
  135628. */
  135629. getAgents(): number[];
  135630. /**
  135631. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  135632. * @param deltaTime in seconds
  135633. */
  135634. update(deltaTime: number): void;
  135635. /**
  135636. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  135637. * The queries will try to find a solution within those bounds
  135638. * default is (1,1,1)
  135639. * @param extent x,y,z value that define the extent around the queries point of reference
  135640. */
  135641. setDefaultQueryExtent(extent: Vector3): void;
  135642. /**
  135643. * Get the Bounding box extent specified by setDefaultQueryExtent
  135644. * @returns the box extent values
  135645. */
  135646. getDefaultQueryExtent(): Vector3;
  135647. /**
  135648. * Release all resources
  135649. */
  135650. dispose(): void;
  135651. }
  135652. }
  135653. declare module BABYLON {
  135654. /**
  135655. * Class used to enable access to IndexedDB
  135656. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  135657. */
  135658. export class Database implements IOfflineProvider {
  135659. private _callbackManifestChecked;
  135660. private _currentSceneUrl;
  135661. private _db;
  135662. private _enableSceneOffline;
  135663. private _enableTexturesOffline;
  135664. private _manifestVersionFound;
  135665. private _mustUpdateRessources;
  135666. private _hasReachedQuota;
  135667. private _isSupported;
  135668. private _idbFactory;
  135669. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  135670. private static IsUASupportingBlobStorage;
  135671. /**
  135672. * Gets a boolean indicating if Database storate is enabled (off by default)
  135673. */
  135674. static IDBStorageEnabled: boolean;
  135675. /**
  135676. * Gets a boolean indicating if scene must be saved in the database
  135677. */
  135678. get enableSceneOffline(): boolean;
  135679. /**
  135680. * Gets a boolean indicating if textures must be saved in the database
  135681. */
  135682. get enableTexturesOffline(): boolean;
  135683. /**
  135684. * Creates a new Database
  135685. * @param urlToScene defines the url to load the scene
  135686. * @param callbackManifestChecked defines the callback to use when manifest is checked
  135687. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  135688. */
  135689. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  135690. private static _ParseURL;
  135691. private static _ReturnFullUrlLocation;
  135692. private _checkManifestFile;
  135693. /**
  135694. * Open the database and make it available
  135695. * @param successCallback defines the callback to call on success
  135696. * @param errorCallback defines the callback to call on error
  135697. */
  135698. open(successCallback: () => void, errorCallback: () => void): void;
  135699. /**
  135700. * Loads an image from the database
  135701. * @param url defines the url to load from
  135702. * @param image defines the target DOM image
  135703. */
  135704. loadImage(url: string, image: HTMLImageElement): void;
  135705. private _loadImageFromDBAsync;
  135706. private _saveImageIntoDBAsync;
  135707. private _checkVersionFromDB;
  135708. private _loadVersionFromDBAsync;
  135709. private _saveVersionIntoDBAsync;
  135710. /**
  135711. * Loads a file from database
  135712. * @param url defines the URL to load from
  135713. * @param sceneLoaded defines a callback to call on success
  135714. * @param progressCallBack defines a callback to call when progress changed
  135715. * @param errorCallback defines a callback to call on error
  135716. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  135717. */
  135718. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  135719. private _loadFileAsync;
  135720. private _saveFileAsync;
  135721. /**
  135722. * Validates if xhr data is correct
  135723. * @param xhr defines the request to validate
  135724. * @param dataType defines the expected data type
  135725. * @returns true if data is correct
  135726. */
  135727. private static _ValidateXHRData;
  135728. }
  135729. }
  135730. declare module BABYLON {
  135731. /** @hidden */
  135732. export var gpuUpdateParticlesPixelShader: {
  135733. name: string;
  135734. shader: string;
  135735. };
  135736. }
  135737. declare module BABYLON {
  135738. /** @hidden */
  135739. export var gpuUpdateParticlesVertexShader: {
  135740. name: string;
  135741. shader: string;
  135742. };
  135743. }
  135744. declare module BABYLON {
  135745. /** @hidden */
  135746. export var clipPlaneFragmentDeclaration2: {
  135747. name: string;
  135748. shader: string;
  135749. };
  135750. }
  135751. declare module BABYLON {
  135752. /** @hidden */
  135753. export var gpuRenderParticlesPixelShader: {
  135754. name: string;
  135755. shader: string;
  135756. };
  135757. }
  135758. declare module BABYLON {
  135759. /** @hidden */
  135760. export var clipPlaneVertexDeclaration2: {
  135761. name: string;
  135762. shader: string;
  135763. };
  135764. }
  135765. declare module BABYLON {
  135766. /** @hidden */
  135767. export var gpuRenderParticlesVertexShader: {
  135768. name: string;
  135769. shader: string;
  135770. };
  135771. }
  135772. declare module BABYLON {
  135773. /**
  135774. * This represents a GPU particle system in Babylon
  135775. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  135776. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  135777. */
  135778. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  135779. /**
  135780. * The layer mask we are rendering the particles through.
  135781. */
  135782. layerMask: number;
  135783. private _capacity;
  135784. private _activeCount;
  135785. private _currentActiveCount;
  135786. private _accumulatedCount;
  135787. private _renderEffect;
  135788. private _updateEffect;
  135789. private _buffer0;
  135790. private _buffer1;
  135791. private _spriteBuffer;
  135792. private _updateVAO;
  135793. private _renderVAO;
  135794. private _targetIndex;
  135795. private _sourceBuffer;
  135796. private _targetBuffer;
  135797. private _engine;
  135798. private _currentRenderId;
  135799. private _started;
  135800. private _stopped;
  135801. private _timeDelta;
  135802. private _randomTexture;
  135803. private _randomTexture2;
  135804. private _attributesStrideSize;
  135805. private _updateEffectOptions;
  135806. private _randomTextureSize;
  135807. private _actualFrame;
  135808. private readonly _rawTextureWidth;
  135809. /**
  135810. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  135811. */
  135812. static get IsSupported(): boolean;
  135813. /**
  135814. * An event triggered when the system is disposed.
  135815. */
  135816. onDisposeObservable: Observable<GPUParticleSystem>;
  135817. /**
  135818. * Gets the maximum number of particles active at the same time.
  135819. * @returns The max number of active particles.
  135820. */
  135821. getCapacity(): number;
  135822. /**
  135823. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  135824. * to override the particles.
  135825. */
  135826. forceDepthWrite: boolean;
  135827. /**
  135828. * Gets or set the number of active particles
  135829. */
  135830. get activeParticleCount(): number;
  135831. set activeParticleCount(value: number);
  135832. private _preWarmDone;
  135833. /**
  135834. * Is this system ready to be used/rendered
  135835. * @return true if the system is ready
  135836. */
  135837. isReady(): boolean;
  135838. /**
  135839. * Gets if the system has been started. (Note: this will still be true after stop is called)
  135840. * @returns True if it has been started, otherwise false.
  135841. */
  135842. isStarted(): boolean;
  135843. /**
  135844. * Starts the particle system and begins to emit
  135845. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  135846. */
  135847. start(delay?: number): void;
  135848. /**
  135849. * Stops the particle system.
  135850. */
  135851. stop(): void;
  135852. /**
  135853. * Remove all active particles
  135854. */
  135855. reset(): void;
  135856. /**
  135857. * Returns the string "GPUParticleSystem"
  135858. * @returns a string containing the class name
  135859. */
  135860. getClassName(): string;
  135861. private _colorGradientsTexture;
  135862. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  135863. /**
  135864. * Adds a new color gradient
  135865. * @param gradient defines the gradient to use (between 0 and 1)
  135866. * @param color1 defines the color to affect to the specified gradient
  135867. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  135868. * @returns the current particle system
  135869. */
  135870. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  135871. /**
  135872. * Remove a specific color gradient
  135873. * @param gradient defines the gradient to remove
  135874. * @returns the current particle system
  135875. */
  135876. removeColorGradient(gradient: number): GPUParticleSystem;
  135877. private _angularSpeedGradientsTexture;
  135878. private _sizeGradientsTexture;
  135879. private _velocityGradientsTexture;
  135880. private _limitVelocityGradientsTexture;
  135881. private _dragGradientsTexture;
  135882. private _addFactorGradient;
  135883. /**
  135884. * Adds a new size gradient
  135885. * @param gradient defines the gradient to use (between 0 and 1)
  135886. * @param factor defines the size factor to affect to the specified gradient
  135887. * @returns the current particle system
  135888. */
  135889. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  135890. /**
  135891. * Remove a specific size gradient
  135892. * @param gradient defines the gradient to remove
  135893. * @returns the current particle system
  135894. */
  135895. removeSizeGradient(gradient: number): GPUParticleSystem;
  135896. /**
  135897. * Adds a new angular speed gradient
  135898. * @param gradient defines the gradient to use (between 0 and 1)
  135899. * @param factor defines the angular speed to affect to the specified gradient
  135900. * @returns the current particle system
  135901. */
  135902. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  135903. /**
  135904. * Remove a specific angular speed gradient
  135905. * @param gradient defines the gradient to remove
  135906. * @returns the current particle system
  135907. */
  135908. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  135909. /**
  135910. * Adds a new velocity gradient
  135911. * @param gradient defines the gradient to use (between 0 and 1)
  135912. * @param factor defines the velocity to affect to the specified gradient
  135913. * @returns the current particle system
  135914. */
  135915. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135916. /**
  135917. * Remove a specific velocity gradient
  135918. * @param gradient defines the gradient to remove
  135919. * @returns the current particle system
  135920. */
  135921. removeVelocityGradient(gradient: number): GPUParticleSystem;
  135922. /**
  135923. * Adds a new limit velocity gradient
  135924. * @param gradient defines the gradient to use (between 0 and 1)
  135925. * @param factor defines the limit velocity value to affect to the specified gradient
  135926. * @returns the current particle system
  135927. */
  135928. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  135929. /**
  135930. * Remove a specific limit velocity gradient
  135931. * @param gradient defines the gradient to remove
  135932. * @returns the current particle system
  135933. */
  135934. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  135935. /**
  135936. * Adds a new drag gradient
  135937. * @param gradient defines the gradient to use (between 0 and 1)
  135938. * @param factor defines the drag value to affect to the specified gradient
  135939. * @returns the current particle system
  135940. */
  135941. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  135942. /**
  135943. * Remove a specific drag gradient
  135944. * @param gradient defines the gradient to remove
  135945. * @returns the current particle system
  135946. */
  135947. removeDragGradient(gradient: number): GPUParticleSystem;
  135948. /**
  135949. * Not supported by GPUParticleSystem
  135950. * @param gradient defines the gradient to use (between 0 and 1)
  135951. * @param factor defines the emit rate value to affect to the specified gradient
  135952. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135953. * @returns the current particle system
  135954. */
  135955. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135956. /**
  135957. * Not supported by GPUParticleSystem
  135958. * @param gradient defines the gradient to remove
  135959. * @returns the current particle system
  135960. */
  135961. removeEmitRateGradient(gradient: number): IParticleSystem;
  135962. /**
  135963. * Not supported by GPUParticleSystem
  135964. * @param gradient defines the gradient to use (between 0 and 1)
  135965. * @param factor defines the start size value to affect to the specified gradient
  135966. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  135967. * @returns the current particle system
  135968. */
  135969. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  135970. /**
  135971. * Not supported by GPUParticleSystem
  135972. * @param gradient defines the gradient to remove
  135973. * @returns the current particle system
  135974. */
  135975. removeStartSizeGradient(gradient: number): IParticleSystem;
  135976. /**
  135977. * Not supported by GPUParticleSystem
  135978. * @param gradient defines the gradient to use (between 0 and 1)
  135979. * @param min defines the color remap minimal range
  135980. * @param max defines the color remap maximal range
  135981. * @returns the current particle system
  135982. */
  135983. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135984. /**
  135985. * Not supported by GPUParticleSystem
  135986. * @param gradient defines the gradient to remove
  135987. * @returns the current particle system
  135988. */
  135989. removeColorRemapGradient(): IParticleSystem;
  135990. /**
  135991. * Not supported by GPUParticleSystem
  135992. * @param gradient defines the gradient to use (between 0 and 1)
  135993. * @param min defines the alpha remap minimal range
  135994. * @param max defines the alpha remap maximal range
  135995. * @returns the current particle system
  135996. */
  135997. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  135998. /**
  135999. * Not supported by GPUParticleSystem
  136000. * @param gradient defines the gradient to remove
  136001. * @returns the current particle system
  136002. */
  136003. removeAlphaRemapGradient(): IParticleSystem;
  136004. /**
  136005. * Not supported by GPUParticleSystem
  136006. * @param gradient defines the gradient to use (between 0 and 1)
  136007. * @param color defines the color to affect to the specified gradient
  136008. * @returns the current particle system
  136009. */
  136010. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  136011. /**
  136012. * Not supported by GPUParticleSystem
  136013. * @param gradient defines the gradient to remove
  136014. * @returns the current particle system
  136015. */
  136016. removeRampGradient(): IParticleSystem;
  136017. /**
  136018. * Not supported by GPUParticleSystem
  136019. * @returns the list of ramp gradients
  136020. */
  136021. getRampGradients(): Nullable<Array<Color3Gradient>>;
  136022. /**
  136023. * Not supported by GPUParticleSystem
  136024. * Gets or sets a boolean indicating that ramp gradients must be used
  136025. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  136026. */
  136027. get useRampGradients(): boolean;
  136028. set useRampGradients(value: boolean);
  136029. /**
  136030. * Not supported by GPUParticleSystem
  136031. * @param gradient defines the gradient to use (between 0 and 1)
  136032. * @param factor defines the life time factor to affect to the specified gradient
  136033. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  136034. * @returns the current particle system
  136035. */
  136036. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  136037. /**
  136038. * Not supported by GPUParticleSystem
  136039. * @param gradient defines the gradient to remove
  136040. * @returns the current particle system
  136041. */
  136042. removeLifeTimeGradient(gradient: number): IParticleSystem;
  136043. /**
  136044. * Instantiates a GPU particle system.
  136045. * 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.
  136046. * @param name The name of the particle system
  136047. * @param options The options used to create the system
  136048. * @param scene The scene the particle system belongs to
  136049. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  136050. */
  136051. constructor(name: string, options: Partial<{
  136052. capacity: number;
  136053. randomTextureSize: number;
  136054. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  136055. protected _reset(): void;
  136056. private _createUpdateVAO;
  136057. private _createRenderVAO;
  136058. private _initialize;
  136059. /** @hidden */
  136060. _recreateUpdateEffect(): void;
  136061. /** @hidden */
  136062. _recreateRenderEffect(): void;
  136063. /**
  136064. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  136065. * @param preWarm defines if we are in the pre-warmimg phase
  136066. */
  136067. animate(preWarm?: boolean): void;
  136068. private _createFactorGradientTexture;
  136069. private _createSizeGradientTexture;
  136070. private _createAngularSpeedGradientTexture;
  136071. private _createVelocityGradientTexture;
  136072. private _createLimitVelocityGradientTexture;
  136073. private _createDragGradientTexture;
  136074. private _createColorGradientTexture;
  136075. /**
  136076. * Renders the particle system in its current state
  136077. * @param preWarm defines if the system should only update the particles but not render them
  136078. * @returns the current number of particles
  136079. */
  136080. render(preWarm?: boolean): number;
  136081. /**
  136082. * Rebuilds the particle system
  136083. */
  136084. rebuild(): void;
  136085. private _releaseBuffers;
  136086. private _releaseVAOs;
  136087. /**
  136088. * Disposes the particle system and free the associated resources
  136089. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  136090. */
  136091. dispose(disposeTexture?: boolean): void;
  136092. /**
  136093. * Clones the particle system.
  136094. * @param name The name of the cloned object
  136095. * @param newEmitter The new emitter to use
  136096. * @returns the cloned particle system
  136097. */
  136098. clone(name: string, newEmitter: any): GPUParticleSystem;
  136099. /**
  136100. * Serializes the particle system to a JSON object.
  136101. * @returns the JSON object
  136102. */
  136103. serialize(): any;
  136104. /**
  136105. * Parses a JSON object to create a GPU particle system.
  136106. * @param parsedParticleSystem The JSON object to parse
  136107. * @param scene The scene to create the particle system in
  136108. * @param rootUrl The root url to use to load external dependencies like texture
  136109. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  136110. * @returns the parsed GPU particle system
  136111. */
  136112. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  136113. }
  136114. }
  136115. declare module BABYLON {
  136116. /**
  136117. * Represents a set of particle systems working together to create a specific effect
  136118. */
  136119. export class ParticleSystemSet implements IDisposable {
  136120. /**
  136121. * Gets or sets base Assets URL
  136122. */
  136123. static BaseAssetsUrl: string;
  136124. private _emitterCreationOptions;
  136125. private _emitterNode;
  136126. /**
  136127. * Gets the particle system list
  136128. */
  136129. systems: IParticleSystem[];
  136130. /**
  136131. * Gets the emitter node used with this set
  136132. */
  136133. get emitterNode(): Nullable<TransformNode>;
  136134. /**
  136135. * Creates a new emitter mesh as a sphere
  136136. * @param options defines the options used to create the sphere
  136137. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  136138. * @param scene defines the hosting scene
  136139. */
  136140. setEmitterAsSphere(options: {
  136141. diameter: number;
  136142. segments: number;
  136143. color: Color3;
  136144. }, renderingGroupId: number, scene: Scene): void;
  136145. /**
  136146. * Starts all particle systems of the set
  136147. * @param emitter defines an optional mesh to use as emitter for the particle systems
  136148. */
  136149. start(emitter?: AbstractMesh): void;
  136150. /**
  136151. * Release all associated resources
  136152. */
  136153. dispose(): void;
  136154. /**
  136155. * Serialize the set into a JSON compatible object
  136156. * @returns a JSON compatible representation of the set
  136157. */
  136158. serialize(): any;
  136159. /**
  136160. * Parse a new ParticleSystemSet from a serialized source
  136161. * @param data defines a JSON compatible representation of the set
  136162. * @param scene defines the hosting scene
  136163. * @param gpu defines if we want GPU particles or CPU particles
  136164. * @returns a new ParticleSystemSet
  136165. */
  136166. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  136167. }
  136168. }
  136169. declare module BABYLON {
  136170. /**
  136171. * This class is made for on one-liner static method to help creating particle system set.
  136172. */
  136173. export class ParticleHelper {
  136174. /**
  136175. * Gets or sets base Assets URL
  136176. */
  136177. static BaseAssetsUrl: string;
  136178. /**
  136179. * Create a default particle system that you can tweak
  136180. * @param emitter defines the emitter to use
  136181. * @param capacity defines the system capacity (default is 500 particles)
  136182. * @param scene defines the hosting scene
  136183. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  136184. * @returns the new Particle system
  136185. */
  136186. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  136187. /**
  136188. * This is the main static method (one-liner) of this helper to create different particle systems
  136189. * @param type This string represents the type to the particle system to create
  136190. * @param scene The scene where the particle system should live
  136191. * @param gpu If the system will use gpu
  136192. * @returns the ParticleSystemSet created
  136193. */
  136194. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  136195. /**
  136196. * Static function used to export a particle system to a ParticleSystemSet variable.
  136197. * Please note that the emitter shape is not exported
  136198. * @param systems defines the particle systems to export
  136199. * @returns the created particle system set
  136200. */
  136201. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  136202. }
  136203. }
  136204. declare module BABYLON {
  136205. interface Engine {
  136206. /**
  136207. * Create an effect to use with particle systems.
  136208. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  136209. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  136210. * @param uniformsNames defines a list of attribute names
  136211. * @param samplers defines an array of string used to represent textures
  136212. * @param defines defines the string containing the defines to use to compile the shaders
  136213. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  136214. * @param onCompiled defines a function to call when the effect creation is successful
  136215. * @param onError defines a function to call when the effect creation has failed
  136216. * @returns the new Effect
  136217. */
  136218. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  136219. }
  136220. interface Mesh {
  136221. /**
  136222. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  136223. * @returns an array of IParticleSystem
  136224. */
  136225. getEmittedParticleSystems(): IParticleSystem[];
  136226. /**
  136227. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  136228. * @returns an array of IParticleSystem
  136229. */
  136230. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  136231. }
  136232. /**
  136233. * @hidden
  136234. */
  136235. export var _IDoNeedToBeInTheBuild: number;
  136236. }
  136237. declare module BABYLON {
  136238. /** Defines the 4 color options */
  136239. export enum PointColor {
  136240. /** color value */
  136241. Color = 2,
  136242. /** uv value */
  136243. UV = 1,
  136244. /** random value */
  136245. Random = 0,
  136246. /** stated value */
  136247. Stated = 3
  136248. }
  136249. /**
  136250. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  136251. * 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.
  136252. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  136253. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  136254. *
  136255. * Full documentation here : TO BE ENTERED
  136256. */
  136257. export class PointsCloudSystem implements IDisposable {
  136258. /**
  136259. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  136260. * Example : var p = SPS.particles[i];
  136261. */
  136262. particles: CloudPoint[];
  136263. /**
  136264. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  136265. */
  136266. nbParticles: number;
  136267. /**
  136268. * This a counter for your own usage. It's not set by any SPS functions.
  136269. */
  136270. counter: number;
  136271. /**
  136272. * The PCS name. This name is also given to the underlying mesh.
  136273. */
  136274. name: string;
  136275. /**
  136276. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  136277. */
  136278. mesh: Mesh;
  136279. /**
  136280. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  136281. * Please read :
  136282. */
  136283. vars: any;
  136284. /**
  136285. * @hidden
  136286. */
  136287. _size: number;
  136288. private _scene;
  136289. private _promises;
  136290. private _positions;
  136291. private _indices;
  136292. private _normals;
  136293. private _colors;
  136294. private _uvs;
  136295. private _indices32;
  136296. private _positions32;
  136297. private _colors32;
  136298. private _uvs32;
  136299. private _updatable;
  136300. private _isVisibilityBoxLocked;
  136301. private _alwaysVisible;
  136302. private _groups;
  136303. private _groupCounter;
  136304. private _computeParticleColor;
  136305. private _computeParticleTexture;
  136306. private _computeParticleRotation;
  136307. private _computeBoundingBox;
  136308. private _isReady;
  136309. /**
  136310. * Creates a PCS (Points Cloud System) object
  136311. * @param name (String) is the PCS name, this will be the underlying mesh name
  136312. * @param pointSize (number) is the size for each point
  136313. * @param scene (Scene) is the scene in which the PCS is added
  136314. * @param options defines the options of the PCS e.g.
  136315. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  136316. */
  136317. constructor(name: string, pointSize: number, scene: Scene, options?: {
  136318. updatable?: boolean;
  136319. });
  136320. /**
  136321. * Builds the PCS underlying mesh. Returns a standard Mesh.
  136322. * If no points were added to the PCS, the returned mesh is just a single point.
  136323. * @returns a promise for the created mesh
  136324. */
  136325. buildMeshAsync(): Promise<Mesh>;
  136326. /**
  136327. * @hidden
  136328. */
  136329. private _buildMesh;
  136330. private _addParticle;
  136331. private _randomUnitVector;
  136332. private _getColorIndicesForCoord;
  136333. private _setPointsColorOrUV;
  136334. private _colorFromTexture;
  136335. private _calculateDensity;
  136336. /**
  136337. * Adds points to the PCS in random positions within a unit sphere
  136338. * @param nb (positive integer) the number of particles to be created from this model
  136339. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  136340. * @returns the number of groups in the system
  136341. */
  136342. addPoints(nb: number, pointFunction?: any): number;
  136343. /**
  136344. * Adds points to the PCS from the surface of the model shape
  136345. * @param mesh is any Mesh object that will be used as a surface model for the points
  136346. * @param nb (positive integer) the number of particles to be created from this model
  136347. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136348. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136349. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136350. * @returns the number of groups in the system
  136351. */
  136352. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136353. /**
  136354. * Adds points to the PCS inside the model shape
  136355. * @param mesh is any Mesh object that will be used as a surface model for the points
  136356. * @param nb (positive integer) the number of particles to be created from this model
  136357. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  136358. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  136359. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  136360. * @returns the number of groups in the system
  136361. */
  136362. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  136363. /**
  136364. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  136365. * This method calls `updateParticle()` for each particle of the SPS.
  136366. * For an animated SPS, it is usually called within the render loop.
  136367. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  136368. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  136369. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  136370. * @returns the PCS.
  136371. */
  136372. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  136373. /**
  136374. * Disposes the PCS.
  136375. */
  136376. dispose(): void;
  136377. /**
  136378. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  136379. * doc :
  136380. * @returns the PCS.
  136381. */
  136382. refreshVisibleSize(): PointsCloudSystem;
  136383. /**
  136384. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  136385. * @param size the size (float) of the visibility box
  136386. * note : this doesn't lock the PCS mesh bounding box.
  136387. * doc :
  136388. */
  136389. setVisibilityBox(size: number): void;
  136390. /**
  136391. * Gets whether the PCS is always visible or not
  136392. * doc :
  136393. */
  136394. get isAlwaysVisible(): boolean;
  136395. /**
  136396. * Sets the PCS as always visible or not
  136397. * doc :
  136398. */
  136399. set isAlwaysVisible(val: boolean);
  136400. /**
  136401. * Tells to `setParticles()` to compute the particle rotations or not
  136402. * Default value : false. The PCS is faster when it's set to false
  136403. * Note : particle rotations are only applied to parent particles
  136404. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  136405. */
  136406. set computeParticleRotation(val: boolean);
  136407. /**
  136408. * Tells to `setParticles()` to compute the particle colors or not.
  136409. * Default value : true. The PCS is faster when it's set to false.
  136410. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136411. */
  136412. set computeParticleColor(val: boolean);
  136413. set computeParticleTexture(val: boolean);
  136414. /**
  136415. * Gets if `setParticles()` computes the particle colors or not.
  136416. * Default value : false. The PCS is faster when it's set to false.
  136417. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  136418. */
  136419. get computeParticleColor(): boolean;
  136420. /**
  136421. * Gets if `setParticles()` computes the particle textures or not.
  136422. * Default value : false. The PCS is faster when it's set to false.
  136423. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  136424. */
  136425. get computeParticleTexture(): boolean;
  136426. /**
  136427. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  136428. */
  136429. set computeBoundingBox(val: boolean);
  136430. /**
  136431. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  136432. */
  136433. get computeBoundingBox(): boolean;
  136434. /**
  136435. * This function does nothing. It may be overwritten to set all the particle first values.
  136436. * The PCS doesn't call this function, you may have to call it by your own.
  136437. * doc :
  136438. */
  136439. initParticles(): void;
  136440. /**
  136441. * This function does nothing. It may be overwritten to recycle a particle
  136442. * The PCS doesn't call this function, you can to call it
  136443. * doc :
  136444. * @param particle The particle to recycle
  136445. * @returns the recycled particle
  136446. */
  136447. recycleParticle(particle: CloudPoint): CloudPoint;
  136448. /**
  136449. * Updates a particle : this function should be overwritten by the user.
  136450. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  136451. * doc :
  136452. * @example : just set a particle position or velocity and recycle conditions
  136453. * @param particle The particle to update
  136454. * @returns the updated particle
  136455. */
  136456. updateParticle(particle: CloudPoint): CloudPoint;
  136457. /**
  136458. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  136459. * This does nothing and may be overwritten by the user.
  136460. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136461. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136462. * @param update the boolean update value actually passed to setParticles()
  136463. */
  136464. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136465. /**
  136466. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  136467. * This will be passed three parameters.
  136468. * This does nothing and may be overwritten by the user.
  136469. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  136470. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  136471. * @param update the boolean update value actually passed to setParticles()
  136472. */
  136473. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  136474. }
  136475. }
  136476. declare module BABYLON {
  136477. /**
  136478. * Represents one particle of a points cloud system.
  136479. */
  136480. export class CloudPoint {
  136481. /**
  136482. * particle global index
  136483. */
  136484. idx: number;
  136485. /**
  136486. * The color of the particle
  136487. */
  136488. color: Nullable<Color4>;
  136489. /**
  136490. * The world space position of the particle.
  136491. */
  136492. position: Vector3;
  136493. /**
  136494. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  136495. */
  136496. rotation: Vector3;
  136497. /**
  136498. * The world space rotation quaternion of the particle.
  136499. */
  136500. rotationQuaternion: Nullable<Quaternion>;
  136501. /**
  136502. * The uv of the particle.
  136503. */
  136504. uv: Nullable<Vector2>;
  136505. /**
  136506. * The current speed of the particle.
  136507. */
  136508. velocity: Vector3;
  136509. /**
  136510. * The pivot point in the particle local space.
  136511. */
  136512. pivot: Vector3;
  136513. /**
  136514. * Must the particle be translated from its pivot point in its local space ?
  136515. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  136516. * Default : false
  136517. */
  136518. translateFromPivot: boolean;
  136519. /**
  136520. * Index of this particle in the global "positions" array (Internal use)
  136521. * @hidden
  136522. */
  136523. _pos: number;
  136524. /**
  136525. * @hidden Index of this particle in the global "indices" array (Internal use)
  136526. */
  136527. _ind: number;
  136528. /**
  136529. * Group this particle belongs to
  136530. */
  136531. _group: PointsGroup;
  136532. /**
  136533. * Group id of this particle
  136534. */
  136535. groupId: number;
  136536. /**
  136537. * Index of the particle in its group id (Internal use)
  136538. */
  136539. idxInGroup: number;
  136540. /**
  136541. * @hidden Particle BoundingInfo object (Internal use)
  136542. */
  136543. _boundingInfo: BoundingInfo;
  136544. /**
  136545. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  136546. */
  136547. _pcs: PointsCloudSystem;
  136548. /**
  136549. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  136550. */
  136551. _stillInvisible: boolean;
  136552. /**
  136553. * @hidden Last computed particle rotation matrix
  136554. */
  136555. _rotationMatrix: number[];
  136556. /**
  136557. * Parent particle Id, if any.
  136558. * Default null.
  136559. */
  136560. parentId: Nullable<number>;
  136561. /**
  136562. * @hidden Internal global position in the PCS.
  136563. */
  136564. _globalPosition: Vector3;
  136565. /**
  136566. * Creates a Point Cloud object.
  136567. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  136568. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  136569. * @param group (PointsGroup) is the group the particle belongs to
  136570. * @param groupId (integer) is the group identifier in the PCS.
  136571. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  136572. * @param pcs defines the PCS it is associated to
  136573. */
  136574. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  136575. /**
  136576. * get point size
  136577. */
  136578. get size(): Vector3;
  136579. /**
  136580. * Set point size
  136581. */
  136582. set size(scale: Vector3);
  136583. /**
  136584. * Legacy support, changed quaternion to rotationQuaternion
  136585. */
  136586. get quaternion(): Nullable<Quaternion>;
  136587. /**
  136588. * Legacy support, changed quaternion to rotationQuaternion
  136589. */
  136590. set quaternion(q: Nullable<Quaternion>);
  136591. /**
  136592. * Returns a boolean. True if the particle intersects a mesh, else false
  136593. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  136594. * @param target is the object (point or mesh) what the intersection is computed against
  136595. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  136596. * @returns true if it intersects
  136597. */
  136598. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  136599. /**
  136600. * get the rotation matrix of the particle
  136601. * @hidden
  136602. */
  136603. getRotationMatrix(m: Matrix): void;
  136604. }
  136605. /**
  136606. * Represents a group of points in a points cloud system
  136607. * * PCS internal tool, don't use it manually.
  136608. */
  136609. export class PointsGroup {
  136610. /**
  136611. * The group id
  136612. * @hidden
  136613. */
  136614. groupID: number;
  136615. /**
  136616. * image data for group (internal use)
  136617. * @hidden
  136618. */
  136619. _groupImageData: Nullable<ArrayBufferView>;
  136620. /**
  136621. * Image Width (internal use)
  136622. * @hidden
  136623. */
  136624. _groupImgWidth: number;
  136625. /**
  136626. * Image Height (internal use)
  136627. * @hidden
  136628. */
  136629. _groupImgHeight: number;
  136630. /**
  136631. * Custom position function (internal use)
  136632. * @hidden
  136633. */
  136634. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  136635. /**
  136636. * density per facet for surface points
  136637. * @hidden
  136638. */
  136639. _groupDensity: number[];
  136640. /**
  136641. * Only when points are colored by texture carries pointer to texture list array
  136642. * @hidden
  136643. */
  136644. _textureNb: number;
  136645. /**
  136646. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  136647. * PCS internal tool, don't use it manually.
  136648. * @hidden
  136649. */
  136650. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  136651. }
  136652. }
  136653. declare module BABYLON {
  136654. interface Scene {
  136655. /** @hidden (Backing field) */
  136656. _physicsEngine: Nullable<IPhysicsEngine>;
  136657. /** @hidden */
  136658. _physicsTimeAccumulator: number;
  136659. /**
  136660. * Gets the current physics engine
  136661. * @returns a IPhysicsEngine or null if none attached
  136662. */
  136663. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  136664. /**
  136665. * Enables physics to the current scene
  136666. * @param gravity defines the scene's gravity for the physics engine
  136667. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  136668. * @return a boolean indicating if the physics engine was initialized
  136669. */
  136670. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  136671. /**
  136672. * Disables and disposes the physics engine associated with the scene
  136673. */
  136674. disablePhysicsEngine(): void;
  136675. /**
  136676. * Gets a boolean indicating if there is an active physics engine
  136677. * @returns a boolean indicating if there is an active physics engine
  136678. */
  136679. isPhysicsEnabled(): boolean;
  136680. /**
  136681. * Deletes a physics compound impostor
  136682. * @param compound defines the compound to delete
  136683. */
  136684. deleteCompoundImpostor(compound: any): void;
  136685. /**
  136686. * An event triggered when physic simulation is about to be run
  136687. */
  136688. onBeforePhysicsObservable: Observable<Scene>;
  136689. /**
  136690. * An event triggered when physic simulation has been done
  136691. */
  136692. onAfterPhysicsObservable: Observable<Scene>;
  136693. }
  136694. interface AbstractMesh {
  136695. /** @hidden */
  136696. _physicsImpostor: Nullable<PhysicsImpostor>;
  136697. /**
  136698. * Gets or sets impostor used for physic simulation
  136699. * @see http://doc.babylonjs.com/features/physics_engine
  136700. */
  136701. physicsImpostor: Nullable<PhysicsImpostor>;
  136702. /**
  136703. * Gets the current physics impostor
  136704. * @see http://doc.babylonjs.com/features/physics_engine
  136705. * @returns a physics impostor or null
  136706. */
  136707. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  136708. /** Apply a physic impulse to the mesh
  136709. * @param force defines the force to apply
  136710. * @param contactPoint defines where to apply the force
  136711. * @returns the current mesh
  136712. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  136713. */
  136714. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  136715. /**
  136716. * Creates a physic joint between two meshes
  136717. * @param otherMesh defines the other mesh to use
  136718. * @param pivot1 defines the pivot to use on this mesh
  136719. * @param pivot2 defines the pivot to use on the other mesh
  136720. * @param options defines additional options (can be plugin dependent)
  136721. * @returns the current mesh
  136722. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  136723. */
  136724. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  136725. /** @hidden */
  136726. _disposePhysicsObserver: Nullable<Observer<Node>>;
  136727. }
  136728. /**
  136729. * Defines the physics engine scene component responsible to manage a physics engine
  136730. */
  136731. export class PhysicsEngineSceneComponent implements ISceneComponent {
  136732. /**
  136733. * The component name helpful to identify the component in the list of scene components.
  136734. */
  136735. readonly name: string;
  136736. /**
  136737. * The scene the component belongs to.
  136738. */
  136739. scene: Scene;
  136740. /**
  136741. * Creates a new instance of the component for the given scene
  136742. * @param scene Defines the scene to register the component in
  136743. */
  136744. constructor(scene: Scene);
  136745. /**
  136746. * Registers the component in a given scene
  136747. */
  136748. register(): void;
  136749. /**
  136750. * Rebuilds the elements related to this component in case of
  136751. * context lost for instance.
  136752. */
  136753. rebuild(): void;
  136754. /**
  136755. * Disposes the component and the associated ressources
  136756. */
  136757. dispose(): void;
  136758. }
  136759. }
  136760. declare module BABYLON {
  136761. /**
  136762. * A helper for physics simulations
  136763. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136764. */
  136765. export class PhysicsHelper {
  136766. private _scene;
  136767. private _physicsEngine;
  136768. /**
  136769. * Initializes the Physics helper
  136770. * @param scene Babylon.js scene
  136771. */
  136772. constructor(scene: Scene);
  136773. /**
  136774. * Applies a radial explosion impulse
  136775. * @param origin the origin of the explosion
  136776. * @param radiusOrEventOptions the radius or the options of radial explosion
  136777. * @param strength the explosion strength
  136778. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136779. * @returns A physics radial explosion event, or null
  136780. */
  136781. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136782. /**
  136783. * Applies a radial explosion force
  136784. * @param origin the origin of the explosion
  136785. * @param radiusOrEventOptions the radius or the options of radial explosion
  136786. * @param strength the explosion strength
  136787. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136788. * @returns A physics radial explosion event, or null
  136789. */
  136790. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  136791. /**
  136792. * Creates a gravitational field
  136793. * @param origin the origin of the explosion
  136794. * @param radiusOrEventOptions the radius or the options of radial explosion
  136795. * @param strength the explosion strength
  136796. * @param falloff possible options: Constant & Linear. Defaults to Constant
  136797. * @returns A physics gravitational field event, or null
  136798. */
  136799. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  136800. /**
  136801. * Creates a physics updraft event
  136802. * @param origin the origin of the updraft
  136803. * @param radiusOrEventOptions the radius or the options of the updraft
  136804. * @param strength the strength of the updraft
  136805. * @param height the height of the updraft
  136806. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  136807. * @returns A physics updraft event, or null
  136808. */
  136809. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  136810. /**
  136811. * Creates a physics vortex event
  136812. * @param origin the of the vortex
  136813. * @param radiusOrEventOptions the radius or the options of the vortex
  136814. * @param strength the strength of the vortex
  136815. * @param height the height of the vortex
  136816. * @returns a Physics vortex event, or null
  136817. * A physics vortex event or null
  136818. */
  136819. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  136820. }
  136821. /**
  136822. * Represents a physics radial explosion event
  136823. */
  136824. class PhysicsRadialExplosionEvent {
  136825. private _scene;
  136826. private _options;
  136827. private _sphere;
  136828. private _dataFetched;
  136829. /**
  136830. * Initializes a radial explosioin event
  136831. * @param _scene BabylonJS scene
  136832. * @param _options The options for the vortex event
  136833. */
  136834. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  136835. /**
  136836. * Returns the data related to the radial explosion event (sphere).
  136837. * @returns The radial explosion event data
  136838. */
  136839. getData(): PhysicsRadialExplosionEventData;
  136840. /**
  136841. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  136842. * @param impostor A physics imposter
  136843. * @param origin the origin of the explosion
  136844. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  136845. */
  136846. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  136847. /**
  136848. * Triggers affecterd impostors callbacks
  136849. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  136850. */
  136851. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  136852. /**
  136853. * Disposes the sphere.
  136854. * @param force Specifies if the sphere should be disposed by force
  136855. */
  136856. dispose(force?: boolean): void;
  136857. /*** Helpers ***/
  136858. private _prepareSphere;
  136859. private _intersectsWithSphere;
  136860. }
  136861. /**
  136862. * Represents a gravitational field event
  136863. */
  136864. class PhysicsGravitationalFieldEvent {
  136865. private _physicsHelper;
  136866. private _scene;
  136867. private _origin;
  136868. private _options;
  136869. private _tickCallback;
  136870. private _sphere;
  136871. private _dataFetched;
  136872. /**
  136873. * Initializes the physics gravitational field event
  136874. * @param _physicsHelper A physics helper
  136875. * @param _scene BabylonJS scene
  136876. * @param _origin The origin position of the gravitational field event
  136877. * @param _options The options for the vortex event
  136878. */
  136879. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  136880. /**
  136881. * Returns the data related to the gravitational field event (sphere).
  136882. * @returns A gravitational field event
  136883. */
  136884. getData(): PhysicsGravitationalFieldEventData;
  136885. /**
  136886. * Enables the gravitational field.
  136887. */
  136888. enable(): void;
  136889. /**
  136890. * Disables the gravitational field.
  136891. */
  136892. disable(): void;
  136893. /**
  136894. * Disposes the sphere.
  136895. * @param force The force to dispose from the gravitational field event
  136896. */
  136897. dispose(force?: boolean): void;
  136898. private _tick;
  136899. }
  136900. /**
  136901. * Represents a physics updraft event
  136902. */
  136903. class PhysicsUpdraftEvent {
  136904. private _scene;
  136905. private _origin;
  136906. private _options;
  136907. private _physicsEngine;
  136908. private _originTop;
  136909. private _originDirection;
  136910. private _tickCallback;
  136911. private _cylinder;
  136912. private _cylinderPosition;
  136913. private _dataFetched;
  136914. /**
  136915. * Initializes the physics updraft event
  136916. * @param _scene BabylonJS scene
  136917. * @param _origin The origin position of the updraft
  136918. * @param _options The options for the updraft event
  136919. */
  136920. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  136921. /**
  136922. * Returns the data related to the updraft event (cylinder).
  136923. * @returns A physics updraft event
  136924. */
  136925. getData(): PhysicsUpdraftEventData;
  136926. /**
  136927. * Enables the updraft.
  136928. */
  136929. enable(): void;
  136930. /**
  136931. * Disables the updraft.
  136932. */
  136933. disable(): void;
  136934. /**
  136935. * Disposes the cylinder.
  136936. * @param force Specifies if the updraft should be disposed by force
  136937. */
  136938. dispose(force?: boolean): void;
  136939. private getImpostorHitData;
  136940. private _tick;
  136941. /*** Helpers ***/
  136942. private _prepareCylinder;
  136943. private _intersectsWithCylinder;
  136944. }
  136945. /**
  136946. * Represents a physics vortex event
  136947. */
  136948. class PhysicsVortexEvent {
  136949. private _scene;
  136950. private _origin;
  136951. private _options;
  136952. private _physicsEngine;
  136953. private _originTop;
  136954. private _tickCallback;
  136955. private _cylinder;
  136956. private _cylinderPosition;
  136957. private _dataFetched;
  136958. /**
  136959. * Initializes the physics vortex event
  136960. * @param _scene The BabylonJS scene
  136961. * @param _origin The origin position of the vortex
  136962. * @param _options The options for the vortex event
  136963. */
  136964. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  136965. /**
  136966. * Returns the data related to the vortex event (cylinder).
  136967. * @returns The physics vortex event data
  136968. */
  136969. getData(): PhysicsVortexEventData;
  136970. /**
  136971. * Enables the vortex.
  136972. */
  136973. enable(): void;
  136974. /**
  136975. * Disables the cortex.
  136976. */
  136977. disable(): void;
  136978. /**
  136979. * Disposes the sphere.
  136980. * @param force
  136981. */
  136982. dispose(force?: boolean): void;
  136983. private getImpostorHitData;
  136984. private _tick;
  136985. /*** Helpers ***/
  136986. private _prepareCylinder;
  136987. private _intersectsWithCylinder;
  136988. }
  136989. /**
  136990. * Options fot the radial explosion event
  136991. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  136992. */
  136993. export class PhysicsRadialExplosionEventOptions {
  136994. /**
  136995. * The radius of the sphere for the radial explosion.
  136996. */
  136997. radius: number;
  136998. /**
  136999. * The strenth of the explosion.
  137000. */
  137001. strength: number;
  137002. /**
  137003. * The strenght of the force in correspondence to the distance of the affected object
  137004. */
  137005. falloff: PhysicsRadialImpulseFalloff;
  137006. /**
  137007. * Sphere options for the radial explosion.
  137008. */
  137009. sphere: {
  137010. segments: number;
  137011. diameter: number;
  137012. };
  137013. /**
  137014. * Sphere options for the radial explosion.
  137015. */
  137016. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  137017. }
  137018. /**
  137019. * Options fot the updraft event
  137020. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137021. */
  137022. export class PhysicsUpdraftEventOptions {
  137023. /**
  137024. * The radius of the cylinder for the vortex
  137025. */
  137026. radius: number;
  137027. /**
  137028. * The strenth of the updraft.
  137029. */
  137030. strength: number;
  137031. /**
  137032. * The height of the cylinder for the updraft.
  137033. */
  137034. height: number;
  137035. /**
  137036. * The mode for the the updraft.
  137037. */
  137038. updraftMode: PhysicsUpdraftMode;
  137039. }
  137040. /**
  137041. * Options fot the vortex event
  137042. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137043. */
  137044. export class PhysicsVortexEventOptions {
  137045. /**
  137046. * The radius of the cylinder for the vortex
  137047. */
  137048. radius: number;
  137049. /**
  137050. * The strenth of the vortex.
  137051. */
  137052. strength: number;
  137053. /**
  137054. * The height of the cylinder for the vortex.
  137055. */
  137056. height: number;
  137057. /**
  137058. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  137059. */
  137060. centripetalForceThreshold: number;
  137061. /**
  137062. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  137063. */
  137064. centripetalForceMultiplier: number;
  137065. /**
  137066. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  137067. */
  137068. centrifugalForceMultiplier: number;
  137069. /**
  137070. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  137071. */
  137072. updraftForceMultiplier: number;
  137073. }
  137074. /**
  137075. * The strenght of the force in correspondence to the distance of the affected object
  137076. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137077. */
  137078. export enum PhysicsRadialImpulseFalloff {
  137079. /** Defines that impulse is constant in strength across it's whole radius */
  137080. Constant = 0,
  137081. /** Defines that impulse gets weaker if it's further from the origin */
  137082. Linear = 1
  137083. }
  137084. /**
  137085. * The strength of the force in correspondence to the distance of the affected object
  137086. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137087. */
  137088. export enum PhysicsUpdraftMode {
  137089. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  137090. Center = 0,
  137091. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  137092. Perpendicular = 1
  137093. }
  137094. /**
  137095. * Interface for a physics hit data
  137096. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137097. */
  137098. export interface PhysicsHitData {
  137099. /**
  137100. * The force applied at the contact point
  137101. */
  137102. force: Vector3;
  137103. /**
  137104. * The contact point
  137105. */
  137106. contactPoint: Vector3;
  137107. /**
  137108. * The distance from the origin to the contact point
  137109. */
  137110. distanceFromOrigin: number;
  137111. }
  137112. /**
  137113. * Interface for radial explosion event data
  137114. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137115. */
  137116. export interface PhysicsRadialExplosionEventData {
  137117. /**
  137118. * A sphere used for the radial explosion event
  137119. */
  137120. sphere: Mesh;
  137121. }
  137122. /**
  137123. * Interface for gravitational field event data
  137124. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137125. */
  137126. export interface PhysicsGravitationalFieldEventData {
  137127. /**
  137128. * A sphere mesh used for the gravitational field event
  137129. */
  137130. sphere: Mesh;
  137131. }
  137132. /**
  137133. * Interface for updraft event data
  137134. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137135. */
  137136. export interface PhysicsUpdraftEventData {
  137137. /**
  137138. * A cylinder used for the updraft event
  137139. */
  137140. cylinder: Mesh;
  137141. }
  137142. /**
  137143. * Interface for vortex event data
  137144. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137145. */
  137146. export interface PhysicsVortexEventData {
  137147. /**
  137148. * A cylinder used for the vortex event
  137149. */
  137150. cylinder: Mesh;
  137151. }
  137152. /**
  137153. * Interface for an affected physics impostor
  137154. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  137155. */
  137156. export interface PhysicsAffectedImpostorWithData {
  137157. /**
  137158. * The impostor affected by the effect
  137159. */
  137160. impostor: PhysicsImpostor;
  137161. /**
  137162. * The data about the hit/horce from the explosion
  137163. */
  137164. hitData: PhysicsHitData;
  137165. }
  137166. }
  137167. declare module BABYLON {
  137168. /** @hidden */
  137169. export var blackAndWhitePixelShader: {
  137170. name: string;
  137171. shader: string;
  137172. };
  137173. }
  137174. declare module BABYLON {
  137175. /**
  137176. * Post process used to render in black and white
  137177. */
  137178. export class BlackAndWhitePostProcess extends PostProcess {
  137179. /**
  137180. * Linear about to convert he result to black and white (default: 1)
  137181. */
  137182. degree: number;
  137183. /**
  137184. * Creates a black and white post process
  137185. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  137186. * @param name The name of the effect.
  137187. * @param options The required width/height ratio to downsize to before computing the render pass.
  137188. * @param camera The camera to apply the render pass to.
  137189. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137190. * @param engine The engine which the post process will be applied. (default: current engine)
  137191. * @param reusable If the post process can be reused on the same frame. (default: false)
  137192. */
  137193. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137194. }
  137195. }
  137196. declare module BABYLON {
  137197. /**
  137198. * This represents a set of one or more post processes in Babylon.
  137199. * A post process can be used to apply a shader to a texture after it is rendered.
  137200. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  137201. */
  137202. export class PostProcessRenderEffect {
  137203. private _postProcesses;
  137204. private _getPostProcesses;
  137205. private _singleInstance;
  137206. private _cameras;
  137207. private _indicesForCamera;
  137208. /**
  137209. * Name of the effect
  137210. * @hidden
  137211. */
  137212. _name: string;
  137213. /**
  137214. * Instantiates a post process render effect.
  137215. * A post process can be used to apply a shader to a texture after it is rendered.
  137216. * @param engine The engine the effect is tied to
  137217. * @param name The name of the effect
  137218. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  137219. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  137220. */
  137221. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  137222. /**
  137223. * Checks if all the post processes in the effect are supported.
  137224. */
  137225. get isSupported(): boolean;
  137226. /**
  137227. * Updates the current state of the effect
  137228. * @hidden
  137229. */
  137230. _update(): void;
  137231. /**
  137232. * Attaches the effect on cameras
  137233. * @param cameras The camera to attach to.
  137234. * @hidden
  137235. */
  137236. _attachCameras(cameras: Camera): void;
  137237. /**
  137238. * Attaches the effect on cameras
  137239. * @param cameras The camera to attach to.
  137240. * @hidden
  137241. */
  137242. _attachCameras(cameras: Camera[]): void;
  137243. /**
  137244. * Detaches the effect on cameras
  137245. * @param cameras The camera to detatch from.
  137246. * @hidden
  137247. */
  137248. _detachCameras(cameras: Camera): void;
  137249. /**
  137250. * Detatches the effect on cameras
  137251. * @param cameras The camera to detatch from.
  137252. * @hidden
  137253. */
  137254. _detachCameras(cameras: Camera[]): void;
  137255. /**
  137256. * Enables the effect on given cameras
  137257. * @param cameras The camera to enable.
  137258. * @hidden
  137259. */
  137260. _enable(cameras: Camera): void;
  137261. /**
  137262. * Enables the effect on given cameras
  137263. * @param cameras The camera to enable.
  137264. * @hidden
  137265. */
  137266. _enable(cameras: Nullable<Camera[]>): void;
  137267. /**
  137268. * Disables the effect on the given cameras
  137269. * @param cameras The camera to disable.
  137270. * @hidden
  137271. */
  137272. _disable(cameras: Camera): void;
  137273. /**
  137274. * Disables the effect on the given cameras
  137275. * @param cameras The camera to disable.
  137276. * @hidden
  137277. */
  137278. _disable(cameras: Nullable<Camera[]>): void;
  137279. /**
  137280. * Gets a list of the post processes contained in the effect.
  137281. * @param camera The camera to get the post processes on.
  137282. * @returns The list of the post processes in the effect.
  137283. */
  137284. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  137285. }
  137286. }
  137287. declare module BABYLON {
  137288. /** @hidden */
  137289. export var extractHighlightsPixelShader: {
  137290. name: string;
  137291. shader: string;
  137292. };
  137293. }
  137294. declare module BABYLON {
  137295. /**
  137296. * 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.
  137297. */
  137298. export class ExtractHighlightsPostProcess extends PostProcess {
  137299. /**
  137300. * The luminance threshold, pixels below this value will be set to black.
  137301. */
  137302. threshold: number;
  137303. /** @hidden */
  137304. _exposure: number;
  137305. /**
  137306. * Post process which has the input texture to be used when performing highlight extraction
  137307. * @hidden
  137308. */
  137309. _inputPostProcess: Nullable<PostProcess>;
  137310. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137311. }
  137312. }
  137313. declare module BABYLON {
  137314. /** @hidden */
  137315. export var bloomMergePixelShader: {
  137316. name: string;
  137317. shader: string;
  137318. };
  137319. }
  137320. declare module BABYLON {
  137321. /**
  137322. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137323. */
  137324. export class BloomMergePostProcess extends PostProcess {
  137325. /** Weight of the bloom to be added to the original input. */
  137326. weight: number;
  137327. /**
  137328. * Creates a new instance of @see BloomMergePostProcess
  137329. * @param name The name of the effect.
  137330. * @param originalFromInput Post process which's input will be used for the merge.
  137331. * @param blurred Blurred highlights post process which's output will be used.
  137332. * @param weight Weight of the bloom to be added to the original input.
  137333. * @param options The required width/height ratio to downsize to before computing the render pass.
  137334. * @param camera The camera to apply the render pass to.
  137335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137336. * @param engine The engine which the post process will be applied. (default: current engine)
  137337. * @param reusable If the post process can be reused on the same frame. (default: false)
  137338. * @param textureType Type of textures used when performing the post process. (default: 0)
  137339. * @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)
  137340. */
  137341. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  137342. /** Weight of the bloom to be added to the original input. */
  137343. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137344. }
  137345. }
  137346. declare module BABYLON {
  137347. /**
  137348. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  137349. */
  137350. export class BloomEffect extends PostProcessRenderEffect {
  137351. private bloomScale;
  137352. /**
  137353. * @hidden Internal
  137354. */
  137355. _effects: Array<PostProcess>;
  137356. /**
  137357. * @hidden Internal
  137358. */
  137359. _downscale: ExtractHighlightsPostProcess;
  137360. private _blurX;
  137361. private _blurY;
  137362. private _merge;
  137363. /**
  137364. * The luminance threshold to find bright areas of the image to bloom.
  137365. */
  137366. get threshold(): number;
  137367. set threshold(value: number);
  137368. /**
  137369. * The strength of the bloom.
  137370. */
  137371. get weight(): number;
  137372. set weight(value: number);
  137373. /**
  137374. * Specifies the size of the bloom blur kernel, relative to the final output size
  137375. */
  137376. get kernel(): number;
  137377. set kernel(value: number);
  137378. /**
  137379. * Creates a new instance of @see BloomEffect
  137380. * @param scene The scene the effect belongs to.
  137381. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  137382. * @param bloomKernel The size of the kernel to be used when applying the blur.
  137383. * @param bloomWeight The the strength of bloom.
  137384. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137385. * @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)
  137386. */
  137387. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  137388. /**
  137389. * Disposes each of the internal effects for a given camera.
  137390. * @param camera The camera to dispose the effect on.
  137391. */
  137392. disposeEffects(camera: Camera): void;
  137393. /**
  137394. * @hidden Internal
  137395. */
  137396. _updateEffects(): void;
  137397. /**
  137398. * Internal
  137399. * @returns if all the contained post processes are ready.
  137400. * @hidden
  137401. */
  137402. _isReady(): boolean;
  137403. }
  137404. }
  137405. declare module BABYLON {
  137406. /** @hidden */
  137407. export var chromaticAberrationPixelShader: {
  137408. name: string;
  137409. shader: string;
  137410. };
  137411. }
  137412. declare module BABYLON {
  137413. /**
  137414. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  137415. */
  137416. export class ChromaticAberrationPostProcess extends PostProcess {
  137417. /**
  137418. * The amount of seperation of rgb channels (default: 30)
  137419. */
  137420. aberrationAmount: number;
  137421. /**
  137422. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  137423. */
  137424. radialIntensity: number;
  137425. /**
  137426. * 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))
  137427. */
  137428. direction: Vector2;
  137429. /**
  137430. * 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))
  137431. */
  137432. centerPosition: Vector2;
  137433. /**
  137434. * Creates a new instance ChromaticAberrationPostProcess
  137435. * @param name The name of the effect.
  137436. * @param screenWidth The width of the screen to apply the effect on.
  137437. * @param screenHeight The height of the screen to apply the effect on.
  137438. * @param options The required width/height ratio to downsize to before computing the render pass.
  137439. * @param camera The camera to apply the render pass to.
  137440. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137441. * @param engine The engine which the post process will be applied. (default: current engine)
  137442. * @param reusable If the post process can be reused on the same frame. (default: false)
  137443. * @param textureType Type of textures used when performing the post process. (default: 0)
  137444. * @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)
  137445. */
  137446. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137447. }
  137448. }
  137449. declare module BABYLON {
  137450. /** @hidden */
  137451. export var circleOfConfusionPixelShader: {
  137452. name: string;
  137453. shader: string;
  137454. };
  137455. }
  137456. declare module BABYLON {
  137457. /**
  137458. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  137459. */
  137460. export class CircleOfConfusionPostProcess extends PostProcess {
  137461. /**
  137462. * 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.
  137463. */
  137464. lensSize: number;
  137465. /**
  137466. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137467. */
  137468. fStop: number;
  137469. /**
  137470. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137471. */
  137472. focusDistance: number;
  137473. /**
  137474. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  137475. */
  137476. focalLength: number;
  137477. private _depthTexture;
  137478. /**
  137479. * Creates a new instance CircleOfConfusionPostProcess
  137480. * @param name The name of the effect.
  137481. * @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.
  137482. * @param options The required width/height ratio to downsize to before computing the render pass.
  137483. * @param camera The camera to apply the render pass to.
  137484. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137485. * @param engine The engine which the post process will be applied. (default: current engine)
  137486. * @param reusable If the post process can be reused on the same frame. (default: false)
  137487. * @param textureType Type of textures used when performing the post process. (default: 0)
  137488. * @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)
  137489. */
  137490. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137491. /**
  137492. * 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.
  137493. */
  137494. set depthTexture(value: RenderTargetTexture);
  137495. }
  137496. }
  137497. declare module BABYLON {
  137498. /** @hidden */
  137499. export var colorCorrectionPixelShader: {
  137500. name: string;
  137501. shader: string;
  137502. };
  137503. }
  137504. declare module BABYLON {
  137505. /**
  137506. *
  137507. * This post-process allows the modification of rendered colors by using
  137508. * a 'look-up table' (LUT). This effect is also called Color Grading.
  137509. *
  137510. * The object needs to be provided an url to a texture containing the color
  137511. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  137512. * Use an image editing software to tweak the LUT to match your needs.
  137513. *
  137514. * For an example of a color LUT, see here:
  137515. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  137516. * For explanations on color grading, see here:
  137517. * @see http://udn.epicgames.com/Three/ColorGrading.html
  137518. *
  137519. */
  137520. export class ColorCorrectionPostProcess extends PostProcess {
  137521. private _colorTableTexture;
  137522. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137523. }
  137524. }
  137525. declare module BABYLON {
  137526. /** @hidden */
  137527. export var convolutionPixelShader: {
  137528. name: string;
  137529. shader: string;
  137530. };
  137531. }
  137532. declare module BABYLON {
  137533. /**
  137534. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  137535. * input texture to perform effects such as edge detection or sharpening
  137536. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  137537. */
  137538. export class ConvolutionPostProcess extends PostProcess {
  137539. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137540. kernel: number[];
  137541. /**
  137542. * Creates a new instance ConvolutionPostProcess
  137543. * @param name The name of the effect.
  137544. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  137545. * @param options The required width/height ratio to downsize to before computing the render pass.
  137546. * @param camera The camera to apply the render pass to.
  137547. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137548. * @param engine The engine which the post process will be applied. (default: current engine)
  137549. * @param reusable If the post process can be reused on the same frame. (default: false)
  137550. * @param textureType Type of textures used when performing the post process. (default: 0)
  137551. */
  137552. constructor(name: string,
  137553. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  137554. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137555. /**
  137556. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137557. */
  137558. static EdgeDetect0Kernel: number[];
  137559. /**
  137560. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137561. */
  137562. static EdgeDetect1Kernel: number[];
  137563. /**
  137564. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137565. */
  137566. static EdgeDetect2Kernel: number[];
  137567. /**
  137568. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137569. */
  137570. static SharpenKernel: number[];
  137571. /**
  137572. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137573. */
  137574. static EmbossKernel: number[];
  137575. /**
  137576. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  137577. */
  137578. static GaussianKernel: number[];
  137579. }
  137580. }
  137581. declare module BABYLON {
  137582. /**
  137583. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  137584. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  137585. * based on samples that have a large difference in distance than the center pixel.
  137586. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  137587. */
  137588. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  137589. direction: Vector2;
  137590. /**
  137591. * Creates a new instance CircleOfConfusionPostProcess
  137592. * @param name The name of the effect.
  137593. * @param scene The scene the effect belongs to.
  137594. * @param direction The direction the blur should be applied.
  137595. * @param kernel The size of the kernel used to blur.
  137596. * @param options The required width/height ratio to downsize to before computing the render pass.
  137597. * @param camera The camera to apply the render pass to.
  137598. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  137599. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  137600. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137601. * @param engine The engine which the post process will be applied. (default: current engine)
  137602. * @param reusable If the post process can be reused on the same frame. (default: false)
  137603. * @param textureType Type of textures used when performing the post process. (default: 0)
  137604. * @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)
  137605. */
  137606. 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);
  137607. }
  137608. }
  137609. declare module BABYLON {
  137610. /** @hidden */
  137611. export var depthOfFieldMergePixelShader: {
  137612. name: string;
  137613. shader: string;
  137614. };
  137615. }
  137616. declare module BABYLON {
  137617. /**
  137618. * Options to be set when merging outputs from the default pipeline.
  137619. */
  137620. export class DepthOfFieldMergePostProcessOptions {
  137621. /**
  137622. * The original image to merge on top of
  137623. */
  137624. originalFromInput: PostProcess;
  137625. /**
  137626. * Parameters to perform the merge of the depth of field effect
  137627. */
  137628. depthOfField?: {
  137629. circleOfConfusion: PostProcess;
  137630. blurSteps: Array<PostProcess>;
  137631. };
  137632. /**
  137633. * Parameters to perform the merge of bloom effect
  137634. */
  137635. bloom?: {
  137636. blurred: PostProcess;
  137637. weight: number;
  137638. };
  137639. }
  137640. /**
  137641. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  137642. */
  137643. export class DepthOfFieldMergePostProcess extends PostProcess {
  137644. private blurSteps;
  137645. /**
  137646. * Creates a new instance of DepthOfFieldMergePostProcess
  137647. * @param name The name of the effect.
  137648. * @param originalFromInput Post process which's input will be used for the merge.
  137649. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  137650. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  137651. * @param options The required width/height ratio to downsize to before computing the render pass.
  137652. * @param camera The camera to apply the render pass to.
  137653. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137654. * @param engine The engine which the post process will be applied. (default: current engine)
  137655. * @param reusable If the post process can be reused on the same frame. (default: false)
  137656. * @param textureType Type of textures used when performing the post process. (default: 0)
  137657. * @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)
  137658. */
  137659. 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);
  137660. /**
  137661. * Updates the effect with the current post process compile time values and recompiles the shader.
  137662. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  137663. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  137664. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  137665. * @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
  137666. * @param onCompiled Called when the shader has been compiled.
  137667. * @param onError Called if there is an error when compiling a shader.
  137668. */
  137669. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  137670. }
  137671. }
  137672. declare module BABYLON {
  137673. /**
  137674. * Specifies the level of max blur that should be applied when using the depth of field effect
  137675. */
  137676. export enum DepthOfFieldEffectBlurLevel {
  137677. /**
  137678. * Subtle blur
  137679. */
  137680. Low = 0,
  137681. /**
  137682. * Medium blur
  137683. */
  137684. Medium = 1,
  137685. /**
  137686. * Large blur
  137687. */
  137688. High = 2
  137689. }
  137690. /**
  137691. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  137692. */
  137693. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  137694. private _circleOfConfusion;
  137695. /**
  137696. * @hidden Internal, blurs from high to low
  137697. */
  137698. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  137699. private _depthOfFieldBlurY;
  137700. private _dofMerge;
  137701. /**
  137702. * @hidden Internal post processes in depth of field effect
  137703. */
  137704. _effects: Array<PostProcess>;
  137705. /**
  137706. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  137707. */
  137708. set focalLength(value: number);
  137709. get focalLength(): number;
  137710. /**
  137711. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  137712. */
  137713. set fStop(value: number);
  137714. get fStop(): number;
  137715. /**
  137716. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  137717. */
  137718. set focusDistance(value: number);
  137719. get focusDistance(): number;
  137720. /**
  137721. * 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.
  137722. */
  137723. set lensSize(value: number);
  137724. get lensSize(): number;
  137725. /**
  137726. * Creates a new instance DepthOfFieldEffect
  137727. * @param scene The scene the effect belongs to.
  137728. * @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.
  137729. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  137730. * @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)
  137731. */
  137732. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  137733. /**
  137734. * Get the current class name of the current effet
  137735. * @returns "DepthOfFieldEffect"
  137736. */
  137737. getClassName(): string;
  137738. /**
  137739. * 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.
  137740. */
  137741. set depthTexture(value: RenderTargetTexture);
  137742. /**
  137743. * Disposes each of the internal effects for a given camera.
  137744. * @param camera The camera to dispose the effect on.
  137745. */
  137746. disposeEffects(camera: Camera): void;
  137747. /**
  137748. * @hidden Internal
  137749. */
  137750. _updateEffects(): void;
  137751. /**
  137752. * Internal
  137753. * @returns if all the contained post processes are ready.
  137754. * @hidden
  137755. */
  137756. _isReady(): boolean;
  137757. }
  137758. }
  137759. declare module BABYLON {
  137760. /** @hidden */
  137761. export var displayPassPixelShader: {
  137762. name: string;
  137763. shader: string;
  137764. };
  137765. }
  137766. declare module BABYLON {
  137767. /**
  137768. * DisplayPassPostProcess which produces an output the same as it's input
  137769. */
  137770. export class DisplayPassPostProcess extends PostProcess {
  137771. /**
  137772. * Creates the DisplayPassPostProcess
  137773. * @param name The name of the effect.
  137774. * @param options The required width/height ratio to downsize to before computing the render pass.
  137775. * @param camera The camera to apply the render pass to.
  137776. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137777. * @param engine The engine which the post process will be applied. (default: current engine)
  137778. * @param reusable If the post process can be reused on the same frame. (default: false)
  137779. */
  137780. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137781. }
  137782. }
  137783. declare module BABYLON {
  137784. /** @hidden */
  137785. export var filterPixelShader: {
  137786. name: string;
  137787. shader: string;
  137788. };
  137789. }
  137790. declare module BABYLON {
  137791. /**
  137792. * Applies a kernel filter to the image
  137793. */
  137794. export class FilterPostProcess extends PostProcess {
  137795. /** The matrix to be applied to the image */
  137796. kernelMatrix: Matrix;
  137797. /**
  137798. *
  137799. * @param name The name of the effect.
  137800. * @param kernelMatrix The matrix to be applied to the image
  137801. * @param options The required width/height ratio to downsize to before computing the render pass.
  137802. * @param camera The camera to apply the render pass to.
  137803. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137804. * @param engine The engine which the post process will be applied. (default: current engine)
  137805. * @param reusable If the post process can be reused on the same frame. (default: false)
  137806. */
  137807. constructor(name: string,
  137808. /** The matrix to be applied to the image */
  137809. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  137810. }
  137811. }
  137812. declare module BABYLON {
  137813. /** @hidden */
  137814. export var fxaaPixelShader: {
  137815. name: string;
  137816. shader: string;
  137817. };
  137818. }
  137819. declare module BABYLON {
  137820. /** @hidden */
  137821. export var fxaaVertexShader: {
  137822. name: string;
  137823. shader: string;
  137824. };
  137825. }
  137826. declare module BABYLON {
  137827. /**
  137828. * Fxaa post process
  137829. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  137830. */
  137831. export class FxaaPostProcess extends PostProcess {
  137832. /** @hidden */
  137833. texelWidth: number;
  137834. /** @hidden */
  137835. texelHeight: number;
  137836. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137837. private _getDefines;
  137838. }
  137839. }
  137840. declare module BABYLON {
  137841. /** @hidden */
  137842. export var grainPixelShader: {
  137843. name: string;
  137844. shader: string;
  137845. };
  137846. }
  137847. declare module BABYLON {
  137848. /**
  137849. * The GrainPostProcess adds noise to the image at mid luminance levels
  137850. */
  137851. export class GrainPostProcess extends PostProcess {
  137852. /**
  137853. * The intensity of the grain added (default: 30)
  137854. */
  137855. intensity: number;
  137856. /**
  137857. * If the grain should be randomized on every frame
  137858. */
  137859. animated: boolean;
  137860. /**
  137861. * Creates a new instance of @see GrainPostProcess
  137862. * @param name The name of the effect.
  137863. * @param options The required width/height ratio to downsize to before computing the render pass.
  137864. * @param camera The camera to apply the render pass to.
  137865. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137866. * @param engine The engine which the post process will be applied. (default: current engine)
  137867. * @param reusable If the post process can be reused on the same frame. (default: false)
  137868. * @param textureType Type of textures used when performing the post process. (default: 0)
  137869. * @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)
  137870. */
  137871. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  137872. }
  137873. }
  137874. declare module BABYLON {
  137875. /** @hidden */
  137876. export var highlightsPixelShader: {
  137877. name: string;
  137878. shader: string;
  137879. };
  137880. }
  137881. declare module BABYLON {
  137882. /**
  137883. * Extracts highlights from the image
  137884. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137885. */
  137886. export class HighlightsPostProcess extends PostProcess {
  137887. /**
  137888. * Extracts highlights from the image
  137889. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  137890. * @param name The name of the effect.
  137891. * @param options The required width/height ratio to downsize to before computing the render pass.
  137892. * @param camera The camera to apply the render pass to.
  137893. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  137894. * @param engine The engine which the post process will be applied. (default: current engine)
  137895. * @param reusable If the post process can be reused on the same frame. (default: false)
  137896. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  137897. */
  137898. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  137899. }
  137900. }
  137901. declare module BABYLON {
  137902. /** @hidden */
  137903. export var mrtFragmentDeclaration: {
  137904. name: string;
  137905. shader: string;
  137906. };
  137907. }
  137908. declare module BABYLON {
  137909. /** @hidden */
  137910. export var geometryPixelShader: {
  137911. name: string;
  137912. shader: string;
  137913. };
  137914. }
  137915. declare module BABYLON {
  137916. /** @hidden */
  137917. export var geometryVertexShader: {
  137918. name: string;
  137919. shader: string;
  137920. };
  137921. }
  137922. declare module BABYLON {
  137923. /** @hidden */
  137924. interface ISavedTransformationMatrix {
  137925. world: Matrix;
  137926. viewProjection: Matrix;
  137927. }
  137928. /**
  137929. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  137930. */
  137931. export class GeometryBufferRenderer {
  137932. /**
  137933. * Constant used to retrieve the position texture index in the G-Buffer textures array
  137934. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  137935. */
  137936. static readonly POSITION_TEXTURE_TYPE: number;
  137937. /**
  137938. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  137939. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  137940. */
  137941. static readonly VELOCITY_TEXTURE_TYPE: number;
  137942. /**
  137943. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  137944. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  137945. */
  137946. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  137947. /**
  137948. * Dictionary used to store the previous transformation matrices of each rendered mesh
  137949. * in order to compute objects velocities when enableVelocity is set to "true"
  137950. * @hidden
  137951. */
  137952. _previousTransformationMatrices: {
  137953. [index: number]: ISavedTransformationMatrix;
  137954. };
  137955. /**
  137956. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  137957. * in order to compute objects velocities when enableVelocity is set to "true"
  137958. * @hidden
  137959. */
  137960. _previousBonesTransformationMatrices: {
  137961. [index: number]: Float32Array;
  137962. };
  137963. /**
  137964. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  137965. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  137966. */
  137967. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  137968. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  137969. renderTransparentMeshes: boolean;
  137970. private _scene;
  137971. private _multiRenderTarget;
  137972. private _ratio;
  137973. private _enablePosition;
  137974. private _enableVelocity;
  137975. private _enableReflectivity;
  137976. private _positionIndex;
  137977. private _velocityIndex;
  137978. private _reflectivityIndex;
  137979. protected _effect: Effect;
  137980. protected _cachedDefines: string;
  137981. /**
  137982. * Set the render list (meshes to be rendered) used in the G buffer.
  137983. */
  137984. set renderList(meshes: Mesh[]);
  137985. /**
  137986. * Gets wether or not G buffer are supported by the running hardware.
  137987. * This requires draw buffer supports
  137988. */
  137989. get isSupported(): boolean;
  137990. /**
  137991. * Returns the index of the given texture type in the G-Buffer textures array
  137992. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  137993. * @returns the index of the given texture type in the G-Buffer textures array
  137994. */
  137995. getTextureIndex(textureType: number): number;
  137996. /**
  137997. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  137998. */
  137999. get enablePosition(): boolean;
  138000. /**
  138001. * Sets whether or not objects positions are enabled for the G buffer.
  138002. */
  138003. set enablePosition(enable: boolean);
  138004. /**
  138005. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  138006. */
  138007. get enableVelocity(): boolean;
  138008. /**
  138009. * Sets wether or not objects velocities are enabled for the G buffer.
  138010. */
  138011. set enableVelocity(enable: boolean);
  138012. /**
  138013. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  138014. */
  138015. get enableReflectivity(): boolean;
  138016. /**
  138017. * Sets wether or not objects roughness are enabled for the G buffer.
  138018. */
  138019. set enableReflectivity(enable: boolean);
  138020. /**
  138021. * Gets the scene associated with the buffer.
  138022. */
  138023. get scene(): Scene;
  138024. /**
  138025. * Gets the ratio used by the buffer during its creation.
  138026. * How big is the buffer related to the main canvas.
  138027. */
  138028. get ratio(): number;
  138029. /** @hidden */
  138030. static _SceneComponentInitialization: (scene: Scene) => void;
  138031. /**
  138032. * Creates a new G Buffer for the scene
  138033. * @param scene The scene the buffer belongs to
  138034. * @param ratio How big is the buffer related to the main canvas.
  138035. */
  138036. constructor(scene: Scene, ratio?: number);
  138037. /**
  138038. * Checks wether everything is ready to render a submesh to the G buffer.
  138039. * @param subMesh the submesh to check readiness for
  138040. * @param useInstances is the mesh drawn using instance or not
  138041. * @returns true if ready otherwise false
  138042. */
  138043. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  138044. /**
  138045. * Gets the current underlying G Buffer.
  138046. * @returns the buffer
  138047. */
  138048. getGBuffer(): MultiRenderTarget;
  138049. /**
  138050. * Gets the number of samples used to render the buffer (anti aliasing).
  138051. */
  138052. get samples(): number;
  138053. /**
  138054. * Sets the number of samples used to render the buffer (anti aliasing).
  138055. */
  138056. set samples(value: number);
  138057. /**
  138058. * Disposes the renderer and frees up associated resources.
  138059. */
  138060. dispose(): void;
  138061. protected _createRenderTargets(): void;
  138062. private _copyBonesTransformationMatrices;
  138063. }
  138064. }
  138065. declare module BABYLON {
  138066. interface Scene {
  138067. /** @hidden (Backing field) */
  138068. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  138069. /**
  138070. * Gets or Sets the current geometry buffer associated to the scene.
  138071. */
  138072. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  138073. /**
  138074. * Enables a GeometryBufferRender and associates it with the scene
  138075. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  138076. * @returns the GeometryBufferRenderer
  138077. */
  138078. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  138079. /**
  138080. * Disables the GeometryBufferRender associated with the scene
  138081. */
  138082. disableGeometryBufferRenderer(): void;
  138083. }
  138084. /**
  138085. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  138086. * in several rendering techniques.
  138087. */
  138088. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  138089. /**
  138090. * The component name helpful to identify the component in the list of scene components.
  138091. */
  138092. readonly name: string;
  138093. /**
  138094. * The scene the component belongs to.
  138095. */
  138096. scene: Scene;
  138097. /**
  138098. * Creates a new instance of the component for the given scene
  138099. * @param scene Defines the scene to register the component in
  138100. */
  138101. constructor(scene: Scene);
  138102. /**
  138103. * Registers the component in a given scene
  138104. */
  138105. register(): void;
  138106. /**
  138107. * Rebuilds the elements related to this component in case of
  138108. * context lost for instance.
  138109. */
  138110. rebuild(): void;
  138111. /**
  138112. * Disposes the component and the associated ressources
  138113. */
  138114. dispose(): void;
  138115. private _gatherRenderTargets;
  138116. }
  138117. }
  138118. declare module BABYLON {
  138119. /** @hidden */
  138120. export var motionBlurPixelShader: {
  138121. name: string;
  138122. shader: string;
  138123. };
  138124. }
  138125. declare module BABYLON {
  138126. /**
  138127. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  138128. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  138129. * As an example, all you have to do is to create the post-process:
  138130. * var mb = new BABYLON.MotionBlurPostProcess(
  138131. * 'mb', // The name of the effect.
  138132. * scene, // The scene containing the objects to blur according to their velocity.
  138133. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  138134. * camera // The camera to apply the render pass to.
  138135. * );
  138136. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  138137. */
  138138. export class MotionBlurPostProcess extends PostProcess {
  138139. /**
  138140. * Defines how much the image is blurred by the movement. Default value is equal to 1
  138141. */
  138142. motionStrength: number;
  138143. /**
  138144. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  138145. */
  138146. get motionBlurSamples(): number;
  138147. /**
  138148. * Sets the number of iterations to be used for motion blur quality
  138149. */
  138150. set motionBlurSamples(samples: number);
  138151. private _motionBlurSamples;
  138152. private _geometryBufferRenderer;
  138153. /**
  138154. * Creates a new instance MotionBlurPostProcess
  138155. * @param name The name of the effect.
  138156. * @param scene The scene containing the objects to blur according to their velocity.
  138157. * @param options The required width/height ratio to downsize to before computing the render pass.
  138158. * @param camera The camera to apply the render pass to.
  138159. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138160. * @param engine The engine which the post process will be applied. (default: current engine)
  138161. * @param reusable If the post process can be reused on the same frame. (default: false)
  138162. * @param textureType Type of textures used when performing the post process. (default: 0)
  138163. * @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)
  138164. */
  138165. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138166. /**
  138167. * Excludes the given skinned mesh from computing bones velocities.
  138168. * 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.
  138169. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  138170. */
  138171. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138172. /**
  138173. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  138174. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  138175. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  138176. */
  138177. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  138178. /**
  138179. * Disposes the post process.
  138180. * @param camera The camera to dispose the post process on.
  138181. */
  138182. dispose(camera?: Camera): void;
  138183. }
  138184. }
  138185. declare module BABYLON {
  138186. /** @hidden */
  138187. export var refractionPixelShader: {
  138188. name: string;
  138189. shader: string;
  138190. };
  138191. }
  138192. declare module BABYLON {
  138193. /**
  138194. * Post process which applies a refractin texture
  138195. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138196. */
  138197. export class RefractionPostProcess extends PostProcess {
  138198. /** the base color of the refraction (used to taint the rendering) */
  138199. color: Color3;
  138200. /** simulated refraction depth */
  138201. depth: number;
  138202. /** the coefficient of the base color (0 to remove base color tainting) */
  138203. colorLevel: number;
  138204. private _refTexture;
  138205. private _ownRefractionTexture;
  138206. /**
  138207. * Gets or sets the refraction texture
  138208. * Please note that you are responsible for disposing the texture if you set it manually
  138209. */
  138210. get refractionTexture(): Texture;
  138211. set refractionTexture(value: Texture);
  138212. /**
  138213. * Initializes the RefractionPostProcess
  138214. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  138215. * @param name The name of the effect.
  138216. * @param refractionTextureUrl Url of the refraction texture to use
  138217. * @param color the base color of the refraction (used to taint the rendering)
  138218. * @param depth simulated refraction depth
  138219. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  138220. * @param camera The camera to apply the render pass to.
  138221. * @param options The required width/height ratio to downsize to before computing the render pass.
  138222. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138223. * @param engine The engine which the post process will be applied. (default: current engine)
  138224. * @param reusable If the post process can be reused on the same frame. (default: false)
  138225. */
  138226. constructor(name: string, refractionTextureUrl: string,
  138227. /** the base color of the refraction (used to taint the rendering) */
  138228. color: Color3,
  138229. /** simulated refraction depth */
  138230. depth: number,
  138231. /** the coefficient of the base color (0 to remove base color tainting) */
  138232. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138233. /**
  138234. * Disposes of the post process
  138235. * @param camera Camera to dispose post process on
  138236. */
  138237. dispose(camera: Camera): void;
  138238. }
  138239. }
  138240. declare module BABYLON {
  138241. /** @hidden */
  138242. export var sharpenPixelShader: {
  138243. name: string;
  138244. shader: string;
  138245. };
  138246. }
  138247. declare module BABYLON {
  138248. /**
  138249. * The SharpenPostProcess applies a sharpen kernel to every pixel
  138250. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  138251. */
  138252. export class SharpenPostProcess extends PostProcess {
  138253. /**
  138254. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  138255. */
  138256. colorAmount: number;
  138257. /**
  138258. * How much sharpness should be applied (default: 0.3)
  138259. */
  138260. edgeAmount: number;
  138261. /**
  138262. * Creates a new instance ConvolutionPostProcess
  138263. * @param name The name of the effect.
  138264. * @param options The required width/height ratio to downsize to before computing the render pass.
  138265. * @param camera The camera to apply the render pass to.
  138266. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138267. * @param engine The engine which the post process will be applied. (default: current engine)
  138268. * @param reusable If the post process can be reused on the same frame. (default: false)
  138269. * @param textureType Type of textures used when performing the post process. (default: 0)
  138270. * @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)
  138271. */
  138272. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  138273. }
  138274. }
  138275. declare module BABYLON {
  138276. /**
  138277. * PostProcessRenderPipeline
  138278. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138279. */
  138280. export class PostProcessRenderPipeline {
  138281. private engine;
  138282. private _renderEffects;
  138283. private _renderEffectsForIsolatedPass;
  138284. /**
  138285. * List of inspectable custom properties (used by the Inspector)
  138286. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  138287. */
  138288. inspectableCustomProperties: IInspectable[];
  138289. /**
  138290. * @hidden
  138291. */
  138292. protected _cameras: Camera[];
  138293. /** @hidden */
  138294. _name: string;
  138295. /**
  138296. * Gets pipeline name
  138297. */
  138298. get name(): string;
  138299. /** Gets the list of attached cameras */
  138300. get cameras(): Camera[];
  138301. /**
  138302. * Initializes a PostProcessRenderPipeline
  138303. * @param engine engine to add the pipeline to
  138304. * @param name name of the pipeline
  138305. */
  138306. constructor(engine: Engine, name: string);
  138307. /**
  138308. * Gets the class name
  138309. * @returns "PostProcessRenderPipeline"
  138310. */
  138311. getClassName(): string;
  138312. /**
  138313. * If all the render effects in the pipeline are supported
  138314. */
  138315. get isSupported(): boolean;
  138316. /**
  138317. * Adds an effect to the pipeline
  138318. * @param renderEffect the effect to add
  138319. */
  138320. addEffect(renderEffect: PostProcessRenderEffect): void;
  138321. /** @hidden */
  138322. _rebuild(): void;
  138323. /** @hidden */
  138324. _enableEffect(renderEffectName: string, cameras: Camera): void;
  138325. /** @hidden */
  138326. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  138327. /** @hidden */
  138328. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138329. /** @hidden */
  138330. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  138331. /** @hidden */
  138332. _attachCameras(cameras: Camera, unique: boolean): void;
  138333. /** @hidden */
  138334. _attachCameras(cameras: Camera[], unique: boolean): void;
  138335. /** @hidden */
  138336. _detachCameras(cameras: Camera): void;
  138337. /** @hidden */
  138338. _detachCameras(cameras: Nullable<Camera[]>): void;
  138339. /** @hidden */
  138340. _update(): void;
  138341. /** @hidden */
  138342. _reset(): void;
  138343. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  138344. /**
  138345. * Disposes of the pipeline
  138346. */
  138347. dispose(): void;
  138348. }
  138349. }
  138350. declare module BABYLON {
  138351. /**
  138352. * PostProcessRenderPipelineManager class
  138353. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138354. */
  138355. export class PostProcessRenderPipelineManager {
  138356. private _renderPipelines;
  138357. /**
  138358. * Initializes a PostProcessRenderPipelineManager
  138359. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138360. */
  138361. constructor();
  138362. /**
  138363. * Gets the list of supported render pipelines
  138364. */
  138365. get supportedPipelines(): PostProcessRenderPipeline[];
  138366. /**
  138367. * Adds a pipeline to the manager
  138368. * @param renderPipeline The pipeline to add
  138369. */
  138370. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  138371. /**
  138372. * Attaches a camera to the pipeline
  138373. * @param renderPipelineName The name of the pipeline to attach to
  138374. * @param cameras the camera to attach
  138375. * @param unique if the camera can be attached multiple times to the pipeline
  138376. */
  138377. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  138378. /**
  138379. * Detaches a camera from the pipeline
  138380. * @param renderPipelineName The name of the pipeline to detach from
  138381. * @param cameras the camera to detach
  138382. */
  138383. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  138384. /**
  138385. * Enables an effect by name on a pipeline
  138386. * @param renderPipelineName the name of the pipeline to enable the effect in
  138387. * @param renderEffectName the name of the effect to enable
  138388. * @param cameras the cameras that the effect should be enabled on
  138389. */
  138390. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138391. /**
  138392. * Disables an effect by name on a pipeline
  138393. * @param renderPipelineName the name of the pipeline to disable the effect in
  138394. * @param renderEffectName the name of the effect to disable
  138395. * @param cameras the cameras that the effect should be disabled on
  138396. */
  138397. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  138398. /**
  138399. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  138400. */
  138401. update(): void;
  138402. /** @hidden */
  138403. _rebuild(): void;
  138404. /**
  138405. * Disposes of the manager and pipelines
  138406. */
  138407. dispose(): void;
  138408. }
  138409. }
  138410. declare module BABYLON {
  138411. interface Scene {
  138412. /** @hidden (Backing field) */
  138413. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138414. /**
  138415. * Gets the postprocess render pipeline manager
  138416. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138417. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138418. */
  138419. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  138420. }
  138421. /**
  138422. * Defines the Render Pipeline scene component responsible to rendering pipelines
  138423. */
  138424. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  138425. /**
  138426. * The component name helpfull to identify the component in the list of scene components.
  138427. */
  138428. readonly name: string;
  138429. /**
  138430. * The scene the component belongs to.
  138431. */
  138432. scene: Scene;
  138433. /**
  138434. * Creates a new instance of the component for the given scene
  138435. * @param scene Defines the scene to register the component in
  138436. */
  138437. constructor(scene: Scene);
  138438. /**
  138439. * Registers the component in a given scene
  138440. */
  138441. register(): void;
  138442. /**
  138443. * Rebuilds the elements related to this component in case of
  138444. * context lost for instance.
  138445. */
  138446. rebuild(): void;
  138447. /**
  138448. * Disposes the component and the associated ressources
  138449. */
  138450. dispose(): void;
  138451. private _gatherRenderTargets;
  138452. }
  138453. }
  138454. declare module BABYLON {
  138455. /**
  138456. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  138457. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  138458. */
  138459. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  138460. private _scene;
  138461. private _camerasToBeAttached;
  138462. /**
  138463. * ID of the sharpen post process,
  138464. */
  138465. private readonly SharpenPostProcessId;
  138466. /**
  138467. * @ignore
  138468. * ID of the image processing post process;
  138469. */
  138470. readonly ImageProcessingPostProcessId: string;
  138471. /**
  138472. * @ignore
  138473. * ID of the Fast Approximate Anti-Aliasing post process;
  138474. */
  138475. readonly FxaaPostProcessId: string;
  138476. /**
  138477. * ID of the chromatic aberration post process,
  138478. */
  138479. private readonly ChromaticAberrationPostProcessId;
  138480. /**
  138481. * ID of the grain post process
  138482. */
  138483. private readonly GrainPostProcessId;
  138484. /**
  138485. * Sharpen post process which will apply a sharpen convolution to enhance edges
  138486. */
  138487. sharpen: SharpenPostProcess;
  138488. private _sharpenEffect;
  138489. private bloom;
  138490. /**
  138491. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  138492. */
  138493. depthOfField: DepthOfFieldEffect;
  138494. /**
  138495. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  138496. */
  138497. fxaa: FxaaPostProcess;
  138498. /**
  138499. * Image post processing pass used to perform operations such as tone mapping or color grading.
  138500. */
  138501. imageProcessing: ImageProcessingPostProcess;
  138502. /**
  138503. * Chromatic aberration post process which will shift rgb colors in the image
  138504. */
  138505. chromaticAberration: ChromaticAberrationPostProcess;
  138506. private _chromaticAberrationEffect;
  138507. /**
  138508. * Grain post process which add noise to the image
  138509. */
  138510. grain: GrainPostProcess;
  138511. private _grainEffect;
  138512. /**
  138513. * Glow post process which adds a glow to emissive areas of the image
  138514. */
  138515. private _glowLayer;
  138516. /**
  138517. * Animations which can be used to tweak settings over a period of time
  138518. */
  138519. animations: Animation[];
  138520. private _imageProcessingConfigurationObserver;
  138521. private _sharpenEnabled;
  138522. private _bloomEnabled;
  138523. private _depthOfFieldEnabled;
  138524. private _depthOfFieldBlurLevel;
  138525. private _fxaaEnabled;
  138526. private _imageProcessingEnabled;
  138527. private _defaultPipelineTextureType;
  138528. private _bloomScale;
  138529. private _chromaticAberrationEnabled;
  138530. private _grainEnabled;
  138531. private _buildAllowed;
  138532. /**
  138533. * Gets active scene
  138534. */
  138535. get scene(): Scene;
  138536. /**
  138537. * Enable or disable the sharpen process from the pipeline
  138538. */
  138539. set sharpenEnabled(enabled: boolean);
  138540. get sharpenEnabled(): boolean;
  138541. private _resizeObserver;
  138542. private _hardwareScaleLevel;
  138543. private _bloomKernel;
  138544. /**
  138545. * Specifies the size of the bloom blur kernel, relative to the final output size
  138546. */
  138547. get bloomKernel(): number;
  138548. set bloomKernel(value: number);
  138549. /**
  138550. * Specifies the weight of the bloom in the final rendering
  138551. */
  138552. private _bloomWeight;
  138553. /**
  138554. * Specifies the luma threshold for the area that will be blurred by the bloom
  138555. */
  138556. private _bloomThreshold;
  138557. private _hdr;
  138558. /**
  138559. * The strength of the bloom.
  138560. */
  138561. set bloomWeight(value: number);
  138562. get bloomWeight(): number;
  138563. /**
  138564. * The strength of the bloom.
  138565. */
  138566. set bloomThreshold(value: number);
  138567. get bloomThreshold(): number;
  138568. /**
  138569. * The scale of the bloom, lower value will provide better performance.
  138570. */
  138571. set bloomScale(value: number);
  138572. get bloomScale(): number;
  138573. /**
  138574. * Enable or disable the bloom from the pipeline
  138575. */
  138576. set bloomEnabled(enabled: boolean);
  138577. get bloomEnabled(): boolean;
  138578. private _rebuildBloom;
  138579. /**
  138580. * If the depth of field is enabled.
  138581. */
  138582. get depthOfFieldEnabled(): boolean;
  138583. set depthOfFieldEnabled(enabled: boolean);
  138584. /**
  138585. * Blur level of the depth of field effect. (Higher blur will effect performance)
  138586. */
  138587. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  138588. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  138589. /**
  138590. * If the anti aliasing is enabled.
  138591. */
  138592. set fxaaEnabled(enabled: boolean);
  138593. get fxaaEnabled(): boolean;
  138594. private _samples;
  138595. /**
  138596. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  138597. */
  138598. set samples(sampleCount: number);
  138599. get samples(): number;
  138600. /**
  138601. * If image processing is enabled.
  138602. */
  138603. set imageProcessingEnabled(enabled: boolean);
  138604. get imageProcessingEnabled(): boolean;
  138605. /**
  138606. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  138607. */
  138608. set glowLayerEnabled(enabled: boolean);
  138609. get glowLayerEnabled(): boolean;
  138610. /**
  138611. * Gets the glow layer (or null if not defined)
  138612. */
  138613. get glowLayer(): Nullable<GlowLayer>;
  138614. /**
  138615. * Enable or disable the chromaticAberration process from the pipeline
  138616. */
  138617. set chromaticAberrationEnabled(enabled: boolean);
  138618. get chromaticAberrationEnabled(): boolean;
  138619. /**
  138620. * Enable or disable the grain process from the pipeline
  138621. */
  138622. set grainEnabled(enabled: boolean);
  138623. get grainEnabled(): boolean;
  138624. /**
  138625. * @constructor
  138626. * @param name - The rendering pipeline name (default: "")
  138627. * @param hdr - If high dynamic range textures should be used (default: true)
  138628. * @param scene - The scene linked to this pipeline (default: the last created scene)
  138629. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  138630. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  138631. */
  138632. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  138633. /**
  138634. * Get the class name
  138635. * @returns "DefaultRenderingPipeline"
  138636. */
  138637. getClassName(): string;
  138638. /**
  138639. * Force the compilation of the entire pipeline.
  138640. */
  138641. prepare(): void;
  138642. private _hasCleared;
  138643. private _prevPostProcess;
  138644. private _prevPrevPostProcess;
  138645. private _setAutoClearAndTextureSharing;
  138646. private _depthOfFieldSceneObserver;
  138647. private _buildPipeline;
  138648. private _disposePostProcesses;
  138649. /**
  138650. * Adds a camera to the pipeline
  138651. * @param camera the camera to be added
  138652. */
  138653. addCamera(camera: Camera): void;
  138654. /**
  138655. * Removes a camera from the pipeline
  138656. * @param camera the camera to remove
  138657. */
  138658. removeCamera(camera: Camera): void;
  138659. /**
  138660. * Dispose of the pipeline and stop all post processes
  138661. */
  138662. dispose(): void;
  138663. /**
  138664. * Serialize the rendering pipeline (Used when exporting)
  138665. * @returns the serialized object
  138666. */
  138667. serialize(): any;
  138668. /**
  138669. * Parse the serialized pipeline
  138670. * @param source Source pipeline.
  138671. * @param scene The scene to load the pipeline to.
  138672. * @param rootUrl The URL of the serialized pipeline.
  138673. * @returns An instantiated pipeline from the serialized object.
  138674. */
  138675. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  138676. }
  138677. }
  138678. declare module BABYLON {
  138679. /** @hidden */
  138680. export var lensHighlightsPixelShader: {
  138681. name: string;
  138682. shader: string;
  138683. };
  138684. }
  138685. declare module BABYLON {
  138686. /** @hidden */
  138687. export var depthOfFieldPixelShader: {
  138688. name: string;
  138689. shader: string;
  138690. };
  138691. }
  138692. declare module BABYLON {
  138693. /**
  138694. * BABYLON.JS Chromatic Aberration GLSL Shader
  138695. * Author: Olivier Guyot
  138696. * Separates very slightly R, G and B colors on the edges of the screen
  138697. * Inspired by Francois Tarlier & Martins Upitis
  138698. */
  138699. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  138700. /**
  138701. * @ignore
  138702. * The chromatic aberration PostProcess id in the pipeline
  138703. */
  138704. LensChromaticAberrationEffect: string;
  138705. /**
  138706. * @ignore
  138707. * The highlights enhancing PostProcess id in the pipeline
  138708. */
  138709. HighlightsEnhancingEffect: string;
  138710. /**
  138711. * @ignore
  138712. * The depth-of-field PostProcess id in the pipeline
  138713. */
  138714. LensDepthOfFieldEffect: string;
  138715. private _scene;
  138716. private _depthTexture;
  138717. private _grainTexture;
  138718. private _chromaticAberrationPostProcess;
  138719. private _highlightsPostProcess;
  138720. private _depthOfFieldPostProcess;
  138721. private _edgeBlur;
  138722. private _grainAmount;
  138723. private _chromaticAberration;
  138724. private _distortion;
  138725. private _highlightsGain;
  138726. private _highlightsThreshold;
  138727. private _dofDistance;
  138728. private _dofAperture;
  138729. private _dofDarken;
  138730. private _dofPentagon;
  138731. private _blurNoise;
  138732. /**
  138733. * @constructor
  138734. *
  138735. * Effect parameters are as follow:
  138736. * {
  138737. * chromatic_aberration: number; // from 0 to x (1 for realism)
  138738. * edge_blur: number; // from 0 to x (1 for realism)
  138739. * distortion: number; // from 0 to x (1 for realism)
  138740. * grain_amount: number; // from 0 to 1
  138741. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  138742. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  138743. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  138744. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  138745. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  138746. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  138747. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  138748. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  138749. * }
  138750. * Note: if an effect parameter is unset, effect is disabled
  138751. *
  138752. * @param name The rendering pipeline name
  138753. * @param parameters - An object containing all parameters (see above)
  138754. * @param scene The scene linked to this pipeline
  138755. * @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)
  138756. * @param cameras The array of cameras that the rendering pipeline will be attached to
  138757. */
  138758. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  138759. /**
  138760. * Get the class name
  138761. * @returns "LensRenderingPipeline"
  138762. */
  138763. getClassName(): string;
  138764. /**
  138765. * Gets associated scene
  138766. */
  138767. get scene(): Scene;
  138768. /**
  138769. * Gets or sets the edge blur
  138770. */
  138771. get edgeBlur(): number;
  138772. set edgeBlur(value: number);
  138773. /**
  138774. * Gets or sets the grain amount
  138775. */
  138776. get grainAmount(): number;
  138777. set grainAmount(value: number);
  138778. /**
  138779. * Gets or sets the chromatic aberration amount
  138780. */
  138781. get chromaticAberration(): number;
  138782. set chromaticAberration(value: number);
  138783. /**
  138784. * Gets or sets the depth of field aperture
  138785. */
  138786. get dofAperture(): number;
  138787. set dofAperture(value: number);
  138788. /**
  138789. * Gets or sets the edge distortion
  138790. */
  138791. get edgeDistortion(): number;
  138792. set edgeDistortion(value: number);
  138793. /**
  138794. * Gets or sets the depth of field distortion
  138795. */
  138796. get dofDistortion(): number;
  138797. set dofDistortion(value: number);
  138798. /**
  138799. * Gets or sets the darken out of focus amount
  138800. */
  138801. get darkenOutOfFocus(): number;
  138802. set darkenOutOfFocus(value: number);
  138803. /**
  138804. * Gets or sets a boolean indicating if blur noise is enabled
  138805. */
  138806. get blurNoise(): boolean;
  138807. set blurNoise(value: boolean);
  138808. /**
  138809. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  138810. */
  138811. get pentagonBokeh(): boolean;
  138812. set pentagonBokeh(value: boolean);
  138813. /**
  138814. * Gets or sets the highlight grain amount
  138815. */
  138816. get highlightsGain(): number;
  138817. set highlightsGain(value: number);
  138818. /**
  138819. * Gets or sets the highlight threshold
  138820. */
  138821. get highlightsThreshold(): number;
  138822. set highlightsThreshold(value: number);
  138823. /**
  138824. * Sets the amount of blur at the edges
  138825. * @param amount blur amount
  138826. */
  138827. setEdgeBlur(amount: number): void;
  138828. /**
  138829. * Sets edge blur to 0
  138830. */
  138831. disableEdgeBlur(): void;
  138832. /**
  138833. * Sets the amout of grain
  138834. * @param amount Amount of grain
  138835. */
  138836. setGrainAmount(amount: number): void;
  138837. /**
  138838. * Set grain amount to 0
  138839. */
  138840. disableGrain(): void;
  138841. /**
  138842. * Sets the chromatic aberration amount
  138843. * @param amount amount of chromatic aberration
  138844. */
  138845. setChromaticAberration(amount: number): void;
  138846. /**
  138847. * Sets chromatic aberration amount to 0
  138848. */
  138849. disableChromaticAberration(): void;
  138850. /**
  138851. * Sets the EdgeDistortion amount
  138852. * @param amount amount of EdgeDistortion
  138853. */
  138854. setEdgeDistortion(amount: number): void;
  138855. /**
  138856. * Sets edge distortion to 0
  138857. */
  138858. disableEdgeDistortion(): void;
  138859. /**
  138860. * Sets the FocusDistance amount
  138861. * @param amount amount of FocusDistance
  138862. */
  138863. setFocusDistance(amount: number): void;
  138864. /**
  138865. * Disables depth of field
  138866. */
  138867. disableDepthOfField(): void;
  138868. /**
  138869. * Sets the Aperture amount
  138870. * @param amount amount of Aperture
  138871. */
  138872. setAperture(amount: number): void;
  138873. /**
  138874. * Sets the DarkenOutOfFocus amount
  138875. * @param amount amount of DarkenOutOfFocus
  138876. */
  138877. setDarkenOutOfFocus(amount: number): void;
  138878. private _pentagonBokehIsEnabled;
  138879. /**
  138880. * Creates a pentagon bokeh effect
  138881. */
  138882. enablePentagonBokeh(): void;
  138883. /**
  138884. * Disables the pentagon bokeh effect
  138885. */
  138886. disablePentagonBokeh(): void;
  138887. /**
  138888. * Enables noise blur
  138889. */
  138890. enableNoiseBlur(): void;
  138891. /**
  138892. * Disables noise blur
  138893. */
  138894. disableNoiseBlur(): void;
  138895. /**
  138896. * Sets the HighlightsGain amount
  138897. * @param amount amount of HighlightsGain
  138898. */
  138899. setHighlightsGain(amount: number): void;
  138900. /**
  138901. * Sets the HighlightsThreshold amount
  138902. * @param amount amount of HighlightsThreshold
  138903. */
  138904. setHighlightsThreshold(amount: number): void;
  138905. /**
  138906. * Disables highlights
  138907. */
  138908. disableHighlights(): void;
  138909. /**
  138910. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  138911. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  138912. */
  138913. dispose(disableDepthRender?: boolean): void;
  138914. private _createChromaticAberrationPostProcess;
  138915. private _createHighlightsPostProcess;
  138916. private _createDepthOfFieldPostProcess;
  138917. private _createGrainTexture;
  138918. }
  138919. }
  138920. declare module BABYLON {
  138921. /** @hidden */
  138922. export var ssao2PixelShader: {
  138923. name: string;
  138924. shader: string;
  138925. };
  138926. }
  138927. declare module BABYLON {
  138928. /** @hidden */
  138929. export var ssaoCombinePixelShader: {
  138930. name: string;
  138931. shader: string;
  138932. };
  138933. }
  138934. declare module BABYLON {
  138935. /**
  138936. * Render pipeline to produce ssao effect
  138937. */
  138938. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  138939. /**
  138940. * @ignore
  138941. * The PassPostProcess id in the pipeline that contains the original scene color
  138942. */
  138943. SSAOOriginalSceneColorEffect: string;
  138944. /**
  138945. * @ignore
  138946. * The SSAO PostProcess id in the pipeline
  138947. */
  138948. SSAORenderEffect: string;
  138949. /**
  138950. * @ignore
  138951. * The horizontal blur PostProcess id in the pipeline
  138952. */
  138953. SSAOBlurHRenderEffect: string;
  138954. /**
  138955. * @ignore
  138956. * The vertical blur PostProcess id in the pipeline
  138957. */
  138958. SSAOBlurVRenderEffect: string;
  138959. /**
  138960. * @ignore
  138961. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  138962. */
  138963. SSAOCombineRenderEffect: string;
  138964. /**
  138965. * The output strength of the SSAO post-process. Default value is 1.0.
  138966. */
  138967. totalStrength: number;
  138968. /**
  138969. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  138970. */
  138971. maxZ: number;
  138972. /**
  138973. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  138974. */
  138975. minZAspect: number;
  138976. private _samples;
  138977. /**
  138978. * Number of samples used for the SSAO calculations. Default value is 8
  138979. */
  138980. set samples(n: number);
  138981. get samples(): number;
  138982. private _textureSamples;
  138983. /**
  138984. * Number of samples to use for antialiasing
  138985. */
  138986. set textureSamples(n: number);
  138987. get textureSamples(): number;
  138988. /**
  138989. * Ratio object used for SSAO ratio and blur ratio
  138990. */
  138991. private _ratio;
  138992. /**
  138993. * Dynamically generated sphere sampler.
  138994. */
  138995. private _sampleSphere;
  138996. /**
  138997. * Blur filter offsets
  138998. */
  138999. private _samplerOffsets;
  139000. private _expensiveBlur;
  139001. /**
  139002. * If bilateral blur should be used
  139003. */
  139004. set expensiveBlur(b: boolean);
  139005. get expensiveBlur(): boolean;
  139006. /**
  139007. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  139008. */
  139009. radius: number;
  139010. /**
  139011. * The base color of the SSAO post-process
  139012. * The final result is "base + ssao" between [0, 1]
  139013. */
  139014. base: number;
  139015. /**
  139016. * Support test.
  139017. */
  139018. static get IsSupported(): boolean;
  139019. private _scene;
  139020. private _depthTexture;
  139021. private _normalTexture;
  139022. private _randomTexture;
  139023. private _originalColorPostProcess;
  139024. private _ssaoPostProcess;
  139025. private _blurHPostProcess;
  139026. private _blurVPostProcess;
  139027. private _ssaoCombinePostProcess;
  139028. /**
  139029. * Gets active scene
  139030. */
  139031. get scene(): Scene;
  139032. /**
  139033. * @constructor
  139034. * @param name The rendering pipeline name
  139035. * @param scene The scene linked to this pipeline
  139036. * @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 }
  139037. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139038. */
  139039. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139040. /**
  139041. * Get the class name
  139042. * @returns "SSAO2RenderingPipeline"
  139043. */
  139044. getClassName(): string;
  139045. /**
  139046. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139047. */
  139048. dispose(disableGeometryBufferRenderer?: boolean): void;
  139049. private _createBlurPostProcess;
  139050. /** @hidden */
  139051. _rebuild(): void;
  139052. private _bits;
  139053. private _radicalInverse_VdC;
  139054. private _hammersley;
  139055. private _hemisphereSample_uniform;
  139056. private _generateHemisphere;
  139057. private _createSSAOPostProcess;
  139058. private _createSSAOCombinePostProcess;
  139059. private _createRandomTexture;
  139060. /**
  139061. * Serialize the rendering pipeline (Used when exporting)
  139062. * @returns the serialized object
  139063. */
  139064. serialize(): any;
  139065. /**
  139066. * Parse the serialized pipeline
  139067. * @param source Source pipeline.
  139068. * @param scene The scene to load the pipeline to.
  139069. * @param rootUrl The URL of the serialized pipeline.
  139070. * @returns An instantiated pipeline from the serialized object.
  139071. */
  139072. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  139073. }
  139074. }
  139075. declare module BABYLON {
  139076. /** @hidden */
  139077. export var ssaoPixelShader: {
  139078. name: string;
  139079. shader: string;
  139080. };
  139081. }
  139082. declare module BABYLON {
  139083. /**
  139084. * Render pipeline to produce ssao effect
  139085. */
  139086. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  139087. /**
  139088. * @ignore
  139089. * The PassPostProcess id in the pipeline that contains the original scene color
  139090. */
  139091. SSAOOriginalSceneColorEffect: string;
  139092. /**
  139093. * @ignore
  139094. * The SSAO PostProcess id in the pipeline
  139095. */
  139096. SSAORenderEffect: string;
  139097. /**
  139098. * @ignore
  139099. * The horizontal blur PostProcess id in the pipeline
  139100. */
  139101. SSAOBlurHRenderEffect: string;
  139102. /**
  139103. * @ignore
  139104. * The vertical blur PostProcess id in the pipeline
  139105. */
  139106. SSAOBlurVRenderEffect: string;
  139107. /**
  139108. * @ignore
  139109. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  139110. */
  139111. SSAOCombineRenderEffect: string;
  139112. /**
  139113. * The output strength of the SSAO post-process. Default value is 1.0.
  139114. */
  139115. totalStrength: number;
  139116. /**
  139117. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  139118. */
  139119. radius: number;
  139120. /**
  139121. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  139122. * Must not be equal to fallOff and superior to fallOff.
  139123. * Default value is 0.0075
  139124. */
  139125. area: number;
  139126. /**
  139127. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  139128. * Must not be equal to area and inferior to area.
  139129. * Default value is 0.000001
  139130. */
  139131. fallOff: number;
  139132. /**
  139133. * The base color of the SSAO post-process
  139134. * The final result is "base + ssao" between [0, 1]
  139135. */
  139136. base: number;
  139137. private _scene;
  139138. private _depthTexture;
  139139. private _randomTexture;
  139140. private _originalColorPostProcess;
  139141. private _ssaoPostProcess;
  139142. private _blurHPostProcess;
  139143. private _blurVPostProcess;
  139144. private _ssaoCombinePostProcess;
  139145. private _firstUpdate;
  139146. /**
  139147. * Gets active scene
  139148. */
  139149. get scene(): Scene;
  139150. /**
  139151. * @constructor
  139152. * @param name - The rendering pipeline name
  139153. * @param scene - The scene linked to this pipeline
  139154. * @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 }
  139155. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  139156. */
  139157. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  139158. /**
  139159. * Get the class name
  139160. * @returns "SSAORenderingPipeline"
  139161. */
  139162. getClassName(): string;
  139163. /**
  139164. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  139165. */
  139166. dispose(disableDepthRender?: boolean): void;
  139167. private _createBlurPostProcess;
  139168. /** @hidden */
  139169. _rebuild(): void;
  139170. private _createSSAOPostProcess;
  139171. private _createSSAOCombinePostProcess;
  139172. private _createRandomTexture;
  139173. }
  139174. }
  139175. declare module BABYLON {
  139176. /** @hidden */
  139177. export var screenSpaceReflectionPixelShader: {
  139178. name: string;
  139179. shader: string;
  139180. };
  139181. }
  139182. declare module BABYLON {
  139183. /**
  139184. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  139185. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  139186. */
  139187. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  139188. /**
  139189. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  139190. */
  139191. threshold: number;
  139192. /**
  139193. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  139194. */
  139195. strength: number;
  139196. /**
  139197. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  139198. */
  139199. reflectionSpecularFalloffExponent: number;
  139200. /**
  139201. * 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]
  139202. */
  139203. step: number;
  139204. /**
  139205. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  139206. */
  139207. roughnessFactor: number;
  139208. private _geometryBufferRenderer;
  139209. private _enableSmoothReflections;
  139210. private _reflectionSamples;
  139211. private _smoothSteps;
  139212. /**
  139213. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  139214. * @param name The name of the effect.
  139215. * @param scene The scene containing the objects to calculate reflections.
  139216. * @param options The required width/height ratio to downsize to before computing the render pass.
  139217. * @param camera The camera to apply the render pass to.
  139218. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139219. * @param engine The engine which the post process will be applied. (default: current engine)
  139220. * @param reusable If the post process can be reused on the same frame. (default: false)
  139221. * @param textureType Type of textures used when performing the post process. (default: 0)
  139222. * @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)
  139223. */
  139224. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139225. /**
  139226. * Gets wether or not smoothing reflections is enabled.
  139227. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139228. */
  139229. get enableSmoothReflections(): boolean;
  139230. /**
  139231. * Sets wether or not smoothing reflections is enabled.
  139232. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  139233. */
  139234. set enableSmoothReflections(enabled: boolean);
  139235. /**
  139236. * Gets the number of samples taken while computing reflections. More samples count is high,
  139237. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139238. */
  139239. get reflectionSamples(): number;
  139240. /**
  139241. * Sets the number of samples taken while computing reflections. More samples count is high,
  139242. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  139243. */
  139244. set reflectionSamples(samples: number);
  139245. /**
  139246. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  139247. * more the post-process will require GPU power and can generate a drop in FPS.
  139248. * Default value (5.0) work pretty well in all cases but can be adjusted.
  139249. */
  139250. get smoothSteps(): number;
  139251. set smoothSteps(steps: number);
  139252. private _updateEffectDefines;
  139253. }
  139254. }
  139255. declare module BABYLON {
  139256. /** @hidden */
  139257. export var standardPixelShader: {
  139258. name: string;
  139259. shader: string;
  139260. };
  139261. }
  139262. declare module BABYLON {
  139263. /**
  139264. * Standard rendering pipeline
  139265. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139266. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  139267. */
  139268. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  139269. /**
  139270. * Public members
  139271. */
  139272. /**
  139273. * Post-process which contains the original scene color before the pipeline applies all the effects
  139274. */
  139275. originalPostProcess: Nullable<PostProcess>;
  139276. /**
  139277. * Post-process used to down scale an image x4
  139278. */
  139279. downSampleX4PostProcess: Nullable<PostProcess>;
  139280. /**
  139281. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  139282. */
  139283. brightPassPostProcess: Nullable<PostProcess>;
  139284. /**
  139285. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  139286. */
  139287. blurHPostProcesses: PostProcess[];
  139288. /**
  139289. * Post-process array storing all the vertical blur post-processes used by the pipeline
  139290. */
  139291. blurVPostProcesses: PostProcess[];
  139292. /**
  139293. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  139294. */
  139295. textureAdderPostProcess: Nullable<PostProcess>;
  139296. /**
  139297. * Post-process used to create volumetric lighting effect
  139298. */
  139299. volumetricLightPostProcess: Nullable<PostProcess>;
  139300. /**
  139301. * Post-process used to smooth the previous volumetric light post-process on the X axis
  139302. */
  139303. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  139304. /**
  139305. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  139306. */
  139307. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  139308. /**
  139309. * Post-process used to merge the volumetric light effect and the real scene color
  139310. */
  139311. volumetricLightMergePostProces: Nullable<PostProcess>;
  139312. /**
  139313. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  139314. */
  139315. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  139316. /**
  139317. * Base post-process used to calculate the average luminance of the final image for HDR
  139318. */
  139319. luminancePostProcess: Nullable<PostProcess>;
  139320. /**
  139321. * Post-processes used to create down sample post-processes in order to get
  139322. * the average luminance of the final image for HDR
  139323. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  139324. */
  139325. luminanceDownSamplePostProcesses: PostProcess[];
  139326. /**
  139327. * Post-process used to create a HDR effect (light adaptation)
  139328. */
  139329. hdrPostProcess: Nullable<PostProcess>;
  139330. /**
  139331. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  139332. */
  139333. textureAdderFinalPostProcess: Nullable<PostProcess>;
  139334. /**
  139335. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  139336. */
  139337. lensFlareFinalPostProcess: Nullable<PostProcess>;
  139338. /**
  139339. * Post-process used to merge the final HDR post-process and the real scene color
  139340. */
  139341. hdrFinalPostProcess: Nullable<PostProcess>;
  139342. /**
  139343. * Post-process used to create a lens flare effect
  139344. */
  139345. lensFlarePostProcess: Nullable<PostProcess>;
  139346. /**
  139347. * Post-process that merges the result of the lens flare post-process and the real scene color
  139348. */
  139349. lensFlareComposePostProcess: Nullable<PostProcess>;
  139350. /**
  139351. * Post-process used to create a motion blur effect
  139352. */
  139353. motionBlurPostProcess: Nullable<PostProcess>;
  139354. /**
  139355. * Post-process used to create a depth of field effect
  139356. */
  139357. depthOfFieldPostProcess: Nullable<PostProcess>;
  139358. /**
  139359. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  139360. */
  139361. fxaaPostProcess: Nullable<FxaaPostProcess>;
  139362. /**
  139363. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  139364. */
  139365. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  139366. /**
  139367. * Represents the brightness threshold in order to configure the illuminated surfaces
  139368. */
  139369. brightThreshold: number;
  139370. /**
  139371. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  139372. */
  139373. blurWidth: number;
  139374. /**
  139375. * Sets if the blur for highlighted surfaces must be only horizontal
  139376. */
  139377. horizontalBlur: boolean;
  139378. /**
  139379. * Gets the overall exposure used by the pipeline
  139380. */
  139381. get exposure(): number;
  139382. /**
  139383. * Sets the overall exposure used by the pipeline
  139384. */
  139385. set exposure(value: number);
  139386. /**
  139387. * Texture used typically to simulate "dirty" on camera lens
  139388. */
  139389. lensTexture: Nullable<Texture>;
  139390. /**
  139391. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  139392. */
  139393. volumetricLightCoefficient: number;
  139394. /**
  139395. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  139396. */
  139397. volumetricLightPower: number;
  139398. /**
  139399. * Used the set the blur intensity to smooth the volumetric lights
  139400. */
  139401. volumetricLightBlurScale: number;
  139402. /**
  139403. * Light (spot or directional) used to generate the volumetric lights rays
  139404. * The source light must have a shadow generate so the pipeline can get its
  139405. * depth map
  139406. */
  139407. sourceLight: Nullable<SpotLight | DirectionalLight>;
  139408. /**
  139409. * For eye adaptation, represents the minimum luminance the eye can see
  139410. */
  139411. hdrMinimumLuminance: number;
  139412. /**
  139413. * For eye adaptation, represents the decrease luminance speed
  139414. */
  139415. hdrDecreaseRate: number;
  139416. /**
  139417. * For eye adaptation, represents the increase luminance speed
  139418. */
  139419. hdrIncreaseRate: number;
  139420. /**
  139421. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139422. */
  139423. get hdrAutoExposure(): boolean;
  139424. /**
  139425. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  139426. */
  139427. set hdrAutoExposure(value: boolean);
  139428. /**
  139429. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  139430. */
  139431. lensColorTexture: Nullable<Texture>;
  139432. /**
  139433. * The overall strengh for the lens flare effect
  139434. */
  139435. lensFlareStrength: number;
  139436. /**
  139437. * Dispersion coefficient for lens flare ghosts
  139438. */
  139439. lensFlareGhostDispersal: number;
  139440. /**
  139441. * Main lens flare halo width
  139442. */
  139443. lensFlareHaloWidth: number;
  139444. /**
  139445. * Based on the lens distortion effect, defines how much the lens flare result
  139446. * is distorted
  139447. */
  139448. lensFlareDistortionStrength: number;
  139449. /**
  139450. * Configures the blur intensity used for for lens flare (halo)
  139451. */
  139452. lensFlareBlurWidth: number;
  139453. /**
  139454. * Lens star texture must be used to simulate rays on the flares and is available
  139455. * in the documentation
  139456. */
  139457. lensStarTexture: Nullable<Texture>;
  139458. /**
  139459. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  139460. * flare effect by taking account of the dirt texture
  139461. */
  139462. lensFlareDirtTexture: Nullable<Texture>;
  139463. /**
  139464. * Represents the focal length for the depth of field effect
  139465. */
  139466. depthOfFieldDistance: number;
  139467. /**
  139468. * Represents the blur intensity for the blurred part of the depth of field effect
  139469. */
  139470. depthOfFieldBlurWidth: number;
  139471. /**
  139472. * Gets how much the image is blurred by the movement while using the motion blur post-process
  139473. */
  139474. get motionStrength(): number;
  139475. /**
  139476. * Sets how much the image is blurred by the movement while using the motion blur post-process
  139477. */
  139478. set motionStrength(strength: number);
  139479. /**
  139480. * Gets wether or not the motion blur post-process is object based or screen based.
  139481. */
  139482. get objectBasedMotionBlur(): boolean;
  139483. /**
  139484. * Sets wether or not the motion blur post-process should be object based or screen based
  139485. */
  139486. set objectBasedMotionBlur(value: boolean);
  139487. /**
  139488. * List of animations for the pipeline (IAnimatable implementation)
  139489. */
  139490. animations: Animation[];
  139491. /**
  139492. * Private members
  139493. */
  139494. private _scene;
  139495. private _currentDepthOfFieldSource;
  139496. private _basePostProcess;
  139497. private _fixedExposure;
  139498. private _currentExposure;
  139499. private _hdrAutoExposure;
  139500. private _hdrCurrentLuminance;
  139501. private _motionStrength;
  139502. private _isObjectBasedMotionBlur;
  139503. private _floatTextureType;
  139504. private _camerasToBeAttached;
  139505. private _ratio;
  139506. private _bloomEnabled;
  139507. private _depthOfFieldEnabled;
  139508. private _vlsEnabled;
  139509. private _lensFlareEnabled;
  139510. private _hdrEnabled;
  139511. private _motionBlurEnabled;
  139512. private _fxaaEnabled;
  139513. private _screenSpaceReflectionsEnabled;
  139514. private _motionBlurSamples;
  139515. private _volumetricLightStepsCount;
  139516. private _samples;
  139517. /**
  139518. * @ignore
  139519. * Specifies if the bloom pipeline is enabled
  139520. */
  139521. get BloomEnabled(): boolean;
  139522. set BloomEnabled(enabled: boolean);
  139523. /**
  139524. * @ignore
  139525. * Specifies if the depth of field pipeline is enabed
  139526. */
  139527. get DepthOfFieldEnabled(): boolean;
  139528. set DepthOfFieldEnabled(enabled: boolean);
  139529. /**
  139530. * @ignore
  139531. * Specifies if the lens flare pipeline is enabed
  139532. */
  139533. get LensFlareEnabled(): boolean;
  139534. set LensFlareEnabled(enabled: boolean);
  139535. /**
  139536. * @ignore
  139537. * Specifies if the HDR pipeline is enabled
  139538. */
  139539. get HDREnabled(): boolean;
  139540. set HDREnabled(enabled: boolean);
  139541. /**
  139542. * @ignore
  139543. * Specifies if the volumetric lights scattering effect is enabled
  139544. */
  139545. get VLSEnabled(): boolean;
  139546. set VLSEnabled(enabled: boolean);
  139547. /**
  139548. * @ignore
  139549. * Specifies if the motion blur effect is enabled
  139550. */
  139551. get MotionBlurEnabled(): boolean;
  139552. set MotionBlurEnabled(enabled: boolean);
  139553. /**
  139554. * Specifies if anti-aliasing is enabled
  139555. */
  139556. get fxaaEnabled(): boolean;
  139557. set fxaaEnabled(enabled: boolean);
  139558. /**
  139559. * Specifies if screen space reflections are enabled.
  139560. */
  139561. get screenSpaceReflectionsEnabled(): boolean;
  139562. set screenSpaceReflectionsEnabled(enabled: boolean);
  139563. /**
  139564. * Specifies the number of steps used to calculate the volumetric lights
  139565. * Typically in interval [50, 200]
  139566. */
  139567. get volumetricLightStepsCount(): number;
  139568. set volumetricLightStepsCount(count: number);
  139569. /**
  139570. * Specifies the number of samples used for the motion blur effect
  139571. * Typically in interval [16, 64]
  139572. */
  139573. get motionBlurSamples(): number;
  139574. set motionBlurSamples(samples: number);
  139575. /**
  139576. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  139577. */
  139578. get samples(): number;
  139579. set samples(sampleCount: number);
  139580. /**
  139581. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  139582. * @constructor
  139583. * @param name The rendering pipeline name
  139584. * @param scene The scene linked to this pipeline
  139585. * @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)
  139586. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  139587. * @param cameras The array of cameras that the rendering pipeline will be attached to
  139588. */
  139589. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  139590. private _buildPipeline;
  139591. private _createDownSampleX4PostProcess;
  139592. private _createBrightPassPostProcess;
  139593. private _createBlurPostProcesses;
  139594. private _createTextureAdderPostProcess;
  139595. private _createVolumetricLightPostProcess;
  139596. private _createLuminancePostProcesses;
  139597. private _createHdrPostProcess;
  139598. private _createLensFlarePostProcess;
  139599. private _createDepthOfFieldPostProcess;
  139600. private _createMotionBlurPostProcess;
  139601. private _getDepthTexture;
  139602. private _disposePostProcesses;
  139603. /**
  139604. * Dispose of the pipeline and stop all post processes
  139605. */
  139606. dispose(): void;
  139607. /**
  139608. * Serialize the rendering pipeline (Used when exporting)
  139609. * @returns the serialized object
  139610. */
  139611. serialize(): any;
  139612. /**
  139613. * Parse the serialized pipeline
  139614. * @param source Source pipeline.
  139615. * @param scene The scene to load the pipeline to.
  139616. * @param rootUrl The URL of the serialized pipeline.
  139617. * @returns An instantiated pipeline from the serialized object.
  139618. */
  139619. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  139620. /**
  139621. * Luminance steps
  139622. */
  139623. static LuminanceSteps: number;
  139624. }
  139625. }
  139626. declare module BABYLON {
  139627. /** @hidden */
  139628. export var tonemapPixelShader: {
  139629. name: string;
  139630. shader: string;
  139631. };
  139632. }
  139633. declare module BABYLON {
  139634. /** Defines operator used for tonemapping */
  139635. export enum TonemappingOperator {
  139636. /** Hable */
  139637. Hable = 0,
  139638. /** Reinhard */
  139639. Reinhard = 1,
  139640. /** HejiDawson */
  139641. HejiDawson = 2,
  139642. /** Photographic */
  139643. Photographic = 3
  139644. }
  139645. /**
  139646. * Defines a post process to apply tone mapping
  139647. */
  139648. export class TonemapPostProcess extends PostProcess {
  139649. private _operator;
  139650. /** Defines the required exposure adjustement */
  139651. exposureAdjustment: number;
  139652. /**
  139653. * Creates a new TonemapPostProcess
  139654. * @param name defines the name of the postprocess
  139655. * @param _operator defines the operator to use
  139656. * @param exposureAdjustment defines the required exposure adjustement
  139657. * @param camera defines the camera to use (can be null)
  139658. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  139659. * @param engine defines the hosting engine (can be ignore if camera is set)
  139660. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  139661. */
  139662. constructor(name: string, _operator: TonemappingOperator,
  139663. /** Defines the required exposure adjustement */
  139664. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  139665. }
  139666. }
  139667. declare module BABYLON {
  139668. /** @hidden */
  139669. export var volumetricLightScatteringPixelShader: {
  139670. name: string;
  139671. shader: string;
  139672. };
  139673. }
  139674. declare module BABYLON {
  139675. /** @hidden */
  139676. export var volumetricLightScatteringPassVertexShader: {
  139677. name: string;
  139678. shader: string;
  139679. };
  139680. }
  139681. declare module BABYLON {
  139682. /** @hidden */
  139683. export var volumetricLightScatteringPassPixelShader: {
  139684. name: string;
  139685. shader: string;
  139686. };
  139687. }
  139688. declare module BABYLON {
  139689. /**
  139690. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  139691. */
  139692. export class VolumetricLightScatteringPostProcess extends PostProcess {
  139693. private _volumetricLightScatteringPass;
  139694. private _volumetricLightScatteringRTT;
  139695. private _viewPort;
  139696. private _screenCoordinates;
  139697. private _cachedDefines;
  139698. /**
  139699. * If not undefined, the mesh position is computed from the attached node position
  139700. */
  139701. attachedNode: {
  139702. position: Vector3;
  139703. };
  139704. /**
  139705. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  139706. */
  139707. customMeshPosition: Vector3;
  139708. /**
  139709. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  139710. */
  139711. useCustomMeshPosition: boolean;
  139712. /**
  139713. * If the post-process should inverse the light scattering direction
  139714. */
  139715. invert: boolean;
  139716. /**
  139717. * The internal mesh used by the post-process
  139718. */
  139719. mesh: Mesh;
  139720. /**
  139721. * @hidden
  139722. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  139723. */
  139724. get useDiffuseColor(): boolean;
  139725. set useDiffuseColor(useDiffuseColor: boolean);
  139726. /**
  139727. * Array containing the excluded meshes not rendered in the internal pass
  139728. */
  139729. excludedMeshes: AbstractMesh[];
  139730. /**
  139731. * Controls the overall intensity of the post-process
  139732. */
  139733. exposure: number;
  139734. /**
  139735. * Dissipates each sample's contribution in range [0, 1]
  139736. */
  139737. decay: number;
  139738. /**
  139739. * Controls the overall intensity of each sample
  139740. */
  139741. weight: number;
  139742. /**
  139743. * Controls the density of each sample
  139744. */
  139745. density: number;
  139746. /**
  139747. * @constructor
  139748. * @param name The post-process name
  139749. * @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)
  139750. * @param camera The camera that the post-process will be attached to
  139751. * @param mesh The mesh used to create the light scattering
  139752. * @param samples The post-process quality, default 100
  139753. * @param samplingModeThe post-process filtering mode
  139754. * @param engine The babylon engine
  139755. * @param reusable If the post-process is reusable
  139756. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  139757. */
  139758. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  139759. /**
  139760. * Returns the string "VolumetricLightScatteringPostProcess"
  139761. * @returns "VolumetricLightScatteringPostProcess"
  139762. */
  139763. getClassName(): string;
  139764. private _isReady;
  139765. /**
  139766. * Sets the new light position for light scattering effect
  139767. * @param position The new custom light position
  139768. */
  139769. setCustomMeshPosition(position: Vector3): void;
  139770. /**
  139771. * Returns the light position for light scattering effect
  139772. * @return Vector3 The custom light position
  139773. */
  139774. getCustomMeshPosition(): Vector3;
  139775. /**
  139776. * Disposes the internal assets and detaches the post-process from the camera
  139777. */
  139778. dispose(camera: Camera): void;
  139779. /**
  139780. * Returns the render target texture used by the post-process
  139781. * @return the render target texture used by the post-process
  139782. */
  139783. getPass(): RenderTargetTexture;
  139784. private _meshExcluded;
  139785. private _createPass;
  139786. private _updateMeshScreenCoordinates;
  139787. /**
  139788. * Creates a default mesh for the Volumeric Light Scattering post-process
  139789. * @param name The mesh name
  139790. * @param scene The scene where to create the mesh
  139791. * @return the default mesh
  139792. */
  139793. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  139794. }
  139795. }
  139796. declare module BABYLON {
  139797. interface Scene {
  139798. /** @hidden (Backing field) */
  139799. _boundingBoxRenderer: BoundingBoxRenderer;
  139800. /** @hidden (Backing field) */
  139801. _forceShowBoundingBoxes: boolean;
  139802. /**
  139803. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  139804. */
  139805. forceShowBoundingBoxes: boolean;
  139806. /**
  139807. * Gets the bounding box renderer associated with the scene
  139808. * @returns a BoundingBoxRenderer
  139809. */
  139810. getBoundingBoxRenderer(): BoundingBoxRenderer;
  139811. }
  139812. interface AbstractMesh {
  139813. /** @hidden (Backing field) */
  139814. _showBoundingBox: boolean;
  139815. /**
  139816. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  139817. */
  139818. showBoundingBox: boolean;
  139819. }
  139820. /**
  139821. * Component responsible of rendering the bounding box of the meshes in a scene.
  139822. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  139823. */
  139824. export class BoundingBoxRenderer implements ISceneComponent {
  139825. /**
  139826. * The component name helpfull to identify the component in the list of scene components.
  139827. */
  139828. readonly name: string;
  139829. /**
  139830. * The scene the component belongs to.
  139831. */
  139832. scene: Scene;
  139833. /**
  139834. * Color of the bounding box lines placed in front of an object
  139835. */
  139836. frontColor: Color3;
  139837. /**
  139838. * Color of the bounding box lines placed behind an object
  139839. */
  139840. backColor: Color3;
  139841. /**
  139842. * Defines if the renderer should show the back lines or not
  139843. */
  139844. showBackLines: boolean;
  139845. /**
  139846. * @hidden
  139847. */
  139848. renderList: SmartArray<BoundingBox>;
  139849. private _colorShader;
  139850. private _vertexBuffers;
  139851. private _indexBuffer;
  139852. private _fillIndexBuffer;
  139853. private _fillIndexData;
  139854. /**
  139855. * Instantiates a new bounding box renderer in a scene.
  139856. * @param scene the scene the renderer renders in
  139857. */
  139858. constructor(scene: Scene);
  139859. /**
  139860. * Registers the component in a given scene
  139861. */
  139862. register(): void;
  139863. private _evaluateSubMesh;
  139864. private _activeMesh;
  139865. private _prepareRessources;
  139866. private _createIndexBuffer;
  139867. /**
  139868. * Rebuilds the elements related to this component in case of
  139869. * context lost for instance.
  139870. */
  139871. rebuild(): void;
  139872. /**
  139873. * @hidden
  139874. */
  139875. reset(): void;
  139876. /**
  139877. * Render the bounding boxes of a specific rendering group
  139878. * @param renderingGroupId defines the rendering group to render
  139879. */
  139880. render(renderingGroupId: number): void;
  139881. /**
  139882. * In case of occlusion queries, we can render the occlusion bounding box through this method
  139883. * @param mesh Define the mesh to render the occlusion bounding box for
  139884. */
  139885. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  139886. /**
  139887. * Dispose and release the resources attached to this renderer.
  139888. */
  139889. dispose(): void;
  139890. }
  139891. }
  139892. declare module BABYLON {
  139893. interface Scene {
  139894. /** @hidden (Backing field) */
  139895. _depthRenderer: {
  139896. [id: string]: DepthRenderer;
  139897. };
  139898. /**
  139899. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  139900. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  139901. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  139902. * @returns the created depth renderer
  139903. */
  139904. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  139905. /**
  139906. * Disables a depth renderer for a given camera
  139907. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  139908. */
  139909. disableDepthRenderer(camera?: Nullable<Camera>): void;
  139910. }
  139911. /**
  139912. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  139913. * in several rendering techniques.
  139914. */
  139915. export class DepthRendererSceneComponent implements ISceneComponent {
  139916. /**
  139917. * The component name helpfull to identify the component in the list of scene components.
  139918. */
  139919. readonly name: string;
  139920. /**
  139921. * The scene the component belongs to.
  139922. */
  139923. scene: Scene;
  139924. /**
  139925. * Creates a new instance of the component for the given scene
  139926. * @param scene Defines the scene to register the component in
  139927. */
  139928. constructor(scene: Scene);
  139929. /**
  139930. * Registers the component in a given scene
  139931. */
  139932. register(): void;
  139933. /**
  139934. * Rebuilds the elements related to this component in case of
  139935. * context lost for instance.
  139936. */
  139937. rebuild(): void;
  139938. /**
  139939. * Disposes the component and the associated ressources
  139940. */
  139941. dispose(): void;
  139942. private _gatherRenderTargets;
  139943. private _gatherActiveCameraRenderTargets;
  139944. }
  139945. }
  139946. declare module BABYLON {
  139947. /** @hidden */
  139948. export var outlinePixelShader: {
  139949. name: string;
  139950. shader: string;
  139951. };
  139952. }
  139953. declare module BABYLON {
  139954. /** @hidden */
  139955. export var outlineVertexShader: {
  139956. name: string;
  139957. shader: string;
  139958. };
  139959. }
  139960. declare module BABYLON {
  139961. interface Scene {
  139962. /** @hidden */
  139963. _outlineRenderer: OutlineRenderer;
  139964. /**
  139965. * Gets the outline renderer associated with the scene
  139966. * @returns a OutlineRenderer
  139967. */
  139968. getOutlineRenderer(): OutlineRenderer;
  139969. }
  139970. interface AbstractMesh {
  139971. /** @hidden (Backing field) */
  139972. _renderOutline: boolean;
  139973. /**
  139974. * Gets or sets a boolean indicating if the outline must be rendered as well
  139975. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  139976. */
  139977. renderOutline: boolean;
  139978. /** @hidden (Backing field) */
  139979. _renderOverlay: boolean;
  139980. /**
  139981. * Gets or sets a boolean indicating if the overlay must be rendered as well
  139982. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  139983. */
  139984. renderOverlay: boolean;
  139985. }
  139986. /**
  139987. * This class is responsible to draw bothe outline/overlay of meshes.
  139988. * It should not be used directly but through the available method on mesh.
  139989. */
  139990. export class OutlineRenderer implements ISceneComponent {
  139991. /**
  139992. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  139993. */
  139994. private static _StencilReference;
  139995. /**
  139996. * The name of the component. Each component must have a unique name.
  139997. */
  139998. name: string;
  139999. /**
  140000. * The scene the component belongs to.
  140001. */
  140002. scene: Scene;
  140003. /**
  140004. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  140005. */
  140006. zOffset: number;
  140007. private _engine;
  140008. private _effect;
  140009. private _cachedDefines;
  140010. private _savedDepthWrite;
  140011. /**
  140012. * Instantiates a new outline renderer. (There could be only one per scene).
  140013. * @param scene Defines the scene it belongs to
  140014. */
  140015. constructor(scene: Scene);
  140016. /**
  140017. * Register the component to one instance of a scene.
  140018. */
  140019. register(): void;
  140020. /**
  140021. * Rebuilds the elements related to this component in case of
  140022. * context lost for instance.
  140023. */
  140024. rebuild(): void;
  140025. /**
  140026. * Disposes the component and the associated ressources.
  140027. */
  140028. dispose(): void;
  140029. /**
  140030. * Renders the outline in the canvas.
  140031. * @param subMesh Defines the sumesh to render
  140032. * @param batch Defines the batch of meshes in case of instances
  140033. * @param useOverlay Defines if the rendering is for the overlay or the outline
  140034. */
  140035. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  140036. /**
  140037. * Returns whether or not the outline renderer is ready for a given submesh.
  140038. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  140039. * @param subMesh Defines the submesh to check readyness for
  140040. * @param useInstances Defines wheter wee are trying to render instances or not
  140041. * @returns true if ready otherwise false
  140042. */
  140043. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140044. private _beforeRenderingMesh;
  140045. private _afterRenderingMesh;
  140046. }
  140047. }
  140048. declare module BABYLON {
  140049. /**
  140050. * Defines the basic options interface of a Sprite Frame Source Size.
  140051. */
  140052. export interface ISpriteJSONSpriteSourceSize {
  140053. /**
  140054. * number of the original width of the Frame
  140055. */
  140056. w: number;
  140057. /**
  140058. * number of the original height of the Frame
  140059. */
  140060. h: number;
  140061. }
  140062. /**
  140063. * Defines the basic options interface of a Sprite Frame Data.
  140064. */
  140065. export interface ISpriteJSONSpriteFrameData {
  140066. /**
  140067. * number of the x offset of the Frame
  140068. */
  140069. x: number;
  140070. /**
  140071. * number of the y offset of the Frame
  140072. */
  140073. y: number;
  140074. /**
  140075. * number of the width of the Frame
  140076. */
  140077. w: number;
  140078. /**
  140079. * number of the height of the Frame
  140080. */
  140081. h: number;
  140082. }
  140083. /**
  140084. * Defines the basic options interface of a JSON Sprite.
  140085. */
  140086. export interface ISpriteJSONSprite {
  140087. /**
  140088. * string name of the Frame
  140089. */
  140090. filename: string;
  140091. /**
  140092. * ISpriteJSONSpriteFrame basic object of the frame data
  140093. */
  140094. frame: ISpriteJSONSpriteFrameData;
  140095. /**
  140096. * boolean to flag is the frame was rotated.
  140097. */
  140098. rotated: boolean;
  140099. /**
  140100. * boolean to flag is the frame was trimmed.
  140101. */
  140102. trimmed: boolean;
  140103. /**
  140104. * ISpriteJSONSpriteFrame basic object of the source data
  140105. */
  140106. spriteSourceSize: ISpriteJSONSpriteFrameData;
  140107. /**
  140108. * ISpriteJSONSpriteFrame basic object of the source data
  140109. */
  140110. sourceSize: ISpriteJSONSpriteSourceSize;
  140111. }
  140112. /**
  140113. * Defines the basic options interface of a JSON atlas.
  140114. */
  140115. export interface ISpriteJSONAtlas {
  140116. /**
  140117. * Array of objects that contain the frame data.
  140118. */
  140119. frames: Array<ISpriteJSONSprite>;
  140120. /**
  140121. * object basic object containing the sprite meta data.
  140122. */
  140123. meta?: object;
  140124. }
  140125. }
  140126. declare module BABYLON {
  140127. /** @hidden */
  140128. export var spriteMapPixelShader: {
  140129. name: string;
  140130. shader: string;
  140131. };
  140132. }
  140133. declare module BABYLON {
  140134. /** @hidden */
  140135. export var spriteMapVertexShader: {
  140136. name: string;
  140137. shader: string;
  140138. };
  140139. }
  140140. declare module BABYLON {
  140141. /**
  140142. * Defines the basic options interface of a SpriteMap
  140143. */
  140144. export interface ISpriteMapOptions {
  140145. /**
  140146. * Vector2 of the number of cells in the grid.
  140147. */
  140148. stageSize?: Vector2;
  140149. /**
  140150. * Vector2 of the size of the output plane in World Units.
  140151. */
  140152. outputSize?: Vector2;
  140153. /**
  140154. * Vector3 of the position of the output plane in World Units.
  140155. */
  140156. outputPosition?: Vector3;
  140157. /**
  140158. * Vector3 of the rotation of the output plane.
  140159. */
  140160. outputRotation?: Vector3;
  140161. /**
  140162. * number of layers that the system will reserve in resources.
  140163. */
  140164. layerCount?: number;
  140165. /**
  140166. * number of max animation frames a single cell will reserve in resources.
  140167. */
  140168. maxAnimationFrames?: number;
  140169. /**
  140170. * number cell index of the base tile when the system compiles.
  140171. */
  140172. baseTile?: number;
  140173. /**
  140174. * boolean flip the sprite after its been repositioned by the framing data.
  140175. */
  140176. flipU?: boolean;
  140177. /**
  140178. * Vector3 scalar of the global RGB values of the SpriteMap.
  140179. */
  140180. colorMultiply?: Vector3;
  140181. }
  140182. /**
  140183. * Defines the IDisposable interface in order to be cleanable from resources.
  140184. */
  140185. export interface ISpriteMap extends IDisposable {
  140186. /**
  140187. * String name of the SpriteMap.
  140188. */
  140189. name: string;
  140190. /**
  140191. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  140192. */
  140193. atlasJSON: ISpriteJSONAtlas;
  140194. /**
  140195. * Texture of the SpriteMap.
  140196. */
  140197. spriteSheet: Texture;
  140198. /**
  140199. * The parameters to initialize the SpriteMap with.
  140200. */
  140201. options: ISpriteMapOptions;
  140202. }
  140203. /**
  140204. * Class used to manage a grid restricted sprite deployment on an Output plane.
  140205. */
  140206. export class SpriteMap implements ISpriteMap {
  140207. /** The Name of the spriteMap */
  140208. name: string;
  140209. /** The JSON file with the frame and meta data */
  140210. atlasJSON: ISpriteJSONAtlas;
  140211. /** The systems Sprite Sheet Texture */
  140212. spriteSheet: Texture;
  140213. /** Arguments passed with the Constructor */
  140214. options: ISpriteMapOptions;
  140215. /** Public Sprite Storage array, parsed from atlasJSON */
  140216. sprites: Array<ISpriteJSONSprite>;
  140217. /** Returns the Number of Sprites in the System */
  140218. get spriteCount(): number;
  140219. /** Returns the Position of Output Plane*/
  140220. get position(): Vector3;
  140221. /** Returns the Position of Output Plane*/
  140222. set position(v: Vector3);
  140223. /** Returns the Rotation of Output Plane*/
  140224. get rotation(): Vector3;
  140225. /** Returns the Rotation of Output Plane*/
  140226. set rotation(v: Vector3);
  140227. /** Sets the AnimationMap*/
  140228. get animationMap(): RawTexture;
  140229. /** Sets the AnimationMap*/
  140230. set animationMap(v: RawTexture);
  140231. /** Scene that the SpriteMap was created in */
  140232. private _scene;
  140233. /** Texture Buffer of Float32 that holds tile frame data*/
  140234. private _frameMap;
  140235. /** Texture Buffers of Float32 that holds tileMap data*/
  140236. private _tileMaps;
  140237. /** Texture Buffer of Float32 that holds Animation Data*/
  140238. private _animationMap;
  140239. /** Custom ShaderMaterial Central to the System*/
  140240. private _material;
  140241. /** Custom ShaderMaterial Central to the System*/
  140242. private _output;
  140243. /** Systems Time Ticker*/
  140244. private _time;
  140245. /**
  140246. * Creates a new SpriteMap
  140247. * @param name defines the SpriteMaps Name
  140248. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  140249. * @param spriteSheet is the Texture that the Sprites are on.
  140250. * @param options a basic deployment configuration
  140251. * @param scene The Scene that the map is deployed on
  140252. */
  140253. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  140254. /**
  140255. * Returns tileID location
  140256. * @returns Vector2 the cell position ID
  140257. */
  140258. getTileID(): Vector2;
  140259. /**
  140260. * Gets the UV location of the mouse over the SpriteMap.
  140261. * @returns Vector2 the UV position of the mouse interaction
  140262. */
  140263. getMousePosition(): Vector2;
  140264. /**
  140265. * Creates the "frame" texture Buffer
  140266. * -------------------------------------
  140267. * Structure of frames
  140268. * "filename": "Falling-Water-2.png",
  140269. * "frame": {"x":69,"y":103,"w":24,"h":32},
  140270. * "rotated": true,
  140271. * "trimmed": true,
  140272. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  140273. * "sourceSize": {"w":32,"h":32}
  140274. * @returns RawTexture of the frameMap
  140275. */
  140276. private _createFrameBuffer;
  140277. /**
  140278. * Creates the tileMap texture Buffer
  140279. * @param buffer normally and array of numbers, or a false to generate from scratch
  140280. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  140281. * @returns RawTexture of the tileMap
  140282. */
  140283. private _createTileBuffer;
  140284. /**
  140285. * Modifies the data of the tileMaps
  140286. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  140287. * @param pos is the iVector2 Coordinates of the Tile
  140288. * @param tile The SpriteIndex of the new Tile
  140289. */
  140290. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  140291. /**
  140292. * Creates the animationMap texture Buffer
  140293. * @param buffer normally and array of numbers, or a false to generate from scratch
  140294. * @returns RawTexture of the animationMap
  140295. */
  140296. private _createTileAnimationBuffer;
  140297. /**
  140298. * Modifies the data of the animationMap
  140299. * @param cellID is the Index of the Sprite
  140300. * @param _frame is the target Animation frame
  140301. * @param toCell is the Target Index of the next frame of the animation
  140302. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  140303. * @param speed is a global scalar of the time variable on the map.
  140304. */
  140305. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  140306. /**
  140307. * Exports the .tilemaps file
  140308. */
  140309. saveTileMaps(): void;
  140310. /**
  140311. * Imports the .tilemaps file
  140312. * @param url of the .tilemaps file
  140313. */
  140314. loadTileMaps(url: string): void;
  140315. /**
  140316. * Release associated resources
  140317. */
  140318. dispose(): void;
  140319. }
  140320. }
  140321. declare module BABYLON {
  140322. /**
  140323. * Class used to manage multiple sprites of different sizes on the same spritesheet
  140324. * @see http://doc.babylonjs.com/babylon101/sprites
  140325. */
  140326. export class SpritePackedManager extends SpriteManager {
  140327. /** defines the packed manager's name */
  140328. name: string;
  140329. /**
  140330. * Creates a new sprite manager from a packed sprite sheet
  140331. * @param name defines the manager's name
  140332. * @param imgUrl defines the sprite sheet url
  140333. * @param capacity defines the maximum allowed number of sprites
  140334. * @param scene defines the hosting scene
  140335. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  140336. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  140337. * @param samplingMode defines the smapling mode to use with spritesheet
  140338. * @param fromPacked set to true; do not alter
  140339. */
  140340. constructor(
  140341. /** defines the packed manager's name */
  140342. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  140343. }
  140344. }
  140345. declare module BABYLON {
  140346. /**
  140347. * Defines the list of states available for a task inside a AssetsManager
  140348. */
  140349. export enum AssetTaskState {
  140350. /**
  140351. * Initialization
  140352. */
  140353. INIT = 0,
  140354. /**
  140355. * Running
  140356. */
  140357. RUNNING = 1,
  140358. /**
  140359. * Done
  140360. */
  140361. DONE = 2,
  140362. /**
  140363. * Error
  140364. */
  140365. ERROR = 3
  140366. }
  140367. /**
  140368. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  140369. */
  140370. export abstract class AbstractAssetTask {
  140371. /**
  140372. * Task name
  140373. */ name: string;
  140374. /**
  140375. * Callback called when the task is successful
  140376. */
  140377. onSuccess: (task: any) => void;
  140378. /**
  140379. * Callback called when the task is not successful
  140380. */
  140381. onError: (task: any, message?: string, exception?: any) => void;
  140382. /**
  140383. * Creates a new AssetsManager
  140384. * @param name defines the name of the task
  140385. */
  140386. constructor(
  140387. /**
  140388. * Task name
  140389. */ name: string);
  140390. private _isCompleted;
  140391. private _taskState;
  140392. private _errorObject;
  140393. /**
  140394. * Get if the task is completed
  140395. */
  140396. get isCompleted(): boolean;
  140397. /**
  140398. * Gets the current state of the task
  140399. */
  140400. get taskState(): AssetTaskState;
  140401. /**
  140402. * Gets the current error object (if task is in error)
  140403. */
  140404. get errorObject(): {
  140405. message?: string;
  140406. exception?: any;
  140407. };
  140408. /**
  140409. * Internal only
  140410. * @hidden
  140411. */
  140412. _setErrorObject(message?: string, exception?: any): void;
  140413. /**
  140414. * Execute the current task
  140415. * @param scene defines the scene where you want your assets to be loaded
  140416. * @param onSuccess is a callback called when the task is successfully executed
  140417. * @param onError is a callback called if an error occurs
  140418. */
  140419. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140420. /**
  140421. * Execute the current task
  140422. * @param scene defines the scene where you want your assets to be loaded
  140423. * @param onSuccess is a callback called when the task is successfully executed
  140424. * @param onError is a callback called if an error occurs
  140425. */
  140426. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140427. /**
  140428. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  140429. * This can be used with failed tasks that have the reason for failure fixed.
  140430. */
  140431. reset(): void;
  140432. private onErrorCallback;
  140433. private onDoneCallback;
  140434. }
  140435. /**
  140436. * Define the interface used by progress events raised during assets loading
  140437. */
  140438. export interface IAssetsProgressEvent {
  140439. /**
  140440. * Defines the number of remaining tasks to process
  140441. */
  140442. remainingCount: number;
  140443. /**
  140444. * Defines the total number of tasks
  140445. */
  140446. totalCount: number;
  140447. /**
  140448. * Defines the task that was just processed
  140449. */
  140450. task: AbstractAssetTask;
  140451. }
  140452. /**
  140453. * Class used to share progress information about assets loading
  140454. */
  140455. export class AssetsProgressEvent implements IAssetsProgressEvent {
  140456. /**
  140457. * Defines the number of remaining tasks to process
  140458. */
  140459. remainingCount: number;
  140460. /**
  140461. * Defines the total number of tasks
  140462. */
  140463. totalCount: number;
  140464. /**
  140465. * Defines the task that was just processed
  140466. */
  140467. task: AbstractAssetTask;
  140468. /**
  140469. * Creates a AssetsProgressEvent
  140470. * @param remainingCount defines the number of remaining tasks to process
  140471. * @param totalCount defines the total number of tasks
  140472. * @param task defines the task that was just processed
  140473. */
  140474. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  140475. }
  140476. /**
  140477. * Define a task used by AssetsManager to load meshes
  140478. */
  140479. export class MeshAssetTask extends AbstractAssetTask {
  140480. /**
  140481. * Defines the name of the task
  140482. */
  140483. name: string;
  140484. /**
  140485. * Defines the list of mesh's names you want to load
  140486. */
  140487. meshesNames: any;
  140488. /**
  140489. * Defines the root url to use as a base to load your meshes and associated resources
  140490. */
  140491. rootUrl: string;
  140492. /**
  140493. * Defines the filename of the scene to load from
  140494. */
  140495. sceneFilename: string;
  140496. /**
  140497. * Gets the list of loaded meshes
  140498. */
  140499. loadedMeshes: Array<AbstractMesh>;
  140500. /**
  140501. * Gets the list of loaded particle systems
  140502. */
  140503. loadedParticleSystems: Array<IParticleSystem>;
  140504. /**
  140505. * Gets the list of loaded skeletons
  140506. */
  140507. loadedSkeletons: Array<Skeleton>;
  140508. /**
  140509. * Gets the list of loaded animation groups
  140510. */
  140511. loadedAnimationGroups: Array<AnimationGroup>;
  140512. /**
  140513. * Callback called when the task is successful
  140514. */
  140515. onSuccess: (task: MeshAssetTask) => void;
  140516. /**
  140517. * Callback called when the task is successful
  140518. */
  140519. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  140520. /**
  140521. * Creates a new MeshAssetTask
  140522. * @param name defines the name of the task
  140523. * @param meshesNames defines the list of mesh's names you want to load
  140524. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  140525. * @param sceneFilename defines the filename of the scene to load from
  140526. */
  140527. constructor(
  140528. /**
  140529. * Defines the name of the task
  140530. */
  140531. name: string,
  140532. /**
  140533. * Defines the list of mesh's names you want to load
  140534. */
  140535. meshesNames: any,
  140536. /**
  140537. * Defines the root url to use as a base to load your meshes and associated resources
  140538. */
  140539. rootUrl: string,
  140540. /**
  140541. * Defines the filename of the scene to load from
  140542. */
  140543. sceneFilename: string);
  140544. /**
  140545. * Execute the current task
  140546. * @param scene defines the scene where you want your assets to be loaded
  140547. * @param onSuccess is a callback called when the task is successfully executed
  140548. * @param onError is a callback called if an error occurs
  140549. */
  140550. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140551. }
  140552. /**
  140553. * Define a task used by AssetsManager to load text content
  140554. */
  140555. export class TextFileAssetTask extends AbstractAssetTask {
  140556. /**
  140557. * Defines the name of the task
  140558. */
  140559. name: string;
  140560. /**
  140561. * Defines the location of the file to load
  140562. */
  140563. url: string;
  140564. /**
  140565. * Gets the loaded text string
  140566. */
  140567. text: string;
  140568. /**
  140569. * Callback called when the task is successful
  140570. */
  140571. onSuccess: (task: TextFileAssetTask) => void;
  140572. /**
  140573. * Callback called when the task is successful
  140574. */
  140575. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  140576. /**
  140577. * Creates a new TextFileAssetTask object
  140578. * @param name defines the name of the task
  140579. * @param url defines the location of the file to load
  140580. */
  140581. constructor(
  140582. /**
  140583. * Defines the name of the task
  140584. */
  140585. name: string,
  140586. /**
  140587. * Defines the location of the file to load
  140588. */
  140589. url: string);
  140590. /**
  140591. * Execute the current task
  140592. * @param scene defines the scene where you want your assets to be loaded
  140593. * @param onSuccess is a callback called when the task is successfully executed
  140594. * @param onError is a callback called if an error occurs
  140595. */
  140596. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140597. }
  140598. /**
  140599. * Define a task used by AssetsManager to load binary data
  140600. */
  140601. export class BinaryFileAssetTask extends AbstractAssetTask {
  140602. /**
  140603. * Defines the name of the task
  140604. */
  140605. name: string;
  140606. /**
  140607. * Defines the location of the file to load
  140608. */
  140609. url: string;
  140610. /**
  140611. * Gets the lodaded data (as an array buffer)
  140612. */
  140613. data: ArrayBuffer;
  140614. /**
  140615. * Callback called when the task is successful
  140616. */
  140617. onSuccess: (task: BinaryFileAssetTask) => void;
  140618. /**
  140619. * Callback called when the task is successful
  140620. */
  140621. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  140622. /**
  140623. * Creates a new BinaryFileAssetTask object
  140624. * @param name defines the name of the new task
  140625. * @param url defines the location of the file to load
  140626. */
  140627. constructor(
  140628. /**
  140629. * Defines the name of the task
  140630. */
  140631. name: string,
  140632. /**
  140633. * Defines the location of the file to load
  140634. */
  140635. url: string);
  140636. /**
  140637. * Execute the current task
  140638. * @param scene defines the scene where you want your assets to be loaded
  140639. * @param onSuccess is a callback called when the task is successfully executed
  140640. * @param onError is a callback called if an error occurs
  140641. */
  140642. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140643. }
  140644. /**
  140645. * Define a task used by AssetsManager to load images
  140646. */
  140647. export class ImageAssetTask extends AbstractAssetTask {
  140648. /**
  140649. * Defines the name of the task
  140650. */
  140651. name: string;
  140652. /**
  140653. * Defines the location of the image to load
  140654. */
  140655. url: string;
  140656. /**
  140657. * Gets the loaded images
  140658. */
  140659. image: HTMLImageElement;
  140660. /**
  140661. * Callback called when the task is successful
  140662. */
  140663. onSuccess: (task: ImageAssetTask) => void;
  140664. /**
  140665. * Callback called when the task is successful
  140666. */
  140667. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  140668. /**
  140669. * Creates a new ImageAssetTask
  140670. * @param name defines the name of the task
  140671. * @param url defines the location of the image to load
  140672. */
  140673. constructor(
  140674. /**
  140675. * Defines the name of the task
  140676. */
  140677. name: string,
  140678. /**
  140679. * Defines the location of the image to load
  140680. */
  140681. url: string);
  140682. /**
  140683. * Execute the current task
  140684. * @param scene defines the scene where you want your assets to be loaded
  140685. * @param onSuccess is a callback called when the task is successfully executed
  140686. * @param onError is a callback called if an error occurs
  140687. */
  140688. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140689. }
  140690. /**
  140691. * Defines the interface used by texture loading tasks
  140692. */
  140693. export interface ITextureAssetTask<TEX extends BaseTexture> {
  140694. /**
  140695. * Gets the loaded texture
  140696. */
  140697. texture: TEX;
  140698. }
  140699. /**
  140700. * Define a task used by AssetsManager to load 2D textures
  140701. */
  140702. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  140703. /**
  140704. * Defines the name of the task
  140705. */
  140706. name: string;
  140707. /**
  140708. * Defines the location of the file to load
  140709. */
  140710. url: string;
  140711. /**
  140712. * Defines if mipmap should not be generated (default is false)
  140713. */
  140714. noMipmap?: boolean | undefined;
  140715. /**
  140716. * Defines if texture must be inverted on Y axis (default is false)
  140717. */
  140718. invertY?: boolean | undefined;
  140719. /**
  140720. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140721. */
  140722. samplingMode: number;
  140723. /**
  140724. * Gets the loaded texture
  140725. */
  140726. texture: Texture;
  140727. /**
  140728. * Callback called when the task is successful
  140729. */
  140730. onSuccess: (task: TextureAssetTask) => void;
  140731. /**
  140732. * Callback called when the task is successful
  140733. */
  140734. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  140735. /**
  140736. * Creates a new TextureAssetTask object
  140737. * @param name defines the name of the task
  140738. * @param url defines the location of the file to load
  140739. * @param noMipmap defines if mipmap should not be generated (default is false)
  140740. * @param invertY defines if texture must be inverted on Y axis (default is false)
  140741. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140742. */
  140743. constructor(
  140744. /**
  140745. * Defines the name of the task
  140746. */
  140747. name: string,
  140748. /**
  140749. * Defines the location of the file to load
  140750. */
  140751. url: string,
  140752. /**
  140753. * Defines if mipmap should not be generated (default is false)
  140754. */
  140755. noMipmap?: boolean | undefined,
  140756. /**
  140757. * Defines if texture must be inverted on Y axis (default is false)
  140758. */
  140759. invertY?: boolean | undefined,
  140760. /**
  140761. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  140762. */
  140763. samplingMode?: number);
  140764. /**
  140765. * Execute the current task
  140766. * @param scene defines the scene where you want your assets to be loaded
  140767. * @param onSuccess is a callback called when the task is successfully executed
  140768. * @param onError is a callback called if an error occurs
  140769. */
  140770. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140771. }
  140772. /**
  140773. * Define a task used by AssetsManager to load cube textures
  140774. */
  140775. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  140776. /**
  140777. * Defines the name of the task
  140778. */
  140779. name: string;
  140780. /**
  140781. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140782. */
  140783. url: string;
  140784. /**
  140785. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140786. */
  140787. extensions?: string[] | undefined;
  140788. /**
  140789. * Defines if mipmaps should not be generated (default is false)
  140790. */
  140791. noMipmap?: boolean | undefined;
  140792. /**
  140793. * Defines the explicit list of files (undefined by default)
  140794. */
  140795. files?: string[] | undefined;
  140796. /**
  140797. * Gets the loaded texture
  140798. */
  140799. texture: CubeTexture;
  140800. /**
  140801. * Callback called when the task is successful
  140802. */
  140803. onSuccess: (task: CubeTextureAssetTask) => void;
  140804. /**
  140805. * Callback called when the task is successful
  140806. */
  140807. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  140808. /**
  140809. * Creates a new CubeTextureAssetTask
  140810. * @param name defines the name of the task
  140811. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140812. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140813. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140814. * @param files defines the explicit list of files (undefined by default)
  140815. */
  140816. constructor(
  140817. /**
  140818. * Defines the name of the task
  140819. */
  140820. name: string,
  140821. /**
  140822. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  140823. */
  140824. url: string,
  140825. /**
  140826. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  140827. */
  140828. extensions?: string[] | undefined,
  140829. /**
  140830. * Defines if mipmaps should not be generated (default is false)
  140831. */
  140832. noMipmap?: boolean | undefined,
  140833. /**
  140834. * Defines the explicit list of files (undefined by default)
  140835. */
  140836. files?: string[] | undefined);
  140837. /**
  140838. * Execute the current task
  140839. * @param scene defines the scene where you want your assets to be loaded
  140840. * @param onSuccess is a callback called when the task is successfully executed
  140841. * @param onError is a callback called if an error occurs
  140842. */
  140843. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140844. }
  140845. /**
  140846. * Define a task used by AssetsManager to load HDR cube textures
  140847. */
  140848. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  140849. /**
  140850. * Defines the name of the task
  140851. */
  140852. name: string;
  140853. /**
  140854. * Defines the location of the file to load
  140855. */
  140856. url: string;
  140857. /**
  140858. * Defines the desired size (the more it increases the longer the generation will be)
  140859. */
  140860. size: number;
  140861. /**
  140862. * Defines if mipmaps should not be generated (default is false)
  140863. */
  140864. noMipmap: boolean;
  140865. /**
  140866. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140867. */
  140868. generateHarmonics: boolean;
  140869. /**
  140870. * 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)
  140871. */
  140872. gammaSpace: boolean;
  140873. /**
  140874. * Internal Use Only
  140875. */
  140876. reserved: boolean;
  140877. /**
  140878. * Gets the loaded texture
  140879. */
  140880. texture: HDRCubeTexture;
  140881. /**
  140882. * Callback called when the task is successful
  140883. */
  140884. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  140885. /**
  140886. * Callback called when the task is successful
  140887. */
  140888. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  140889. /**
  140890. * Creates a new HDRCubeTextureAssetTask object
  140891. * @param name defines the name of the task
  140892. * @param url defines the location of the file to load
  140893. * @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.
  140894. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140895. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140896. * @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)
  140897. * @param reserved Internal use only
  140898. */
  140899. constructor(
  140900. /**
  140901. * Defines the name of the task
  140902. */
  140903. name: string,
  140904. /**
  140905. * Defines the location of the file to load
  140906. */
  140907. url: string,
  140908. /**
  140909. * Defines the desired size (the more it increases the longer the generation will be)
  140910. */
  140911. size: number,
  140912. /**
  140913. * Defines if mipmaps should not be generated (default is false)
  140914. */
  140915. noMipmap?: boolean,
  140916. /**
  140917. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  140918. */
  140919. generateHarmonics?: boolean,
  140920. /**
  140921. * 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)
  140922. */
  140923. gammaSpace?: boolean,
  140924. /**
  140925. * Internal Use Only
  140926. */
  140927. reserved?: boolean);
  140928. /**
  140929. * Execute the current task
  140930. * @param scene defines the scene where you want your assets to be loaded
  140931. * @param onSuccess is a callback called when the task is successfully executed
  140932. * @param onError is a callback called if an error occurs
  140933. */
  140934. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  140935. }
  140936. /**
  140937. * Define a task used by AssetsManager to load Equirectangular cube textures
  140938. */
  140939. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  140940. /**
  140941. * Defines the name of the task
  140942. */
  140943. name: string;
  140944. /**
  140945. * Defines the location of the file to load
  140946. */
  140947. url: string;
  140948. /**
  140949. * Defines the desired size (the more it increases the longer the generation will be)
  140950. */
  140951. size: number;
  140952. /**
  140953. * Defines if mipmaps should not be generated (default is false)
  140954. */
  140955. noMipmap: boolean;
  140956. /**
  140957. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  140958. * but the standard material would require them in Gamma space) (default is true)
  140959. */
  140960. gammaSpace: boolean;
  140961. /**
  140962. * Gets the loaded texture
  140963. */
  140964. texture: EquiRectangularCubeTexture;
  140965. /**
  140966. * Callback called when the task is successful
  140967. */
  140968. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  140969. /**
  140970. * Callback called when the task is successful
  140971. */
  140972. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  140973. /**
  140974. * Creates a new EquiRectangularCubeTextureAssetTask object
  140975. * @param name defines the name of the task
  140976. * @param url defines the location of the file to load
  140977. * @param size defines the desired size (the more it increases the longer the generation will be)
  140978. * If the size is omitted this implies you are using a preprocessed cubemap.
  140979. * @param noMipmap defines if mipmaps should not be generated (default is false)
  140980. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  140981. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  140982. * (default is true)
  140983. */
  140984. constructor(
  140985. /**
  140986. * Defines the name of the task
  140987. */
  140988. name: string,
  140989. /**
  140990. * Defines the location of the file to load
  140991. */
  140992. url: string,
  140993. /**
  140994. * Defines the desired size (the more it increases the longer the generation will be)
  140995. */
  140996. size: number,
  140997. /**
  140998. * Defines if mipmaps should not be generated (default is false)
  140999. */
  141000. noMipmap?: boolean,
  141001. /**
  141002. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  141003. * but the standard material would require them in Gamma space) (default is true)
  141004. */
  141005. gammaSpace?: boolean);
  141006. /**
  141007. * Execute the current task
  141008. * @param scene defines the scene where you want your assets to be loaded
  141009. * @param onSuccess is a callback called when the task is successfully executed
  141010. * @param onError is a callback called if an error occurs
  141011. */
  141012. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  141013. }
  141014. /**
  141015. * This class can be used to easily import assets into a scene
  141016. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  141017. */
  141018. export class AssetsManager {
  141019. private _scene;
  141020. private _isLoading;
  141021. protected _tasks: AbstractAssetTask[];
  141022. protected _waitingTasksCount: number;
  141023. protected _totalTasksCount: number;
  141024. /**
  141025. * Callback called when all tasks are processed
  141026. */
  141027. onFinish: (tasks: AbstractAssetTask[]) => void;
  141028. /**
  141029. * Callback called when a task is successful
  141030. */
  141031. onTaskSuccess: (task: AbstractAssetTask) => void;
  141032. /**
  141033. * Callback called when a task had an error
  141034. */
  141035. onTaskError: (task: AbstractAssetTask) => void;
  141036. /**
  141037. * Callback called when a task is done (whatever the result is)
  141038. */
  141039. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  141040. /**
  141041. * Observable called when all tasks are processed
  141042. */
  141043. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  141044. /**
  141045. * Observable called when a task had an error
  141046. */
  141047. onTaskErrorObservable: Observable<AbstractAssetTask>;
  141048. /**
  141049. * Observable called when all tasks were executed
  141050. */
  141051. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  141052. /**
  141053. * Observable called when a task is done (whatever the result is)
  141054. */
  141055. onProgressObservable: Observable<IAssetsProgressEvent>;
  141056. /**
  141057. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  141058. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  141059. */
  141060. useDefaultLoadingScreen: boolean;
  141061. /**
  141062. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  141063. * when all assets have been downloaded.
  141064. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  141065. */
  141066. autoHideLoadingUI: boolean;
  141067. /**
  141068. * Creates a new AssetsManager
  141069. * @param scene defines the scene to work on
  141070. */
  141071. constructor(scene: Scene);
  141072. /**
  141073. * Add a MeshAssetTask to the list of active tasks
  141074. * @param taskName defines the name of the new task
  141075. * @param meshesNames defines the name of meshes to load
  141076. * @param rootUrl defines the root url to use to locate files
  141077. * @param sceneFilename defines the filename of the scene file
  141078. * @returns a new MeshAssetTask object
  141079. */
  141080. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  141081. /**
  141082. * Add a TextFileAssetTask to the list of active tasks
  141083. * @param taskName defines the name of the new task
  141084. * @param url defines the url of the file to load
  141085. * @returns a new TextFileAssetTask object
  141086. */
  141087. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  141088. /**
  141089. * Add a BinaryFileAssetTask to the list of active tasks
  141090. * @param taskName defines the name of the new task
  141091. * @param url defines the url of the file to load
  141092. * @returns a new BinaryFileAssetTask object
  141093. */
  141094. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  141095. /**
  141096. * Add a ImageAssetTask to the list of active tasks
  141097. * @param taskName defines the name of the new task
  141098. * @param url defines the url of the file to load
  141099. * @returns a new ImageAssetTask object
  141100. */
  141101. addImageTask(taskName: string, url: string): ImageAssetTask;
  141102. /**
  141103. * Add a TextureAssetTask to the list of active tasks
  141104. * @param taskName defines the name of the new task
  141105. * @param url defines the url of the file to load
  141106. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141107. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  141108. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  141109. * @returns a new TextureAssetTask object
  141110. */
  141111. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  141112. /**
  141113. * Add a CubeTextureAssetTask to the list of active tasks
  141114. * @param taskName defines the name of the new task
  141115. * @param url defines the url of the file to load
  141116. * @param extensions defines the extension to use to load the cube map (can be null)
  141117. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141118. * @param files defines the list of files to load (can be null)
  141119. * @returns a new CubeTextureAssetTask object
  141120. */
  141121. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  141122. /**
  141123. *
  141124. * Add a HDRCubeTextureAssetTask to the list of active tasks
  141125. * @param taskName defines the name of the new task
  141126. * @param url defines the url of the file to load
  141127. * @param size defines the size you want for the cubemap (can be null)
  141128. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141129. * @param generateHarmonics defines if you want to automatically generate (true by default)
  141130. * @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)
  141131. * @param reserved Internal use only
  141132. * @returns a new HDRCubeTextureAssetTask object
  141133. */
  141134. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  141135. /**
  141136. *
  141137. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  141138. * @param taskName defines the name of the new task
  141139. * @param url defines the url of the file to load
  141140. * @param size defines the size you want for the cubemap (can be null)
  141141. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  141142. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  141143. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  141144. * @returns a new EquiRectangularCubeTextureAssetTask object
  141145. */
  141146. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  141147. /**
  141148. * Remove a task from the assets manager.
  141149. * @param task the task to remove
  141150. */
  141151. removeTask(task: AbstractAssetTask): void;
  141152. private _decreaseWaitingTasksCount;
  141153. private _runTask;
  141154. /**
  141155. * Reset the AssetsManager and remove all tasks
  141156. * @return the current instance of the AssetsManager
  141157. */
  141158. reset(): AssetsManager;
  141159. /**
  141160. * Start the loading process
  141161. * @return the current instance of the AssetsManager
  141162. */
  141163. load(): AssetsManager;
  141164. /**
  141165. * Start the loading process as an async operation
  141166. * @return a promise returning the list of failed tasks
  141167. */
  141168. loadAsync(): Promise<void>;
  141169. }
  141170. }
  141171. declare module BABYLON {
  141172. /**
  141173. * Wrapper class for promise with external resolve and reject.
  141174. */
  141175. export class Deferred<T> {
  141176. /**
  141177. * The promise associated with this deferred object.
  141178. */
  141179. readonly promise: Promise<T>;
  141180. private _resolve;
  141181. private _reject;
  141182. /**
  141183. * The resolve method of the promise associated with this deferred object.
  141184. */
  141185. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  141186. /**
  141187. * The reject method of the promise associated with this deferred object.
  141188. */
  141189. get reject(): (reason?: any) => void;
  141190. /**
  141191. * Constructor for this deferred object.
  141192. */
  141193. constructor();
  141194. }
  141195. }
  141196. declare module BABYLON {
  141197. /**
  141198. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  141199. */
  141200. export class MeshExploder {
  141201. private _centerMesh;
  141202. private _meshes;
  141203. private _meshesOrigins;
  141204. private _toCenterVectors;
  141205. private _scaledDirection;
  141206. private _newPosition;
  141207. private _centerPosition;
  141208. /**
  141209. * Explodes meshes from a center mesh.
  141210. * @param meshes The meshes to explode.
  141211. * @param centerMesh The mesh to be center of explosion.
  141212. */
  141213. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  141214. private _setCenterMesh;
  141215. /**
  141216. * Get class name
  141217. * @returns "MeshExploder"
  141218. */
  141219. getClassName(): string;
  141220. /**
  141221. * "Exploded meshes"
  141222. * @returns Array of meshes with the centerMesh at index 0.
  141223. */
  141224. getMeshes(): Array<Mesh>;
  141225. /**
  141226. * Explodes meshes giving a specific direction
  141227. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  141228. */
  141229. explode(direction?: number): void;
  141230. }
  141231. }
  141232. declare module BABYLON {
  141233. /**
  141234. * Class used to help managing file picking and drag'n'drop
  141235. */
  141236. export class FilesInput {
  141237. /**
  141238. * List of files ready to be loaded
  141239. */
  141240. static get FilesToLoad(): {
  141241. [key: string]: File;
  141242. };
  141243. /**
  141244. * Callback called when a file is processed
  141245. */
  141246. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  141247. private _engine;
  141248. private _currentScene;
  141249. private _sceneLoadedCallback;
  141250. private _progressCallback;
  141251. private _additionalRenderLoopLogicCallback;
  141252. private _textureLoadingCallback;
  141253. private _startingProcessingFilesCallback;
  141254. private _onReloadCallback;
  141255. private _errorCallback;
  141256. private _elementToMonitor;
  141257. private _sceneFileToLoad;
  141258. private _filesToLoad;
  141259. /**
  141260. * Creates a new FilesInput
  141261. * @param engine defines the rendering engine
  141262. * @param scene defines the hosting scene
  141263. * @param sceneLoadedCallback callback called when scene is loaded
  141264. * @param progressCallback callback called to track progress
  141265. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  141266. * @param textureLoadingCallback callback called when a texture is loading
  141267. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  141268. * @param onReloadCallback callback called when a reload is requested
  141269. * @param errorCallback callback call if an error occurs
  141270. */
  141271. 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);
  141272. private _dragEnterHandler;
  141273. private _dragOverHandler;
  141274. private _dropHandler;
  141275. /**
  141276. * Calls this function to listen to drag'n'drop events on a specific DOM element
  141277. * @param elementToMonitor defines the DOM element to track
  141278. */
  141279. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  141280. /**
  141281. * Release all associated resources
  141282. */
  141283. dispose(): void;
  141284. private renderFunction;
  141285. private drag;
  141286. private drop;
  141287. private _traverseFolder;
  141288. private _processFiles;
  141289. /**
  141290. * Load files from a drop event
  141291. * @param event defines the drop event to use as source
  141292. */
  141293. loadFiles(event: any): void;
  141294. private _processReload;
  141295. /**
  141296. * Reload the current scene from the loaded files
  141297. */
  141298. reload(): void;
  141299. }
  141300. }
  141301. declare module BABYLON {
  141302. /**
  141303. * Defines the root class used to create scene optimization to use with SceneOptimizer
  141304. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141305. */
  141306. export class SceneOptimization {
  141307. /**
  141308. * Defines the priority of this optimization (0 by default which means first in the list)
  141309. */
  141310. priority: number;
  141311. /**
  141312. * Gets a string describing the action executed by the current optimization
  141313. * @returns description string
  141314. */
  141315. getDescription(): string;
  141316. /**
  141317. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141318. * @param scene defines the current scene where to apply this optimization
  141319. * @param optimizer defines the current optimizer
  141320. * @returns true if everything that can be done was applied
  141321. */
  141322. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141323. /**
  141324. * Creates the SceneOptimization object
  141325. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141326. * @param desc defines the description associated with the optimization
  141327. */
  141328. constructor(
  141329. /**
  141330. * Defines the priority of this optimization (0 by default which means first in the list)
  141331. */
  141332. priority?: number);
  141333. }
  141334. /**
  141335. * Defines an optimization used to reduce the size of render target textures
  141336. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141337. */
  141338. export class TextureOptimization extends SceneOptimization {
  141339. /**
  141340. * Defines the priority of this optimization (0 by default which means first in the list)
  141341. */
  141342. priority: number;
  141343. /**
  141344. * 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
  141345. */
  141346. maximumSize: number;
  141347. /**
  141348. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141349. */
  141350. step: number;
  141351. /**
  141352. * Gets a string describing the action executed by the current optimization
  141353. * @returns description string
  141354. */
  141355. getDescription(): string;
  141356. /**
  141357. * Creates the TextureOptimization object
  141358. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141359. * @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
  141360. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141361. */
  141362. constructor(
  141363. /**
  141364. * Defines the priority of this optimization (0 by default which means first in the list)
  141365. */
  141366. priority?: number,
  141367. /**
  141368. * 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
  141369. */
  141370. maximumSize?: number,
  141371. /**
  141372. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  141373. */
  141374. step?: number);
  141375. /**
  141376. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141377. * @param scene defines the current scene where to apply this optimization
  141378. * @param optimizer defines the current optimizer
  141379. * @returns true if everything that can be done was applied
  141380. */
  141381. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141382. }
  141383. /**
  141384. * Defines an optimization used to increase or decrease the rendering resolution
  141385. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141386. */
  141387. export class HardwareScalingOptimization extends SceneOptimization {
  141388. /**
  141389. * Defines the priority of this optimization (0 by default which means first in the list)
  141390. */
  141391. priority: number;
  141392. /**
  141393. * Defines the maximum scale to use (2 by default)
  141394. */
  141395. maximumScale: number;
  141396. /**
  141397. * Defines the step to use between two passes (0.5 by default)
  141398. */
  141399. step: number;
  141400. private _currentScale;
  141401. private _directionOffset;
  141402. /**
  141403. * Gets a string describing the action executed by the current optimization
  141404. * @return description string
  141405. */
  141406. getDescription(): string;
  141407. /**
  141408. * Creates the HardwareScalingOptimization object
  141409. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141410. * @param maximumScale defines the maximum scale to use (2 by default)
  141411. * @param step defines the step to use between two passes (0.5 by default)
  141412. */
  141413. constructor(
  141414. /**
  141415. * Defines the priority of this optimization (0 by default which means first in the list)
  141416. */
  141417. priority?: number,
  141418. /**
  141419. * Defines the maximum scale to use (2 by default)
  141420. */
  141421. maximumScale?: number,
  141422. /**
  141423. * Defines the step to use between two passes (0.5 by default)
  141424. */
  141425. step?: number);
  141426. /**
  141427. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141428. * @param scene defines the current scene where to apply this optimization
  141429. * @param optimizer defines the current optimizer
  141430. * @returns true if everything that can be done was applied
  141431. */
  141432. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141433. }
  141434. /**
  141435. * Defines an optimization used to remove shadows
  141436. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141437. */
  141438. export class ShadowsOptimization extends SceneOptimization {
  141439. /**
  141440. * Gets a string describing the action executed by the current optimization
  141441. * @return description string
  141442. */
  141443. getDescription(): string;
  141444. /**
  141445. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141446. * @param scene defines the current scene where to apply this optimization
  141447. * @param optimizer defines the current optimizer
  141448. * @returns true if everything that can be done was applied
  141449. */
  141450. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141451. }
  141452. /**
  141453. * Defines an optimization used to turn post-processes off
  141454. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141455. */
  141456. export class PostProcessesOptimization extends SceneOptimization {
  141457. /**
  141458. * Gets a string describing the action executed by the current optimization
  141459. * @return description string
  141460. */
  141461. getDescription(): string;
  141462. /**
  141463. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141464. * @param scene defines the current scene where to apply this optimization
  141465. * @param optimizer defines the current optimizer
  141466. * @returns true if everything that can be done was applied
  141467. */
  141468. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141469. }
  141470. /**
  141471. * Defines an optimization used to turn lens flares off
  141472. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141473. */
  141474. export class LensFlaresOptimization extends SceneOptimization {
  141475. /**
  141476. * Gets a string describing the action executed by the current optimization
  141477. * @return description string
  141478. */
  141479. getDescription(): string;
  141480. /**
  141481. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141482. * @param scene defines the current scene where to apply this optimization
  141483. * @param optimizer defines the current optimizer
  141484. * @returns true if everything that can be done was applied
  141485. */
  141486. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141487. }
  141488. /**
  141489. * Defines an optimization based on user defined callback.
  141490. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141491. */
  141492. export class CustomOptimization extends SceneOptimization {
  141493. /**
  141494. * Callback called to apply the custom optimization.
  141495. */
  141496. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  141497. /**
  141498. * Callback called to get custom description
  141499. */
  141500. onGetDescription: () => string;
  141501. /**
  141502. * Gets a string describing the action executed by the current optimization
  141503. * @returns description string
  141504. */
  141505. getDescription(): string;
  141506. /**
  141507. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141508. * @param scene defines the current scene where to apply this optimization
  141509. * @param optimizer defines the current optimizer
  141510. * @returns true if everything that can be done was applied
  141511. */
  141512. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141513. }
  141514. /**
  141515. * Defines an optimization used to turn particles off
  141516. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141517. */
  141518. export class ParticlesOptimization extends SceneOptimization {
  141519. /**
  141520. * Gets a string describing the action executed by the current optimization
  141521. * @return description string
  141522. */
  141523. getDescription(): string;
  141524. /**
  141525. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141526. * @param scene defines the current scene where to apply this optimization
  141527. * @param optimizer defines the current optimizer
  141528. * @returns true if everything that can be done was applied
  141529. */
  141530. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141531. }
  141532. /**
  141533. * Defines an optimization used to turn render targets off
  141534. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141535. */
  141536. export class RenderTargetsOptimization extends SceneOptimization {
  141537. /**
  141538. * Gets a string describing the action executed by the current optimization
  141539. * @return description string
  141540. */
  141541. getDescription(): string;
  141542. /**
  141543. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141544. * @param scene defines the current scene where to apply this optimization
  141545. * @param optimizer defines the current optimizer
  141546. * @returns true if everything that can be done was applied
  141547. */
  141548. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  141549. }
  141550. /**
  141551. * Defines an optimization used to merge meshes with compatible materials
  141552. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141553. */
  141554. export class MergeMeshesOptimization extends SceneOptimization {
  141555. private static _UpdateSelectionTree;
  141556. /**
  141557. * Gets or sets a boolean which defines if optimization octree has to be updated
  141558. */
  141559. static get UpdateSelectionTree(): boolean;
  141560. /**
  141561. * Gets or sets a boolean which defines if optimization octree has to be updated
  141562. */
  141563. static set UpdateSelectionTree(value: boolean);
  141564. /**
  141565. * Gets a string describing the action executed by the current optimization
  141566. * @return description string
  141567. */
  141568. getDescription(): string;
  141569. private _canBeMerged;
  141570. /**
  141571. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  141572. * @param scene defines the current scene where to apply this optimization
  141573. * @param optimizer defines the current optimizer
  141574. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  141575. * @returns true if everything that can be done was applied
  141576. */
  141577. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  141578. }
  141579. /**
  141580. * Defines a list of options used by SceneOptimizer
  141581. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141582. */
  141583. export class SceneOptimizerOptions {
  141584. /**
  141585. * Defines the target frame rate to reach (60 by default)
  141586. */
  141587. targetFrameRate: number;
  141588. /**
  141589. * Defines the interval between two checkes (2000ms by default)
  141590. */
  141591. trackerDuration: number;
  141592. /**
  141593. * Gets the list of optimizations to apply
  141594. */
  141595. optimizations: SceneOptimization[];
  141596. /**
  141597. * Creates a new list of options used by SceneOptimizer
  141598. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  141599. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  141600. */
  141601. constructor(
  141602. /**
  141603. * Defines the target frame rate to reach (60 by default)
  141604. */
  141605. targetFrameRate?: number,
  141606. /**
  141607. * Defines the interval between two checkes (2000ms by default)
  141608. */
  141609. trackerDuration?: number);
  141610. /**
  141611. * Add a new optimization
  141612. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  141613. * @returns the current SceneOptimizerOptions
  141614. */
  141615. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  141616. /**
  141617. * Add a new custom optimization
  141618. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  141619. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  141620. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  141621. * @returns the current SceneOptimizerOptions
  141622. */
  141623. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  141624. /**
  141625. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  141626. * @param targetFrameRate defines the target frame rate (60 by default)
  141627. * @returns a SceneOptimizerOptions object
  141628. */
  141629. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141630. /**
  141631. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  141632. * @param targetFrameRate defines the target frame rate (60 by default)
  141633. * @returns a SceneOptimizerOptions object
  141634. */
  141635. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141636. /**
  141637. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  141638. * @param targetFrameRate defines the target frame rate (60 by default)
  141639. * @returns a SceneOptimizerOptions object
  141640. */
  141641. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  141642. }
  141643. /**
  141644. * Class used to run optimizations in order to reach a target frame rate
  141645. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  141646. */
  141647. export class SceneOptimizer implements IDisposable {
  141648. private _isRunning;
  141649. private _options;
  141650. private _scene;
  141651. private _currentPriorityLevel;
  141652. private _targetFrameRate;
  141653. private _trackerDuration;
  141654. private _currentFrameRate;
  141655. private _sceneDisposeObserver;
  141656. private _improvementMode;
  141657. /**
  141658. * Defines an observable called when the optimizer reaches the target frame rate
  141659. */
  141660. onSuccessObservable: Observable<SceneOptimizer>;
  141661. /**
  141662. * Defines an observable called when the optimizer enables an optimization
  141663. */
  141664. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  141665. /**
  141666. * Defines an observable called when the optimizer is not able to reach the target frame rate
  141667. */
  141668. onFailureObservable: Observable<SceneOptimizer>;
  141669. /**
  141670. * Gets a boolean indicating if the optimizer is in improvement mode
  141671. */
  141672. get isInImprovementMode(): boolean;
  141673. /**
  141674. * Gets the current priority level (0 at start)
  141675. */
  141676. get currentPriorityLevel(): number;
  141677. /**
  141678. * Gets the current frame rate checked by the SceneOptimizer
  141679. */
  141680. get currentFrameRate(): number;
  141681. /**
  141682. * Gets or sets the current target frame rate (60 by default)
  141683. */
  141684. get targetFrameRate(): number;
  141685. /**
  141686. * Gets or sets the current target frame rate (60 by default)
  141687. */
  141688. set targetFrameRate(value: number);
  141689. /**
  141690. * Gets or sets the current interval between two checks (every 2000ms by default)
  141691. */
  141692. get trackerDuration(): number;
  141693. /**
  141694. * Gets or sets the current interval between two checks (every 2000ms by default)
  141695. */
  141696. set trackerDuration(value: number);
  141697. /**
  141698. * Gets the list of active optimizations
  141699. */
  141700. get optimizations(): SceneOptimization[];
  141701. /**
  141702. * Creates a new SceneOptimizer
  141703. * @param scene defines the scene to work on
  141704. * @param options defines the options to use with the SceneOptimizer
  141705. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  141706. * @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)
  141707. */
  141708. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  141709. /**
  141710. * Stops the current optimizer
  141711. */
  141712. stop(): void;
  141713. /**
  141714. * Reset the optimizer to initial step (current priority level = 0)
  141715. */
  141716. reset(): void;
  141717. /**
  141718. * Start the optimizer. By default it will try to reach a specific framerate
  141719. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  141720. */
  141721. start(): void;
  141722. private _checkCurrentState;
  141723. /**
  141724. * Release all resources
  141725. */
  141726. dispose(): void;
  141727. /**
  141728. * Helper function to create a SceneOptimizer with one single line of code
  141729. * @param scene defines the scene to work on
  141730. * @param options defines the options to use with the SceneOptimizer
  141731. * @param onSuccess defines a callback to call on success
  141732. * @param onFailure defines a callback to call on failure
  141733. * @returns the new SceneOptimizer object
  141734. */
  141735. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  141736. }
  141737. }
  141738. declare module BABYLON {
  141739. /**
  141740. * Class used to serialize a scene into a string
  141741. */
  141742. export class SceneSerializer {
  141743. /**
  141744. * Clear cache used by a previous serialization
  141745. */
  141746. static ClearCache(): void;
  141747. /**
  141748. * Serialize a scene into a JSON compatible object
  141749. * @param scene defines the scene to serialize
  141750. * @returns a JSON compatible object
  141751. */
  141752. static Serialize(scene: Scene): any;
  141753. /**
  141754. * Serialize a mesh into a JSON compatible object
  141755. * @param toSerialize defines the mesh to serialize
  141756. * @param withParents defines if parents must be serialized as well
  141757. * @param withChildren defines if children must be serialized as well
  141758. * @returns a JSON compatible object
  141759. */
  141760. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  141761. }
  141762. }
  141763. declare module BABYLON {
  141764. /**
  141765. * Class used to host texture specific utilities
  141766. */
  141767. export class TextureTools {
  141768. /**
  141769. * Uses the GPU to create a copy texture rescaled at a given size
  141770. * @param texture Texture to copy from
  141771. * @param width defines the desired width
  141772. * @param height defines the desired height
  141773. * @param useBilinearMode defines if bilinear mode has to be used
  141774. * @return the generated texture
  141775. */
  141776. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  141777. }
  141778. }
  141779. declare module BABYLON {
  141780. /**
  141781. * This represents the different options available for the video capture.
  141782. */
  141783. export interface VideoRecorderOptions {
  141784. /** Defines the mime type of the video. */
  141785. mimeType: string;
  141786. /** Defines the FPS the video should be recorded at. */
  141787. fps: number;
  141788. /** Defines the chunk size for the recording data. */
  141789. recordChunckSize: number;
  141790. /** The audio tracks to attach to the recording. */
  141791. audioTracks?: MediaStreamTrack[];
  141792. }
  141793. /**
  141794. * This can help with recording videos from BabylonJS.
  141795. * This is based on the available WebRTC functionalities of the browser.
  141796. *
  141797. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  141798. */
  141799. export class VideoRecorder {
  141800. private static readonly _defaultOptions;
  141801. /**
  141802. * Returns whether or not the VideoRecorder is available in your browser.
  141803. * @param engine Defines the Babylon Engine.
  141804. * @returns true if supported otherwise false.
  141805. */
  141806. static IsSupported(engine: Engine): boolean;
  141807. private readonly _options;
  141808. private _canvas;
  141809. private _mediaRecorder;
  141810. private _recordedChunks;
  141811. private _fileName;
  141812. private _resolve;
  141813. private _reject;
  141814. /**
  141815. * True when a recording is already in progress.
  141816. */
  141817. get isRecording(): boolean;
  141818. /**
  141819. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  141820. * @param engine Defines the BabylonJS Engine you wish to record.
  141821. * @param options Defines options that can be used to customize the capture.
  141822. */
  141823. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  141824. /**
  141825. * Stops the current recording before the default capture timeout passed in the startRecording function.
  141826. */
  141827. stopRecording(): void;
  141828. /**
  141829. * Starts recording the canvas for a max duration specified in parameters.
  141830. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  141831. * If null no automatic download will start and you can rely on the promise to get the data back.
  141832. * @param maxDuration Defines the maximum recording time in seconds.
  141833. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  141834. * @return A promise callback at the end of the recording with the video data in Blob.
  141835. */
  141836. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  141837. /**
  141838. * Releases internal resources used during the recording.
  141839. */
  141840. dispose(): void;
  141841. private _handleDataAvailable;
  141842. private _handleError;
  141843. private _handleStop;
  141844. }
  141845. }
  141846. declare module BABYLON {
  141847. /**
  141848. * Class containing a set of static utilities functions for screenshots
  141849. */
  141850. export class ScreenshotTools {
  141851. /**
  141852. * Captures a screenshot of the current rendering
  141853. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141854. * @param engine defines the rendering engine
  141855. * @param camera defines the source camera
  141856. * @param size This parameter can be set to a single number or to an object with the
  141857. * following (optional) properties: precision, width, height. If a single number is passed,
  141858. * it will be used for both width and height. If an object is passed, the screenshot size
  141859. * will be derived from the parameters. The precision property is a multiplier allowing
  141860. * rendering at a higher or lower resolution
  141861. * @param successCallback defines the callback receives a single parameter which contains the
  141862. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141863. * src parameter of an <img> to display it
  141864. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141865. * Check your browser for supported MIME types
  141866. */
  141867. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  141868. /**
  141869. * Captures a screenshot of the current rendering
  141870. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141871. * @param engine defines the rendering engine
  141872. * @param camera defines the source camera
  141873. * @param size This parameter can be set to a single number or to an object with the
  141874. * following (optional) properties: precision, width, height. If a single number is passed,
  141875. * it will be used for both width and height. If an object is passed, the screenshot size
  141876. * will be derived from the parameters. The precision property is a multiplier allowing
  141877. * rendering at a higher or lower resolution
  141878. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  141879. * Check your browser for supported MIME types
  141880. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141881. * to the src parameter of an <img> to display it
  141882. */
  141883. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  141884. /**
  141885. * Generates an image screenshot from the specified camera.
  141886. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141887. * @param engine The engine to use for rendering
  141888. * @param camera The camera to use for rendering
  141889. * @param size This parameter can be set to a single number or to an object with the
  141890. * following (optional) properties: precision, width, height. If a single number is passed,
  141891. * it will be used for both width and height. If an object is passed, the screenshot size
  141892. * will be derived from the parameters. The precision property is a multiplier allowing
  141893. * rendering at a higher or lower resolution
  141894. * @param successCallback The callback receives a single parameter which contains the
  141895. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  141896. * src parameter of an <img> to display it
  141897. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141898. * Check your browser for supported MIME types
  141899. * @param samples Texture samples (default: 1)
  141900. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141901. * @param fileName A name for for the downloaded file.
  141902. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  141903. */
  141904. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  141905. /**
  141906. * Generates an image screenshot from the specified camera.
  141907. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  141908. * @param engine The engine to use for rendering
  141909. * @param camera The camera to use for rendering
  141910. * @param size This parameter can be set to a single number or to an object with the
  141911. * following (optional) properties: precision, width, height. If a single number is passed,
  141912. * it will be used for both width and height. If an object is passed, the screenshot size
  141913. * will be derived from the parameters. The precision property is a multiplier allowing
  141914. * rendering at a higher or lower resolution
  141915. * @param mimeType The MIME type of the screenshot image (default: image/png).
  141916. * Check your browser for supported MIME types
  141917. * @param samples Texture samples (default: 1)
  141918. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  141919. * @param fileName A name for for the downloaded file.
  141920. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  141921. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  141922. * to the src parameter of an <img> to display it
  141923. */
  141924. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  141925. /**
  141926. * Gets height and width for screenshot size
  141927. * @private
  141928. */
  141929. private static _getScreenshotSize;
  141930. }
  141931. }
  141932. declare module BABYLON {
  141933. /**
  141934. * Interface for a data buffer
  141935. */
  141936. export interface IDataBuffer {
  141937. /**
  141938. * Reads bytes from the data buffer.
  141939. * @param byteOffset The byte offset to read
  141940. * @param byteLength The byte length to read
  141941. * @returns A promise that resolves when the bytes are read
  141942. */
  141943. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  141944. /**
  141945. * The byte length of the buffer.
  141946. */
  141947. readonly byteLength: number;
  141948. }
  141949. /**
  141950. * Utility class for reading from a data buffer
  141951. */
  141952. export class DataReader {
  141953. /**
  141954. * The data buffer associated with this data reader.
  141955. */
  141956. readonly buffer: IDataBuffer;
  141957. /**
  141958. * The current byte offset from the beginning of the data buffer.
  141959. */
  141960. byteOffset: number;
  141961. private _dataView;
  141962. private _dataByteOffset;
  141963. /**
  141964. * Constructor
  141965. * @param buffer The buffer to read
  141966. */
  141967. constructor(buffer: IDataBuffer);
  141968. /**
  141969. * Loads the given byte length.
  141970. * @param byteLength The byte length to load
  141971. * @returns A promise that resolves when the load is complete
  141972. */
  141973. loadAsync(byteLength: number): Promise<void>;
  141974. /**
  141975. * Read a unsigned 32-bit integer from the currently loaded data range.
  141976. * @returns The 32-bit integer read
  141977. */
  141978. readUint32(): number;
  141979. /**
  141980. * Read a byte array from the currently loaded data range.
  141981. * @param byteLength The byte length to read
  141982. * @returns The byte array read
  141983. */
  141984. readUint8Array(byteLength: number): Uint8Array;
  141985. /**
  141986. * Read a string from the currently loaded data range.
  141987. * @param byteLength The byte length to read
  141988. * @returns The string read
  141989. */
  141990. readString(byteLength: number): string;
  141991. /**
  141992. * Skips the given byte length the currently loaded data range.
  141993. * @param byteLength The byte length to skip
  141994. */
  141995. skipBytes(byteLength: number): void;
  141996. }
  141997. }
  141998. declare module BABYLON {
  141999. /**
  142000. * Options used for hit testing
  142001. */
  142002. export interface IWebXRHitTestOptions {
  142003. /**
  142004. * Only test when user interacted with the scene. Default - hit test every frame
  142005. */
  142006. testOnPointerDownOnly?: boolean;
  142007. /**
  142008. * The node to use to transform the local results to world coordinates
  142009. */
  142010. worldParentNode?: TransformNode;
  142011. }
  142012. /**
  142013. * Interface defining the babylon result of raycasting/hit-test
  142014. */
  142015. export interface IWebXRHitResult {
  142016. /**
  142017. * The native hit test result
  142018. */
  142019. xrHitResult: XRHitResult;
  142020. /**
  142021. * Transformation matrix that can be applied to a node that will put it in the hit point location
  142022. */
  142023. transformationMatrix: Matrix;
  142024. }
  142025. /**
  142026. * The currently-working hit-test module.
  142027. * Hit test (or raycasting) is used to interact with the real world.
  142028. * For further information read here - https://github.com/immersive-web/hit-test
  142029. */
  142030. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  142031. /**
  142032. * options to use when constructing this feature
  142033. */
  142034. readonly options: IWebXRHitTestOptions;
  142035. /**
  142036. * The module's name
  142037. */
  142038. static readonly Name: string;
  142039. /**
  142040. * The (Babylon) version of this module.
  142041. * This is an integer representing the implementation version.
  142042. * This number does not correspond to the webxr specs version
  142043. */
  142044. static readonly Version: number;
  142045. /**
  142046. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  142047. * @param event the (select) event to use to select with
  142048. * @param referenceSpace the reference space to use for this hit test
  142049. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  142050. */
  142051. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  142052. /**
  142053. * execute a hit test with an XR Ray
  142054. *
  142055. * @param xrSession a native xrSession that will execute this hit test
  142056. * @param xrRay the ray (position and direction) to use for raycasting
  142057. * @param referenceSpace native XR reference space to use for the hit-test
  142058. * @param filter filter function that will filter the results
  142059. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  142060. */
  142061. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  142062. /**
  142063. * Triggered when new babylon (transformed) hit test results are available
  142064. */
  142065. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  142066. private _onSelectEnabled;
  142067. /**
  142068. * Creates a new instance of the (legacy version) hit test feature
  142069. * @param _xrSessionManager an instance of WebXRSessionManager
  142070. * @param options options to use when constructing this feature
  142071. */
  142072. constructor(_xrSessionManager: WebXRSessionManager,
  142073. /**
  142074. * options to use when constructing this feature
  142075. */
  142076. options?: IWebXRHitTestOptions);
  142077. /**
  142078. * Populated with the last native XR Hit Results
  142079. */
  142080. lastNativeXRHitResults: XRHitResult[];
  142081. /**
  142082. * attach this feature
  142083. * Will usually be called by the features manager
  142084. *
  142085. * @returns true if successful.
  142086. */
  142087. attach(): boolean;
  142088. /**
  142089. * detach this feature.
  142090. * Will usually be called by the features manager
  142091. *
  142092. * @returns true if successful.
  142093. */
  142094. detach(): boolean;
  142095. private _onHitTestResults;
  142096. private _origin;
  142097. private _direction;
  142098. private _mat;
  142099. protected _onXRFrame(frame: XRFrame): void;
  142100. private _onSelect;
  142101. /**
  142102. * Dispose this feature and all of the resources attached
  142103. */
  142104. dispose(): void;
  142105. }
  142106. }
  142107. declare module BABYLON {
  142108. /**
  142109. * Options used in the plane detector module
  142110. */
  142111. export interface IWebXRPlaneDetectorOptions {
  142112. /**
  142113. * The node to use to transform the local results to world coordinates
  142114. */
  142115. worldParentNode?: TransformNode;
  142116. }
  142117. /**
  142118. * A babylon interface for a webxr plane.
  142119. * A Plane is actually a polygon, built from N points in space
  142120. *
  142121. * Supported in chrome 79, not supported in canary 81 ATM
  142122. */
  142123. export interface IWebXRPlane {
  142124. /**
  142125. * a babylon-assigned ID for this polygon
  142126. */
  142127. id: number;
  142128. /**
  142129. * the native xr-plane object
  142130. */
  142131. xrPlane: XRPlane;
  142132. /**
  142133. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  142134. */
  142135. polygonDefinition: Array<Vector3>;
  142136. /**
  142137. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  142138. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  142139. */
  142140. transformationMatrix: Matrix;
  142141. }
  142142. /**
  142143. * The plane detector is used to detect planes in the real world when in AR
  142144. * For more information see https://github.com/immersive-web/real-world-geometry/
  142145. */
  142146. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  142147. private _options;
  142148. /**
  142149. * The module's name
  142150. */
  142151. static readonly Name: string;
  142152. /**
  142153. * The (Babylon) version of this module.
  142154. * This is an integer representing the implementation version.
  142155. * This number does not correspond to the webxr specs version
  142156. */
  142157. static readonly Version: number;
  142158. /**
  142159. * Observers registered here will be executed when a new plane was added to the session
  142160. */
  142161. onPlaneAddedObservable: Observable<IWebXRPlane>;
  142162. /**
  142163. * Observers registered here will be executed when a plane is no longer detected in the session
  142164. */
  142165. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  142166. /**
  142167. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  142168. * This can execute N times every frame
  142169. */
  142170. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  142171. private _enabled;
  142172. private _detectedPlanes;
  142173. private _lastFrameDetected;
  142174. /**
  142175. * construct a new Plane Detector
  142176. * @param _xrSessionManager an instance of xr Session manager
  142177. * @param _options configuration to use when constructing this feature
  142178. */
  142179. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  142180. private _init;
  142181. protected _onXRFrame(frame: XRFrame): void;
  142182. /**
  142183. * Dispose this feature and all of the resources attached
  142184. */
  142185. dispose(): void;
  142186. private _updatePlaneWithXRPlane;
  142187. /**
  142188. * avoiding using Array.find for global support.
  142189. * @param xrPlane the plane to find in the array
  142190. */
  142191. private findIndexInPlaneArray;
  142192. }
  142193. }
  142194. declare module BABYLON {
  142195. /**
  142196. * Configuration options of the anchor system
  142197. */
  142198. export interface IWebXRAnchorSystemOptions {
  142199. /**
  142200. * a node that will be used to convert local to world coordinates
  142201. */
  142202. worldParentNode?: TransformNode;
  142203. /**
  142204. * should the anchor system use plane detection.
  142205. * If set to true, the plane-detection feature should be set using setPlaneDetector
  142206. */
  142207. usePlaneDetection?: boolean;
  142208. /**
  142209. * Should a new anchor be added every time a select event is triggered
  142210. */
  142211. addAnchorOnSelect?: boolean;
  142212. }
  142213. /**
  142214. * A babylon container for an XR Anchor
  142215. */
  142216. export interface IWebXRAnchor {
  142217. /**
  142218. * A babylon-assigned ID for this anchor
  142219. */
  142220. id: number;
  142221. /**
  142222. * The native anchor object
  142223. */
  142224. xrAnchor: XRAnchor;
  142225. /**
  142226. * Transformation matrix to apply to an object attached to this anchor
  142227. */
  142228. transformationMatrix: Matrix;
  142229. }
  142230. /**
  142231. * An implementation of the anchor system of WebXR.
  142232. * Note that the current documented implementation is not available in any browser. Future implementations
  142233. * will use the frame to create an anchor and not the session or a detected plane
  142234. * For further information see https://github.com/immersive-web/anchors/
  142235. */
  142236. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  142237. private _options;
  142238. /**
  142239. * The module's name
  142240. */
  142241. static readonly Name: string;
  142242. /**
  142243. * The (Babylon) version of this module.
  142244. * This is an integer representing the implementation version.
  142245. * This number does not correspond to the webxr specs version
  142246. */
  142247. static readonly Version: number;
  142248. /**
  142249. * Observers registered here will be executed when a new anchor was added to the session
  142250. */
  142251. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  142252. /**
  142253. * Observers registered here will be executed when an existing anchor updates
  142254. * This can execute N times every frame
  142255. */
  142256. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  142257. /**
  142258. * Observers registered here will be executed when an anchor was removed from the session
  142259. */
  142260. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  142261. private _planeDetector;
  142262. private _hitTestModule;
  142263. private _enabled;
  142264. private _trackedAnchors;
  142265. private _lastFrameDetected;
  142266. /**
  142267. * constructs a new anchor system
  142268. * @param _xrSessionManager an instance of WebXRSessionManager
  142269. * @param _options configuration object for this feature
  142270. */
  142271. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  142272. /**
  142273. * set the plane detector to use in order to create anchors from frames
  142274. * @param planeDetector the plane-detector module to use
  142275. * @param enable enable plane-anchors. default is true
  142276. */
  142277. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  142278. /**
  142279. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  142280. * @param hitTestModule the hit-test module to use.
  142281. */
  142282. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  142283. /**
  142284. * attach this feature
  142285. * Will usually be called by the features manager
  142286. *
  142287. * @returns true if successful.
  142288. */
  142289. attach(): boolean;
  142290. /**
  142291. * detach this feature.
  142292. * Will usually be called by the features manager
  142293. *
  142294. * @returns true if successful.
  142295. */
  142296. detach(): boolean;
  142297. /**
  142298. * Dispose this feature and all of the resources attached
  142299. */
  142300. dispose(): void;
  142301. protected _onXRFrame(frame: XRFrame): void;
  142302. private _onSelect;
  142303. /**
  142304. * Add anchor at a specific XR point.
  142305. *
  142306. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  142307. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  142308. * @returns a promise the fulfills when the anchor was created
  142309. */
  142310. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  142311. private _updateAnchorWithXRFrame;
  142312. /**
  142313. * avoiding using Array.find for global support.
  142314. * @param xrAnchor the plane to find in the array
  142315. */
  142316. private _findIndexInAnchorArray;
  142317. }
  142318. }
  142319. declare module BABYLON {
  142320. /**
  142321. * Options interface for the background remover plugin
  142322. */
  142323. export interface IWebXRBackgroundRemoverOptions {
  142324. /**
  142325. * don't disable the environment helper
  142326. */
  142327. ignoreEnvironmentHelper?: boolean;
  142328. /**
  142329. * flags to configure the removal of the environment helper.
  142330. * If not set, the entire background will be removed. If set, flags should be set as well.
  142331. */
  142332. environmentHelperRemovalFlags?: {
  142333. /**
  142334. * Should the skybox be removed (default false)
  142335. */
  142336. skyBox?: boolean;
  142337. /**
  142338. * Should the ground be removed (default false)
  142339. */
  142340. ground?: boolean;
  142341. };
  142342. /**
  142343. * Further background meshes to disable when entering AR
  142344. */
  142345. backgroundMeshes?: AbstractMesh[];
  142346. }
  142347. /**
  142348. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  142349. */
  142350. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  142351. /**
  142352. * read-only options to be used in this module
  142353. */
  142354. readonly options: IWebXRBackgroundRemoverOptions;
  142355. /**
  142356. * The module's name
  142357. */
  142358. static readonly Name: string;
  142359. /**
  142360. * The (Babylon) version of this module.
  142361. * This is an integer representing the implementation version.
  142362. * This number does not correspond to the webxr specs version
  142363. */
  142364. static readonly Version: number;
  142365. /**
  142366. * registered observers will be triggered when the background state changes
  142367. */
  142368. onBackgroundStateChangedObservable: Observable<boolean>;
  142369. /**
  142370. * constructs a new background remover module
  142371. * @param _xrSessionManager the session manager for this module
  142372. * @param options read-only options to be used in this module
  142373. */
  142374. constructor(_xrSessionManager: WebXRSessionManager,
  142375. /**
  142376. * read-only options to be used in this module
  142377. */
  142378. options?: IWebXRBackgroundRemoverOptions);
  142379. /**
  142380. * attach this feature
  142381. * Will usually be called by the features manager
  142382. *
  142383. * @returns true if successful.
  142384. */
  142385. attach(): boolean;
  142386. /**
  142387. * detach this feature.
  142388. * Will usually be called by the features manager
  142389. *
  142390. * @returns true if successful.
  142391. */
  142392. detach(): boolean;
  142393. private _setBackgroundState;
  142394. /**
  142395. * Dispose this feature and all of the resources attached
  142396. */
  142397. dispose(): void;
  142398. protected _onXRFrame(_xrFrame: XRFrame): void;
  142399. }
  142400. }
  142401. declare module BABYLON {
  142402. /**
  142403. * Options for the controller physics feature
  142404. */
  142405. export class IWebXRControllerPhysicsOptions {
  142406. /**
  142407. * the xr input to use with this pointer selection
  142408. */
  142409. xrInput: WebXRInput;
  142410. /**
  142411. * The physics properties of the future impostors
  142412. */
  142413. physicsProperties?: {
  142414. /**
  142415. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  142416. * Note that this requires a physics engine that supports mesh impostors!
  142417. */
  142418. useControllerMesh?: boolean;
  142419. /**
  142420. * The type of impostor to create. Default is sphere
  142421. */
  142422. impostorType?: number;
  142423. /**
  142424. * the size of the impostor. Defaults to 10cm
  142425. */
  142426. impostorSize?: number | {
  142427. width: number;
  142428. height: number;
  142429. depth: number;
  142430. };
  142431. /**
  142432. * Friction definitions
  142433. */
  142434. friction?: number;
  142435. /**
  142436. * Restitution
  142437. */
  142438. restitution?: number;
  142439. };
  142440. /**
  142441. * Should the headset get its own impostor
  142442. */
  142443. enableHeadsetImpostor?: boolean;
  142444. /**
  142445. * Optional parameters for the headset impostor
  142446. */
  142447. headsetImpostorParams?: {
  142448. /**
  142449. * The type of impostor to create. Default is sphere
  142450. */
  142451. impostorType: number;
  142452. /**
  142453. * the size of the impostor. Defaults to 10cm
  142454. */
  142455. impostorSize?: number | {
  142456. width: number;
  142457. height: number;
  142458. depth: number;
  142459. };
  142460. /**
  142461. * Friction definitions
  142462. */
  142463. friction?: number;
  142464. /**
  142465. * Restitution
  142466. */
  142467. restitution?: number;
  142468. };
  142469. }
  142470. /**
  142471. * Add physics impostor to your webxr controllers,
  142472. * including naive calculation of their linear and angular velocity
  142473. */
  142474. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  142475. private readonly _options;
  142476. /**
  142477. * The module's name
  142478. */
  142479. static readonly Name: string;
  142480. /**
  142481. * The (Babylon) version of this module.
  142482. * This is an integer representing the implementation version.
  142483. * This number does not correspond to the webxr specs version
  142484. */
  142485. static readonly Version: number;
  142486. private _lastTimestamp;
  142487. private _delta;
  142488. private _controllers;
  142489. private _headsetImpostor?;
  142490. private _headsetMesh?;
  142491. private _tmpVector;
  142492. private _tmpQuaternion;
  142493. /**
  142494. * Construct a new Controller Physics Feature
  142495. * @param _xrSessionManager the corresponding xr session manager
  142496. * @param _options options to create this feature with
  142497. */
  142498. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  142499. /**
  142500. * Update the physics properties provided in the constructor
  142501. * @param newProperties the new properties object
  142502. */
  142503. setPhysicsProperties(newProperties: {
  142504. impostorType?: number;
  142505. impostorSize?: number | {
  142506. width: number;
  142507. height: number;
  142508. depth: number;
  142509. };
  142510. friction?: number;
  142511. restitution?: number;
  142512. }): void;
  142513. /**
  142514. * Get the physics impostor of a specific controller.
  142515. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  142516. * @param controller the controller or the controller id of which to get the impostor
  142517. * @returns the impostor or null
  142518. */
  142519. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  142520. /**
  142521. * Get the headset impostor, if enabled
  142522. * @returns the impostor
  142523. */
  142524. getHeadsetImpostor(): PhysicsImpostor | undefined;
  142525. /**
  142526. * attach this feature
  142527. * Will usually be called by the features manager
  142528. *
  142529. * @returns true if successful.
  142530. */
  142531. attach(): boolean;
  142532. /**
  142533. * detach this feature.
  142534. * Will usually be called by the features manager
  142535. *
  142536. * @returns true if successful.
  142537. */
  142538. detach(): boolean;
  142539. /**
  142540. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  142541. * @param xrController the controller to add
  142542. */
  142543. addController(xrController: WebXRInputSource): void;
  142544. private _debugMode;
  142545. /**
  142546. * @hidden
  142547. * enable debugging - will show console outputs and the impostor mesh
  142548. */
  142549. _enablePhysicsDebug(): void;
  142550. private _attachController;
  142551. private _detachController;
  142552. protected _onXRFrame(_xrFrame: any): void;
  142553. }
  142554. }
  142555. declare module BABYLON {
  142556. /**
  142557. * The motion controller class for all microsoft mixed reality controllers
  142558. */
  142559. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  142560. /**
  142561. * The base url used to load the left and right controller models
  142562. */
  142563. static MODEL_BASE_URL: string;
  142564. /**
  142565. * The name of the left controller model file
  142566. */
  142567. static MODEL_LEFT_FILENAME: string;
  142568. /**
  142569. * The name of the right controller model file
  142570. */
  142571. static MODEL_RIGHT_FILENAME: string;
  142572. profileId: string;
  142573. protected readonly _mapping: {
  142574. defaultButton: {
  142575. "valueNodeName": string;
  142576. "unpressedNodeName": string;
  142577. "pressedNodeName": string;
  142578. };
  142579. defaultAxis: {
  142580. "valueNodeName": string;
  142581. "minNodeName": string;
  142582. "maxNodeName": string;
  142583. };
  142584. buttons: {
  142585. "xr-standard-trigger": {
  142586. "rootNodeName": string;
  142587. "componentProperty": string;
  142588. "states": string[];
  142589. };
  142590. "xr-standard-squeeze": {
  142591. "rootNodeName": string;
  142592. "componentProperty": string;
  142593. "states": string[];
  142594. };
  142595. "xr-standard-touchpad": {
  142596. "rootNodeName": string;
  142597. "labelAnchorNodeName": string;
  142598. "touchPointNodeName": string;
  142599. };
  142600. "xr-standard-thumbstick": {
  142601. "rootNodeName": string;
  142602. "componentProperty": string;
  142603. "states": string[];
  142604. };
  142605. };
  142606. axes: {
  142607. "xr-standard-touchpad": {
  142608. "x-axis": {
  142609. "rootNodeName": string;
  142610. };
  142611. "y-axis": {
  142612. "rootNodeName": string;
  142613. };
  142614. };
  142615. "xr-standard-thumbstick": {
  142616. "x-axis": {
  142617. "rootNodeName": string;
  142618. };
  142619. "y-axis": {
  142620. "rootNodeName": string;
  142621. };
  142622. };
  142623. };
  142624. };
  142625. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142626. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142627. protected _getFilenameAndPath(): {
  142628. filename: string;
  142629. path: string;
  142630. };
  142631. protected _updateModel(): void;
  142632. protected _getModelLoadingConstraints(): boolean;
  142633. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142634. }
  142635. }
  142636. declare module BABYLON {
  142637. /**
  142638. * The motion controller class for oculus touch (quest, rift).
  142639. * This class supports legacy mapping as well the standard xr mapping
  142640. */
  142641. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  142642. private _forceLegacyControllers;
  142643. /**
  142644. * The base url used to load the left and right controller models
  142645. */
  142646. static MODEL_BASE_URL: string;
  142647. /**
  142648. * The name of the left controller model file
  142649. */
  142650. static MODEL_LEFT_FILENAME: string;
  142651. /**
  142652. * The name of the right controller model file
  142653. */
  142654. static MODEL_RIGHT_FILENAME: string;
  142655. /**
  142656. * Base Url for the Quest controller model.
  142657. */
  142658. static QUEST_MODEL_BASE_URL: string;
  142659. profileId: string;
  142660. private _modelRootNode;
  142661. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  142662. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142663. protected _getFilenameAndPath(): {
  142664. filename: string;
  142665. path: string;
  142666. };
  142667. /**
  142668. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  142669. * between the touch and touch 2.
  142670. */
  142671. private _isQuest;
  142672. protected _updateModel(): void;
  142673. protected _getModelLoadingConstraints(): boolean;
  142674. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142675. }
  142676. }
  142677. declare module BABYLON {
  142678. /**
  142679. * The motion controller class for the standard HTC-Vive controllers
  142680. */
  142681. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  142682. /**
  142683. * The base url used to load the left and right controller models
  142684. */
  142685. static MODEL_BASE_URL: string;
  142686. /**
  142687. * File name for the controller model.
  142688. */
  142689. static MODEL_FILENAME: string;
  142690. profileId: string;
  142691. private _modelRootNode;
  142692. /**
  142693. * Create a new Vive motion controller object
  142694. * @param scene the scene to use to create this controller
  142695. * @param gamepadObject the corresponding gamepad object
  142696. * @param handness the handness of the controller
  142697. */
  142698. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  142699. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  142700. protected _getFilenameAndPath(): {
  142701. filename: string;
  142702. path: string;
  142703. };
  142704. protected _updateModel(): void;
  142705. protected _getModelLoadingConstraints(): boolean;
  142706. protected _setRootMesh(meshes: AbstractMesh[]): void;
  142707. }
  142708. }
  142709. declare module BABYLON {
  142710. /**
  142711. * A cursor which tracks a point on a path
  142712. */
  142713. export class PathCursor {
  142714. private path;
  142715. /**
  142716. * Stores path cursor callbacks for when an onchange event is triggered
  142717. */
  142718. private _onchange;
  142719. /**
  142720. * The value of the path cursor
  142721. */
  142722. value: number;
  142723. /**
  142724. * The animation array of the path cursor
  142725. */
  142726. animations: Animation[];
  142727. /**
  142728. * Initializes the path cursor
  142729. * @param path The path to track
  142730. */
  142731. constructor(path: Path2);
  142732. /**
  142733. * Gets the cursor point on the path
  142734. * @returns A point on the path cursor at the cursor location
  142735. */
  142736. getPoint(): Vector3;
  142737. /**
  142738. * Moves the cursor ahead by the step amount
  142739. * @param step The amount to move the cursor forward
  142740. * @returns This path cursor
  142741. */
  142742. moveAhead(step?: number): PathCursor;
  142743. /**
  142744. * Moves the cursor behind by the step amount
  142745. * @param step The amount to move the cursor back
  142746. * @returns This path cursor
  142747. */
  142748. moveBack(step?: number): PathCursor;
  142749. /**
  142750. * Moves the cursor by the step amount
  142751. * If the step amount is greater than one, an exception is thrown
  142752. * @param step The amount to move the cursor
  142753. * @returns This path cursor
  142754. */
  142755. move(step: number): PathCursor;
  142756. /**
  142757. * Ensures that the value is limited between zero and one
  142758. * @returns This path cursor
  142759. */
  142760. private ensureLimits;
  142761. /**
  142762. * Runs onchange callbacks on change (used by the animation engine)
  142763. * @returns This path cursor
  142764. */
  142765. private raiseOnChange;
  142766. /**
  142767. * Executes a function on change
  142768. * @param f A path cursor onchange callback
  142769. * @returns This path cursor
  142770. */
  142771. onchange(f: (cursor: PathCursor) => void): PathCursor;
  142772. }
  142773. }
  142774. declare module BABYLON {
  142775. /** @hidden */
  142776. export var blurPixelShader: {
  142777. name: string;
  142778. shader: string;
  142779. };
  142780. }
  142781. declare module BABYLON {
  142782. /** @hidden */
  142783. export var pointCloudVertexDeclaration: {
  142784. name: string;
  142785. shader: string;
  142786. };
  142787. }
  142788. // Mixins
  142789. interface Window {
  142790. mozIndexedDB: IDBFactory;
  142791. webkitIndexedDB: IDBFactory;
  142792. msIndexedDB: IDBFactory;
  142793. webkitURL: typeof URL;
  142794. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  142795. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  142796. WebGLRenderingContext: WebGLRenderingContext;
  142797. MSGesture: MSGesture;
  142798. CANNON: any;
  142799. AudioContext: AudioContext;
  142800. webkitAudioContext: AudioContext;
  142801. PointerEvent: any;
  142802. Math: Math;
  142803. Uint8Array: Uint8ArrayConstructor;
  142804. Float32Array: Float32ArrayConstructor;
  142805. mozURL: typeof URL;
  142806. msURL: typeof URL;
  142807. VRFrameData: any; // WebVR, from specs 1.1
  142808. DracoDecoderModule: any;
  142809. setImmediate(handler: (...args: any[]) => void): number;
  142810. }
  142811. interface HTMLCanvasElement {
  142812. requestPointerLock(): void;
  142813. msRequestPointerLock?(): void;
  142814. mozRequestPointerLock?(): void;
  142815. webkitRequestPointerLock?(): void;
  142816. /** Track wether a record is in progress */
  142817. isRecording: boolean;
  142818. /** Capture Stream method defined by some browsers */
  142819. captureStream(fps?: number): MediaStream;
  142820. }
  142821. interface CanvasRenderingContext2D {
  142822. msImageSmoothingEnabled: boolean;
  142823. }
  142824. interface MouseEvent {
  142825. mozMovementX: number;
  142826. mozMovementY: number;
  142827. webkitMovementX: number;
  142828. webkitMovementY: number;
  142829. msMovementX: number;
  142830. msMovementY: number;
  142831. }
  142832. interface Navigator {
  142833. mozGetVRDevices: (any: any) => any;
  142834. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142835. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142836. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  142837. webkitGetGamepads(): Gamepad[];
  142838. msGetGamepads(): Gamepad[];
  142839. webkitGamepads(): Gamepad[];
  142840. }
  142841. interface HTMLVideoElement {
  142842. mozSrcObject: any;
  142843. }
  142844. interface Math {
  142845. fround(x: number): number;
  142846. imul(a: number, b: number): number;
  142847. }
  142848. interface WebGLRenderingContext {
  142849. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  142850. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  142851. vertexAttribDivisor(index: number, divisor: number): void;
  142852. createVertexArray(): any;
  142853. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  142854. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  142855. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  142856. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  142857. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  142858. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  142859. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  142860. // Queries
  142861. createQuery(): WebGLQuery;
  142862. deleteQuery(query: WebGLQuery): void;
  142863. beginQuery(target: number, query: WebGLQuery): void;
  142864. endQuery(target: number): void;
  142865. getQueryParameter(query: WebGLQuery, pname: number): any;
  142866. getQuery(target: number, pname: number): any;
  142867. MAX_SAMPLES: number;
  142868. RGBA8: number;
  142869. READ_FRAMEBUFFER: number;
  142870. DRAW_FRAMEBUFFER: number;
  142871. UNIFORM_BUFFER: number;
  142872. HALF_FLOAT_OES: number;
  142873. RGBA16F: number;
  142874. RGBA32F: number;
  142875. R32F: number;
  142876. RG32F: number;
  142877. RGB32F: number;
  142878. R16F: number;
  142879. RG16F: number;
  142880. RGB16F: number;
  142881. RED: number;
  142882. RG: number;
  142883. R8: number;
  142884. RG8: number;
  142885. UNSIGNED_INT_24_8: number;
  142886. DEPTH24_STENCIL8: number;
  142887. MIN: number;
  142888. MAX: number;
  142889. /* Multiple Render Targets */
  142890. drawBuffers(buffers: number[]): void;
  142891. readBuffer(src: number): void;
  142892. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  142893. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  142894. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  142895. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  142896. // Occlusion Query
  142897. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  142898. ANY_SAMPLES_PASSED: number;
  142899. QUERY_RESULT_AVAILABLE: number;
  142900. QUERY_RESULT: number;
  142901. }
  142902. interface WebGLProgram {
  142903. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  142904. }
  142905. interface EXT_disjoint_timer_query {
  142906. QUERY_COUNTER_BITS_EXT: number;
  142907. TIME_ELAPSED_EXT: number;
  142908. TIMESTAMP_EXT: number;
  142909. GPU_DISJOINT_EXT: number;
  142910. QUERY_RESULT_EXT: number;
  142911. QUERY_RESULT_AVAILABLE_EXT: number;
  142912. queryCounterEXT(query: WebGLQuery, target: number): void;
  142913. createQueryEXT(): WebGLQuery;
  142914. beginQueryEXT(target: number, query: WebGLQuery): void;
  142915. endQueryEXT(target: number): void;
  142916. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  142917. deleteQueryEXT(query: WebGLQuery): void;
  142918. }
  142919. interface WebGLUniformLocation {
  142920. _currentState: any;
  142921. }
  142922. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  142923. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  142924. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  142925. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  142926. interface WebGLRenderingContext {
  142927. readonly RASTERIZER_DISCARD: number;
  142928. readonly DEPTH_COMPONENT24: number;
  142929. readonly TEXTURE_3D: number;
  142930. readonly TEXTURE_2D_ARRAY: number;
  142931. readonly TEXTURE_COMPARE_FUNC: number;
  142932. readonly TEXTURE_COMPARE_MODE: number;
  142933. readonly COMPARE_REF_TO_TEXTURE: number;
  142934. readonly TEXTURE_WRAP_R: number;
  142935. readonly HALF_FLOAT: number;
  142936. readonly RGB8: number;
  142937. readonly RED_INTEGER: number;
  142938. readonly RG_INTEGER: number;
  142939. readonly RGB_INTEGER: number;
  142940. readonly RGBA_INTEGER: number;
  142941. readonly R8_SNORM: number;
  142942. readonly RG8_SNORM: number;
  142943. readonly RGB8_SNORM: number;
  142944. readonly RGBA8_SNORM: number;
  142945. readonly R8I: number;
  142946. readonly RG8I: number;
  142947. readonly RGB8I: number;
  142948. readonly RGBA8I: number;
  142949. readonly R8UI: number;
  142950. readonly RG8UI: number;
  142951. readonly RGB8UI: number;
  142952. readonly RGBA8UI: number;
  142953. readonly R16I: number;
  142954. readonly RG16I: number;
  142955. readonly RGB16I: number;
  142956. readonly RGBA16I: number;
  142957. readonly R16UI: number;
  142958. readonly RG16UI: number;
  142959. readonly RGB16UI: number;
  142960. readonly RGBA16UI: number;
  142961. readonly R32I: number;
  142962. readonly RG32I: number;
  142963. readonly RGB32I: number;
  142964. readonly RGBA32I: number;
  142965. readonly R32UI: number;
  142966. readonly RG32UI: number;
  142967. readonly RGB32UI: number;
  142968. readonly RGBA32UI: number;
  142969. readonly RGB10_A2UI: number;
  142970. readonly R11F_G11F_B10F: number;
  142971. readonly RGB9_E5: number;
  142972. readonly RGB10_A2: number;
  142973. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  142974. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  142975. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  142976. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  142977. readonly DEPTH_COMPONENT32F: number;
  142978. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  142979. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  142980. 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;
  142981. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  142982. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  142983. readonly TRANSFORM_FEEDBACK: number;
  142984. readonly INTERLEAVED_ATTRIBS: number;
  142985. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  142986. createTransformFeedback(): WebGLTransformFeedback;
  142987. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  142988. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  142989. beginTransformFeedback(primitiveMode: number): void;
  142990. endTransformFeedback(): void;
  142991. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  142992. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142993. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142994. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  142995. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  142996. }
  142997. interface ImageBitmap {
  142998. readonly width: number;
  142999. readonly height: number;
  143000. close(): void;
  143001. }
  143002. interface WebGLQuery extends WebGLObject {
  143003. }
  143004. declare var WebGLQuery: {
  143005. prototype: WebGLQuery;
  143006. new(): WebGLQuery;
  143007. };
  143008. interface WebGLSampler extends WebGLObject {
  143009. }
  143010. declare var WebGLSampler: {
  143011. prototype: WebGLSampler;
  143012. new(): WebGLSampler;
  143013. };
  143014. interface WebGLSync extends WebGLObject {
  143015. }
  143016. declare var WebGLSync: {
  143017. prototype: WebGLSync;
  143018. new(): WebGLSync;
  143019. };
  143020. interface WebGLTransformFeedback extends WebGLObject {
  143021. }
  143022. declare var WebGLTransformFeedback: {
  143023. prototype: WebGLTransformFeedback;
  143024. new(): WebGLTransformFeedback;
  143025. };
  143026. interface WebGLVertexArrayObject extends WebGLObject {
  143027. }
  143028. declare var WebGLVertexArrayObject: {
  143029. prototype: WebGLVertexArrayObject;
  143030. new(): WebGLVertexArrayObject;
  143031. };
  143032. // Type definitions for WebVR API
  143033. // Project: https://w3c.github.io/webvr/
  143034. // Definitions by: six a <https://github.com/lostfictions>
  143035. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  143036. interface VRDisplay extends EventTarget {
  143037. /**
  143038. * Dictionary of capabilities describing the VRDisplay.
  143039. */
  143040. readonly capabilities: VRDisplayCapabilities;
  143041. /**
  143042. * z-depth defining the far plane of the eye view frustum
  143043. * enables mapping of values in the render target depth
  143044. * attachment to scene coordinates. Initially set to 10000.0.
  143045. */
  143046. depthFar: number;
  143047. /**
  143048. * z-depth defining the near plane of the eye view frustum
  143049. * enables mapping of values in the render target depth
  143050. * attachment to scene coordinates. Initially set to 0.01.
  143051. */
  143052. depthNear: number;
  143053. /**
  143054. * An identifier for this distinct VRDisplay. Used as an
  143055. * association point in the Gamepad API.
  143056. */
  143057. readonly displayId: number;
  143058. /**
  143059. * A display name, a user-readable name identifying it.
  143060. */
  143061. readonly displayName: string;
  143062. readonly isConnected: boolean;
  143063. readonly isPresenting: boolean;
  143064. /**
  143065. * If this VRDisplay supports room-scale experiences, the optional
  143066. * stage attribute contains details on the room-scale parameters.
  143067. */
  143068. readonly stageParameters: VRStageParameters | null;
  143069. /**
  143070. * Passing the value returned by `requestAnimationFrame` to
  143071. * `cancelAnimationFrame` will unregister the callback.
  143072. * @param handle Define the hanle of the request to cancel
  143073. */
  143074. cancelAnimationFrame(handle: number): void;
  143075. /**
  143076. * Stops presenting to the VRDisplay.
  143077. * @returns a promise to know when it stopped
  143078. */
  143079. exitPresent(): Promise<void>;
  143080. /**
  143081. * Return the current VREyeParameters for the given eye.
  143082. * @param whichEye Define the eye we want the parameter for
  143083. * @returns the eye parameters
  143084. */
  143085. getEyeParameters(whichEye: string): VREyeParameters;
  143086. /**
  143087. * Populates the passed VRFrameData with the information required to render
  143088. * the current frame.
  143089. * @param frameData Define the data structure to populate
  143090. * @returns true if ok otherwise false
  143091. */
  143092. getFrameData(frameData: VRFrameData): boolean;
  143093. /**
  143094. * Get the layers currently being presented.
  143095. * @returns the list of VR layers
  143096. */
  143097. getLayers(): VRLayer[];
  143098. /**
  143099. * Return a VRPose containing the future predicted pose of the VRDisplay
  143100. * when the current frame will be presented. The value returned will not
  143101. * change until JavaScript has returned control to the browser.
  143102. *
  143103. * The VRPose will contain the position, orientation, velocity,
  143104. * and acceleration of each of these properties.
  143105. * @returns the pose object
  143106. */
  143107. getPose(): VRPose;
  143108. /**
  143109. * Return the current instantaneous pose of the VRDisplay, with no
  143110. * prediction applied.
  143111. * @returns the current instantaneous pose
  143112. */
  143113. getImmediatePose(): VRPose;
  143114. /**
  143115. * The callback passed to `requestAnimationFrame` will be called
  143116. * any time a new frame should be rendered. When the VRDisplay is
  143117. * presenting the callback will be called at the native refresh
  143118. * rate of the HMD. When not presenting this function acts
  143119. * identically to how window.requestAnimationFrame acts. Content should
  143120. * make no assumptions of frame rate or vsync behavior as the HMD runs
  143121. * asynchronously from other displays and at differing refresh rates.
  143122. * @param callback Define the eaction to run next frame
  143123. * @returns the request handle it
  143124. */
  143125. requestAnimationFrame(callback: FrameRequestCallback): number;
  143126. /**
  143127. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  143128. * Repeat calls while already presenting will update the VRLayers being displayed.
  143129. * @param layers Define the list of layer to present
  143130. * @returns a promise to know when the request has been fulfilled
  143131. */
  143132. requestPresent(layers: VRLayer[]): Promise<void>;
  143133. /**
  143134. * Reset the pose for this display, treating its current position and
  143135. * orientation as the "origin/zero" values. VRPose.position,
  143136. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  143137. * updated when calling resetPose(). This should be called in only
  143138. * sitting-space experiences.
  143139. */
  143140. resetPose(): void;
  143141. /**
  143142. * The VRLayer provided to the VRDisplay will be captured and presented
  143143. * in the HMD. Calling this function has the same effect on the source
  143144. * canvas as any other operation that uses its source image, and canvases
  143145. * created without preserveDrawingBuffer set to true will be cleared.
  143146. * @param pose Define the pose to submit
  143147. */
  143148. submitFrame(pose?: VRPose): void;
  143149. }
  143150. declare var VRDisplay: {
  143151. prototype: VRDisplay;
  143152. new(): VRDisplay;
  143153. };
  143154. interface VRLayer {
  143155. leftBounds?: number[] | Float32Array | null;
  143156. rightBounds?: number[] | Float32Array | null;
  143157. source?: HTMLCanvasElement | null;
  143158. }
  143159. interface VRDisplayCapabilities {
  143160. readonly canPresent: boolean;
  143161. readonly hasExternalDisplay: boolean;
  143162. readonly hasOrientation: boolean;
  143163. readonly hasPosition: boolean;
  143164. readonly maxLayers: number;
  143165. }
  143166. interface VREyeParameters {
  143167. /** @deprecated */
  143168. readonly fieldOfView: VRFieldOfView;
  143169. readonly offset: Float32Array;
  143170. readonly renderHeight: number;
  143171. readonly renderWidth: number;
  143172. }
  143173. interface VRFieldOfView {
  143174. readonly downDegrees: number;
  143175. readonly leftDegrees: number;
  143176. readonly rightDegrees: number;
  143177. readonly upDegrees: number;
  143178. }
  143179. interface VRFrameData {
  143180. readonly leftProjectionMatrix: Float32Array;
  143181. readonly leftViewMatrix: Float32Array;
  143182. readonly pose: VRPose;
  143183. readonly rightProjectionMatrix: Float32Array;
  143184. readonly rightViewMatrix: Float32Array;
  143185. readonly timestamp: number;
  143186. }
  143187. interface VRPose {
  143188. readonly angularAcceleration: Float32Array | null;
  143189. readonly angularVelocity: Float32Array | null;
  143190. readonly linearAcceleration: Float32Array | null;
  143191. readonly linearVelocity: Float32Array | null;
  143192. readonly orientation: Float32Array | null;
  143193. readonly position: Float32Array | null;
  143194. readonly timestamp: number;
  143195. }
  143196. interface VRStageParameters {
  143197. sittingToStandingTransform?: Float32Array;
  143198. sizeX?: number;
  143199. sizeY?: number;
  143200. }
  143201. interface Navigator {
  143202. getVRDisplays(): Promise<VRDisplay[]>;
  143203. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  143204. }
  143205. interface Window {
  143206. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  143207. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  143208. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  143209. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143210. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  143211. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  143212. }
  143213. interface Gamepad {
  143214. readonly displayId: number;
  143215. }
  143216. type XRSessionMode =
  143217. | "inline"
  143218. | "immersive-vr"
  143219. | "immersive-ar";
  143220. type XRReferenceSpaceType =
  143221. | "viewer"
  143222. | "local"
  143223. | "local-floor"
  143224. | "bounded-floor"
  143225. | "unbounded";
  143226. type XREnvironmentBlendMode =
  143227. | "opaque"
  143228. | "additive"
  143229. | "alpha-blend";
  143230. type XRVisibilityState =
  143231. | "visible"
  143232. | "visible-blurred"
  143233. | "hidden";
  143234. type XRHandedness =
  143235. | "none"
  143236. | "left"
  143237. | "right";
  143238. type XRTargetRayMode =
  143239. | "gaze"
  143240. | "tracked-pointer"
  143241. | "screen";
  143242. type XREye =
  143243. | "none"
  143244. | "left"
  143245. | "right";
  143246. interface XRSpace extends EventTarget {
  143247. }
  143248. interface XRRenderState {
  143249. depthNear?: number;
  143250. depthFar?: number;
  143251. inlineVerticalFieldOfView?: number;
  143252. baseLayer?: XRWebGLLayer;
  143253. }
  143254. interface XRInputSource {
  143255. handedness: XRHandedness;
  143256. targetRayMode: XRTargetRayMode;
  143257. targetRaySpace: XRSpace;
  143258. gripSpace: XRSpace | undefined;
  143259. gamepad: Gamepad | undefined;
  143260. profiles: Array<string>;
  143261. }
  143262. interface XRSessionInit {
  143263. optionalFeatures?: XRReferenceSpaceType[];
  143264. requiredFeatures?: XRReferenceSpaceType[];
  143265. }
  143266. interface XRSession extends XRAnchorCreator {
  143267. addEventListener: Function;
  143268. removeEventListener: Function;
  143269. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  143270. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  143271. requestAnimationFrame: Function;
  143272. end(): Promise<void>;
  143273. renderState: XRRenderState;
  143274. inputSources: Array<XRInputSource>;
  143275. // AR hit test
  143276. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143277. updateWorldTrackingState(options: {
  143278. planeDetectionState?: { enabled: boolean; }
  143279. }): void;
  143280. }
  143281. interface XRReferenceSpace extends XRSpace {
  143282. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  143283. onreset: any;
  143284. }
  143285. type XRPlaneSet = Set<XRPlane>;
  143286. type XRAnchorSet = Set<XRAnchor>;
  143287. interface XRFrame {
  143288. session: XRSession;
  143289. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  143290. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  143291. // Anchors
  143292. trackedAnchors?: XRAnchorSet;
  143293. // Planes
  143294. worldInformation: {
  143295. detectedPlanes?: XRPlaneSet;
  143296. };
  143297. }
  143298. interface XRViewerPose extends XRPose {
  143299. views: Array<XRView>;
  143300. }
  143301. interface XRPose {
  143302. transform: XRRigidTransform;
  143303. emulatedPosition: boolean;
  143304. }
  143305. interface XRWebGLLayerOptions {
  143306. antialias?: boolean;
  143307. depth?: boolean;
  143308. stencil?: boolean;
  143309. alpha?: boolean;
  143310. multiview?: boolean;
  143311. framebufferScaleFactor?: number;
  143312. }
  143313. declare var XRWebGLLayer: {
  143314. prototype: XRWebGLLayer;
  143315. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  143316. };
  143317. interface XRWebGLLayer {
  143318. framebuffer: WebGLFramebuffer;
  143319. framebufferWidth: number;
  143320. framebufferHeight: number;
  143321. getViewport: Function;
  143322. }
  143323. declare class XRRigidTransform {
  143324. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  143325. position: DOMPointReadOnly;
  143326. orientation: DOMPointReadOnly;
  143327. matrix: Float32Array;
  143328. inverse: XRRigidTransform;
  143329. }
  143330. interface XRView {
  143331. eye: XREye;
  143332. projectionMatrix: Float32Array;
  143333. transform: XRRigidTransform;
  143334. }
  143335. interface XRInputSourceChangeEvent {
  143336. session: XRSession;
  143337. removed: Array<XRInputSource>;
  143338. added: Array<XRInputSource>;
  143339. }
  143340. interface XRInputSourceEvent extends Event {
  143341. readonly frame: XRFrame;
  143342. readonly inputSource: XRInputSource;
  143343. }
  143344. // Experimental(er) features
  143345. declare class XRRay {
  143346. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  143347. origin: DOMPointReadOnly;
  143348. direction: DOMPointReadOnly;
  143349. matrix: Float32Array;
  143350. }
  143351. interface XRHitResult {
  143352. hitMatrix: Float32Array;
  143353. }
  143354. interface XRAnchor {
  143355. // remove?
  143356. id?: string;
  143357. anchorSpace: XRSpace;
  143358. lastChangedTime: number;
  143359. detach(): void;
  143360. }
  143361. interface XRPlane extends XRAnchorCreator {
  143362. orientation: "Horizontal" | "Vertical";
  143363. planeSpace: XRSpace;
  143364. polygon: Array<DOMPointReadOnly>;
  143365. lastChangedTime: number;
  143366. }
  143367. interface XRAnchorCreator {
  143368. // AR Anchors
  143369. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  143370. }